@antv/g6 5.0.0-beta.1 → 5.0.0-beta.10

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 (409) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/constant/shape.d.ts +4 -1
  3. package/esm/constant/shape.js.map +1 -1
  4. package/esm/index.d.ts +22 -7
  5. package/esm/index.js +3 -2
  6. package/esm/index.js.map +1 -1
  7. package/esm/item/combo.d.ts +1 -1
  8. package/esm/item/combo.js +16 -9
  9. package/esm/item/combo.js.map +1 -1
  10. package/esm/item/edge.d.ts +20 -3
  11. package/esm/item/edge.js +99 -43
  12. package/esm/item/edge.js.map +1 -1
  13. package/esm/item/item.d.ts +3 -2
  14. package/esm/item/item.js +21 -11
  15. package/esm/item/item.js.map +1 -1
  16. package/esm/item/node.d.ts +2 -1
  17. package/esm/item/node.js +33 -16
  18. package/esm/item/node.js.map +1 -1
  19. package/esm/runtime/controller/data.d.ts +7 -10
  20. package/esm/runtime/controller/data.js +125 -281
  21. package/esm/runtime/controller/data.js.map +1 -1
  22. package/esm/runtime/controller/item.d.ts +1 -0
  23. package/esm/runtime/controller/item.js +267 -151
  24. package/esm/runtime/controller/item.js.map +1 -1
  25. package/esm/runtime/graph.d.ts +103 -23
  26. package/esm/runtime/graph.js +460 -88
  27. package/esm/runtime/graph.js.map +1 -1
  28. package/esm/stdlib/behavior/activate-relations.d.ts +9 -9
  29. package/esm/stdlib/behavior/activate-relations.js +8 -8
  30. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  31. package/esm/stdlib/behavior/brush-select.js +1 -2
  32. package/esm/stdlib/behavior/brush-select.js.map +1 -1
  33. package/esm/stdlib/behavior/click-select.js +1 -1
  34. package/esm/stdlib/behavior/click-select.js.map +1 -1
  35. package/esm/stdlib/behavior/create-edge.d.ts +57 -0
  36. package/esm/stdlib/behavior/create-edge.js +207 -0
  37. package/esm/stdlib/behavior/create-edge.js.map +1 -0
  38. package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
  39. package/esm/stdlib/behavior/drag-canvas.js +59 -28
  40. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  41. package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
  42. package/esm/stdlib/behavior/drag-combo.js +43 -32
  43. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  44. package/esm/stdlib/behavior/drag-node.d.ts +3 -3
  45. package/esm/stdlib/behavior/drag-node.js +76 -63
  46. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  47. package/esm/stdlib/behavior/index.d.ts +3 -0
  48. package/esm/stdlib/behavior/index.js +3 -0
  49. package/esm/stdlib/behavior/index.js.map +1 -1
  50. package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
  51. package/esm/stdlib/behavior/lasso-select.js +1 -2
  52. package/esm/stdlib/behavior/lasso-select.js.map +1 -1
  53. package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
  54. package/esm/stdlib/behavior/scroll-canvas.js +266 -0
  55. package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
  56. package/esm/stdlib/behavior/shortcuts-call.d.ts +38 -0
  57. package/esm/stdlib/behavior/shortcuts-call.js +80 -0
  58. package/esm/stdlib/behavior/shortcuts-call.js.map +1 -0
  59. package/esm/stdlib/behavior/zoom-canvas.d.ts +2 -1
  60. package/esm/stdlib/behavior/zoom-canvas.js +55 -24
  61. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  62. package/esm/stdlib/data/mapNodeSize.d.ts +2 -2
  63. package/esm/stdlib/data/mapNodeSize.js +2 -2
  64. package/esm/stdlib/data/mapNodeSize.js.map +1 -1
  65. package/esm/stdlib/data/transformV4Data.d.ts +2 -2
  66. package/esm/stdlib/data/transformV4Data.js +2 -2
  67. package/esm/stdlib/data/transformV4Data.js.map +1 -1
  68. package/esm/stdlib/data/validateData.d.ts +2 -2
  69. package/esm/stdlib/data/validateData.js +9 -9
  70. package/esm/stdlib/data/validateData.js.map +1 -1
  71. package/esm/stdlib/index.d.ts +16 -6
  72. package/esm/stdlib/index.js +20 -10
  73. package/esm/stdlib/index.js.map +1 -1
  74. package/esm/stdlib/item/edge/base.d.ts +10 -1
  75. package/esm/stdlib/item/edge/base.js +20 -13
  76. package/esm/stdlib/item/edge/base.js.map +1 -1
  77. package/esm/stdlib/item/edge/line.js +5 -2
  78. package/esm/stdlib/item/edge/line.js.map +1 -1
  79. package/esm/stdlib/item/edge/polyline.d.ts +3 -2
  80. package/esm/stdlib/item/edge/polyline.js +3 -3
  81. package/esm/stdlib/item/edge/polyline.js.map +1 -1
  82. package/esm/stdlib/item/node/base.d.ts +1 -1
  83. package/esm/stdlib/item/node/base.js +18 -26
  84. package/esm/stdlib/item/node/base.js.map +1 -1
  85. package/esm/stdlib/item/node/base3d.d.ts +1 -0
  86. package/esm/stdlib/item/node/base3d.js +1 -0
  87. package/esm/stdlib/item/node/base3d.js.map +1 -1
  88. package/esm/stdlib/item/node/diamond.js +1 -1
  89. package/esm/stdlib/item/node/ellipse.js +2 -2
  90. package/esm/stdlib/item/node/hexagon.js +12 -5
  91. package/esm/stdlib/item/node/hexagon.js.map +1 -1
  92. package/esm/stdlib/item/node/image.d.ts +40 -0
  93. package/esm/stdlib/item/node/image.js +110 -0
  94. package/esm/stdlib/item/node/image.js.map +1 -0
  95. package/esm/stdlib/item/node/index.d.ts +1 -0
  96. package/esm/stdlib/item/node/index.js +1 -0
  97. package/esm/stdlib/item/node/index.js.map +1 -1
  98. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  99. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  100. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  101. package/esm/stdlib/plugin/history/index.js +14 -14
  102. package/esm/stdlib/plugin/history/index.js.map +1 -1
  103. package/esm/stdlib/plugin/history/item-data-command.js +25 -16
  104. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  105. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  106. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  107. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  108. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  109. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  110. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  111. package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  112. package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
  113. package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
  114. package/esm/stdlib/plugin/index.d.ts +2 -0
  115. package/esm/stdlib/plugin/index.js +2 -0
  116. package/esm/stdlib/plugin/index.js.map +1 -1
  117. package/esm/stdlib/plugin/legend/index.js +1 -1
  118. package/esm/stdlib/plugin/legend/index.js.map +1 -1
  119. package/esm/stdlib/plugin/map/index.d.ts +118 -0
  120. package/esm/stdlib/plugin/map/index.js +683 -0
  121. package/esm/stdlib/plugin/map/index.js.map +1 -0
  122. package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
  123. package/esm/stdlib/plugin/minimap/index.js +116 -9
  124. package/esm/stdlib/plugin/minimap/index.js.map +1 -1
  125. package/esm/stdlib/plugin/snapline/index.d.ts +167 -0
  126. package/esm/stdlib/plugin/snapline/index.js +1063 -0
  127. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  128. package/esm/stdlib/plugin/timebar/index.d.ts +98 -0
  129. package/esm/stdlib/plugin/timebar/index.js +303 -0
  130. package/esm/stdlib/plugin/timebar/index.js.map +1 -0
  131. package/esm/stdlib/plugin/toolbar/index.js +1 -1
  132. package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
  133. package/esm/stdlib/plugin/types.d.ts +2 -0
  134. package/esm/stdlib/theme/dark.js +42 -2
  135. package/esm/stdlib/theme/dark.js.map +1 -1
  136. package/esm/stdlib/theme/light.js +4 -4
  137. package/esm/types/common.d.ts +1 -0
  138. package/esm/types/event.d.ts +1 -0
  139. package/esm/types/graph.d.ts +48 -22
  140. package/esm/types/hook.d.ts +22 -2
  141. package/esm/types/item.d.ts +6 -0
  142. package/esm/types/item.js.map +1 -1
  143. package/esm/types/spec.d.ts +19 -3
  144. package/esm/types/view.d.ts +5 -0
  145. package/esm/util/bbox.d.ts +16 -1
  146. package/esm/util/bbox.js +29 -0
  147. package/esm/util/bbox.js.map +1 -1
  148. package/esm/util/canvas.d.ts +2 -2
  149. package/esm/util/canvas.js +5 -11
  150. package/esm/util/canvas.js.map +1 -1
  151. package/esm/util/event.d.ts +3 -1
  152. package/esm/util/event.js +8 -1
  153. package/esm/util/event.js.map +1 -1
  154. package/esm/util/item.d.ts +16 -1
  155. package/esm/util/item.js +31 -8
  156. package/esm/util/item.js.map +1 -1
  157. package/esm/util/layout.d.ts +11 -0
  158. package/esm/util/layout.js +45 -0
  159. package/esm/util/layout.js.map +1 -1
  160. package/esm/util/point.js +9 -2
  161. package/esm/util/point.js.map +1 -1
  162. package/esm/util/router.d.ts +4 -3
  163. package/esm/util/router.js +8 -5
  164. package/esm/util/router.js.map +1 -1
  165. package/esm/util/shape.d.ts +3 -3
  166. package/esm/util/shape.js +8 -12
  167. package/esm/util/shape.js.map +1 -1
  168. package/esm/util/warn.d.ts +14 -0
  169. package/esm/util/warn.js +4 -0
  170. package/esm/util/warn.js.map +1 -0
  171. package/lib/constant/shape.d.ts +4 -1
  172. package/lib/constant/shape.js.map +1 -1
  173. package/lib/index.d.ts +22 -7
  174. package/lib/index.js +4 -2
  175. package/lib/index.js.map +1 -1
  176. package/lib/item/combo.d.ts +1 -1
  177. package/lib/item/combo.js +16 -9
  178. package/lib/item/combo.js.map +1 -1
  179. package/lib/item/edge.d.ts +20 -3
  180. package/lib/item/edge.js +98 -42
  181. package/lib/item/edge.js.map +1 -1
  182. package/lib/item/item.d.ts +3 -2
  183. package/lib/item/item.js +21 -11
  184. package/lib/item/item.js.map +1 -1
  185. package/lib/item/node.d.ts +2 -1
  186. package/lib/item/node.js +33 -16
  187. package/lib/item/node.js.map +1 -1
  188. package/lib/runtime/controller/data.d.ts +7 -10
  189. package/lib/runtime/controller/data.js +125 -281
  190. package/lib/runtime/controller/data.js.map +1 -1
  191. package/lib/runtime/controller/item.d.ts +1 -0
  192. package/lib/runtime/controller/item.js +266 -150
  193. package/lib/runtime/controller/item.js.map +1 -1
  194. package/lib/runtime/graph.d.ts +103 -23
  195. package/lib/runtime/graph.js +460 -88
  196. package/lib/runtime/graph.js.map +1 -1
  197. package/lib/stdlib/behavior/activate-relations.d.ts +9 -9
  198. package/lib/stdlib/behavior/activate-relations.js +8 -8
  199. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  200. package/lib/stdlib/behavior/brush-select.js +1 -2
  201. package/lib/stdlib/behavior/brush-select.js.map +1 -1
  202. package/lib/stdlib/behavior/click-select.js +1 -1
  203. package/lib/stdlib/behavior/click-select.js.map +1 -1
  204. package/lib/stdlib/behavior/create-edge.d.ts +57 -0
  205. package/lib/stdlib/behavior/create-edge.js +211 -0
  206. package/lib/stdlib/behavior/create-edge.js.map +1 -0
  207. package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
  208. package/lib/stdlib/behavior/drag-canvas.js +59 -28
  209. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  210. package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
  211. package/lib/stdlib/behavior/drag-combo.js +43 -32
  212. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  213. package/lib/stdlib/behavior/drag-node.d.ts +3 -3
  214. package/lib/stdlib/behavior/drag-node.js +76 -63
  215. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  216. package/lib/stdlib/behavior/index.d.ts +3 -0
  217. package/lib/stdlib/behavior/index.js +3 -0
  218. package/lib/stdlib/behavior/index.js.map +1 -1
  219. package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
  220. package/lib/stdlib/behavior/lasso-select.js +1 -2
  221. package/lib/stdlib/behavior/lasso-select.js.map +1 -1
  222. package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
  223. package/lib/stdlib/behavior/scroll-canvas.js +270 -0
  224. package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
  225. package/lib/stdlib/behavior/shortcuts-call.d.ts +38 -0
  226. package/lib/stdlib/behavior/shortcuts-call.js +84 -0
  227. package/lib/stdlib/behavior/shortcuts-call.js.map +1 -0
  228. package/lib/stdlib/behavior/zoom-canvas.d.ts +2 -1
  229. package/lib/stdlib/behavior/zoom-canvas.js +55 -24
  230. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  231. package/lib/stdlib/data/mapNodeSize.d.ts +2 -2
  232. package/lib/stdlib/data/mapNodeSize.js +2 -2
  233. package/lib/stdlib/data/mapNodeSize.js.map +1 -1
  234. package/lib/stdlib/data/transformV4Data.d.ts +2 -2
  235. package/lib/stdlib/data/transformV4Data.js +2 -2
  236. package/lib/stdlib/data/transformV4Data.js.map +1 -1
  237. package/lib/stdlib/data/validateData.d.ts +2 -2
  238. package/lib/stdlib/data/validateData.js +9 -9
  239. package/lib/stdlib/data/validateData.js.map +1 -1
  240. package/lib/stdlib/index.d.ts +16 -6
  241. package/lib/stdlib/index.js +20 -10
  242. package/lib/stdlib/index.js.map +1 -1
  243. package/lib/stdlib/item/edge/base.d.ts +10 -1
  244. package/lib/stdlib/item/edge/base.js +20 -13
  245. package/lib/stdlib/item/edge/base.js.map +1 -1
  246. package/lib/stdlib/item/edge/line.js +5 -2
  247. package/lib/stdlib/item/edge/line.js.map +1 -1
  248. package/lib/stdlib/item/edge/polyline.d.ts +3 -2
  249. package/lib/stdlib/item/edge/polyline.js +3 -3
  250. package/lib/stdlib/item/edge/polyline.js.map +1 -1
  251. package/lib/stdlib/item/node/base.d.ts +1 -1
  252. package/lib/stdlib/item/node/base.js +18 -26
  253. package/lib/stdlib/item/node/base.js.map +1 -1
  254. package/lib/stdlib/item/node/base3d.d.ts +1 -0
  255. package/lib/stdlib/item/node/base3d.js +1 -0
  256. package/lib/stdlib/item/node/base3d.js.map +1 -1
  257. package/lib/stdlib/item/node/diamond.js +1 -1
  258. package/lib/stdlib/item/node/ellipse.js +2 -2
  259. package/lib/stdlib/item/node/hexagon.js +12 -5
  260. package/lib/stdlib/item/node/hexagon.js.map +1 -1
  261. package/lib/stdlib/item/node/image.d.ts +40 -0
  262. package/lib/stdlib/item/node/image.js +114 -0
  263. package/lib/stdlib/item/node/image.js.map +1 -0
  264. package/lib/stdlib/item/node/index.d.ts +1 -0
  265. package/lib/stdlib/item/node/index.js +1 -0
  266. package/lib/stdlib/item/node/index.js.map +1 -1
  267. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  268. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  269. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  270. package/lib/stdlib/plugin/history/index.js +14 -14
  271. package/lib/stdlib/plugin/history/index.js.map +1 -1
  272. package/lib/stdlib/plugin/history/item-data-command.js +25 -16
  273. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  274. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  275. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  276. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  277. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  278. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  279. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  280. package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
  281. package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
  282. package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
  283. package/lib/stdlib/plugin/index.d.ts +2 -0
  284. package/lib/stdlib/plugin/index.js +2 -0
  285. package/lib/stdlib/plugin/index.js.map +1 -1
  286. package/lib/stdlib/plugin/legend/index.js +1 -1
  287. package/lib/stdlib/plugin/legend/index.js.map +1 -1
  288. package/lib/stdlib/plugin/map/index.d.ts +118 -0
  289. package/lib/stdlib/plugin/map/index.js +687 -0
  290. package/lib/stdlib/plugin/map/index.js.map +1 -0
  291. package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
  292. package/lib/stdlib/plugin/minimap/index.js +116 -9
  293. package/lib/stdlib/plugin/minimap/index.js.map +1 -1
  294. package/lib/stdlib/plugin/snapline/index.d.ts +167 -0
  295. package/lib/stdlib/plugin/snapline/index.js +1067 -0
  296. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  297. package/lib/stdlib/plugin/timebar/index.d.ts +98 -0
  298. package/lib/stdlib/plugin/timebar/index.js +307 -0
  299. package/lib/stdlib/plugin/timebar/index.js.map +1 -0
  300. package/lib/stdlib/plugin/toolbar/index.js +1 -1
  301. package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
  302. package/lib/stdlib/plugin/types.d.ts +2 -0
  303. package/lib/stdlib/theme/dark.js +42 -2
  304. package/lib/stdlib/theme/dark.js.map +1 -1
  305. package/lib/stdlib/theme/light.js +4 -4
  306. package/lib/types/common.d.ts +1 -0
  307. package/lib/types/event.d.ts +1 -0
  308. package/lib/types/graph.d.ts +48 -22
  309. package/lib/types/hook.d.ts +22 -2
  310. package/lib/types/item.d.ts +6 -0
  311. package/lib/types/item.js.map +1 -1
  312. package/lib/types/spec.d.ts +19 -3
  313. package/lib/types/view.d.ts +5 -0
  314. package/lib/util/bbox.d.ts +16 -1
  315. package/lib/util/bbox.js +32 -1
  316. package/lib/util/bbox.js.map +1 -1
  317. package/lib/util/canvas.d.ts +2 -2
  318. package/lib/util/canvas.js +5 -11
  319. package/lib/util/canvas.js.map +1 -1
  320. package/lib/util/event.d.ts +3 -1
  321. package/lib/util/event.js +8 -1
  322. package/lib/util/event.js.map +1 -1
  323. package/lib/util/item.d.ts +16 -1
  324. package/lib/util/item.js +33 -9
  325. package/lib/util/item.js.map +1 -1
  326. package/lib/util/layout.d.ts +11 -0
  327. package/lib/util/layout.js +47 -1
  328. package/lib/util/layout.js.map +1 -1
  329. package/lib/util/point.js +9 -2
  330. package/lib/util/point.js.map +1 -1
  331. package/lib/util/router.d.ts +4 -3
  332. package/lib/util/router.js +8 -5
  333. package/lib/util/router.js.map +1 -1
  334. package/lib/util/shape.d.ts +3 -3
  335. package/lib/util/shape.js +8 -12
  336. package/lib/util/shape.js.map +1 -1
  337. package/lib/util/warn.d.ts +14 -0
  338. package/lib/util/warn.js +8 -0
  339. package/lib/util/warn.js.map +1 -0
  340. package/package.json +10 -10
  341. package/src/constant/shape.ts +2 -1
  342. package/src/index.ts +4 -2
  343. package/src/item/combo.ts +14 -9
  344. package/src/item/edge.ts +131 -57
  345. package/src/item/item.ts +24 -15
  346. package/src/item/node.ts +38 -24
  347. package/src/runtime/controller/data.ts +140 -339
  348. package/src/runtime/controller/item.ts +236 -72
  349. package/src/runtime/graph.ts +592 -96
  350. package/src/stdlib/behavior/activate-relations.ts +8 -8
  351. package/src/stdlib/behavior/brush-select.ts +4 -2
  352. package/src/stdlib/behavior/click-select.ts +1 -1
  353. package/src/stdlib/behavior/create-edge.ts +296 -0
  354. package/src/stdlib/behavior/drag-canvas.ts +78 -29
  355. package/src/stdlib/behavior/drag-combo.ts +10 -10
  356. package/src/stdlib/behavior/drag-node.ts +18 -18
  357. package/src/stdlib/behavior/index.ts +3 -0
  358. package/src/stdlib/behavior/lasso-select.ts +5 -3
  359. package/src/stdlib/behavior/scroll-canvas.ts +348 -0
  360. package/src/stdlib/behavior/shortcuts-call.ts +120 -0
  361. package/src/stdlib/behavior/zoom-canvas.ts +72 -25
  362. package/src/stdlib/data/mapNodeSize.ts +2 -2
  363. package/src/stdlib/data/transformV4Data.ts +2 -2
  364. package/src/stdlib/data/validateData.ts +9 -9
  365. package/src/stdlib/index.ts +33 -9
  366. package/src/stdlib/item/edge/base.ts +26 -13
  367. package/src/stdlib/item/edge/line.ts +8 -2
  368. package/src/stdlib/item/edge/polyline.ts +7 -5
  369. package/src/stdlib/item/node/base.ts +24 -29
  370. package/src/stdlib/item/node/base3d.ts +1 -0
  371. package/src/stdlib/item/node/diamond.ts +1 -1
  372. package/src/stdlib/item/node/ellipse.ts +2 -2
  373. package/src/stdlib/item/node/hexagon.ts +14 -6
  374. package/src/stdlib/item/node/image.ts +190 -0
  375. package/src/stdlib/item/node/index.ts +1 -0
  376. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  377. package/src/stdlib/plugin/history/index.ts +14 -14
  378. package/src/stdlib/plugin/history/item-data-command.ts +35 -17
  379. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  380. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  381. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  382. package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
  383. package/src/stdlib/plugin/index.ts +2 -0
  384. package/src/stdlib/plugin/legend/index.ts +1 -1
  385. package/src/stdlib/plugin/map/index.ts +808 -0
  386. package/src/stdlib/plugin/minimap/index.ts +120 -10
  387. package/src/stdlib/plugin/snapline/index.ts +1297 -0
  388. package/src/stdlib/plugin/timebar/index.ts +473 -0
  389. package/src/stdlib/plugin/toolbar/index.ts +1 -1
  390. package/src/stdlib/plugin/types.ts +2 -0
  391. package/src/stdlib/theme/dark.ts +66 -2
  392. package/src/stdlib/theme/light.ts +4 -4
  393. package/src/types/common.ts +1 -0
  394. package/src/types/event.ts +1 -0
  395. package/src/types/graph.ts +59 -25
  396. package/src/types/hook.ts +22 -2
  397. package/src/types/item.ts +10 -0
  398. package/src/types/spec.ts +22 -3
  399. package/src/types/view.ts +8 -3
  400. package/src/util/bbox.ts +38 -1
  401. package/src/util/canvas.ts +5 -5
  402. package/src/util/event.ts +14 -1
  403. package/src/util/item.ts +65 -28
  404. package/src/util/layout.ts +45 -0
  405. package/src/util/point.ts +8 -3
  406. package/src/util/router.ts +15 -6
  407. package/src/util/shape.ts +16 -14
  408. package/src/util/warn.ts +20 -0
  409. package/src/api-doc/readme.md +0 -59
