@antv/g6 5.0.0-beta.37 → 5.0.0-beta.39

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 (604) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/animations/executor.d.ts +4 -5
  3. package/dist/lib/animations/index.d.ts +22 -8
  4. package/dist/lib/animations/types.d.ts +78 -20
  5. package/dist/lib/behaviors/{click-element.d.ts → click-select.d.ts} +27 -11
  6. package/dist/lib/behaviors/collapse-expand.d.ts +10 -1
  7. package/dist/lib/behaviors/drag-canvas.d.ts +1 -0
  8. package/{lib/behaviors/hover-element.d.ts → dist/lib/behaviors/hover-activate.d.ts} +7 -5
  9. package/dist/lib/behaviors/index.d.ts +4 -4
  10. package/dist/lib/constants/animation.d.ts +3 -2
  11. package/dist/lib/constants/events/animation.d.ts +2 -0
  12. package/dist/lib/constants/events/graph.d.ts +0 -12
  13. package/dist/lib/elements/base-element.d.ts +35 -0
  14. package/dist/lib/elements/combos/base-combo.d.ts +8 -32
  15. package/dist/lib/elements/combos/circle.d.ts +1 -2
  16. package/dist/lib/elements/edges/base-edge.d.ts +21 -30
  17. package/dist/lib/elements/nodes/base-node.d.ts +7 -27
  18. package/dist/lib/elements/nodes/html.d.ts +2 -1
  19. package/dist/lib/elements/shapes/badge.d.ts +1 -1
  20. package/dist/lib/elements/shapes/base-shape.d.ts +6 -0
  21. package/dist/lib/exports.d.ts +6 -5
  22. package/dist/lib/layouts/index.d.ts +1 -1
  23. package/dist/lib/layouts/types.d.ts +3 -3
  24. package/dist/lib/plugins/background/index.d.ts +38 -0
  25. package/{esm/plugins/contextmenu.d.ts → dist/lib/plugins/contextmenu/index.d.ts} +5 -5
  26. package/dist/lib/plugins/index.d.ts +2 -0
  27. package/{lib/plugins/watermark.d.ts → dist/lib/plugins/watermark/index.d.ts} +3 -3
  28. package/dist/lib/runtime/animation.d.ts +54 -0
  29. package/dist/lib/runtime/canvas.d.ts +0 -2
  30. package/dist/lib/runtime/data.d.ts +13 -4
  31. package/dist/lib/runtime/element.d.ts +27 -41
  32. package/dist/lib/runtime/graph.d.ts +1 -0
  33. package/dist/lib/runtime/layout.d.ts +7 -0
  34. package/dist/lib/runtime/transform.d.ts +1 -0
  35. package/dist/lib/runtime/types.d.ts +7 -0
  36. package/dist/lib/spec/data.d.ts +14 -0
  37. package/dist/lib/spec/element/animation.d.ts +3 -9
  38. package/dist/lib/spec/element/combo.d.ts +4 -3
  39. package/dist/lib/spec/element/edge.d.ts +4 -3
  40. package/dist/lib/spec/element/node.d.ts +4 -3
  41. package/dist/lib/transforms/base-transform.d.ts +2 -1
  42. package/dist/lib/transforms/collapse-expand-combo.d.ts +4 -3
  43. package/dist/lib/transforms/collapse-expand-node.d.ts +12 -0
  44. package/dist/lib/transforms/get-edge-actual-ends.d.ts +13 -0
  45. package/dist/lib/transforms/index.d.ts +2 -0
  46. package/dist/lib/transforms/process-parallel-edges.d.ts +6 -4
  47. package/dist/lib/transforms/types.d.ts +2 -2
  48. package/dist/lib/transforms/update-related-edge.d.ts +2 -1
  49. package/dist/lib/transforms/utils.d.ts +13 -0
  50. package/dist/lib/types/animation.d.ts +1 -2
  51. package/dist/lib/types/node.d.ts +24 -0
  52. package/dist/lib/utils/animation.d.ts +17 -29
  53. package/dist/lib/utils/collapsibility.d.ts +9 -0
  54. package/dist/lib/utils/element.d.ts +19 -2
  55. package/dist/lib/utils/prefix.d.ts +1 -1
  56. package/dist/lib/utils/style.d.ts +10 -0
  57. package/dist/lib/utils/theme.d.ts +9 -0
  58. package/dist/lib/utils/transform.d.ts +14 -0
  59. package/esm/animations/executor.d.ts +4 -5
  60. package/esm/animations/executor.js +31 -48
  61. package/esm/animations/executor.js.map +1 -1
  62. package/esm/animations/index.d.ts +22 -8
  63. package/esm/animations/index.js +10 -12
  64. package/esm/animations/index.js.map +1 -1
  65. package/esm/animations/types.d.ts +78 -20
  66. package/{lib/behaviors/click-element.d.ts → esm/behaviors/click-select.d.ts} +27 -11
  67. package/esm/behaviors/{click-element.js → click-select.js} +40 -24
  68. package/esm/behaviors/click-select.js.map +1 -0
  69. package/esm/behaviors/collapse-expand.d.ts +10 -1
  70. package/esm/behaviors/collapse-expand.js +15 -6
  71. package/esm/behaviors/collapse-expand.js.map +1 -1
  72. package/esm/behaviors/create-edge.js +2 -2
  73. package/esm/behaviors/create-edge.js.map +1 -1
  74. package/esm/behaviors/drag-canvas.d.ts +1 -0
  75. package/esm/behaviors/drag-canvas.js +5 -1
  76. package/esm/behaviors/drag-canvas.js.map +1 -1
  77. package/esm/behaviors/drag-element.js +2 -2
  78. package/esm/behaviors/drag-element.js.map +1 -1
  79. package/{dist/lib/behaviors/hover-element.d.ts → esm/behaviors/hover-activate.d.ts} +7 -5
  80. package/esm/behaviors/{hover-element.js → hover-activate.js} +19 -9
  81. package/esm/behaviors/hover-activate.js.map +1 -0
  82. package/esm/behaviors/index.d.ts +4 -4
  83. package/esm/behaviors/index.js +2 -2
  84. package/esm/behaviors/index.js.map +1 -1
  85. package/esm/constants/animation.d.ts +3 -2
  86. package/esm/constants/animation.js.map +1 -1
  87. package/esm/constants/events/animation.d.ts +2 -0
  88. package/esm/constants/events/animation.js +2 -0
  89. package/esm/constants/events/animation.js.map +1 -1
  90. package/esm/constants/events/graph.d.ts +0 -12
  91. package/esm/constants/events/graph.js +0 -12
  92. package/esm/constants/events/graph.js.map +1 -1
  93. package/esm/elements/base-element.d.ts +35 -0
  94. package/esm/elements/base-element.js +42 -0
  95. package/esm/elements/base-element.js.map +1 -0
  96. package/esm/elements/combos/base-combo.d.ts +8 -32
  97. package/esm/elements/combos/base-combo.js +55 -56
  98. package/esm/elements/combos/base-combo.js.map +1 -1
  99. package/esm/elements/combos/circle.d.ts +1 -2
  100. package/esm/elements/combos/circle.js +1 -12
  101. package/esm/elements/combos/circle.js.map +1 -1
  102. package/esm/elements/combos/rect.js +1 -2
  103. package/esm/elements/combos/rect.js.map +1 -1
  104. package/esm/elements/edges/base-edge.d.ts +21 -30
  105. package/esm/elements/edges/base-edge.js +43 -39
  106. package/esm/elements/edges/base-edge.js.map +1 -1
  107. package/esm/elements/edges/cubic-horizontal.js +2 -2
  108. package/esm/elements/edges/cubic-horizontal.js.map +1 -1
  109. package/esm/elements/edges/cubic-vertical.js +2 -2
  110. package/esm/elements/edges/cubic-vertical.js.map +1 -1
  111. package/esm/elements/edges/cubic.js +2 -2
  112. package/esm/elements/edges/cubic.js.map +1 -1
  113. package/esm/elements/edges/line.js +2 -2
  114. package/esm/elements/edges/line.js.map +1 -1
  115. package/esm/elements/edges/polyline.js +10 -6
  116. package/esm/elements/edges/polyline.js.map +1 -1
  117. package/esm/elements/edges/quadratic.js +2 -2
  118. package/esm/elements/edges/quadratic.js.map +1 -1
  119. package/esm/elements/nodes/base-node.d.ts +7 -27
  120. package/esm/elements/nodes/base-node.js +24 -46
  121. package/esm/elements/nodes/base-node.js.map +1 -1
  122. package/esm/elements/nodes/circle.js +2 -2
  123. package/esm/elements/nodes/circle.js.map +1 -1
  124. package/esm/elements/nodes/donut.js +3 -2
  125. package/esm/elements/nodes/donut.js.map +1 -1
  126. package/esm/elements/nodes/ellipse.js +2 -2
  127. package/esm/elements/nodes/ellipse.js.map +1 -1
  128. package/esm/elements/nodes/html.d.ts +2 -1
  129. package/esm/elements/nodes/html.js +8 -1
  130. package/esm/elements/nodes/html.js.map +1 -1
  131. package/esm/elements/nodes/image.js +2 -2
  132. package/esm/elements/nodes/image.js.map +1 -1
  133. package/esm/elements/nodes/rect.js +2 -2
  134. package/esm/elements/nodes/rect.js.map +1 -1
  135. package/esm/elements/nodes/triangle.js +3 -2
  136. package/esm/elements/nodes/triangle.js.map +1 -1
  137. package/esm/elements/shapes/badge.d.ts +1 -1
  138. package/esm/elements/shapes/badge.js +2 -2
  139. package/esm/elements/shapes/badge.js.map +1 -1
  140. package/esm/elements/shapes/base-shape.d.ts +6 -0
  141. package/esm/elements/shapes/base-shape.js +23 -6
  142. package/esm/elements/shapes/base-shape.js.map +1 -1
  143. package/esm/elements/shapes/contour.js +2 -2
  144. package/esm/elements/shapes/contour.js.map +1 -1
  145. package/esm/elements/shapes/label.js +2 -2
  146. package/esm/elements/shapes/label.js.map +1 -1
  147. package/esm/exports.d.ts +6 -5
  148. package/esm/exports.js +2 -2
  149. package/esm/exports.js.map +1 -1
  150. package/esm/layouts/index.d.ts +1 -1
  151. package/esm/layouts/index.js +1 -1
  152. package/esm/layouts/index.js.map +1 -1
  153. package/esm/layouts/types.d.ts +3 -3
  154. package/esm/plugins/background/index.d.ts +38 -0
  155. package/esm/plugins/background/index.js +48 -0
  156. package/esm/plugins/background/index.js.map +1 -0
  157. package/{dist/lib/plugins/contextmenu.d.ts → esm/plugins/contextmenu/index.d.ts} +5 -5
  158. package/esm/plugins/{contextmenu.js → contextmenu/index.js} +4 -4
  159. package/esm/plugins/contextmenu/index.js.map +1 -0
  160. package/esm/{utils/contextmenu.js → plugins/contextmenu/util.js} +1 -1
  161. package/esm/{utils/contextmenu.js.map → plugins/contextmenu/util.js.map} +1 -1
  162. package/esm/plugins/history/index.js +1 -1
  163. package/esm/plugins/history/index.js.map +1 -1
  164. package/esm/plugins/history/{utils.js → util.js} +1 -1
  165. package/esm/plugins/history/util.js.map +1 -0
  166. package/esm/plugins/index.d.ts +2 -0
  167. package/esm/plugins/index.js +1 -0
  168. package/esm/plugins/index.js.map +1 -1
  169. package/esm/plugins/timebar.js +1 -1
  170. package/esm/plugins/timebar.js.map +1 -1
  171. package/esm/plugins/{watermark.d.ts → watermark/index.d.ts} +3 -3
  172. package/esm/plugins/{watermark.js → watermark/index.js} +4 -4
  173. package/esm/plugins/watermark/index.js.map +1 -0
  174. package/esm/{utils/watermark.js → plugins/watermark/util.js} +1 -1
  175. package/esm/plugins/watermark/util.js.map +1 -0
  176. package/esm/registry/build-in.js +19 -12
  177. package/esm/registry/build-in.js.map +1 -1
  178. package/esm/runtime/animation.d.ts +54 -0
  179. package/esm/runtime/animation.js +139 -0
  180. package/esm/runtime/animation.js.map +1 -0
  181. package/esm/runtime/canvas.d.ts +0 -2
  182. package/esm/runtime/canvas.js +0 -21
  183. package/esm/runtime/canvas.js.map +1 -1
  184. package/esm/runtime/data.d.ts +13 -4
  185. package/esm/runtime/data.js +35 -24
  186. package/esm/runtime/data.js.map +1 -1
  187. package/esm/runtime/element.d.ts +27 -41
  188. package/esm/runtime/element.js +239 -193
  189. package/esm/runtime/element.js.map +1 -1
  190. package/esm/runtime/graph.d.ts +1 -0
  191. package/esm/runtime/graph.js +45 -11
  192. package/esm/runtime/graph.js.map +1 -1
  193. package/esm/runtime/layout.d.ts +7 -0
  194. package/esm/runtime/layout.js +44 -3
  195. package/esm/runtime/layout.js.map +1 -1
  196. package/esm/runtime/transform.d.ts +1 -0
  197. package/esm/runtime/transform.js +9 -2
  198. package/esm/runtime/transform.js.map +1 -1
  199. package/esm/runtime/types.d.ts +7 -0
  200. package/esm/runtime/viewport.js +2 -2
  201. package/esm/runtime/viewport.js.map +1 -1
  202. package/esm/spec/data.d.ts +14 -0
  203. package/esm/spec/element/animation.d.ts +3 -9
  204. package/esm/spec/element/combo.d.ts +4 -3
  205. package/esm/spec/element/edge.d.ts +4 -3
  206. package/esm/spec/element/node.d.ts +4 -3
  207. package/esm/themes/base.js +14 -10
  208. package/esm/themes/base.js.map +1 -1
  209. package/esm/transforms/base-transform.d.ts +2 -1
  210. package/esm/transforms/base-transform.js +1 -1
  211. package/esm/transforms/base-transform.js.map +1 -1
  212. package/esm/transforms/collapse-expand-combo.d.ts +4 -3
  213. package/esm/transforms/collapse-expand-combo.js +9 -25
  214. package/esm/transforms/collapse-expand-combo.js.map +1 -1
  215. package/esm/transforms/collapse-expand-node.d.ts +12 -0
  216. package/esm/transforms/collapse-expand-node.js +91 -0
  217. package/esm/transforms/collapse-expand-node.js.map +1 -0
  218. package/esm/transforms/get-edge-actual-ends.d.ts +13 -0
  219. package/esm/transforms/get-edge-actual-ends.js +36 -0
  220. package/esm/transforms/get-edge-actual-ends.js.map +1 -0
  221. package/esm/transforms/index.d.ts +2 -0
  222. package/esm/transforms/index.js +2 -0
  223. package/esm/transforms/index.js.map +1 -1
  224. package/esm/transforms/process-parallel-edges.d.ts +6 -4
  225. package/esm/transforms/process-parallel-edges.js +42 -27
  226. package/esm/transforms/process-parallel-edges.js.map +1 -1
  227. package/esm/transforms/types.d.ts +2 -2
  228. package/esm/transforms/types.js +1 -10
  229. package/esm/transforms/types.js.map +1 -1
  230. package/esm/transforms/update-related-edge.d.ts +2 -1
  231. package/esm/transforms/update-related-edge.js +4 -1
  232. package/esm/transforms/update-related-edge.js.map +1 -1
  233. package/esm/transforms/utils.d.ts +13 -0
  234. package/esm/transforms/utils.js +25 -0
  235. package/esm/transforms/utils.js.map +1 -0
  236. package/esm/types/animation.d.ts +1 -2
  237. package/esm/types/node.d.ts +24 -0
  238. package/esm/utils/animation.d.ts +17 -29
  239. package/esm/utils/animation.js +64 -54
  240. package/esm/utils/animation.js.map +1 -1
  241. package/esm/utils/cache.js +0 -1
  242. package/esm/utils/cache.js.map +1 -1
  243. package/esm/utils/collapsibility.d.ts +9 -0
  244. package/esm/utils/collapsibility.js +11 -0
  245. package/esm/utils/collapsibility.js.map +1 -0
  246. package/esm/utils/dom.js +1 -2
  247. package/esm/utils/dom.js.map +1 -1
  248. package/esm/utils/edge.js +2 -1
  249. package/esm/utils/edge.js.map +1 -1
  250. package/esm/utils/element.d.ts +19 -2
  251. package/esm/utils/element.js +24 -3
  252. package/esm/utils/element.js.map +1 -1
  253. package/esm/utils/id.js +2 -4
  254. package/esm/utils/id.js.map +1 -1
  255. package/esm/utils/palette.js +17 -9
  256. package/esm/utils/palette.js.map +1 -1
  257. package/esm/utils/prefix.d.ts +1 -1
  258. package/esm/utils/prefix.js +7 -6
  259. package/esm/utils/prefix.js.map +1 -1
  260. package/esm/utils/shape.js +1 -1
  261. package/esm/utils/shape.js.map +1 -1
  262. package/esm/utils/size.js +2 -3
  263. package/esm/utils/size.js.map +1 -1
  264. package/esm/utils/style.d.ts +10 -0
  265. package/esm/utils/style.js +15 -0
  266. package/esm/utils/style.js.map +1 -1
  267. package/esm/utils/theme.d.ts +9 -0
  268. package/esm/utils/theme.js +17 -0
  269. package/esm/utils/theme.js.map +1 -0
  270. package/esm/utils/transform.d.ts +14 -0
  271. package/esm/utils/transform.js +24 -0
  272. package/esm/utils/transform.js.map +1 -1
  273. package/lib/animations/executor.d.ts +4 -5
  274. package/lib/animations/executor.js +30 -47
  275. package/lib/animations/executor.js.map +1 -1
  276. package/lib/animations/index.d.ts +22 -8
  277. package/lib/animations/index.js +12 -14
  278. package/lib/animations/index.js.map +1 -1
  279. package/lib/animations/types.d.ts +78 -20
  280. package/{esm/behaviors/click-element.d.ts → lib/behaviors/click-select.d.ts} +27 -11
  281. package/lib/behaviors/{click-element.js → click-select.js} +42 -26
  282. package/lib/behaviors/click-select.js.map +1 -0
  283. package/lib/behaviors/collapse-expand.d.ts +10 -1
  284. package/lib/behaviors/collapse-expand.js +15 -6
  285. package/lib/behaviors/collapse-expand.js.map +1 -1
  286. package/lib/behaviors/create-edge.js +2 -2
  287. package/lib/behaviors/create-edge.js.map +1 -1
  288. package/lib/behaviors/drag-canvas.d.ts +1 -0
  289. package/lib/behaviors/drag-canvas.js +5 -1
  290. package/lib/behaviors/drag-canvas.js.map +1 -1
  291. package/lib/behaviors/drag-element.js +2 -2
  292. package/lib/behaviors/drag-element.js.map +1 -1
  293. package/{esm/behaviors/hover-element.d.ts → lib/behaviors/hover-activate.d.ts} +7 -5
  294. package/lib/behaviors/{hover-element.js → hover-activate.js} +21 -11
  295. package/lib/behaviors/hover-activate.js.map +1 -0
  296. package/lib/behaviors/index.d.ts +4 -4
  297. package/lib/behaviors/index.js +5 -5
  298. package/lib/behaviors/index.js.map +1 -1
  299. package/lib/constants/animation.d.ts +3 -2
  300. package/lib/constants/animation.js.map +1 -1
  301. package/lib/constants/events/animation.d.ts +2 -0
  302. package/lib/constants/events/animation.js +2 -0
  303. package/lib/constants/events/animation.js.map +1 -1
  304. package/lib/constants/events/graph.d.ts +0 -12
  305. package/lib/constants/events/graph.js +0 -12
  306. package/lib/constants/events/graph.js.map +1 -1
  307. package/lib/elements/base-element.d.ts +35 -0
  308. package/lib/elements/base-element.js +46 -0
  309. package/lib/elements/base-element.js.map +1 -0
  310. package/lib/elements/combos/base-combo.d.ts +8 -32
  311. package/lib/elements/combos/base-combo.js +54 -55
  312. package/lib/elements/combos/base-combo.js.map +1 -1
  313. package/lib/elements/combos/circle.d.ts +1 -2
  314. package/lib/elements/combos/circle.js +1 -12
  315. package/lib/elements/combos/circle.js.map +1 -1
  316. package/lib/elements/combos/rect.js +1 -2
  317. package/lib/elements/combos/rect.js.map +1 -1
  318. package/lib/elements/edges/base-edge.d.ts +21 -30
  319. package/lib/elements/edges/base-edge.js +42 -38
  320. package/lib/elements/edges/base-edge.js.map +1 -1
  321. package/lib/elements/edges/cubic-horizontal.js +2 -2
  322. package/lib/elements/edges/cubic-horizontal.js.map +1 -1
  323. package/lib/elements/edges/cubic-vertical.js +2 -2
  324. package/lib/elements/edges/cubic-vertical.js.map +1 -1
  325. package/lib/elements/edges/cubic.js +2 -2
  326. package/lib/elements/edges/cubic.js.map +1 -1
  327. package/lib/elements/edges/line.js +2 -2
  328. package/lib/elements/edges/line.js.map +1 -1
  329. package/lib/elements/edges/polyline.js +10 -6
  330. package/lib/elements/edges/polyline.js.map +1 -1
  331. package/lib/elements/edges/quadratic.js +2 -2
  332. package/lib/elements/edges/quadratic.js.map +1 -1
  333. package/lib/elements/nodes/base-node.d.ts +7 -27
  334. package/lib/elements/nodes/base-node.js +23 -45
  335. package/lib/elements/nodes/base-node.js.map +1 -1
  336. package/lib/elements/nodes/circle.js +2 -2
  337. package/lib/elements/nodes/circle.js.map +1 -1
  338. package/lib/elements/nodes/donut.js +2 -1
  339. package/lib/elements/nodes/donut.js.map +1 -1
  340. package/lib/elements/nodes/ellipse.js +2 -2
  341. package/lib/elements/nodes/ellipse.js.map +1 -1
  342. package/lib/elements/nodes/html.d.ts +2 -1
  343. package/lib/elements/nodes/html.js +8 -1
  344. package/lib/elements/nodes/html.js.map +1 -1
  345. package/lib/elements/nodes/image.js +2 -2
  346. package/lib/elements/nodes/image.js.map +1 -1
  347. package/lib/elements/nodes/rect.js +2 -2
  348. package/lib/elements/nodes/rect.js.map +1 -1
  349. package/lib/elements/nodes/triangle.js +2 -1
  350. package/lib/elements/nodes/triangle.js.map +1 -1
  351. package/lib/elements/shapes/badge.d.ts +1 -1
  352. package/lib/elements/shapes/badge.js +2 -2
  353. package/lib/elements/shapes/badge.js.map +1 -1
  354. package/lib/elements/shapes/base-shape.d.ts +6 -0
  355. package/lib/elements/shapes/base-shape.js +23 -6
  356. package/lib/elements/shapes/base-shape.js.map +1 -1
  357. package/lib/elements/shapes/contour.js +2 -2
  358. package/lib/elements/shapes/contour.js.map +1 -1
  359. package/lib/elements/shapes/label.js +2 -2
  360. package/lib/elements/shapes/label.js.map +1 -1
  361. package/lib/exports.d.ts +6 -5
  362. package/lib/exports.js +4 -5
  363. package/lib/exports.js.map +1 -1
  364. package/lib/layouts/index.d.ts +1 -1
  365. package/lib/layouts/index.js +1 -2
  366. package/lib/layouts/index.js.map +1 -1
  367. package/lib/layouts/types.d.ts +3 -3
  368. package/lib/plugins/background/index.d.ts +38 -0
  369. package/lib/plugins/background/index.js +52 -0
  370. package/lib/plugins/background/index.js.map +1 -0
  371. package/lib/plugins/{contextmenu.d.ts → contextmenu/index.d.ts} +5 -5
  372. package/lib/plugins/{contextmenu.js → contextmenu/index.js} +6 -6
  373. package/lib/plugins/{contextmenu.js.map → contextmenu/index.js.map} +1 -1
  374. package/lib/{utils/contextmenu.js → plugins/contextmenu/util.js} +1 -1
  375. package/lib/{utils/contextmenu.js.map → plugins/contextmenu/util.js.map} +1 -1
  376. package/lib/plugins/history/index.js +2 -2
  377. package/lib/plugins/history/index.js.map +1 -1
  378. package/lib/plugins/history/{utils.js → util.js} +1 -1
  379. package/lib/plugins/history/util.js.map +1 -0
  380. package/lib/plugins/index.d.ts +2 -0
  381. package/lib/plugins/index.js +3 -1
  382. package/lib/plugins/index.js.map +1 -1
  383. package/lib/plugins/timebar.js +1 -1
  384. package/lib/plugins/timebar.js.map +1 -1
  385. package/{dist/lib/plugins/watermark.d.ts → lib/plugins/watermark/index.d.ts} +3 -3
  386. package/lib/plugins/{watermark.js → watermark/index.js} +6 -6
  387. package/lib/plugins/watermark/index.js.map +1 -0
  388. package/lib/{utils/watermark.js → plugins/watermark/util.js} +1 -1
  389. package/lib/plugins/watermark/util.js.map +1 -0
  390. package/lib/registry/build-in.js +14 -7
  391. package/lib/registry/build-in.js.map +1 -1
  392. package/lib/runtime/animation.d.ts +54 -0
  393. package/lib/runtime/animation.js +143 -0
  394. package/lib/runtime/animation.js.map +1 -0
  395. package/lib/runtime/canvas.d.ts +0 -2
  396. package/lib/runtime/canvas.js +0 -21
  397. package/lib/runtime/canvas.js.map +1 -1
  398. package/lib/runtime/data.d.ts +13 -4
  399. package/lib/runtime/data.js +34 -23
  400. package/lib/runtime/data.js.map +1 -1
  401. package/lib/runtime/element.d.ts +27 -41
  402. package/lib/runtime/element.js +236 -190
  403. package/lib/runtime/element.js.map +1 -1
  404. package/lib/runtime/graph.d.ts +1 -0
  405. package/lib/runtime/graph.js +45 -11
  406. package/lib/runtime/graph.js.map +1 -1
  407. package/lib/runtime/layout.d.ts +7 -0
  408. package/lib/runtime/layout.js +43 -2
  409. package/lib/runtime/layout.js.map +1 -1
  410. package/lib/runtime/transform.d.ts +1 -0
  411. package/lib/runtime/transform.js +9 -2
  412. package/lib/runtime/transform.js.map +1 -1
  413. package/lib/runtime/types.d.ts +7 -0
  414. package/lib/runtime/viewport.js +1 -1
  415. package/lib/runtime/viewport.js.map +1 -1
  416. package/lib/spec/data.d.ts +14 -0
  417. package/lib/spec/element/animation.d.ts +3 -9
  418. package/lib/spec/element/combo.d.ts +4 -3
  419. package/lib/spec/element/edge.d.ts +4 -3
  420. package/lib/spec/element/node.d.ts +4 -3
  421. package/lib/themes/base.js +14 -10
  422. package/lib/themes/base.js.map +1 -1
  423. package/lib/transforms/base-transform.d.ts +2 -1
  424. package/lib/transforms/base-transform.js +1 -1
  425. package/lib/transforms/base-transform.js.map +1 -1
  426. package/lib/transforms/collapse-expand-combo.d.ts +4 -3
  427. package/lib/transforms/collapse-expand-combo.js +13 -29
  428. package/lib/transforms/collapse-expand-combo.js.map +1 -1
  429. package/lib/transforms/collapse-expand-node.d.ts +12 -0
  430. package/lib/transforms/collapse-expand-node.js +95 -0
  431. package/lib/transforms/collapse-expand-node.js.map +1 -0
  432. package/lib/transforms/get-edge-actual-ends.d.ts +13 -0
  433. package/lib/transforms/get-edge-actual-ends.js +41 -0
  434. package/lib/transforms/get-edge-actual-ends.js.map +1 -0
  435. package/lib/transforms/index.d.ts +2 -0
  436. package/lib/transforms/index.js +5 -1
  437. package/lib/transforms/index.js.map +1 -1
  438. package/lib/transforms/process-parallel-edges.d.ts +6 -4
  439. package/lib/transforms/process-parallel-edges.js +41 -26
  440. package/lib/transforms/process-parallel-edges.js.map +1 -1
  441. package/lib/transforms/types.d.ts +2 -2
  442. package/lib/transforms/types.js +0 -12
  443. package/lib/transforms/types.js.map +1 -1
  444. package/lib/transforms/update-related-edge.d.ts +2 -1
  445. package/lib/transforms/update-related-edge.js +4 -1
  446. package/lib/transforms/update-related-edge.js.map +1 -1
  447. package/lib/transforms/utils.d.ts +13 -0
  448. package/lib/transforms/utils.js +29 -0
  449. package/lib/transforms/utils.js.map +1 -0
  450. package/lib/types/animation.d.ts +1 -2
  451. package/lib/types/node.d.ts +24 -0
  452. package/lib/utils/animation.d.ts +17 -29
  453. package/lib/utils/animation.js +65 -56
  454. package/lib/utils/animation.js.map +1 -1
  455. package/lib/utils/cache.js +0 -1
  456. package/lib/utils/cache.js.map +1 -1
  457. package/lib/utils/collapsibility.d.ts +9 -0
  458. package/lib/utils/collapsibility.js +15 -0
  459. package/lib/utils/collapsibility.js.map +1 -0
  460. package/lib/utils/dom.js +1 -2
  461. package/lib/utils/dom.js.map +1 -1
  462. package/lib/utils/edge.js +2 -1
  463. package/lib/utils/edge.js.map +1 -1
  464. package/lib/utils/element.d.ts +19 -2
  465. package/lib/utils/element.js +26 -3
  466. package/lib/utils/element.js.map +1 -1
  467. package/lib/utils/id.js +2 -4
  468. package/lib/utils/id.js.map +1 -1
  469. package/lib/utils/palette.js +16 -8
  470. package/lib/utils/palette.js.map +1 -1
  471. package/lib/utils/prefix.d.ts +1 -1
  472. package/lib/utils/prefix.js +6 -5
  473. package/lib/utils/prefix.js.map +1 -1
  474. package/lib/utils/shape.js +1 -1
  475. package/lib/utils/shape.js.map +1 -1
  476. package/lib/utils/size.js +2 -3
  477. package/lib/utils/size.js.map +1 -1
  478. package/lib/utils/style.d.ts +10 -0
  479. package/lib/utils/style.js +17 -1
  480. package/lib/utils/style.js.map +1 -1
  481. package/lib/utils/theme.d.ts +9 -0
  482. package/lib/utils/theme.js +21 -0
  483. package/lib/utils/theme.js.map +1 -0
  484. package/lib/utils/transform.d.ts +14 -0
  485. package/lib/utils/transform.js +26 -1
  486. package/lib/utils/transform.js.map +1 -1
  487. package/package.json +6 -6
  488. package/src/animations/executor.ts +39 -61
  489. package/src/animations/index.ts +19 -15
  490. package/src/animations/types.ts +82 -27
  491. package/src/behaviors/{click-element.ts → click-select.ts} +72 -31
  492. package/src/behaviors/collapse-expand.ts +25 -9
  493. package/src/behaviors/create-edge.ts +2 -2
  494. package/src/behaviors/drag-canvas.ts +6 -1
  495. package/src/behaviors/drag-element.ts +2 -2
  496. package/src/behaviors/{hover-element.ts → hover-activate.ts} +27 -13
  497. package/src/behaviors/index.ts +4 -4
  498. package/src/constants/animation.ts +4 -2
  499. package/src/constants/events/animation.ts +2 -0
  500. package/src/constants/events/graph.ts +0 -12
  501. package/src/elements/base-element.ts +52 -0
  502. package/src/elements/combos/base-combo.ts +68 -75
  503. package/src/elements/combos/circle.ts +2 -20
  504. package/src/elements/combos/rect.ts +1 -2
  505. package/src/elements/edges/base-edge.ts +62 -49
  506. package/src/elements/edges/cubic-horizontal.ts +2 -2
  507. package/src/elements/edges/cubic-vertical.ts +2 -2
  508. package/src/elements/edges/cubic.ts +2 -2
  509. package/src/elements/edges/line.ts +2 -2
  510. package/src/elements/edges/polyline.ts +10 -6
  511. package/src/elements/edges/quadratic.ts +2 -2
  512. package/src/elements/nodes/base-node.ts +28 -55
  513. package/src/elements/nodes/circle.ts +2 -2
  514. package/src/elements/nodes/donut.ts +3 -2
  515. package/src/elements/nodes/ellipse.ts +2 -2
  516. package/src/elements/nodes/html.ts +9 -1
  517. package/src/elements/nodes/image.ts +2 -2
  518. package/src/elements/nodes/rect.ts +2 -2
  519. package/src/elements/nodes/triangle.ts +3 -2
  520. package/src/elements/shapes/badge.ts +2 -2
  521. package/src/elements/shapes/base-shape.ts +24 -9
  522. package/src/elements/shapes/contour.ts +2 -2
  523. package/src/elements/shapes/label.ts +2 -2
  524. package/src/exports.ts +7 -7
  525. package/src/layouts/index.ts +0 -1
  526. package/src/layouts/types.ts +3 -3
  527. package/src/plugins/background/index.ts +64 -0
  528. package/src/plugins/{contextmenu.ts → contextmenu/index.ts} +7 -7
  529. package/src/plugins/history/index.ts +1 -1
  530. package/src/plugins/index.ts +2 -0
  531. package/src/plugins/timebar.ts +1 -1
  532. package/src/plugins/{watermark.ts → watermark/index.ts} +5 -5
  533. package/src/registry/build-in.ts +26 -12
  534. package/src/runtime/animation.ts +186 -0
  535. package/src/runtime/canvas.ts +0 -24
  536. package/src/runtime/data.ts +36 -24
  537. package/src/runtime/element.ts +305 -266
  538. package/src/runtime/graph.ts +45 -11
  539. package/src/runtime/layout.ts +51 -4
  540. package/src/runtime/transform.ts +10 -2
  541. package/src/runtime/types.ts +7 -0
  542. package/src/runtime/viewport.ts +2 -2
  543. package/src/spec/data.ts +14 -1
  544. package/src/spec/element/animation.ts +3 -13
  545. package/src/spec/element/combo.ts +4 -3
  546. package/src/spec/element/edge.ts +4 -3
  547. package/src/spec/element/node.ts +4 -3
  548. package/src/themes/base.ts +14 -10
  549. package/src/transforms/base-transform.ts +2 -1
  550. package/src/transforms/collapse-expand-combo.ts +11 -32
  551. package/src/transforms/collapse-expand-node.ts +107 -0
  552. package/src/transforms/get-edge-actual-ends.ts +45 -0
  553. package/src/transforms/index.ts +2 -0
  554. package/src/transforms/process-parallel-edges.ts +50 -36
  555. package/src/transforms/types.ts +5 -5
  556. package/src/transforms/update-related-edge.ts +5 -1
  557. package/src/transforms/utils.ts +31 -0
  558. package/src/types/animation.ts +1 -3
  559. package/src/types/node.ts +24 -0
  560. package/src/utils/animation.ts +73 -63
  561. package/src/utils/cache.ts +0 -1
  562. package/src/utils/collapsibility.ts +12 -0
  563. package/src/utils/dom.ts +1 -2
  564. package/src/utils/edge.ts +2 -1
  565. package/src/utils/element.ts +28 -3
  566. package/src/utils/id.ts +2 -4
  567. package/src/utils/palette.ts +17 -9
  568. package/src/utils/prefix.ts +8 -7
  569. package/src/utils/shape.ts +1 -1
  570. package/src/utils/size.ts +1 -2
  571. package/src/utils/style.ts +17 -0
  572. package/src/utils/theme.ts +18 -0
  573. package/src/utils/transform.ts +33 -0
  574. package/dist/lib/utils/combo.d.ts +0 -34
  575. package/esm/behaviors/click-element.js.map +0 -1
  576. package/esm/behaviors/hover-element.js.map +0 -1
  577. package/esm/plugins/contextmenu.js.map +0 -1
  578. package/esm/plugins/history/utils.js.map +0 -1
  579. package/esm/plugins/watermark.js.map +0 -1
  580. package/esm/utils/combo.d.ts +0 -34
  581. package/esm/utils/combo.js +0 -111
  582. package/esm/utils/combo.js.map +0 -1
  583. package/esm/utils/watermark.js.map +0 -1
  584. package/lib/behaviors/click-element.js.map +0 -1
  585. package/lib/behaviors/hover-element.js.map +0 -1
  586. package/lib/plugins/history/utils.js.map +0 -1
  587. package/lib/plugins/watermark.js.map +0 -1
  588. package/lib/utils/combo.d.ts +0 -34
  589. package/lib/utils/combo.js +0 -117
  590. package/lib/utils/combo.js.map +0 -1
  591. package/lib/utils/watermark.js.map +0 -1
  592. package/src/utils/combo.ts +0 -134
  593. /package/dist/lib/{utils/contextmenu.d.ts → plugins/contextmenu/util.d.ts} +0 -0
  594. /package/dist/lib/plugins/history/{utils.d.ts → util.d.ts} +0 -0
  595. /package/dist/lib/{utils/watermark.d.ts → plugins/watermark/util.d.ts} +0 -0
  596. /package/esm/{utils/contextmenu.d.ts → plugins/contextmenu/util.d.ts} +0 -0
  597. /package/esm/plugins/history/{utils.d.ts → util.d.ts} +0 -0
  598. /package/esm/{utils/watermark.d.ts → plugins/watermark/util.d.ts} +0 -0
  599. /package/lib/{utils/contextmenu.d.ts → plugins/contextmenu/util.d.ts} +0 -0
  600. /package/lib/plugins/history/{utils.d.ts → util.d.ts} +0 -0
  601. /package/lib/{utils/watermark.d.ts → plugins/watermark/util.d.ts} +0 -0
  602. /package/src/{utils/contextmenu.ts → plugins/contextmenu/util.ts} +0 -0
  603. /package/src/plugins/history/{utils.ts → util.ts} +0 -0
  604. /package/src/{utils/watermark.ts → plugins/watermark/util.ts} +0 -0
