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

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 (466) 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/collapse-expand.d.ts +10 -1
  6. package/dist/lib/behaviors/drag-canvas.d.ts +1 -0
  7. package/dist/lib/behaviors/hover-element.d.ts +2 -0
  8. package/dist/lib/constants/animation.d.ts +3 -2
  9. package/dist/lib/constants/events/animation.d.ts +2 -0
  10. package/dist/lib/constants/events/graph.d.ts +0 -12
  11. package/dist/lib/elements/base-element.d.ts +35 -0
  12. package/dist/lib/elements/combos/base-combo.d.ts +8 -32
  13. package/dist/lib/elements/combos/circle.d.ts +1 -2
  14. package/dist/lib/elements/edges/base-edge.d.ts +21 -30
  15. package/dist/lib/elements/nodes/base-node.d.ts +7 -27
  16. package/dist/lib/elements/nodes/html.d.ts +2 -1
  17. package/dist/lib/elements/shapes/badge.d.ts +1 -1
  18. package/dist/lib/elements/shapes/base-shape.d.ts +6 -0
  19. package/dist/lib/exports.d.ts +3 -2
  20. package/dist/lib/layouts/types.d.ts +1 -1
  21. package/dist/lib/plugins/background/index.d.ts +38 -0
  22. package/dist/lib/plugins/{contextmenu.d.ts → contextmenu/index.d.ts} +5 -5
  23. package/dist/lib/plugins/index.d.ts +2 -0
  24. package/{lib/plugins/watermark.d.ts → dist/lib/plugins/watermark/index.d.ts} +3 -3
  25. package/dist/lib/runtime/animation.d.ts +54 -0
  26. package/dist/lib/runtime/canvas.d.ts +0 -2
  27. package/dist/lib/runtime/data.d.ts +4 -4
  28. package/dist/lib/runtime/element.d.ts +26 -40
  29. package/dist/lib/runtime/graph.d.ts +1 -0
  30. package/dist/lib/runtime/layout.d.ts +7 -0
  31. package/dist/lib/runtime/transform.d.ts +1 -0
  32. package/dist/lib/runtime/types.d.ts +7 -0
  33. package/dist/lib/spec/data.d.ts +14 -0
  34. package/dist/lib/spec/element/animation.d.ts +3 -9
  35. package/dist/lib/spec/element/combo.d.ts +4 -3
  36. package/dist/lib/spec/element/edge.d.ts +4 -3
  37. package/dist/lib/spec/element/node.d.ts +4 -3
  38. package/dist/lib/transforms/base-transform.d.ts +2 -1
  39. package/dist/lib/transforms/collapse-expand-combo.d.ts +4 -3
  40. package/dist/lib/transforms/collapse-expand-node.d.ts +12 -0
  41. package/dist/lib/transforms/get-edge-actual-ends.d.ts +13 -0
  42. package/dist/lib/transforms/index.d.ts +2 -0
  43. package/dist/lib/transforms/process-parallel-edges.d.ts +6 -4
  44. package/dist/lib/transforms/types.d.ts +2 -2
  45. package/dist/lib/transforms/update-related-edge.d.ts +2 -1
  46. package/dist/lib/transforms/utils.d.ts +13 -0
  47. package/dist/lib/types/animation.d.ts +1 -2
  48. package/dist/lib/types/node.d.ts +12 -0
  49. package/dist/lib/utils/animation.d.ts +17 -29
  50. package/dist/lib/utils/collapsibility.d.ts +9 -0
  51. package/dist/lib/utils/element.d.ts +19 -2
  52. package/dist/lib/utils/theme.d.ts +9 -0
  53. package/dist/lib/utils/transform.d.ts +14 -0
  54. package/esm/animations/executor.d.ts +4 -5
  55. package/esm/animations/executor.js +31 -48
  56. package/esm/animations/executor.js.map +1 -1
  57. package/esm/animations/index.d.ts +22 -8
  58. package/esm/animations/index.js +10 -12
  59. package/esm/animations/index.js.map +1 -1
  60. package/esm/animations/types.d.ts +78 -20
  61. package/esm/behaviors/collapse-expand.d.ts +10 -1
  62. package/esm/behaviors/collapse-expand.js +15 -6
  63. package/esm/behaviors/collapse-expand.js.map +1 -1
  64. package/esm/behaviors/create-edge.js +2 -2
  65. package/esm/behaviors/create-edge.js.map +1 -1
  66. package/esm/behaviors/drag-canvas.d.ts +1 -0
  67. package/esm/behaviors/drag-canvas.js +5 -1
  68. package/esm/behaviors/drag-canvas.js.map +1 -1
  69. package/esm/behaviors/drag-element.js +2 -2
  70. package/esm/behaviors/drag-element.js.map +1 -1
  71. package/esm/behaviors/hover-element.d.ts +2 -0
  72. package/esm/behaviors/hover-element.js +12 -2
  73. package/esm/behaviors/hover-element.js.map +1 -1
  74. package/esm/constants/animation.d.ts +3 -2
  75. package/esm/constants/animation.js.map +1 -1
  76. package/esm/constants/events/animation.d.ts +2 -0
  77. package/esm/constants/events/animation.js +2 -0
  78. package/esm/constants/events/animation.js.map +1 -1
  79. package/esm/constants/events/graph.d.ts +0 -12
  80. package/esm/constants/events/graph.js +0 -12
  81. package/esm/constants/events/graph.js.map +1 -1
  82. package/esm/elements/base-element.d.ts +35 -0
  83. package/esm/elements/base-element.js +42 -0
  84. package/esm/elements/base-element.js.map +1 -0
  85. package/esm/elements/combos/base-combo.d.ts +8 -32
  86. package/esm/elements/combos/base-combo.js +53 -55
  87. package/esm/elements/combos/base-combo.js.map +1 -1
  88. package/esm/elements/combos/circle.d.ts +1 -2
  89. package/esm/elements/combos/circle.js +1 -12
  90. package/esm/elements/combos/circle.js.map +1 -1
  91. package/esm/elements/combos/rect.js +1 -2
  92. package/esm/elements/combos/rect.js.map +1 -1
  93. package/esm/elements/edges/base-edge.d.ts +21 -30
  94. package/esm/elements/edges/base-edge.js +38 -35
  95. package/esm/elements/edges/base-edge.js.map +1 -1
  96. package/esm/elements/edges/polyline.js +8 -4
  97. package/esm/elements/edges/polyline.js.map +1 -1
  98. package/esm/elements/nodes/base-node.d.ts +7 -27
  99. package/esm/elements/nodes/base-node.js +16 -38
  100. package/esm/elements/nodes/base-node.js.map +1 -1
  101. package/esm/elements/nodes/html.d.ts +2 -1
  102. package/esm/elements/nodes/html.js +8 -1
  103. package/esm/elements/nodes/html.js.map +1 -1
  104. package/esm/elements/shapes/badge.d.ts +1 -1
  105. package/esm/elements/shapes/base-shape.d.ts +6 -0
  106. package/esm/elements/shapes/base-shape.js +23 -6
  107. package/esm/elements/shapes/base-shape.js.map +1 -1
  108. package/esm/exports.d.ts +3 -2
  109. package/esm/layouts/types.d.ts +1 -1
  110. package/esm/plugins/background/index.d.ts +38 -0
  111. package/esm/plugins/background/index.js +49 -0
  112. package/esm/plugins/background/index.js.map +1 -0
  113. package/esm/plugins/{contextmenu.d.ts → contextmenu/index.d.ts} +5 -5
  114. package/esm/plugins/{contextmenu.js → contextmenu/index.js} +4 -4
  115. package/esm/plugins/contextmenu/index.js.map +1 -0
  116. package/esm/{utils/contextmenu.js → plugins/contextmenu/util.js} +1 -1
  117. package/esm/{utils/contextmenu.js.map → plugins/contextmenu/util.js.map} +1 -1
  118. package/esm/plugins/history/index.js +1 -1
  119. package/esm/plugins/history/index.js.map +1 -1
  120. package/esm/plugins/history/{utils.js → util.js} +1 -1
  121. package/esm/plugins/history/util.js.map +1 -0
  122. package/esm/plugins/index.d.ts +2 -0
  123. package/esm/plugins/index.js +1 -0
  124. package/esm/plugins/index.js.map +1 -1
  125. package/esm/plugins/timebar.js +1 -1
  126. package/esm/plugins/timebar.js.map +1 -1
  127. package/{dist/lib/plugins/watermark.d.ts → esm/plugins/watermark/index.d.ts} +3 -3
  128. package/esm/plugins/{watermark.js → watermark/index.js} +4 -4
  129. package/esm/plugins/watermark/index.js.map +1 -0
  130. package/esm/{utils/watermark.js → plugins/watermark/util.js} +1 -1
  131. package/esm/plugins/watermark/util.js.map +1 -0
  132. package/esm/registry/build-in.js +14 -6
  133. package/esm/registry/build-in.js.map +1 -1
  134. package/esm/runtime/animation.d.ts +54 -0
  135. package/esm/runtime/animation.js +139 -0
  136. package/esm/runtime/animation.js.map +1 -0
  137. package/esm/runtime/canvas.d.ts +0 -2
  138. package/esm/runtime/canvas.js +0 -21
  139. package/esm/runtime/canvas.js.map +1 -1
  140. package/esm/runtime/data.d.ts +4 -4
  141. package/esm/runtime/data.js +16 -17
  142. package/esm/runtime/data.js.map +1 -1
  143. package/esm/runtime/element.d.ts +26 -40
  144. package/esm/runtime/element.js +218 -179
  145. package/esm/runtime/element.js.map +1 -1
  146. package/esm/runtime/graph.d.ts +1 -0
  147. package/esm/runtime/graph.js +44 -11
  148. package/esm/runtime/graph.js.map +1 -1
  149. package/esm/runtime/layout.d.ts +7 -0
  150. package/esm/runtime/layout.js +44 -3
  151. package/esm/runtime/layout.js.map +1 -1
  152. package/esm/runtime/transform.d.ts +1 -0
  153. package/esm/runtime/transform.js +9 -2
  154. package/esm/runtime/transform.js.map +1 -1
  155. package/esm/runtime/types.d.ts +7 -0
  156. package/esm/runtime/viewport.js +2 -2
  157. package/esm/runtime/viewport.js.map +1 -1
  158. package/esm/spec/data.d.ts +14 -0
  159. package/esm/spec/element/animation.d.ts +3 -9
  160. package/esm/spec/element/combo.d.ts +4 -3
  161. package/esm/spec/element/edge.d.ts +4 -3
  162. package/esm/spec/element/node.d.ts +4 -3
  163. package/esm/themes/base.js +14 -10
  164. package/esm/themes/base.js.map +1 -1
  165. package/esm/transforms/base-transform.d.ts +2 -1
  166. package/esm/transforms/base-transform.js +1 -1
  167. package/esm/transforms/base-transform.js.map +1 -1
  168. package/esm/transforms/collapse-expand-combo.d.ts +4 -3
  169. package/esm/transforms/collapse-expand-combo.js +9 -25
  170. package/esm/transforms/collapse-expand-combo.js.map +1 -1
  171. package/esm/transforms/collapse-expand-node.d.ts +12 -0
  172. package/esm/transforms/collapse-expand-node.js +91 -0
  173. package/esm/transforms/collapse-expand-node.js.map +1 -0
  174. package/esm/transforms/get-edge-actual-ends.d.ts +13 -0
  175. package/esm/transforms/get-edge-actual-ends.js +36 -0
  176. package/esm/transforms/get-edge-actual-ends.js.map +1 -0
  177. package/esm/transforms/index.d.ts +2 -0
  178. package/esm/transforms/index.js +2 -0
  179. package/esm/transforms/index.js.map +1 -1
  180. package/esm/transforms/process-parallel-edges.d.ts +6 -4
  181. package/esm/transforms/process-parallel-edges.js +42 -27
  182. package/esm/transforms/process-parallel-edges.js.map +1 -1
  183. package/esm/transforms/types.d.ts +2 -2
  184. package/esm/transforms/types.js +1 -10
  185. package/esm/transforms/types.js.map +1 -1
  186. package/esm/transforms/update-related-edge.d.ts +2 -1
  187. package/esm/transforms/update-related-edge.js +4 -1
  188. package/esm/transforms/update-related-edge.js.map +1 -1
  189. package/esm/transforms/utils.d.ts +13 -0
  190. package/esm/transforms/utils.js +25 -0
  191. package/esm/transforms/utils.js.map +1 -0
  192. package/esm/types/animation.d.ts +1 -2
  193. package/esm/types/node.d.ts +12 -0
  194. package/esm/utils/animation.d.ts +17 -29
  195. package/esm/utils/animation.js +64 -54
  196. package/esm/utils/animation.js.map +1 -1
  197. package/esm/utils/cache.js +0 -1
  198. package/esm/utils/cache.js.map +1 -1
  199. package/esm/utils/collapsibility.d.ts +9 -0
  200. package/esm/utils/collapsibility.js +11 -0
  201. package/esm/utils/collapsibility.js.map +1 -0
  202. package/esm/utils/dom.js +1 -2
  203. package/esm/utils/dom.js.map +1 -1
  204. package/esm/utils/edge.js +2 -1
  205. package/esm/utils/edge.js.map +1 -1
  206. package/esm/utils/element.d.ts +19 -2
  207. package/esm/utils/element.js +24 -3
  208. package/esm/utils/element.js.map +1 -1
  209. package/esm/utils/theme.d.ts +9 -0
  210. package/esm/utils/theme.js +17 -0
  211. package/esm/utils/theme.js.map +1 -0
  212. package/esm/utils/transform.d.ts +14 -0
  213. package/esm/utils/transform.js +24 -0
  214. package/esm/utils/transform.js.map +1 -1
  215. package/lib/animations/executor.d.ts +4 -5
  216. package/lib/animations/executor.js +30 -47
  217. package/lib/animations/executor.js.map +1 -1
  218. package/lib/animations/index.d.ts +22 -8
  219. package/lib/animations/index.js +12 -14
  220. package/lib/animations/index.js.map +1 -1
  221. package/lib/animations/types.d.ts +78 -20
  222. package/lib/behaviors/collapse-expand.d.ts +10 -1
  223. package/lib/behaviors/collapse-expand.js +15 -6
  224. package/lib/behaviors/collapse-expand.js.map +1 -1
  225. package/lib/behaviors/create-edge.js +2 -2
  226. package/lib/behaviors/create-edge.js.map +1 -1
  227. package/lib/behaviors/drag-canvas.d.ts +1 -0
  228. package/lib/behaviors/drag-canvas.js +5 -1
  229. package/lib/behaviors/drag-canvas.js.map +1 -1
  230. package/lib/behaviors/drag-element.js +2 -2
  231. package/lib/behaviors/drag-element.js.map +1 -1
  232. package/lib/behaviors/hover-element.d.ts +2 -0
  233. package/lib/behaviors/hover-element.js +12 -2
  234. package/lib/behaviors/hover-element.js.map +1 -1
  235. package/lib/constants/animation.d.ts +3 -2
  236. package/lib/constants/animation.js.map +1 -1
  237. package/lib/constants/events/animation.d.ts +2 -0
  238. package/lib/constants/events/animation.js +2 -0
  239. package/lib/constants/events/animation.js.map +1 -1
  240. package/lib/constants/events/graph.d.ts +0 -12
  241. package/lib/constants/events/graph.js +0 -12
  242. package/lib/constants/events/graph.js.map +1 -1
  243. package/lib/elements/base-element.d.ts +35 -0
  244. package/lib/elements/base-element.js +46 -0
  245. package/lib/elements/base-element.js.map +1 -0
  246. package/lib/elements/combos/base-combo.d.ts +8 -32
  247. package/lib/elements/combos/base-combo.js +52 -54
  248. package/lib/elements/combos/base-combo.js.map +1 -1
  249. package/lib/elements/combos/circle.d.ts +1 -2
  250. package/lib/elements/combos/circle.js +1 -12
  251. package/lib/elements/combos/circle.js.map +1 -1
  252. package/lib/elements/combos/rect.js +1 -2
  253. package/lib/elements/combos/rect.js.map +1 -1
  254. package/lib/elements/edges/base-edge.d.ts +21 -30
  255. package/lib/elements/edges/base-edge.js +38 -35
  256. package/lib/elements/edges/base-edge.js.map +1 -1
  257. package/lib/elements/edges/polyline.js +8 -4
  258. package/lib/elements/edges/polyline.js.map +1 -1
  259. package/lib/elements/nodes/base-node.d.ts +7 -27
  260. package/lib/elements/nodes/base-node.js +15 -37
  261. package/lib/elements/nodes/base-node.js.map +1 -1
  262. package/lib/elements/nodes/html.d.ts +2 -1
  263. package/lib/elements/nodes/html.js +8 -1
  264. package/lib/elements/nodes/html.js.map +1 -1
  265. package/lib/elements/shapes/badge.d.ts +1 -1
  266. package/lib/elements/shapes/base-shape.d.ts +6 -0
  267. package/lib/elements/shapes/base-shape.js +23 -6
  268. package/lib/elements/shapes/base-shape.js.map +1 -1
  269. package/lib/exports.d.ts +3 -2
  270. package/lib/layouts/types.d.ts +1 -1
  271. package/lib/plugins/background/index.d.ts +38 -0
  272. package/lib/plugins/background/index.js +53 -0
  273. package/lib/plugins/background/index.js.map +1 -0
  274. package/lib/plugins/{contextmenu.d.ts → contextmenu/index.d.ts} +5 -5
  275. package/lib/plugins/{contextmenu.js → contextmenu/index.js} +6 -6
  276. package/lib/plugins/{contextmenu.js.map → contextmenu/index.js.map} +1 -1
  277. package/lib/{utils/contextmenu.js → plugins/contextmenu/util.js} +1 -1
  278. package/lib/{utils/contextmenu.js.map → plugins/contextmenu/util.js.map} +1 -1
  279. package/lib/plugins/history/index.js +2 -2
  280. package/lib/plugins/history/index.js.map +1 -1
  281. package/lib/plugins/history/{utils.js → util.js} +1 -1
  282. package/lib/plugins/history/util.js.map +1 -0
  283. package/lib/plugins/index.d.ts +2 -0
  284. package/lib/plugins/index.js +3 -1
  285. package/lib/plugins/index.js.map +1 -1
  286. package/lib/plugins/timebar.js +1 -1
  287. package/lib/plugins/timebar.js.map +1 -1
  288. package/{esm/plugins/watermark.d.ts → lib/plugins/watermark/index.d.ts} +3 -3
  289. package/lib/plugins/{watermark.js → watermark/index.js} +6 -6
  290. package/lib/plugins/watermark/index.js.map +1 -0
  291. package/lib/{utils/watermark.js → plugins/watermark/util.js} +1 -1
  292. package/lib/plugins/watermark/util.js.map +1 -0
  293. package/lib/registry/build-in.js +11 -3
  294. package/lib/registry/build-in.js.map +1 -1
  295. package/lib/runtime/animation.d.ts +54 -0
  296. package/lib/runtime/animation.js +143 -0
  297. package/lib/runtime/animation.js.map +1 -0
  298. package/lib/runtime/canvas.d.ts +0 -2
  299. package/lib/runtime/canvas.js +0 -21
  300. package/lib/runtime/canvas.js.map +1 -1
  301. package/lib/runtime/data.d.ts +4 -4
  302. package/lib/runtime/data.js +15 -16
  303. package/lib/runtime/data.js.map +1 -1
  304. package/lib/runtime/element.d.ts +26 -40
  305. package/lib/runtime/element.js +215 -176
  306. package/lib/runtime/element.js.map +1 -1
  307. package/lib/runtime/graph.d.ts +1 -0
  308. package/lib/runtime/graph.js +44 -11
  309. package/lib/runtime/graph.js.map +1 -1
  310. package/lib/runtime/layout.d.ts +7 -0
  311. package/lib/runtime/layout.js +43 -2
  312. package/lib/runtime/layout.js.map +1 -1
  313. package/lib/runtime/transform.d.ts +1 -0
  314. package/lib/runtime/transform.js +9 -2
  315. package/lib/runtime/transform.js.map +1 -1
  316. package/lib/runtime/types.d.ts +7 -0
  317. package/lib/runtime/viewport.js +1 -1
  318. package/lib/runtime/viewport.js.map +1 -1
  319. package/lib/spec/data.d.ts +14 -0
  320. package/lib/spec/element/animation.d.ts +3 -9
  321. package/lib/spec/element/combo.d.ts +4 -3
  322. package/lib/spec/element/edge.d.ts +4 -3
  323. package/lib/spec/element/node.d.ts +4 -3
  324. package/lib/themes/base.js +14 -10
  325. package/lib/themes/base.js.map +1 -1
  326. package/lib/transforms/base-transform.d.ts +2 -1
  327. package/lib/transforms/base-transform.js +1 -1
  328. package/lib/transforms/base-transform.js.map +1 -1
  329. package/lib/transforms/collapse-expand-combo.d.ts +4 -3
  330. package/lib/transforms/collapse-expand-combo.js +13 -29
  331. package/lib/transforms/collapse-expand-combo.js.map +1 -1
  332. package/lib/transforms/collapse-expand-node.d.ts +12 -0
  333. package/lib/transforms/collapse-expand-node.js +95 -0
  334. package/lib/transforms/collapse-expand-node.js.map +1 -0
  335. package/lib/transforms/get-edge-actual-ends.d.ts +13 -0
  336. package/lib/transforms/get-edge-actual-ends.js +41 -0
  337. package/lib/transforms/get-edge-actual-ends.js.map +1 -0
  338. package/lib/transforms/index.d.ts +2 -0
  339. package/lib/transforms/index.js +5 -1
  340. package/lib/transforms/index.js.map +1 -1
  341. package/lib/transforms/process-parallel-edges.d.ts +6 -4
  342. package/lib/transforms/process-parallel-edges.js +41 -26
  343. package/lib/transforms/process-parallel-edges.js.map +1 -1
  344. package/lib/transforms/types.d.ts +2 -2
  345. package/lib/transforms/types.js +0 -12
  346. package/lib/transforms/types.js.map +1 -1
  347. package/lib/transforms/update-related-edge.d.ts +2 -1
  348. package/lib/transforms/update-related-edge.js +4 -1
  349. package/lib/transforms/update-related-edge.js.map +1 -1
  350. package/lib/transforms/utils.d.ts +13 -0
  351. package/lib/transforms/utils.js +29 -0
  352. package/lib/transforms/utils.js.map +1 -0
  353. package/lib/types/animation.d.ts +1 -2
  354. package/lib/types/node.d.ts +12 -0
  355. package/lib/utils/animation.d.ts +17 -29
  356. package/lib/utils/animation.js +65 -56
  357. package/lib/utils/animation.js.map +1 -1
  358. package/lib/utils/cache.js +0 -1
  359. package/lib/utils/cache.js.map +1 -1
  360. package/lib/utils/collapsibility.d.ts +9 -0
  361. package/lib/utils/collapsibility.js +15 -0
  362. package/lib/utils/collapsibility.js.map +1 -0
  363. package/lib/utils/dom.js +1 -2
  364. package/lib/utils/dom.js.map +1 -1
  365. package/lib/utils/edge.js +2 -1
  366. package/lib/utils/edge.js.map +1 -1
  367. package/lib/utils/element.d.ts +19 -2
  368. package/lib/utils/element.js +26 -3
  369. package/lib/utils/element.js.map +1 -1
  370. package/lib/utils/theme.d.ts +9 -0
  371. package/lib/utils/theme.js +21 -0
  372. package/lib/utils/theme.js.map +1 -0
  373. package/lib/utils/transform.d.ts +14 -0
  374. package/lib/utils/transform.js +26 -1
  375. package/lib/utils/transform.js.map +1 -1
  376. package/package.json +6 -6
  377. package/src/animations/executor.ts +39 -61
  378. package/src/animations/index.ts +19 -15
  379. package/src/animations/types.ts +82 -27
  380. package/src/behaviors/collapse-expand.ts +25 -9
  381. package/src/behaviors/create-edge.ts +2 -2
  382. package/src/behaviors/drag-canvas.ts +6 -1
  383. package/src/behaviors/drag-element.ts +2 -2
  384. package/src/behaviors/hover-element.ts +17 -3
  385. package/src/constants/animation.ts +4 -2
  386. package/src/constants/events/animation.ts +2 -0
  387. package/src/constants/events/graph.ts +0 -12
  388. package/src/elements/base-element.ts +52 -0
  389. package/src/elements/combos/base-combo.ts +66 -74
  390. package/src/elements/combos/circle.ts +2 -20
  391. package/src/elements/combos/rect.ts +1 -2
  392. package/src/elements/edges/base-edge.ts +57 -45
  393. package/src/elements/edges/polyline.ts +8 -4
  394. package/src/elements/nodes/base-node.ts +20 -47
  395. package/src/elements/nodes/html.ts +9 -1
  396. package/src/elements/shapes/base-shape.ts +24 -9
  397. package/src/exports.ts +3 -2
  398. package/src/layouts/types.ts +1 -1
  399. package/src/plugins/background/index.ts +65 -0
  400. package/src/plugins/{contextmenu.ts → contextmenu/index.ts} +7 -7
  401. package/src/plugins/history/index.ts +1 -1
  402. package/src/plugins/index.ts +2 -0
  403. package/src/plugins/timebar.ts +1 -1
  404. package/src/plugins/{watermark.ts → watermark/index.ts} +5 -5
  405. package/src/registry/build-in.ts +21 -5
  406. package/src/runtime/animation.ts +186 -0
  407. package/src/runtime/canvas.ts +0 -24
  408. package/src/runtime/data.ts +16 -19
  409. package/src/runtime/element.ts +289 -255
  410. package/src/runtime/graph.ts +44 -11
  411. package/src/runtime/layout.ts +51 -4
  412. package/src/runtime/transform.ts +10 -2
  413. package/src/runtime/types.ts +7 -0
  414. package/src/runtime/viewport.ts +2 -2
  415. package/src/spec/data.ts +14 -1
  416. package/src/spec/element/animation.ts +3 -13
  417. package/src/spec/element/combo.ts +4 -3
  418. package/src/spec/element/edge.ts +4 -3
  419. package/src/spec/element/node.ts +4 -3
  420. package/src/themes/base.ts +14 -10
  421. package/src/transforms/base-transform.ts +2 -1
  422. package/src/transforms/collapse-expand-combo.ts +11 -32
  423. package/src/transforms/collapse-expand-node.ts +107 -0
  424. package/src/transforms/get-edge-actual-ends.ts +45 -0
  425. package/src/transforms/index.ts +2 -0
  426. package/src/transforms/process-parallel-edges.ts +50 -36
  427. package/src/transforms/types.ts +5 -5
  428. package/src/transforms/update-related-edge.ts +5 -1
  429. package/src/transforms/utils.ts +31 -0
  430. package/src/types/animation.ts +1 -3
  431. package/src/types/node.ts +12 -0
  432. package/src/utils/animation.ts +73 -63
  433. package/src/utils/cache.ts +0 -1
  434. package/src/utils/collapsibility.ts +12 -0
  435. package/src/utils/dom.ts +1 -2
  436. package/src/utils/edge.ts +2 -1
  437. package/src/utils/element.ts +28 -3
  438. package/src/utils/theme.ts +18 -0
  439. package/src/utils/transform.ts +33 -0
  440. package/dist/lib/utils/combo.d.ts +0 -34
  441. package/esm/plugins/contextmenu.js.map +0 -1
  442. package/esm/plugins/history/utils.js.map +0 -1
  443. package/esm/plugins/watermark.js.map +0 -1
  444. package/esm/utils/combo.d.ts +0 -34
  445. package/esm/utils/combo.js +0 -111
  446. package/esm/utils/combo.js.map +0 -1
  447. package/esm/utils/watermark.js.map +0 -1
  448. package/lib/plugins/history/utils.js.map +0 -1
  449. package/lib/plugins/watermark.js.map +0 -1
  450. package/lib/utils/combo.d.ts +0 -34
  451. package/lib/utils/combo.js +0 -117
  452. package/lib/utils/combo.js.map +0 -1
  453. package/lib/utils/watermark.js.map +0 -1
  454. package/src/utils/combo.ts +0 -134
  455. /package/dist/lib/{utils/contextmenu.d.ts → plugins/contextmenu/util.d.ts} +0 -0
  456. /package/dist/lib/plugins/history/{utils.d.ts → util.d.ts} +0 -0
  457. /package/dist/lib/{utils/watermark.d.ts → plugins/watermark/util.d.ts} +0 -0
  458. /package/esm/{utils/contextmenu.d.ts → plugins/contextmenu/util.d.ts} +0 -0
  459. /package/esm/plugins/history/{utils.d.ts → util.d.ts} +0 -0
  460. /package/esm/{utils/watermark.d.ts → plugins/watermark/util.d.ts} +0 -0
  461. /package/lib/{utils/contextmenu.d.ts → plugins/contextmenu/util.d.ts} +0 -0
  462. /package/lib/plugins/history/{utils.d.ts → util.d.ts} +0 -0
  463. /package/lib/{utils/watermark.d.ts → plugins/watermark/util.d.ts} +0 -0
  464. /package/src/{utils/contextmenu.ts → plugins/contextmenu/util.ts} +0 -0
  465. /package/src/plugins/history/{utils.ts → util.ts} +0 -0
  466. /package/src/{utils/watermark.ts → plugins/watermark/util.ts} +0 -0