@@ -12,7 +12,7 @@ type PathArray = any; //TODO: cannot import type PathArray
12
12
  export class DiamondNode extends BaseNode {
13
13
  override defaultStyles = {
14
14
  keyShape: {
15
- size: [50, 30],
15
+ size: [32, 32],
16
16
  x: 0,
17
17
  y: 0,
18
18
  },
@@ -11,8 +11,8 @@ import { BaseNode } from './base';
11
11
  export class EllipseNode extends BaseNode {
12
12
  override defaultStyles = {
13
13
  keyShape: {
14
- rx: 30,
15
- ry: 20,
14
+ rx: 16,
15
+ ry: 12,
16
16
  x: 0,
17
17
  y: 0,
18
18
  },
@@ -9,13 +9,18 @@ import {
9
9
  } from '../../../types/node';
10
10
  import { BaseNode } from './base';
11
11
 
12
+ const offsetAngleMap = {
13
+ horizontal: 0,
14
+ vertical: Math.PI / 2,
15
+ };
16
+
12
17
  export class HexagonNode extends BaseNode {
13
18
  override defaultStyles = {
14
19
  keyShape: {
15
- r: 20,
20
+ r: 16,
16
21
  x: 0,
17
22
  y: 0,
18
- direction: 'horizontal',
23
+ direction: 'vertical',
19
24
  },
20
25
  };
21
26
  mergedStyles: NodeShapeStyles;
@@ -119,9 +124,9 @@ export class HexagonNode extends BaseNode {
119
124
  private getHexagonPoints(r: number, direction: string): [number, number][] {
120
125
  const angleIncrement = Math.PI / 3; //The angle increment between vertex.
121
126
  const v = [];
122
- const offsetAngle = direction === 'horizontal' ? 0 : Math.PI / 2;
127
+
123
128
  for (let i = 0; i < 6; i++) {
124
- const angle = i * angleIncrement + offsetAngle;
129
+ const angle = i * angleIncrement + offsetAngleMap[direction];
125
130
  const vx = r * Math.cos(angle);
126
131
  const vy = r * Math.sin(angle);
127
132
  v.push([vx, vy]);
@@ -153,8 +158,7 @@ export class HexagonNode extends BaseNode {
153
158
  ? anchorPositionHorizontal
154
159
  : anchorPositionVertical;
155
160
  const angleIncrement = Math.PI / 3; //The angle increment between vertex.
156
- const offsetAngle =
157
- keyShapeStyle.direction === 'horizontal' ? 0 : Math.PI / 2;
161
+ const offsetAngle = offsetAngleMap[keyShapeStyle.direction];
158
162
  const r = keyShapeStyle.r;
159
163
  const anchorPositionMap = {};
160
164
  for (let i = 0; i < 6; i++) {
@@ -163,6 +167,10 @@ export class HexagonNode extends BaseNode {
163
167
  const vy = r * Math.sin(angle);
164
168
  anchorPositionMap[anchorPositionDirection[i]] = [vx, vy];
165
169
  }
170
+ if (!anchorPositionMap.hasOwnProperty('default')) {
171
+ anchorPositionMap['default'] =
172
+ anchorPositionMap[anchorPositionDirection[0]];
173
+ }
166
174
  return anchorPositionMap;
167
175
  }
168
176
  }
@@ -0,0 +1,190 @@
1
+ import { DisplayObject } from '@antv/g';
2
+ import { ComboDisplayModel, NodeDisplayModel } from '../../../types';
3
+ import { State } from '../../../types/item';
4
+ import {
5
+ NodeModelData,
6
+ NodeShapeMap,
7
+ NodeShapeStyles,
8
+ } from '../../../types/node';
9
+ import { convertToNumber } from '../../../util/type';
10
+ import { ComboModelData, ComboShapeMap } from '../../../types/combo';
11
+ import { ShapeTagMap } from '../../../util/shape';
12
+ import { BaseNode } from './base';
13
+
14
+ export class ImageNode extends BaseNode {
15
+ override defaultStyles = {
16
+ keyShape: {
17
+ x: 0,
18
+ y: 0,
19
+ width: 32,
20
+ height: 32,
21
+ },
22
+ };
23
+ mergedStyles: NodeShapeStyles;
24
+ constructor(props) {
25
+ super(props);
26
+ // suggest to merge default styles like this to avoid style value missing
27
+ // this.defaultStyles = mergeStyles([this.baseDefaultStyles, this.defaultStyles]);
28
+ }
29
+
30
+ public override drawKeyShape(
31
+ model: NodeDisplayModel,
32
+ shapeMap: NodeShapeMap,
33
+ diffData?: { previous: NodeModelData; current: NodeModelData },
34
+ diffState?: { previous: State[]; current: State[] },
35
+ ): DisplayObject {
36
+ const clipCfg = this.mergedStyles.keyShape?.clipCfg;
37
+ let clipPath: DisplayObject | undefined;
38
+ if (clipCfg) {
39
+ const { type, ...rest } = clipCfg;
40
+ clipPath = new ShapeTagMap[type]();
41
+ clipPath.attr(rest);
42
+ }
43
+
44
+ const shape = this.upsertShape(
45
+ 'image',
46
+ 'keyShape',
47
+ {
48
+ ...this.mergedStyles.keyShape,
49
+ x: this.mergedStyles.keyShape!.x,
50
+ y: this.mergedStyles.keyShape!.y,
51
+ anchor: '0.5 0.5',
52
+ },
53
+ shapeMap,
54
+ model,
55
+ );
56
+
57
+ if (clipPath) {
58
+ shape.appendChild(clipPath);
59
+ shape.attr('clipPath', clipPath);
60
+ }
61
+
62
+ return shape;
63
+ }
64
+
65
+ public override calculateAnchorPosition(keyShapeStyle) {
66
+ const x = convertToNumber(keyShapeStyle.x);
67
+ const y = convertToNumber(keyShapeStyle.y);
68
+ const height = keyShapeStyle.height;
69
+ const width = keyShapeStyle.width;
70
+ const anchorPositionMap = {};
71
+ anchorPositionMap['top'] = [x, y - height / 2];
72
+ anchorPositionMap['left'] = [x - width / 2, y];
73
+ anchorPositionMap['right'] = anchorPositionMap['default'] = [
74
+ x + width / 2,
75
+ y,
76
+ ];
77
+ anchorPositionMap['bottom'] = [x, y + height / 2];
78
+ return anchorPositionMap;
79
+ }
80
+
81
+ public draw(
82
+ model: NodeDisplayModel,
83
+ shapeMap: NodeShapeMap,
84
+ diffData?: { previous: NodeModelData; current: NodeModelData },
85
+ diffState?: { previous: State[]; current: State[] },
86
+ ): NodeShapeMap {
87
+ const { data = {} } = model;
88
+ let shapes: NodeShapeMap = { keyShape: undefined };
89
+
90
+ // keyShape
91
+ shapes.keyShape = this.drawKeyShape(model, shapeMap, diffData);
92
+
93
+ // labelShape
94
+ if (data.labelShape) {
95
+ shapes.labelShape = this.drawLabelShape(model, shapeMap, diffData);
96
+ }
97
+
98
+ // haloShape
99
+ if (data.haloShape && this.drawHaloShape) {
100
+ shapes.haloShape = this.drawHaloShape(model, shapeMap, diffData);
101
+ }
102
+
103
+ // labelBackgroundShape
104
+ if (data.labelBackgroundShape) {
105
+ shapes.labelBackgroundShape = this.drawLabelBackgroundShape(
106
+ model,
107
+ shapeMap,
108
+ diffData,
109
+ );
110
+ }
111
+
112
+ // anchor shapes
113
+ if (data.anchorShapes) {
114
+ const anchorShapes = this.drawAnchorShapes(
115
+ model,
116
+ shapeMap,
117
+ diffData,
118
+ diffState,
119
+ );
120
+ shapes = {
121
+ ...shapes,
122
+ ...anchorShapes,
123
+ };
124
+ }
125
+
126
+ // iconShape
127
+ if (data.iconShape) {
128
+ shapes.iconShape = this.drawIconShape(model, shapeMap, diffData);
129
+ }
130
+
131
+ // badgeShape
132
+ if (data.badgeShapes) {
133
+ const badgeShapes = this.drawBadgeShapes(
134
+ model,
135
+ shapeMap,
136
+ diffData,
137
+ diffState,
138
+ );
139
+ shapes = {
140
+ ...shapes,
141
+ ...badgeShapes,
142
+ };
143
+ }
144
+
145
+ // otherShapes
146
+ if (data.otherShapes && this.drawOtherShapes) {
147
+ shapes = {
148
+ ...shapes,
149
+ ...this.drawOtherShapes(model, shapeMap, diffData),
150
+ };
151
+ }
152
+ return shapes;
153
+ }
154
+
155
+ public drawHaloShape(
156
+ model: NodeDisplayModel | ComboDisplayModel,
157
+ shapeMap: NodeShapeMap | ComboShapeMap,
158
+ diffData?: {
159
+ previous: NodeModelData | ComboModelData;
160
+ current: NodeModelData | ComboModelData;
161
+ },
162
+ diffState?: { previous: State[]; current: State[] },
163
+ ): DisplayObject {
164
+ const { keyShape } = shapeMap;
165
+ const { haloShape: haloShapeStyle, keyShape: keyShapeStyle } =
166
+ this.mergedStyles;
167
+ if (haloShapeStyle?.visible === false) return;
168
+
169
+ const clipShape = haloShapeStyle?.clipCfg?.type || 'rect';
170
+ const { attributes } = keyShape;
171
+ const { x, y, fill } = attributes;
172
+
173
+ return this.upsertShape(
174
+ clipShape,
175
+ 'haloShape',
176
+ {
177
+ ...attributes,
178
+ ...keyShapeStyle,
179
+ x,
180
+ y,
181
+ stroke: fill,
182
+ ...haloShapeStyle,
183
+ fill: 'transparent',
184
+ batchKey: 'halo',
185
+ },
186
+ shapeMap,
187
+ model,
188
+ );
189
+ }
190
+ }
@@ -8,3 +8,4 @@ export * from './ellipse';
8
8
  export * from './donut';
9
9
  export * from './diamond';
10
10
  export * from './modelRect';
11
+ export * from './image';
@@ -11,7 +11,7 @@ export class ComboCommand implements Command {
11
11
  }
12
12
 
13
13
  undo(graph: IGraph) {
14
- graph.executeWithoutStacking(() => {
14
+ graph.executeWithNoStack(() => {
15
15
  this.action === 'expandCombo'
16
16
  ? graph.collapseCombo(this.ids)
17
17
  : graph.expandCombo(this.ids);
@@ -19,7 +19,7 @@ export class ComboCommand implements Command {
19
19
  }
20
20
 
21
21
  redo(graph: IGraph) {
22
- graph.executeWithoutStacking(() => {
22
+ graph.executeWithNoStack(() => {
23
23
  this.action === 'collapseCombo'
24
24
  ? graph.collapseCombo(this.ids)
25
25
  : graph.expandCombo(this.ids);
@@ -200,7 +200,7 @@ export class History extends Base {
200
200
  /**
201
201
  * Pause stacking operations.
202
202
  */
203
- pauseStacking(): void {
203
+ pauseStack(): void {
204
204
  this.withoutStackingCounter++;
205
205
 
206
206
  if (this.withoutStackingCounter === 1) {
@@ -212,7 +212,7 @@ export class History extends Base {
212
212
  /**
213
213
  * Resume stacking operations.
214
214
  */
215
- resumeStacking(): void {
215
+ resumeStack(): void {
216
216
  if (this.withoutStackingCounter > 0) {
217
217
  this.withoutStackingCounter--;
218
218
  }
@@ -260,14 +260,14 @@ export class History extends Base {
260
260
  }
261
261
 
262
262
  /**
263
- * Begin a batch operation.
264
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
263
+ * Begin a historyBatch operation.
264
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
265
265
  * treated as a single operation when undoing or redoing.
266
266
  */
267
- public startBatch() {
267
+ public startHistoryBatch() {
268
268
  if (this.isBatching) {
269
269
  throw new Error(
270
- 'Ensure that batch processing is stopped before starting.',
270
+ 'Ensure that historyBatch processing is stopped before starting.',
271
271
  );
272
272
  }
273
273
  this.initBatchCommands();
@@ -275,14 +275,14 @@ export class History extends Base {
275
275
  }
276
276
 
277
277
  /**
278
- * End a batch operation.
279
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
278
+ * End a historyBatch operation.
279
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
280
280
  * treated as a single operation when undoing or redoing.
281
281
  */
282
- public stopBatch() {
282
+ public stopHistoryBatch() {
283
283
  if (!this.isBatching) {
284
284
  throw new Error(
285
- 'Ensure that batch processing is started before stopping.',
285
+ 'Ensure that historyBatch processing is started before stopping.',
286
286
  );
287
287
  }
288
288
  this.push(this.batchCommands);
@@ -290,13 +290,13 @@ export class History extends Base {
290
290
  }
291
291
 
292
292
  /**
293
- * Execute the provided function in a batch mode
293
+ * Execute the provided function in a historyBatch mode
294
294
  * @param callback
295
295
  */
296
- public batch(callback) {
297
- this.startBatch();
296
+ public historyBatch(callback) {
297
+ this.startHistoryBatch();
298
298
  callback();
299
- this.stopBatch();
299
+ this.stopHistoryBatch();
300
300
  }
301
301
 
302
302
  public getEvents() {
@@ -26,14 +26,14 @@ export class ItemDataCommand implements Command {
26
26
 
27
27
  private removeChangedData(graph) {
28
28
  const ids = this.changes.map((data) => data.value?.id).filter(Boolean);
29
- graph.executeWithoutStacking(() => {
29
+ graph.executeWithNoStack(() => {
30
30
  graph.removeData(this.type, ids);
31
31
  });
32
32
  }
33
33
 
34
34
  private addChangedData(graph) {
35
35
  const models = this.changes.map((data) => data.value).filter(Boolean);
36
- graph.executeWithoutStacking(() => {
36
+ graph.executeWithNoStack(() => {
37
37
  graph.addData(this.type, models);
38
38
  });
39
39
  }
@@ -43,31 +43,49 @@ export class ItemDataCommand implements Command {
43
43
  operationType: StackType,
44
44
  onlyMove = false,
45
45
  ) {
46
- let models;
46
+ const modelMap = new Map();
47
47
  if (this.type === 'combo' && !onlyMove) {
48
- models = this.changes.map((data) => ({
49
- id: data.nodeId,
50
- data: {
51
- parentId: STACK_TYPE.undo ? data.oldParentId : data.newParentId,
52
- },
53
- }));
48
+ this.changes.forEach((data) => {
49
+ const model = modelMap.get(data.nodeId) || {};
50
+ modelMap.set(data.nodeId, {
51
+ id: data.nodeId,
52
+ data: {
53
+ ...model.data,
54
+ parentId: STACK_TYPE.undo ? data.oldParentId : data.newParentId,
55
+ },
56
+ });
57
+ });
54
58
  } else {
55
- models = this.changes.map((data) => {
56
- return {
59
+ this.changes.forEach((data) => {
60
+ const value =
61
+ operationType === STACK_TYPE.undo ? data.oldValue : data.newValue;
62
+ if (
63
+ (typeof value === 'number' && isNaN(value)) ||
64
+ (['x', 'y'].includes(data.propertyName) && value === undefined)
65
+ ) {
66
+ return;
67
+ }
68
+
69
+ const model = modelMap.get(data.nodeId) || {};
70
+ modelMap.set(data.id, {
57
71
  id: data.id,
58
- data:
59
- operationType === STACK_TYPE.undo ? data.oldValue : data.newValue,
60
- };
72
+ data: {
73
+ ...model.data,
74
+ [data.propertyName]: value,
75
+ },
76
+ });
61
77
  });
62
78
  }
63
79
 
64
- graph.pauseStacking();
80
+ graph.pauseStack();
81
+ const models = Array.from(modelMap.values());
65
82
  if (onlyMove) {
66
- graph.updatePosition(this.type, models, this.upsertAncestors);
83
+ // No matter it is node or combo, update the nodes' positions
84
+ graph.updateNodePosition(models, this.upsertAncestors);
67
85
  } else {
68
86
  graph.updateData(this.type, models);
69
87
  }
70
- graph.resumeStacking();
88
+ graph.resumeStack();
71
89
  }
72
90
 
73
91
  undo(graph: IGraph) {
@@ -11,7 +11,7 @@ export class LayerUpdatedCommand implements Command {
11
11
  }
12
12
 
13
13
  undo(graph: IGraph) {
14
- graph.executeWithoutStacking(() => {
14
+ graph.executeWithNoStack(() => {
15
15
  this.action === 'front'
16
16
  ? graph.backItem(this.ids)
17
17
  : graph.frontItem(this.ids);
@@ -19,7 +19,7 @@ export class LayerUpdatedCommand implements Command {
19
19
  }
20
20
 
21
21
  redo(graph: IGraph) {
22
- graph.executeWithoutStacking(() => {
22
+ graph.executeWithNoStack(() => {
23
23
  this.action === 'front'
24
24
  ? graph.frontItem(this.ids)
25
25
  : graph.backItem(this.ids);
@@ -20,7 +20,7 @@ export class StateUpdatedCommand implements Command {
20
20
  private updateItemsStates(graph, stateOptions) {
21
21
  stateOptions?.map((option) => {
22
22
  const { ids, states, value } = option;
23
- graph.executeWithoutStacking(() => {
23
+ graph.executeWithNoStack(() => {
24
24
  graph.setItemState(ids, states, value);
25
25
  });
26
26
  });
@@ -20,13 +20,13 @@ export class VisibilityUpdatedCommand implements Command {
20
20
  }
21
21
 
22
22
  private toggleItemsVisible(graph: IGraph, values) {
23
- graph.pauseStacking();
23
+ graph.pauseStack();
24
24
  each(values, (value) =>
25
25
  value.visible
26
26
  ? graph.showItem(value.ids, this.disableAnimate)
27
27
  : graph.hideItem(value.ids, this.disableAnimate),
28
28
  );
29
- graph.resumeStacking();
29
+ graph.resumeStack();
30
30
  }
31
31
 
32
32
  undo(graph: IGraph) {
@@ -51,7 +51,8 @@ interface HullComponentFullOptions extends HullComponentOptions {
51
51
  export default class Hull {
52
52
  graph: IGraph;
53
53
 
54
- path: any[][];
54
+ // TODO: PathArray is not exported by @antv/util 2.x but by 3.x. Correct the type String | PathArray after upgrading @antv/util
55
+ path: any;
55
56
 
56
57
  members: (NodeModel | ComboModel)[];
57
58
 
@@ -172,9 +173,9 @@ export default class Hull {
172
173
  const shape = this.graph.drawTransient('path', this.options.id, {
173
174
  style: {
174
175
  path: this.path,
176
+ pointerEvents: 'none',
175
177
  ...this.options.style,
176
178
  },
177
- capture: false,
178
179
  });
179
180
  const { labelShape } = this.options;
180
181
  if (labelShape?.text) {
@@ -183,10 +184,10 @@ export default class Hull {
183
184
  const formattedLabelStyle = this.getLabelStyle(labelShape, shapeBounds);
184
185
  this.graph.drawTransient('text', `${this.options.id}-label`, {
185
186
  style: {
187
+ pointerEvents: 'none',
186
188
  ...labelShapeStyle,
187
189
  ...formattedLabelStyle,
188
190
  },
189
- capture: false,
190
191
  });
191
192
  }
192
193
  shape.toBack();
@@ -426,8 +427,10 @@ export default class Hull {
426
427
 
427
428
  public updateStyle(style: ShapeStyle) {
428
429
  this.graph.drawTransient('path', this.options.id, {
429
- style,
430
- capture: false,
430
+ style: {
431
+ ...style,
432
+ pointerEvents: 'none',
433
+ },
431
434
  });
432
435
  }
433
436
 
@@ -6,3 +6,5 @@ export * from './menu';
6
6
  export * from './minimap';
7
7
  export * from './toolbar';
8
8
  export * from './tooltip';
9
+ export * from './timebar';
10
+ export * from './snapline';
@@ -235,7 +235,7 @@ export class Legend extends Base {
235
235
  canvasSize[0],
236
236
  canvasSize[1],
237
237
  undefined,
238
- background,
238
+ { background },
239
239
  );
240
240
  }
241
241