@@ -27,12 +27,11 @@ export class RectCombo extends BaseCombo<RectComboStyleProps> {
27
27
 
28
28
  protected getKeyStyle(attributes: Required<RectComboStyleProps>): GRectStyleProps {
29
29
  const keyStyle = super.getKeyStyle(attributes);
30
- const collapsedStyle = subStyleProps(keyStyle, 'collapsed');
31
30
 
32
31
  const [width, height] = this.getKeySize(attributes);
33
32
  return {
34
33
  ...keyStyle,
35
- ...(attributes.collapsed && collapsedStyle),
34
+ ...(attributes.collapsed && subStyleProps(keyStyle, 'collapsed')),
36
35
  width,
37
36
  height,
38
37
  x: -width / 2,
@@ -8,12 +8,13 @@ import type {
8
8
  } from '@antv/g';
9
9
  import { Image, Path } from '@antv/g';
10
10
  import type { PathArray } from '@antv/util';
11
- import { deepMix, isEmpty, isFunction } from '@antv/util';
11
+ import { isFunction } from '@antv/util';
12
12
  import type {
13
13
  BaseElementStyleProps,
14
14
  EdgeArrowStyleProps,
15
15
  EdgeKey,
16
16
  EdgeLabelStyleProps,
17
+ ID,
17
18
  Keyframe,
18
19
  LoopStyleProps,
19
20
  Node,
@@ -25,11 +26,12 @@ import { getCubicLoopPath, getLabelPositionStyle } from '../../utils/edge';
25
26
  import { findPorts, getConnectionPoint, isSameNode } from '../../utils/element';
26
27
  import { omitStyleProps, subStyleProps } from '../../utils/prefix';
27
28
  import { parseSize } from '../../utils/size';
29
+ import { mergeOptions } from '../../utils/style';
28
30
  import * as Symbol from '../../utils/symbol';
29
31
  import { getWordWrapWidthByEnds } from '../../utils/text';
32
+ import { BaseElement } from '../base-element';
30
33
  import type { LabelStyleProps } from '../shapes';
31
34
  import { Label } from '../shapes';
32
- import { BaseShape } from '../shapes/base-shape';
33
35
 
34
36
  /**
35
37
  * <zh/> 边的通用样式属性
@@ -50,6 +52,13 @@ export interface BaseEdgeStyleProps
50
52
  * @defaultValue true
51
53
  */
52
54
  label?: boolean;
55
+ /**
56
+ * <zh/> 是否启用自环边
57
+ *
58
+ * <en/> Whether to enable self-loop edge
59
+ * @defaultValue true
60
+ */
61
+ loop?: boolean;
53
62
  /**
54
63
  * <zh/> 是否显示边的光晕
55
64
  *
@@ -84,19 +93,21 @@ export interface BaseEdgeStyleProps
84
93
  */
85
94
  endArrowOffset?: number;
86
95
  /**
87
- * <zh/> 边的起点 shape
96
+ * <zh/> 边的起点 ID
88
97
  *
89
- * <en/> The source shape. Represents the start of the edge
90
- * @internal
98
+ * <en/> The ID of the source node
99
+ * @remarks
100
+ * <zh/> 该属性指向物理意义上的起点,由 G6 内部维护,用户无需过多关注。通常情况下,`sourceNode` 与上一级的 `source` 属性一致。但在某些情况下,`sourceNode` 可能会被 G6 内部转换,例如在 Combo 收起时内部节点上的边会自动连接到父 Combo,此时 `sourceNode` 会变更为父 Combo 的 ID。
101
+ *
102
+ * <en/> This property concerning the physical origin, maintained internally by G6. In general, `sourceNode` corresponds to the `source` attribute of the parent level. However, in certain cases, such as when a Combo is collapsed and internal nodes are destroyed, corresponding edges will automatically connect to the parent Combo. At this point, `sourceNode` will be changed to the ID of the parent Combo
91
103
  */
92
- sourceNode: Node;
104
+ sourceNode: ID;
93
105
  /**
94
106
  * <zh/> 边的终点 shape
95
107
  *
96
108
  * <en/> The source shape. Represents the start of the edge
97
- * @internal
98
109
  */
99
- targetNode: Node;
110
+ targetNode: ID;
100
111
  /**
101
112
  * <zh/> 边起始连接的 port
102
113
  *
@@ -157,7 +168,7 @@ type ParsedBaseEdgeStyleProps = Required<BaseEdgeStyleProps>;
157
168
  *
158
169
  * <en/> Base class of the edge
159
170
  */
160
- export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
171
+ export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> {
161
172
  public type = 'edge';
162
173
 
163
174
  static defaultStyleProps: Partial<BaseEdgeStyleProps> = {
@@ -178,6 +189,7 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
178
189
  haloPointerEvents: 'none',
179
190
  haloStrokeOpacity: 0.25,
180
191
  haloZIndex: -1,
192
+ loop: true,
181
193
  startArrow: false,
182
194
  startArrowSize: 8,
183
195
  startArrowLineDash: 0,
@@ -195,13 +207,25 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
195
207
  };
196
208
 
197
209
  constructor(options: DisplayObjectConfig<BaseEdgeStyleProps>) {
198
- super(deepMix({}, { style: BaseEdge.defaultStyleProps }, options));
210
+ super(mergeOptions({ style: BaseEdge.defaultStyleProps }, options));
211
+ }
212
+
213
+ protected get sourceNode() {
214
+ const { context, sourceNode: source } = this.parsedAttributes;
215
+ return context.element!.getElement<Node>(source)!;
216
+ }
217
+
218
+ protected get targetNode() {
219
+ const { context, targetNode: target } = this.parsedAttributes;
220
+ return context.element!.getElement<Node>(target)!;
199
221
  }
200
222
 
201
223
  protected getKeyStyle(attributes: ParsedBaseEdgeStyleProps): PathStyleProps {
202
- const { sourceNode, targetNode, ...style } = this.getGraphicStyle(attributes);
224
+ const { loop, ...style } = this.getGraphicStyle(attributes);
225
+ const { sourceNode, targetNode } = this;
226
+
227
+ const d = loop && isSameNode(sourceNode, targetNode) ? this.getLoopPath(attributes) : this.getKeyPath(attributes);
203
228
 
204
- const d = isSameNode(sourceNode, targetNode) ? this.getLoopPath(attributes) : this.getKeyPath(attributes);
205
229
  return {
206
230
  d,
207
231
  ...omitStyleProps(style, ['halo', 'label', 'startArrow', 'endArrow']),
@@ -211,7 +235,8 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
211
235
  protected abstract getKeyPath(attributes: ParsedBaseEdgeStyleProps): PathArray;
212
236
 
213
237
  protected getLoopPath(attributes: ParsedBaseEdgeStyleProps): PathArray {
214
- const { sourceNode: node, sourcePort, targetPort } = attributes;
238
+ const { sourcePort, targetPort } = attributes;
239
+ const node = this.sourceNode;
215
240
 
216
241
  const bbox = getNodeBBox(node);
217
242
  const defaultDist = Math.max(getBBoxWidth(bbox), getBBoxHeight(bbox));
@@ -226,7 +251,8 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
226
251
  }
227
252
 
228
253
  protected getEndpoints(attributes: ParsedBaseEdgeStyleProps): [Point, Point] {
229
- const { sourceNode, targetNode, sourcePort: sourcePortKey, targetPort: targetPortKey } = attributes;
254
+ const { sourcePort: sourcePortKey, targetPort: targetPortKey } = attributes;
255
+ const { sourceNode, targetNode } = this;
230
256
 
231
257
  const [sourcePort, targetPort] = findPorts(sourceNode, targetNode, sourcePortKey, targetPortKey);
232
258
 
@@ -246,7 +272,7 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
246
272
  }
247
273
 
248
274
  protected getLabelStyle(attributes: ParsedBaseEdgeStyleProps): false | LabelStyleProps {
249
- if (attributes.label === false || isEmpty(attributes.labelText)) return false;
275
+ if (attributes.label === false || !attributes.labelText) return false;
250
276
 
251
277
  const labelStyle = subStyleProps<Required<EdgeLabelStyleProps>>(this.getGraphicStyle(attributes), 'label');
252
278
  const { placement, offsetX, offsetY, autoRotate, maxWidth, ...restStyle } = labelStyle;
@@ -273,12 +299,12 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
273
299
 
274
300
  if (enable) {
275
301
  const arrowStyle = this.getArrowStyle(attributes, isStart);
276
- const Ctor = !isEmpty(arrowStyle.src) ? Image : Path;
302
+ const Ctor = arrowStyle.src ? Image : Path;
277
303
  const [marker, markerOffset, arrowOffset] = isStart
278
304
  ? (['markerStart', 'markerStartOffset', 'startArrowOffset'] as const)
279
305
  : (['markerEnd', 'markerEndOffset', 'endArrowOffset'] as const);
280
306
 
281
- const arrow = keyShape.style[marker];
307
+ const arrow = keyShape.parsedStyle[marker];
282
308
  // update
283
309
  if (arrow) arrow.attr(arrowStyle);
284
310
  // create
@@ -340,39 +366,26 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
340
366
  this.drawHaloShape(attributes, container);
341
367
  }
342
368
 
343
- /**
344
- * <zh/> 在元素完成创建并执行完入场动画后调用
345
- *
346
- * <en/> Called after the element is created and the entrance animation is completed
347
- * @override
348
- */
349
- public onCreate() {}
350
-
351
- /**
352
- * <zh/> 在元素更新并执行完过渡动画后调用
353
- *
354
- * <en/> Called after the element is updated and the transition animation is completed
355
- * @override
356
- */
357
- public onUpdate() {}
358
-
359
- /**
360
- * <zh/> 在元素完成退场动画并销毁后调用
361
- *
362
- * <en/> Called after the element completes the exit animation and is destroyed
363
- * @override
364
- */
365
- public onDestroy() {}
369
+ protected onframe() {
370
+ this.drawKeyShape(this.parsedAttributes, this);
371
+ this.drawHaloShape(this.parsedAttributes, this);
372
+ this.drawLabelShape(this.parsedAttributes, this);
373
+ }
366
374
 
367
375
  public animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions) {
368
- const result = super.animate(keyframes, options);
369
-
370
- if (result) {
371
- result.onframe = () => {
372
- this.drawLabelShape(this.parsedAttributes, this);
373
- };
374
- }
375
-
376
- return result;
376
+ const animation = super.animate(keyframes, options);
377
+
378
+ if (!animation) return animation;
379
+
380
+ // 设置 currentTime 时触发更新
381
+ // Trigger update when setting currentTime
382
+ return new Proxy(animation, {
383
+ set: (target, propKey, value) => {
384
+ // 需要推迟 onframe 调用时机,等待节点位置更新完成
385
+ // Need to delay the timing of the onframe call, wait for the node position update to complete
386
+ if (propKey === 'currentTime') Promise.resolve().then(() => this.onframe());
387
+ return Reflect.set(target, propKey, value);
388
+ },
389
+ });
377
390
  }
378
391
  }
@@ -1,6 +1,6 @@
1
1
  import type { DisplayObjectConfig } from '@antv/g';
2
- import { deepMix } from '@antv/util';
3
2
  import type { Point } from '../../types';
3
+ import { mergeOptions } from '../../utils/style';
4
4
  import type { BaseEdgeStyleProps } from './base-edge';
5
5
  import { Cubic } from './cubic';
6
6
 
@@ -42,7 +42,7 @@ export class CubicHorizontal extends Cubic {
42
42
  };
43
43
 
44
44
  constructor(options: DisplayObjectConfig<CubicHorizontalStyleProps>) {
45
- super(deepMix({}, { style: CubicHorizontal.defaultStyleProps }, options));
45
+ super(mergeOptions({ style: CubicHorizontal.defaultStyleProps }, options));
46
46
  }
47
47
 
48
48
  protected getControlPoints(
@@ -1,6 +1,6 @@
1
1
  import type { DisplayObjectConfig } from '@antv/g';
2
- import { deepMix } from '@antv/util';
3
2
  import type { Point } from '../../types';
3
+ import { mergeOptions } from '../../utils/style';
4
4
  import type { BaseEdgeStyleProps } from './base-edge';
5
5
  import { Cubic } from './cubic';
6
6
 
@@ -42,7 +42,7 @@ export class CubicVertical extends Cubic {
42
42
  };
43
43
 
44
44
  constructor(options: DisplayObjectConfig<CubicVerticalStyleProps>) {
45
- super(deepMix({}, { style: CubicVertical.defaultStyleProps }, options));
45
+ super(mergeOptions({ style: CubicVertical.defaultStyleProps }, options));
46
46
  }
47
47
 
48
48
  protected getControlPoints(
@@ -1,8 +1,8 @@
1
1
  import type { DisplayObjectConfig } from '@antv/g';
2
2
  import type { PathArray } from '@antv/util';
3
- import { deepMix } from '@antv/util';
4
3
  import type { Point } from '../../types';
5
4
  import { getCubicPath, getCurveControlPoint, parseCurveOffset, parseCurvePosition } from '../../utils/edge';
5
+ import { mergeOptions } from '../../utils/style';
6
6
  import type { BaseEdgeStyleProps } from './base-edge';
7
7
  import { BaseEdge } from './base-edge';
8
8
 
@@ -48,7 +48,7 @@ export class Cubic extends BaseEdge {
48
48
  };
49
49
 
50
50
  constructor(options: DisplayObjectConfig<CubicStyleProps>) {
51
- super(deepMix({}, { style: Cubic.defaultStyleProps }, options));
51
+ super(mergeOptions({ style: Cubic.defaultStyleProps }, options));
52
52
  }
53
53
 
54
54
  /**
@@ -1,6 +1,6 @@
1
1
  import type { DisplayObjectConfig } from '@antv/g';
2
2
  import type { PathArray } from '@antv/util';
3
- import { deepMix } from '@antv/util';
3
+ import { mergeOptions } from '../../utils/style';
4
4
  import type { BaseEdgeStyleProps } from './base-edge';
5
5
  import { BaseEdge } from './base-edge';
6
6
 
@@ -24,7 +24,7 @@ export class Line extends BaseEdge {
24
24
  static defaultStyleProps: Partial<LineStyleProps> = {};
25
25
 
26
26
  constructor(options: DisplayObjectConfig<LineStyleProps>) {
27
- super(deepMix({}, { style: Line.defaultStyleProps }, options));
27
+ super(mergeOptions({ style: Line.defaultStyleProps }, options));
28
28
  }
29
29
 
30
30
  protected getKeyPath(attributes: ParsedLineStyleProps): PathArray {
@@ -1,12 +1,12 @@
1
1
  import type { DisplayObjectConfig } from '@antv/g';
2
2
  import type { PathArray } from '@antv/util';
3
- import { deepMix } from '@antv/util';
4
3
  import type { LoopStyleProps, Padding, Point, Port } from '../../types';
5
4
  import { getBBoxHeight, getBBoxWidth, getNodeBBox } from '../../utils/bbox';
6
5
  import { getPolylineLoopPath, getPolylinePath } from '../../utils/edge';
7
6
  import { findPorts, getConnectionPoint, getPortPosition } from '../../utils/element';
8
7
  import { subStyleProps } from '../../utils/prefix';
9
8
  import { orth } from '../../utils/router/orth';
9
+ import { mergeOptions } from '../../utils/style';
10
10
  import type { BaseEdgeStyleProps } from './base-edge';
11
11
  import { BaseEdge } from './base-edge';
12
12
 
@@ -70,11 +70,12 @@ export class Polyline extends BaseEdge {
70
70
  };
71
71
 
72
72
  constructor(options: DisplayObjectConfig<PolylineStyleProps>) {
73
- super(deepMix({}, { style: Polyline.defaultStyleProps }, options));
73
+ super(mergeOptions({ style: Polyline.defaultStyleProps }, options));
74
74
  }
75
75
 
76
76
  protected getKeyPath(attributes: ParsedPolylineStyleProps): PathArray {
77
- const { sourceNode, targetNode, radius } = attributes;
77
+ const { radius } = attributes;
78
+ const { sourceNode, targetNode } = this;
78
79
  // 1. 获取连接点(若有连接桩,取连接桩中心;反之,取节点中心)和连接桩 | Get connection points (if port, take port center; otherwise, take node center) and ports
79
80
  const { sourcePoint, targetPoint, sourcePort, targetPort } = this.getEndpointsAndPorts(attributes);
80
81
 
@@ -98,7 +99,8 @@ export class Polyline extends BaseEdge {
98
99
  sourcePort: Port | undefined;
99
100
  targetPort: Port | undefined;
100
101
  } {
101
- const { sourceNode, targetNode, sourcePort: sourcePortKey, targetPort: targetPortKey } = attributes;
102
+ const { sourcePort: sourcePortKey, targetPort: targetPortKey } = attributes;
103
+ const { sourceNode, targetNode } = this;
102
104
 
103
105
  const [sourcePort, targetPort] = findPorts(sourceNode, targetNode, sourcePortKey, targetPortKey);
104
106
 
@@ -111,7 +113,8 @@ export class Polyline extends BaseEdge {
111
113
  }
112
114
 
113
115
  protected getControlPoints(attributes: ParsedPolylineStyleProps, sourcePoint: Point, targetPoint: Point): Point[] {
114
- const { controlPoints, sourceNode, targetNode, router, routerPadding } = attributes;
116
+ const { controlPoints, router, routerPadding } = attributes;
117
+ const { sourceNode, targetNode } = this;
115
118
 
116
119
  if (!router) return [...controlPoints];
117
120
 
@@ -122,7 +125,8 @@ export class Polyline extends BaseEdge {
122
125
  }
123
126
 
124
127
  protected getLoopPath(attributes: ParsedPolylineStyleProps): PathArray {
125
- const { sourceNode: node, sourcePort: sourcePortKey, targetPort: targetPortKey, radius } = attributes;
128
+ const { sourcePort: sourcePortKey, targetPort: targetPortKey, radius } = attributes;
129
+ const node = this.sourceNode;
126
130
 
127
131
  const bbox = getNodeBBox(node);
128
132
  // 默认转折点距离为 bbox 的最大宽高的 1/4 | Default distance of the turning point is 1/4 of the maximum width and height of the bbox
@@ -1,8 +1,8 @@
1
1
  import type { DisplayObjectConfig } from '@antv/g';
2
2
  import type { PathArray } from '@antv/util';
3
- import { deepMix } from '@antv/util';
4
3
  import type { Point } from '../../types';
5
4
  import { getCurveControlPoint, getQuadraticPath } from '../../utils/edge';
5
+ import { mergeOptions } from '../../utils/style';
6
6
  import type { BaseEdgeStyleProps } from './base-edge';
7
7
  import { BaseEdge } from './base-edge';
8
8
 
@@ -48,7 +48,7 @@ export class Quadratic extends BaseEdge {
48
48
  };
49
49
 
50
50
  constructor(options: DisplayObjectConfig<QuadraticStyleProps>) {
51
- super(deepMix({}, { style: Quadratic.defaultStyleProps }, options));
51
+ super(mergeOptions({ style: Quadratic.defaultStyleProps }, options));
52
52
  }
53
53
 
54
54
  protected getKeyPath(attributes: ParsedQuadraticStyleProps): PathArray {
@@ -1,12 +1,10 @@
1
1
  import type { BaseStyleProps, DisplayObject, DisplayObjectConfig, Group } from '@antv/g';
2
2
  import { Circle as GCircle } from '@antv/g';
3
- import { deepMix, isEmpty } from '@antv/util';
4
3
  import type { CategoricalPalette } from '../../palettes/types';
5
4
  import type { NodeData } from '../../spec';
6
5
  import type {
7
6
  BaseElementStyleProps,
8
- Keyframe,
9
- Node,
7
+ ID,
10
8
  NodeBadgeStyleProps,
11
9
  NodeLabelStyleProps,
12
10
  NodePortStyleProps,
@@ -23,10 +21,12 @@ import { getRectIntersectPoint } from '../../utils/point';
23
21
  import { getXYByPlacement } from '../../utils/position';
24
22
  import { omitStyleProps, subObject, subStyleProps } from '../../utils/prefix';
25
23
  import { parseSize } from '../../utils/size';
24
+ import { mergeOptions } from '../../utils/style';
26
25
  import { getWordWrapWidthByBox } from '../../utils/text';
27
26
  import { replaceTranslateInTransform } from '../../utils/transform';
27
+ import { BaseElement } from '../base-element';
28
28
  import type { BadgeStyleProps, IconStyleProps, LabelStyleProps } from '../shapes';
29
- import { Badge, BaseShape, Icon, Label } from '../shapes';
29
+ import { Badge, Icon, Label } from '../shapes';
30
30
 
31
31
  /**
32
32
  * <zh/> 节点通用样式配置项
@@ -83,7 +83,7 @@ export interface BaseNodeStyleProps
83
83
  *
84
84
  * <en/> Only valid in the tree graph
85
85
  */
86
- childrenNode?: Node[];
86
+ childrenNode?: ID[];
87
87
  /**
88
88
  * <zh/> 子节点数据
89
89
  *
@@ -184,7 +184,7 @@ export interface BaseNodeStyleProps
184
184
  *
185
185
  * <en/> Design document: https://www.yuque.com/antv/g6/gl1iof1xpzg6ed98
186
186
  */
187
- export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps> extends BaseShape<S> {
187
+ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps> extends BaseElement<S> {
188
188
  public type = 'node';
189
189
 
190
190
  static defaultStyleProps: Partial<BaseNodeStyleProps> = {
@@ -218,11 +218,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
218
218
  };
219
219
 
220
220
  constructor(options: DisplayObjectConfig<S>) {
221
- super(deepMix({}, { style: BaseNode.defaultStyleProps }, options));
222
- }
223
-
224
- public get parsedAttributes() {
225
- return this.attributes as Required<S>;
221
+ super(mergeOptions({ style: BaseNode.defaultStyleProps }, options));
226
222
  }
227
223
 
228
224
  protected getSize(attributes = this.attributes) {
@@ -237,9 +233,9 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
237
233
  }
238
234
 
239
235
  protected getLabelStyle(attributes: Required<S>): false | LabelStyleProps {
240
- if (attributes.label === false || isEmpty(attributes.labelText)) return false;
236
+ if (attributes.label === false || !attributes.labelText) return false;
241
237
 
242
- const { placement, maxWidth, ...labelStyle } = subStyleProps<Required<NodeLabelStyleProps>>(
238
+ const { placement, maxWidth, offsetX, offsetY, ...labelStyle } = subStyleProps<Required<NodeLabelStyleProps>>(
243
239
  this.getGraphicStyle(attributes),
244
240
  'label',
245
241
  );
@@ -247,7 +243,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
247
243
  const keyBounds = keyShape.getLocalBounds();
248
244
 
249
245
  return Object.assign(
250
- getTextStyleByPlacement(keyBounds, placement),
246
+ getTextStyleByPlacement(keyBounds, placement, offsetX, offsetY),
251
247
  { wordWrapWidth: getWordWrapWidthByBox(keyBounds, maxWidth) },
252
248
  labelStyle,
253
249
  );
@@ -263,7 +259,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
263
259
  }
264
260
 
265
261
  protected getIconStyle(attributes: Required<S>): false | IconStyleProps {
266
- if (attributes.icon === false || isEmpty(attributes.iconText || attributes.iconSrc)) return false;
262
+ if (attributes.icon === false || (!attributes.iconText && !attributes.iconSrc)) return false;
267
263
 
268
264
  const iconStyle = subStyleProps(this.getGraphicStyle(attributes), 'icon');
269
265
  const keyShape = this.getKey();
@@ -279,7 +275,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
279
275
  Object.keys(badges).forEach((key) => {
280
276
  badgesShapeStyle[key] = false;
281
277
  });
282
- if (attributes.badge === false || isEmpty(attributes.badges)) return badgesShapeStyle;
278
+ if (attributes.badge === false || !attributes.badges?.length) return badgesShapeStyle;
283
279
 
284
280
  const { badges: badgeOptions = [], badgePalette, opacity = 1, ...restAttributes } = attributes;
285
281
  const colors = getPaletteColors(badgePalette);
@@ -299,8 +295,8 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
299
295
 
300
296
  protected getBadgeStyle(style: NodeBadgeStyleProps): NodeBadgeStyleProps {
301
297
  const keyShape = this.getKey();
302
- const { placement = 'top', ...restStyle } = style;
303
- const textStyle = getTextStyleByPlacement(keyShape.getLocalBounds(), placement, true);
298
+ const { placement = 'top', offsetX, offsetY, ...restStyle } = style;
299
+ const textStyle = getTextStyleByPlacement(keyShape.getLocalBounds(), placement, offsetX, offsetY, true);
304
300
  return { ...textStyle, ...restStyle };
305
301
  }
306
302
 
@@ -312,7 +308,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
312
308
  portsShapeStyle[key] = false;
313
309
  });
314
310
 
315
- if (attributes.port === false || isEmpty(attributes.ports)) return portsShapeStyle;
311
+ if (attributes.port === false || !attributes.ports?.length) return portsShapeStyle;
316
312
 
317
313
  const portStyle = subStyleProps<PortStyleProps>(this.getGraphicStyle(attributes), 'port');
318
314
  const { ports: portOptions = [] } = attributes;
@@ -379,6 +375,10 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
379
375
  );
380
376
  }
381
377
 
378
+ protected drawIconShape(attributes: Required<S>, container: Group): void {
379
+ this.upsert('icon', Icon, this.getIconStyle(attributes), container);
380
+ }
381
+
382
382
  protected drawBadgeShapes(attributes: Required<S>, container: Group): void {
383
383
  const badgesStyle = this.getBadgesStyle(attributes);
384
384
  Object.keys(badgesStyle).forEach((key) => {
@@ -393,6 +393,10 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
393
393
  });
394
394
  }
395
395
 
396
+ protected drawLabelShape(attributes: Required<S>, container: Group): void {
397
+ this.upsert('label', Label, this.getLabelStyle(attributes), container);
398
+ }
399
+
396
400
  protected abstract drawKeyShape(attributes: Required<S>, container: Group): DisplayObject | undefined;
397
401
 
398
402
  public render(attributes = this.parsedAttributes, container: Group = this) {
@@ -410,51 +414,20 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
410
414
  this.drawHaloShape(attributes, container);
411
415
 
412
416
  // 3. icon
413
- this.upsert('icon', Icon, this.getIconStyle(attributes), container);
417
+ this.drawIconShape(attributes, container);
414
418
 
415
419
  // 4. badges
416
420
  this.drawBadgeShapes(attributes, container);
417
421
 
418
422
  // 5. label
419
- this.upsert('label', Label, this.getLabelStyle(attributes), container);
423
+ this.drawLabelShape(attributes, container);
420
424
 
421
425
  // 6. ports
422
426
  this.drawPortShapes(attributes, container);
423
427
  }
424
428
 
425
- /**
426
- * <zh/> 在元素完成创建并执行完入场动画后调用
427
- *
428
- * <en/> Called after the element is created and the entrance animation is completed
429
- * @override
430
- */
431
- public onCreate() {}
432
-
433
- /**
434
- * <zh/> 在元素更新并执行完过渡动画后调用
435
- *
436
- * <en/> Called after the element is updated and the transition animation is completed
437
- * @override
438
- */
439
- public onUpdate() {}
440
-
441
- /**
442
- * <zh/> 在元素完成退场动画并销毁后调用
443
- *
444
- * <en/> Called after the element completes the exit animation and is destroyed
445
- * @override
446
- */
447
- public onDestroy() {}
448
-
449
- public animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions) {
450
- const result = super.animate(keyframes, options);
451
-
452
- if (result) {
453
- result.onframe = () => {
454
- this.drawBadgeShapes(this.parsedAttributes, this);
455
- };
456
- }
457
-
458
- return result;
429
+ protected onframe() {
430
+ this.drawBadgeShapes(this.parsedAttributes, this);
431
+ this.drawLabelShape(this.parsedAttributes, this);
459
432
  }
460
433
  }
@@ -1,9 +1,9 @@
1
1
  import type { DisplayObjectConfig, CircleStyleProps as GCircleStyleProps, Group } from '@antv/g';
2
2
  import { Circle as GCircle } from '@antv/g';
3
- import { deepMix } from '@antv/util';
4
3
  import { ICON_SIZE_RATIO } from '../../constants/element';
5
4
  import type { Point } from '../../types';
6
5
  import { getEllipseIntersectPoint } from '../../utils/point';
6
+ import { mergeOptions } from '../../utils/style';
7
7
  import type { IconStyleProps } from '../shapes';
8
8
  import type { BaseNodeStyleProps } from './base-node';
9
9
  import { BaseNode } from './base-node';
@@ -26,7 +26,7 @@ export class Circle extends BaseNode {
26
26
  };
27
27
 
28
28
  constructor(options: DisplayObjectConfig<CircleStyleProps>) {
29
- super(deepMix({}, { style: Circle.defaultStyleProps }, options));
29
+ super(mergeOptions({ style: Circle.defaultStyleProps }, options));
30
30
  }
31
31
 
32
32
  protected drawKeyShape(attributes: Required<CircleStyleProps>, container: Group) {
@@ -1,5 +1,5 @@
1
1
  import { Path } from '@antv/g';
2
- import { deepMix, isNumber, isString } from '@antv/util';
2
+ import { isNumber, isString } from '@antv/util';
3
3
  import { getPaletteColors } from '../../utils/palette';
4
4
  import { subStyleProps } from '../../utils/prefix';
5
5
  import { parseSize } from '../../utils/size';
@@ -8,6 +8,7 @@ import { Circle } from './circle';
8
8
  import type { BaseStyleProps, DisplayObjectConfig, Group } from '@antv/g';
9
9
  import type { CategoricalPalette } from '../../palettes/types';
10
10
  import type { DonutRound, Prefix } from '../../types';
11
+ import { mergeOptions } from '../../utils/style';
11
12
  import type { CircleStyleProps } from './circle';
12
13
 
13
14
  /**
@@ -51,7 +52,7 @@ export class Donut extends Circle {
51
52
  };
52
53
 
53
54
  constructor(options: DisplayObjectConfig<DonutStyleProps>) {
54
- super(deepMix({}, { style: Donut.defaultStyleProps }, options));
55
+ super(mergeOptions({ style: Donut.defaultStyleProps }, options));
55
56
  }
56
57
 
57
58
  private parseOuterR() {
@@ -1,9 +1,9 @@
1
1
  import type { DisplayObjectConfig, EllipseStyleProps as GEllipseStyleProps, Group } from '@antv/g';
2
2
  import { Ellipse as GEllipse } from '@antv/g';
3
- import { deepMix } from '@antv/util';
4
3
  import { ICON_SIZE_RATIO } from '../../constants/element';
5
4
  import type { Point } from '../../types';
6
5
  import { getEllipseIntersectPoint } from '../../utils/point';
6
+ import { mergeOptions } from '../../utils/style';
7
7
  import type { IconStyleProps } from '../shapes';
8
8
  import type { BaseNodeStyleProps } from './base-node';
9
9
  import { BaseNode } from './base-node';
@@ -26,7 +26,7 @@ export class Ellipse extends BaseNode {
26
26
  };
27
27
 
28
28
  constructor(options: DisplayObjectConfig<EllipseStyleProps>) {
29
- super(deepMix({}, { style: Ellipse.defaultStyleProps }, options));
29
+ super(mergeOptions({ style: Ellipse.defaultStyleProps }, options));
30
30
  }
31
31
 
32
32
  protected drawKeyShape(attributes: Required<EllipseStyleProps>, container: Group) {
@@ -95,12 +95,13 @@ export class HTML extends BaseNode<HTMLStyleProps> {
95
95
  }
96
96
  }
97
97
 
98
- public onDestroy() {
98
+ public destroy() {
99
99
  const element = this.getDomElement();
100
100
  this.events.forEach((eventName) => {
101
101
  // @ts-expect-error assert event is PointerEvent
102
102
  element.removeEventListener(eventName, this.forwardEvents);
103
103
  });
104
+ super.destroy();
104
105
  }
105
106
 
106
107
  private forwardEvents = (nativeEvent: PointerEvent) => {
@@ -245,4 +246,11 @@ export class HTML extends BaseNode<HTMLStyleProps> {
245
246
  }
246
247
  return { x, y };
247
248
  }
249
+
250
+ protected onframe(): void {
251
+ super.onframe();
252
+ // sync opacity
253
+ const { opacity } = this.attributes;
254
+ this.getDomElement().style.opacity = `${opacity}`;
255
+ }
248
256
  }