@@ -14,6 +14,7 @@ import type {
14
14
  EdgeArrowStyleProps,
15
15
  EdgeKey,
16
16
  EdgeLabelStyleProps,
17
+ ID,
17
18
  Keyframe,
18
19
  LoopStyleProps,
19
20
  Node,
@@ -27,9 +28,9 @@ import { omitStyleProps, subStyleProps } from '../../utils/prefix';
27
28
  import { parseSize } from '../../utils/size';
28
29
  import * as Symbol from '../../utils/symbol';
29
30
  import { getWordWrapWidthByEnds } from '../../utils/text';
31
+ import { BaseElement } from '../base-element';
30
32
  import type { LabelStyleProps } from '../shapes';
31
33
  import { Label } from '../shapes';
32
- import { BaseShape } from '../shapes/base-shape';
33
34
 
34
35
  /**
35
36
  * <zh/> 边的通用样式属性
@@ -50,6 +51,13 @@ export interface BaseEdgeStyleProps
50
51
  * @defaultValue true
51
52
  */
52
53
  label?: boolean;
54
+ /**
55
+ * <zh/> 是否启用自环边
56
+ *
57
+ * <en/> Whether to enable self-loop edge
58
+ * @defaultValue true
59
+ */
60
+ loop?: boolean;
53
61
  /**
54
62
  * <zh/> 是否显示边的光晕
55
63
  *
@@ -84,19 +92,21 @@ export interface BaseEdgeStyleProps
84
92
  */
85
93
  endArrowOffset?: number;
86
94
  /**
87
- * <zh/> 边的起点 shape
95
+ * <zh/> 边的起点 ID
88
96
  *
89
- * <en/> The source shape. Represents the start of the edge
90
- * @internal
97
+ * <en/> The ID of the source node
98
+ * @remarks
99
+ * <zh/> 该属性指向物理意义上的起点,由 G6 内部维护,用户无需过多关注。通常情况下,`sourceNode` 与上一级的 `source` 属性一致。但在某些情况下,`sourceNode` 可能会被 G6 内部转换,例如在 Combo 收起时内部节点上的边会自动连接到父 Combo,此时 `sourceNode` 会变更为父 Combo 的 ID。
100
+ *
101
+ * <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
102
  */
92
- sourceNode: Node;
103
+ sourceNode: ID;
93
104
  /**
94
105
  * <zh/> 边的终点 shape
95
106
  *
96
107
  * <en/> The source shape. Represents the start of the edge
97
- * @internal
98
108
  */
99
- targetNode: Node;
109
+ targetNode: ID;
100
110
  /**
101
111
  * <zh/> 边起始连接的 port
102
112
  *
@@ -157,7 +167,7 @@ type ParsedBaseEdgeStyleProps = Required<BaseEdgeStyleProps>;
157
167
  *
158
168
  * <en/> Base class of the edge
159
169
  */
160
- export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
170
+ export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> {
161
171
  public type = 'edge';
162
172
 
163
173
  static defaultStyleProps: Partial<BaseEdgeStyleProps> = {
@@ -178,6 +188,7 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
178
188
  haloPointerEvents: 'none',
179
189
  haloStrokeOpacity: 0.25,
180
190
  haloZIndex: -1,
191
+ loop: true,
181
192
  startArrow: false,
182
193
  startArrowSize: 8,
183
194
  startArrowLineDash: 0,
@@ -198,10 +209,22 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
198
209
  super(deepMix({}, { style: BaseEdge.defaultStyleProps }, options));
199
210
  }
200
211
 
212
+ protected get sourceNode() {
213
+ const { context, sourceNode: source } = this.parsedAttributes;
214
+ return context.element!.getElement<Node>(source)!;
215
+ }
216
+
217
+ protected get targetNode() {
218
+ const { context, targetNode: target } = this.parsedAttributes;
219
+ return context.element!.getElement<Node>(target)!;
220
+ }
221
+
201
222
  protected getKeyStyle(attributes: ParsedBaseEdgeStyleProps): PathStyleProps {
202
- const { sourceNode, targetNode, ...style } = this.getGraphicStyle(attributes);
223
+ const { loop, ...style } = this.getGraphicStyle(attributes);
224
+ const { sourceNode, targetNode } = this;
225
+
226
+ const d = loop && isSameNode(sourceNode, targetNode) ? this.getLoopPath(attributes) : this.getKeyPath(attributes);
203
227
 
204
- const d = isSameNode(sourceNode, targetNode) ? this.getLoopPath(attributes) : this.getKeyPath(attributes);
205
228
  return {
206
229
  d,
207
230
  ...omitStyleProps(style, ['halo', 'label', 'startArrow', 'endArrow']),
@@ -211,7 +234,8 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
211
234
  protected abstract getKeyPath(attributes: ParsedBaseEdgeStyleProps): PathArray;
212
235
 
213
236
  protected getLoopPath(attributes: ParsedBaseEdgeStyleProps): PathArray {
214
- const { sourceNode: node, sourcePort, targetPort } = attributes;
237
+ const { sourcePort, targetPort } = attributes;
238
+ const node = this.sourceNode;
215
239
 
216
240
  const bbox = getNodeBBox(node);
217
241
  const defaultDist = Math.max(getBBoxWidth(bbox), getBBoxHeight(bbox));
@@ -226,7 +250,8 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
226
250
  }
227
251
 
228
252
  protected getEndpoints(attributes: ParsedBaseEdgeStyleProps): [Point, Point] {
229
- const { sourceNode, targetNode, sourcePort: sourcePortKey, targetPort: targetPortKey } = attributes;
253
+ const { sourcePort: sourcePortKey, targetPort: targetPortKey } = attributes;
254
+ const { sourceNode, targetNode } = this;
230
255
 
231
256
  const [sourcePort, targetPort] = findPorts(sourceNode, targetNode, sourcePortKey, targetPortKey);
232
257
 
@@ -278,7 +303,7 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
278
303
  ? (['markerStart', 'markerStartOffset', 'startArrowOffset'] as const)
279
304
  : (['markerEnd', 'markerEndOffset', 'endArrowOffset'] as const);
280
305
 
281
- const arrow = keyShape.style[marker];
306
+ const arrow = keyShape.parsedStyle[marker];
282
307
  // update
283
308
  if (arrow) arrow.attr(arrowStyle);
284
309
  // create
@@ -340,39 +365,26 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
340
365
  this.drawHaloShape(attributes, container);
341
366
  }
342
367
 
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() {}
368
+ protected onframe() {
369
+ this.drawKeyShape(this.parsedAttributes, this);
370
+ this.drawHaloShape(this.parsedAttributes, this);
371
+ this.drawLabelShape(this.parsedAttributes, this);
372
+ }
366
373
 
367
374
  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;
375
+ const animation = super.animate(keyframes, options);
376
+
377
+ if (!animation) return animation;
378
+
379
+ // 设置 currentTime 时触发更新
380
+ // Trigger update when setting currentTime
381
+ return new Proxy(animation, {
382
+ set: (target, propKey, value) => {
383
+ // 需要推迟 onframe 调用时机,等待节点位置更新完成
384
+ // Need to delay the timing of the onframe call, wait for the node position update to complete
385
+ if (propKey === 'currentTime') Promise.resolve().then(() => this.onframe());
386
+ return Reflect.set(target, propKey, value);
387
+ },
388
+ });
377
389
  }
378
390
  }
@@ -74,7 +74,8 @@ export class Polyline extends BaseEdge {
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
@@ -5,8 +5,7 @@ import type { CategoricalPalette } from '../../palettes/types';
5
5
  import type { NodeData } from '../../spec';
6
6
  import type {
7
7
  BaseElementStyleProps,
8
- Keyframe,
9
- Node,
8
+ ID,
10
9
  NodeBadgeStyleProps,
11
10
  NodeLabelStyleProps,
12
11
  NodePortStyleProps,
@@ -25,8 +24,9 @@ import { omitStyleProps, subObject, subStyleProps } from '../../utils/prefix';
25
24
  import { parseSize } from '../../utils/size';
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> = {
@@ -221,10 +221,6 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
221
221
  super(deepMix({}, { style: BaseNode.defaultStyleProps }, options));
222
222
  }
223
223
 
224
- public get parsedAttributes() {
225
- return this.attributes as Required<S>;
226
- }
227
-
228
224
  protected getSize(attributes = this.attributes) {
229
225
  const { size } = attributes;
230
226
  return parseSize(size);
@@ -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
 
@@ -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
  }
@@ -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
  }
@@ -109,12 +109,30 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
109
109
  return style;
110
110
  }
111
111
 
112
+ /**
113
+ * Get the prefix pairs for composite shapes used to handle animation
114
+ * @returns tuples array where each tuple contains a key corresponding to a method `get${key}Style` and its shape prefix
115
+ */
116
+ protected get compositeShapes(): [string, string][] {
117
+ return [
118
+ ['badges', 'badge-'],
119
+ ['ports', 'port-'],
120
+ ];
121
+ }
122
+
123
+ /*
124
+ * <zh/> 是否自动托管动画
125
+ *
126
+ * <en/> Whether to automatically host animation
127
+ */
128
+ protected hostingAnimation = true;
129
+
112
130
  public animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions): IAnimation | null {
113
131
  if (keyframes.length === 0) return null;
114
-
115
132
  const animationMap: IAnimation[] = [];
116
133
 
117
134
  const result = super.animate(keyframes, options);
135
+ if (!this.hostingAnimation) return result;
118
136
  if (result) animationMap.push(result);
119
137
 
120
138
  if (Array.isArray(keyframes) && keyframes.length > 0) {
@@ -132,17 +150,12 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
132
150
  const subKeyframes: Keyframe[] = keyframes.map((style) =>
133
151
  method.call(this, { ...this.attributes, ...style }),
134
152
  );
135
-
136
153
  const result = shape.animate(preprocessKeyframes(subKeyframes), options);
137
154
  if (result) animationMap.push(result);
138
155
  }
139
156
  });
140
157
 
141
- // 针对 badges/ports 执行动画
142
- const badges = subObject(this.shapeMap, 'badge-');
143
- const ports = subObject(this.shapeMap, 'port-');
144
-
145
- const handleShapeSet = (shapeSet: Record<string, DisplayObject>, name: string) => {
158
+ const handleCompositeShapeAnimation = (shapeSet: Record<string, DisplayObject>, name: string) => {
146
159
  if (!isEmpty(shapeSet)) {
147
160
  const methodName = `get${upperFirst(name)}Style` as keyof this;
148
161
  const method = this[methodName];
@@ -160,8 +173,10 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
160
173
  }
161
174
  };
162
175
 
163
- handleShapeSet(badges, 'badges');
164
- handleShapeSet(ports, 'ports');
176
+ this.compositeShapes.forEach(([key, prefix]) => {
177
+ const shapeSet = subObject(this.shapeMap, prefix);
178
+ handleCompositeShapeAnimation(shapeSet, key);
179
+ });
165
180
  }
166
181
  }
167
182
 
package/src/exports.ts CHANGED
@@ -103,7 +103,7 @@ export type {
103
103
  RandomLayoutOptions,
104
104
  } from '@antv/layout';
105
105
  export type { PathArray } from '@antv/util';
106
- export type { AnimationContext, AnimationEffectTiming, AnimationExecutor } from './animations/types';
106
+ export type { AnimationContext, AnimationEffectTiming, AnimationExecutor, AnimationOptions } from './animations/types';
107
107
  export type {
108
108
  BaseBehaviorOptions,
109
109
  BrushSelectOptions,
@@ -150,7 +150,7 @@ export type {
150
150
  PolygonStyleProps,
151
151
  } from './elements/shapes';
152
152
  export type { ContourLabelStyleProps, ContourStyleProps } from './elements/shapes/contour';
153
- export type { AnimationOptions, BaseLayoutOptions, WebWorkerLayoutOptions } from './layouts/types';
153
+ export type { BaseLayoutOptions, WebWorkerLayoutOptions } from './layouts/types';
154
154
  export type { CategoricalPalette } from './palettes/types';
155
155
  export type {
156
156
  BasePluginOptions,
@@ -183,6 +183,7 @@ export type {
183
183
  ViewportOptions,
184
184
  } from './spec';
185
185
  export type { CustomBehaviorOption } from './spec/behavior';
186
+ export type { AnimationStage } from './spec/element/animation';
186
187
  export type { LayoutOptions, STDLayoutOptions, SingleLayoutOptions } from './spec/layout';
187
188
  export type { CustomPluginOption } from './spec/plugin';
188
189
  export type { BaseTransformOptions } from './transforms';
@@ -102,7 +102,7 @@ interface DagreLayout extends BaseLayoutOptions, DagreLayoutOptions {
102
102
  type: 'dagre';
103
103
  }
104
104
 
105
- export interface AnimationOptions {
105
+ interface AnimationOptions {
106
106
  /**
107
107
  * <zh/> 启用布局动画,对于迭代布局,会在两次迭代之间进行动画过渡
108
108
  *
@@ -0,0 +1,65 @@
1
+ import { omit } from '@antv/util';
2
+ import type { RuntimeContext } from '../../runtime/types';
3
+ import { createPluginContainer } from '../../utils/dom';
4
+ import type { BasePluginOptions } from '../base-plugin';
5
+ import { BasePlugin } from '../base-plugin';
6
+
7
+ /**
8
+ * <zh/> 背景配置项
9
+ *
10
+ * <en/> Background options
11
+ */
12
+ export interface BackgroundOptions extends BasePluginOptions, CSSStyleDeclaration {}
13
+
14
+ /**
15
+ * <zh/> 背景图
16
+ *
17
+ * <en/> Background image
18
+ * @remarks
19
+ * <zh/> 支持为图画布设置一个背景图片,让画布更有层次感、叙事性。
20
+ *
21
+ * <en/> Support setting a background image for the canvas to make the canvas more hierarchical and narrative.
22
+ */
23
+ export class Background extends BasePlugin<BackgroundOptions> {
24
+ static defaultOptions: Partial<BackgroundOptions> = {
25
+ transition: 'background 0.5s',
26
+ backgroundSize: 'cover',
27
+ opacity: '0.35',
28
+ };
29
+
30
+ private $element: HTMLElement = createPluginContainer('background');
31
+
32
+ constructor(context: RuntimeContext, options: BackgroundOptions) {
33
+ super(context, Object.assign({}, Background.defaultOptions, options));
34
+
35
+ const $container = this.context.canvas.getContainer();
36
+ $container!.appendChild(this.$element);
37
+
38
+ this.update(options);
39
+ }
40
+
41
+ /**
42
+ * <zh/> 更新背景图配置
43
+ *
44
+ * <en/> Update the background image configuration
45
+ * @param options - <zh/> 配置项 | <en/> Options
46
+ * @internal
47
+ */
48
+ public async update(options: Partial<BackgroundOptions>) {
49
+ super.update(options);
50
+
51
+ // Set the background style.
52
+ Object.assign(this.$element.style, omit(this.options, ['key', 'type']));
53
+ }
54
+
55
+ /**
56
+ * <zh/> 销毁背景图
57
+ *
58
+ * <en/> Destroy the background image
59
+ */
60
+ public destroy(): void {
61
+ super.destroy();
62
+ // Remove the background dom.
63
+ this.$element.remove();
64
+ }
65
+ }
@@ -1,10 +1,10 @@
1
- import type { RuntimeContext } from '../runtime/types';
2
- import type { IElementEvent } from '../types/event';
3
- import type { Item } from '../utils/contextmenu';
4
- import { CONTEXTMENU_CSS, getContentFromItems } from '../utils/contextmenu';
5
- import { createPluginContainer, insertDOM } from '../utils/dom';
6
- import type { BasePluginOptions } from './base-plugin';
7
- import { BasePlugin } from './base-plugin';
1
+ import type { RuntimeContext } from '../../runtime/types';
2
+ import type { IElementEvent } from '../../types/event';
3
+ import { createPluginContainer, insertDOM } from '../../utils/dom';
4
+ import type { BasePluginOptions } from '../base-plugin';
5
+ import { BasePlugin } from '../base-plugin';
6
+ import type { Item } from './util';
7
+ import { CONTEXTMENU_CSS, getContentFromItems } from './util';
8
8
 
9
9
  /**
10
10
  * <zh/> 上下文菜单配置项
@@ -8,7 +8,7 @@ import type { GraphLifeCycleEvent } from '../../utils/event';
8
8
  import { idsOf } from '../../utils/id';
9
9
  import type { BasePluginOptions } from '../base-plugin';
10
10
  import { BasePlugin } from '../base-plugin';
11
- import { parseCommand } from './utils';
11
+ import { parseCommand } from './util';
12
12
 
13
13
  /**
14
14
  * <zh/> 历史记录配置项
@@ -1,3 +1,4 @@
1
+ export { Background } from './background';
1
2
  export { BasePlugin } from './base-plugin';
2
3
  export { BubbleSets } from './bubble-sets';
3
4
  export { CameraSetting } from './camera-setting';
@@ -11,6 +12,7 @@ export { Toolbar } from './toolbar';
11
12
  export { Tooltip } from './tooltip';
12
13
  export { Watermark } from './watermark';
13
14
 
15
+ export type { BackgroundOptions } from './background';
14
16
  export type { BasePluginOptions } from './base-plugin';
15
17
  export type { BubbleSetsOptions } from './bubble-sets';
16
18
  export type { CameraSettingOptions } from './camera-setting';
@@ -390,7 +390,7 @@ export class Timebar extends BasePlugin<TimebarOptions> {
390
390
  });
391
391
 
392
392
  graph.setData(newData);
393
- await element!.draw({ animation: false, silence: true });
393
+ await element!.draw({ animation: false, silence: true })?.finished;
394
394
  }
395
395
 
396
396
  private hiddenElements(range: number | [number, number]) {
@@ -1,8 +1,8 @@
1
- import type { RuntimeContext } from '../runtime/types';
2
- import { createPluginContainer } from '../utils/dom';
3
- import { getImageWatermark, getTextWatermark } from '../utils/watermark';
4
- import type { BasePluginOptions } from './base-plugin';
5
- import { BasePlugin } from './base-plugin';
1
+ import type { RuntimeContext } from '../../runtime/types';
2
+ import { createPluginContainer } from '../../utils/dom';
3
+ import type { BasePluginOptions } from '../base-plugin';
4
+ import { BasePlugin } from '../base-plugin';
5
+ import { getImageWatermark, getTextWatermark } from './util';
6
6
 
7
7
  /**
8
8
  * <zh/> 水印配置项