@antv/g6 5.0.0-beta.32 → 5.0.0-beta.33

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 (615) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/behaviors/brush-select.d.ts +104 -0
  3. package/dist/lib/behaviors/click-element.d.ts +77 -0
  4. package/dist/lib/behaviors/drag-element-force.d.ts +14 -0
  5. package/dist/lib/behaviors/drag-element.d.ts +13 -12
  6. package/dist/lib/behaviors/index.d.ts +8 -0
  7. package/dist/lib/behaviors/lasso-select.d.ts +20 -0
  8. package/dist/lib/behaviors/types.d.ts +1 -0
  9. package/dist/lib/constants/change.d.ts +1 -1
  10. package/dist/lib/constants/events/graph.d.ts +9 -7
  11. package/dist/lib/constants/registry.d.ts +3 -1
  12. package/dist/lib/elements/combos/base-combo.d.ts +43 -6
  13. package/dist/lib/elements/combos/circle.d.ts +8 -12
  14. package/dist/lib/elements/combos/rect.d.ts +5 -9
  15. package/dist/lib/elements/edges/base-edge.d.ts +64 -10
  16. package/dist/lib/elements/edges/cubic-horizontal.d.ts +2 -2
  17. package/dist/lib/elements/edges/cubic-vertical.d.ts +2 -2
  18. package/dist/lib/elements/edges/cubic.d.ts +2 -2
  19. package/dist/lib/elements/edges/polyline.d.ts +2 -2
  20. package/dist/lib/elements/edges/quadratic.d.ts +2 -2
  21. package/dist/lib/elements/nodes/base-node.d.ts +104 -13
  22. package/dist/lib/elements/nodes/circle.d.ts +5 -8
  23. package/dist/lib/elements/nodes/diamond.d.ts +2 -4
  24. package/dist/lib/elements/nodes/ellipse.d.ts +5 -8
  25. package/dist/lib/elements/nodes/hexagon.d.ts +6 -9
  26. package/dist/lib/elements/nodes/image.d.ts +9 -11
  27. package/dist/lib/elements/nodes/polygon.d.ts +9 -8
  28. package/dist/lib/elements/nodes/rect.d.ts +2 -3
  29. package/dist/lib/elements/nodes/star.d.ts +7 -10
  30. package/dist/lib/elements/nodes/triangle.d.ts +7 -10
  31. package/dist/lib/exports.d.ts +4 -2
  32. package/dist/lib/layouts/index.d.ts +1 -1
  33. package/dist/lib/layouts/types.d.ts +6 -6
  34. package/dist/lib/palettes/index.d.ts +1 -0
  35. package/dist/lib/plugins/history/events.d.ts +21 -0
  36. package/dist/lib/plugins/history/index.d.ts +82 -0
  37. package/dist/lib/plugins/history/utils.d.ts +31 -0
  38. package/dist/lib/plugins/hull/index.d.ts +59 -0
  39. package/dist/lib/plugins/hull/shape.d.ts +49 -0
  40. package/dist/lib/plugins/hull/util.d.ts +12 -0
  41. package/dist/lib/plugins/index.d.ts +4 -0
  42. package/dist/lib/registry/extension/index.d.ts +1 -1
  43. package/dist/lib/registry/types.d.ts +4 -0
  44. package/dist/lib/runtime/batch.d.ts +11 -0
  45. package/dist/lib/runtime/behavior.d.ts +1 -1
  46. package/dist/lib/runtime/canvas.d.ts +13 -3
  47. package/dist/lib/runtime/data.d.ts +4 -4
  48. package/dist/lib/runtime/element.d.ts +3 -19
  49. package/dist/lib/runtime/graph.d.ts +40 -2
  50. package/dist/lib/runtime/layout.d.ts +5 -11
  51. package/dist/lib/runtime/plugin.d.ts +1 -1
  52. package/dist/lib/runtime/transform.d.ts +11 -0
  53. package/dist/lib/runtime/types.d.ts +14 -0
  54. package/dist/lib/spec/index.d.ts +1 -0
  55. package/dist/lib/spec/spec.d.ts +7 -0
  56. package/dist/lib/spec/transform.d.ts +12 -0
  57. package/dist/lib/transforms/arrange-draw-order.d.ts +10 -0
  58. package/dist/lib/transforms/base-transform.d.ts +7 -0
  59. package/dist/lib/transforms/collapse-expand-combo.d.ts +10 -0
  60. package/dist/lib/transforms/index.d.ts +6 -0
  61. package/dist/lib/transforms/process-parallel-edges.d.ts +84 -0
  62. package/dist/lib/transforms/types.d.ts +20 -0
  63. package/dist/lib/transforms/update-related-edge.d.ts +9 -0
  64. package/dist/lib/types/canvas.d.ts +1 -1
  65. package/dist/lib/types/change.d.ts +27 -10
  66. package/dist/lib/types/element.d.ts +6 -140
  67. package/dist/lib/types/node.d.ts +3 -3
  68. package/dist/lib/types/point.d.ts +1 -0
  69. package/dist/lib/utils/animation.d.ts +1 -1
  70. package/dist/lib/utils/behaviors/brush.d.ts +19 -0
  71. package/dist/lib/utils/behaviors/lasso.d.ts +13 -0
  72. package/dist/lib/utils/behaviors/utils.d.ts +21 -0
  73. package/dist/lib/utils/change.d.ts +9 -1
  74. package/dist/lib/utils/combo.d.ts +5 -4
  75. package/dist/lib/utils/edge.d.ts +11 -0
  76. package/dist/lib/utils/event/events.d.ts +1 -1
  77. package/dist/lib/utils/extension.d.ts +1 -1
  78. package/dist/lib/utils/id.d.ts +3 -8
  79. package/dist/lib/utils/line.d.ts +21 -0
  80. package/dist/lib/utils/path.d.ts +35 -0
  81. package/dist/lib/utils/point.d.ts +74 -20
  82. package/dist/lib/utils/polygon.d.ts +17 -0
  83. package/dist/lib/utils/position.d.ts +14 -1
  84. package/dist/lib/utils/prefix.d.ts +1 -1
  85. package/dist/lib/utils/shortcut.d.ts +1 -0
  86. package/dist/lib/utils/vector.d.ts +3 -2
  87. package/esm/behaviors/brush-select.d.ts +104 -0
  88. package/esm/behaviors/brush-select.js +199 -0
  89. package/esm/behaviors/brush-select.js.map +1 -0
  90. package/esm/behaviors/click-element.d.ts +77 -0
  91. package/esm/behaviors/click-element.js +108 -0
  92. package/esm/behaviors/click-element.js.map +1 -0
  93. package/esm/behaviors/drag-element-force.d.ts +14 -0
  94. package/esm/behaviors/drag-element-force.js +55 -0
  95. package/esm/behaviors/drag-element-force.js.map +1 -0
  96. package/esm/behaviors/drag-element.d.ts +13 -12
  97. package/esm/behaviors/drag-element.js +17 -9
  98. package/esm/behaviors/drag-element.js.map +1 -1
  99. package/esm/behaviors/hover-element.js +2 -2
  100. package/esm/behaviors/hover-element.js.map +1 -1
  101. package/esm/behaviors/index.d.ts +8 -0
  102. package/esm/behaviors/index.js +4 -0
  103. package/esm/behaviors/index.js.map +1 -1
  104. package/esm/behaviors/lasso-select.d.ts +20 -0
  105. package/esm/behaviors/lasso-select.js +79 -0
  106. package/esm/behaviors/lasso-select.js.map +1 -0
  107. package/esm/behaviors/types.d.ts +1 -0
  108. package/esm/constants/change.d.ts +1 -1
  109. package/esm/constants/change.js +12 -12
  110. package/esm/constants/change.js.map +1 -1
  111. package/esm/constants/events/graph.d.ts +9 -7
  112. package/esm/constants/events/graph.js +8 -8
  113. package/esm/constants/events/graph.js.map +1 -1
  114. package/esm/constants/registry.d.ts +3 -1
  115. package/esm/constants/registry.js +2 -0
  116. package/esm/constants/registry.js.map +1 -1
  117. package/esm/elements/combos/base-combo.d.ts +43 -6
  118. package/esm/elements/combos/base-combo.js.map +1 -1
  119. package/esm/elements/combos/circle.d.ts +8 -12
  120. package/esm/elements/combos/circle.js.map +1 -1
  121. package/esm/elements/combos/rect.d.ts +5 -9
  122. package/esm/elements/combos/rect.js.map +1 -1
  123. package/esm/elements/edges/base-edge.d.ts +64 -10
  124. package/esm/elements/edges/base-edge.js.map +1 -1
  125. package/esm/elements/edges/cubic-horizontal.d.ts +2 -2
  126. package/esm/elements/edges/cubic-vertical.d.ts +2 -2
  127. package/esm/elements/edges/cubic.d.ts +2 -2
  128. package/esm/elements/edges/polyline.d.ts +2 -2
  129. package/esm/elements/edges/quadratic.d.ts +2 -2
  130. package/esm/elements/nodes/base-node.d.ts +104 -13
  131. package/esm/elements/nodes/base-node.js +4 -1
  132. package/esm/elements/nodes/base-node.js.map +1 -1
  133. package/esm/elements/nodes/circle.d.ts +5 -8
  134. package/esm/elements/nodes/circle.js.map +1 -1
  135. package/esm/elements/nodes/diamond.d.ts +2 -4
  136. package/esm/elements/nodes/diamond.js +2 -2
  137. package/esm/elements/nodes/diamond.js.map +1 -1
  138. package/esm/elements/nodes/ellipse.d.ts +5 -8
  139. package/esm/elements/nodes/ellipse.js +1 -1
  140. package/esm/elements/nodes/ellipse.js.map +1 -1
  141. package/esm/elements/nodes/hexagon.d.ts +6 -9
  142. package/esm/elements/nodes/hexagon.js.map +1 -1
  143. package/esm/elements/nodes/image.d.ts +9 -11
  144. package/esm/elements/nodes/image.js.map +1 -1
  145. package/esm/elements/nodes/polygon.d.ts +9 -8
  146. package/esm/elements/nodes/polygon.js +4 -1
  147. package/esm/elements/nodes/polygon.js.map +1 -1
  148. package/esm/elements/nodes/rect.d.ts +2 -3
  149. package/esm/elements/nodes/rect.js.map +1 -1
  150. package/esm/elements/nodes/star.d.ts +7 -10
  151. package/esm/elements/nodes/star.js.map +1 -1
  152. package/esm/elements/nodes/triangle.d.ts +7 -10
  153. package/esm/elements/nodes/triangle.js.map +1 -1
  154. package/esm/exports.d.ts +4 -2
  155. package/esm/exports.js +2 -1
  156. package/esm/exports.js.map +1 -1
  157. package/esm/layouts/index.d.ts +1 -1
  158. package/esm/layouts/index.js +1 -1
  159. package/esm/layouts/index.js.map +1 -1
  160. package/esm/layouts/types.d.ts +6 -6
  161. package/esm/palettes/index.d.ts +1 -0
  162. package/esm/palettes/index.js +12 -0
  163. package/esm/palettes/index.js.map +1 -1
  164. package/esm/plugins/history/events.d.ts +21 -0
  165. package/esm/plugins/history/events.js +16 -0
  166. package/esm/plugins/history/events.js.map +1 -0
  167. package/esm/plugins/history/index.d.ts +82 -0
  168. package/esm/plugins/history/index.js +168 -0
  169. package/esm/plugins/history/index.js.map +1 -0
  170. package/esm/plugins/history/utils.d.ts +31 -0
  171. package/esm/plugins/history/utils.js +79 -0
  172. package/esm/plugins/history/utils.js.map +1 -0
  173. package/esm/plugins/hull/index.d.ts +59 -0
  174. package/esm/plugins/hull/index.js +107 -0
  175. package/esm/plugins/hull/index.js.map +1 -0
  176. package/esm/plugins/hull/shape.d.ts +49 -0
  177. package/esm/plugins/hull/shape.js +35 -0
  178. package/esm/plugins/hull/shape.js.map +1 -0
  179. package/esm/plugins/hull/util.d.ts +12 -0
  180. package/esm/plugins/hull/util.js +203 -0
  181. package/esm/plugins/hull/util.js.map +1 -0
  182. package/esm/plugins/index.d.ts +4 -0
  183. package/esm/plugins/index.js +2 -0
  184. package/esm/plugins/index.js.map +1 -1
  185. package/esm/plugins/legend.js.map +1 -1
  186. package/esm/registry/build-in.js +19 -4
  187. package/esm/registry/build-in.js.map +1 -1
  188. package/esm/registry/extension/index.d.ts +1 -1
  189. package/esm/registry/index.js +1 -0
  190. package/esm/registry/index.js.map +1 -1
  191. package/esm/registry/types.d.ts +4 -0
  192. package/esm/runtime/batch.d.ts +11 -0
  193. package/esm/runtime/batch.js +31 -0
  194. package/esm/runtime/batch.js.map +1 -0
  195. package/esm/runtime/behavior.d.ts +1 -1
  196. package/esm/runtime/behavior.js.map +1 -1
  197. package/esm/runtime/canvas.d.ts +13 -3
  198. package/esm/runtime/canvas.js +36 -12
  199. package/esm/runtime/canvas.js.map +1 -1
  200. package/esm/runtime/data.d.ts +4 -4
  201. package/esm/runtime/data.js +23 -25
  202. package/esm/runtime/data.js.map +1 -1
  203. package/esm/runtime/element.d.ts +3 -19
  204. package/esm/runtime/element.js +16 -137
  205. package/esm/runtime/element.js.map +1 -1
  206. package/esm/runtime/graph.d.ts +40 -2
  207. package/esm/runtime/graph.js +57 -1
  208. package/esm/runtime/graph.js.map +1 -1
  209. package/esm/runtime/layout.d.ts +5 -11
  210. package/esm/runtime/layout.js +29 -75
  211. package/esm/runtime/layout.js.map +1 -1
  212. package/esm/runtime/plugin.d.ts +1 -1
  213. package/esm/runtime/plugin.js.map +1 -1
  214. package/esm/runtime/transform.d.ts +11 -0
  215. package/esm/runtime/transform.js +20 -0
  216. package/esm/runtime/transform.js.map +1 -0
  217. package/esm/runtime/types.d.ts +14 -0
  218. package/esm/spec/index.d.ts +1 -0
  219. package/esm/spec/spec.d.ts +7 -0
  220. package/esm/spec/transform.d.ts +12 -0
  221. package/esm/spec/transform.js +2 -0
  222. package/esm/spec/transform.js.map +1 -0
  223. package/esm/themes/base.js +9 -1
  224. package/esm/themes/base.js.map +1 -1
  225. package/esm/transforms/arrange-draw-order.d.ts +10 -0
  226. package/esm/transforms/arrange-draw-order.js +27 -0
  227. package/esm/transforms/arrange-draw-order.js.map +1 -0
  228. package/esm/transforms/base-transform.d.ts +7 -0
  229. package/esm/transforms/base-transform.js +7 -0
  230. package/esm/transforms/base-transform.js.map +1 -0
  231. package/esm/transforms/collapse-expand-combo.d.ts +10 -0
  232. package/esm/transforms/collapse-expand-combo.js +82 -0
  233. package/esm/transforms/collapse-expand-combo.js.map +1 -0
  234. package/esm/transforms/index.d.ts +6 -0
  235. package/esm/transforms/index.js +6 -0
  236. package/esm/transforms/index.js.map +1 -0
  237. package/esm/transforms/process-parallel-edges.d.ts +84 -0
  238. package/esm/transforms/process-parallel-edges.js +215 -0
  239. package/esm/transforms/process-parallel-edges.js.map +1 -0
  240. package/esm/transforms/types.d.ts +20 -0
  241. package/esm/transforms/types.js +11 -0
  242. package/esm/transforms/types.js.map +1 -0
  243. package/esm/transforms/update-related-edge.d.ts +9 -0
  244. package/esm/transforms/update-related-edge.js +20 -0
  245. package/esm/transforms/update-related-edge.js.map +1 -0
  246. package/esm/types/canvas.d.ts +1 -1
  247. package/esm/types/change.d.ts +27 -10
  248. package/esm/types/element.d.ts +6 -140
  249. package/esm/types/node.d.ts +3 -3
  250. package/esm/types/point.d.ts +1 -0
  251. package/esm/utils/animation.d.ts +1 -1
  252. package/esm/utils/animation.js +6 -0
  253. package/esm/utils/animation.js.map +1 -1
  254. package/esm/utils/behaviors/brush.d.ts +19 -0
  255. package/esm/utils/behaviors/brush.js +25 -0
  256. package/esm/utils/behaviors/brush.js.map +1 -0
  257. package/esm/utils/behaviors/lasso.d.ts +13 -0
  258. package/esm/utils/behaviors/lasso.js +112 -0
  259. package/esm/utils/behaviors/lasso.js.map +1 -0
  260. package/esm/utils/behaviors/utils.d.ts +21 -0
  261. package/esm/utils/behaviors/utils.js +42 -0
  262. package/esm/utils/behaviors/utils.js.map +1 -0
  263. package/esm/utils/change.d.ts +9 -1
  264. package/esm/utils/change.js +28 -0
  265. package/esm/utils/change.js.map +1 -1
  266. package/esm/utils/combo.d.ts +5 -4
  267. package/esm/utils/combo.js.map +1 -1
  268. package/esm/utils/edge.d.ts +11 -0
  269. package/esm/utils/edge.js +1 -1
  270. package/esm/utils/edge.js.map +1 -1
  271. package/esm/utils/event/events.d.ts +1 -1
  272. package/esm/utils/event/events.js.map +1 -1
  273. package/esm/utils/extension.d.ts +1 -1
  274. package/esm/utils/extension.js.map +1 -1
  275. package/esm/utils/id.d.ts +3 -8
  276. package/esm/utils/id.js +8 -2
  277. package/esm/utils/id.js.map +1 -1
  278. package/esm/utils/line.d.ts +21 -0
  279. package/esm/utils/line.js +41 -0
  280. package/esm/utils/line.js.map +1 -0
  281. package/esm/utils/path.d.ts +35 -0
  282. package/esm/utils/path.js +143 -0
  283. package/esm/utils/path.js.map +1 -0
  284. package/esm/utils/point.d.ts +74 -20
  285. package/esm/utils/point.js +168 -44
  286. package/esm/utils/point.js.map +1 -1
  287. package/esm/utils/polygon.d.ts +17 -0
  288. package/esm/utils/polygon.js +62 -0
  289. package/esm/utils/polygon.js.map +1 -0
  290. package/esm/utils/position.d.ts +14 -1
  291. package/esm/utils/position.js +16 -0
  292. package/esm/utils/position.js.map +1 -1
  293. package/esm/utils/prefix.d.ts +1 -1
  294. package/esm/utils/prefix.js.map +1 -1
  295. package/esm/utils/shortcut.d.ts +1 -0
  296. package/esm/utils/shortcut.js +13 -2
  297. package/esm/utils/shortcut.js.map +1 -1
  298. package/esm/utils/style.js.map +1 -1
  299. package/esm/utils/vector.d.ts +3 -2
  300. package/esm/utils/vector.js +10 -3
  301. package/esm/utils/vector.js.map +1 -1
  302. package/lib/behaviors/brush-select.d.ts +104 -0
  303. package/lib/behaviors/brush-select.js +203 -0
  304. package/lib/behaviors/brush-select.js.map +1 -0
  305. package/lib/behaviors/click-element.d.ts +77 -0
  306. package/lib/behaviors/click-element.js +112 -0
  307. package/lib/behaviors/click-element.js.map +1 -0
  308. package/lib/behaviors/drag-element-force.d.ts +14 -0
  309. package/lib/behaviors/drag-element-force.js +59 -0
  310. package/lib/behaviors/drag-element-force.js.map +1 -0
  311. package/lib/behaviors/drag-element.d.ts +13 -12
  312. package/lib/behaviors/drag-element.js +17 -9
  313. package/lib/behaviors/drag-element.js.map +1 -1
  314. package/lib/behaviors/hover-element.js +1 -1
  315. package/lib/behaviors/hover-element.js.map +1 -1
  316. package/lib/behaviors/index.d.ts +8 -0
  317. package/lib/behaviors/index.js +9 -1
  318. package/lib/behaviors/index.js.map +1 -1
  319. package/lib/behaviors/lasso-select.d.ts +20 -0
  320. package/lib/behaviors/lasso-select.js +83 -0
  321. package/lib/behaviors/lasso-select.js.map +1 -0
  322. package/lib/behaviors/types.d.ts +1 -0
  323. package/lib/constants/change.d.ts +1 -1
  324. package/lib/constants/change.js +13 -13
  325. package/lib/constants/change.js.map +1 -1
  326. package/lib/constants/events/graph.d.ts +9 -7
  327. package/lib/constants/events/graph.js +9 -9
  328. package/lib/constants/events/graph.js.map +1 -1
  329. package/lib/constants/registry.d.ts +3 -1
  330. package/lib/constants/registry.js +2 -0
  331. package/lib/constants/registry.js.map +1 -1
  332. package/lib/elements/combos/base-combo.d.ts +43 -6
  333. package/lib/elements/combos/base-combo.js.map +1 -1
  334. package/lib/elements/combos/circle.d.ts +8 -12
  335. package/lib/elements/combos/circle.js.map +1 -1
  336. package/lib/elements/combos/rect.d.ts +5 -9
  337. package/lib/elements/combos/rect.js.map +1 -1
  338. package/lib/elements/edges/base-edge.d.ts +64 -10
  339. package/lib/elements/edges/base-edge.js.map +1 -1
  340. package/lib/elements/edges/cubic-horizontal.d.ts +2 -2
  341. package/lib/elements/edges/cubic-vertical.d.ts +2 -2
  342. package/lib/elements/edges/cubic.d.ts +2 -2
  343. package/lib/elements/edges/polyline.d.ts +2 -2
  344. package/lib/elements/edges/quadratic.d.ts +2 -2
  345. package/lib/elements/nodes/base-node.d.ts +104 -13
  346. package/lib/elements/nodes/base-node.js +4 -1
  347. package/lib/elements/nodes/base-node.js.map +1 -1
  348. package/lib/elements/nodes/circle.d.ts +5 -8
  349. package/lib/elements/nodes/circle.js.map +1 -1
  350. package/lib/elements/nodes/diamond.d.ts +2 -4
  351. package/lib/elements/nodes/diamond.js +2 -2
  352. package/lib/elements/nodes/diamond.js.map +1 -1
  353. package/lib/elements/nodes/ellipse.d.ts +5 -8
  354. package/lib/elements/nodes/ellipse.js +1 -1
  355. package/lib/elements/nodes/ellipse.js.map +1 -1
  356. package/lib/elements/nodes/hexagon.d.ts +6 -9
  357. package/lib/elements/nodes/hexagon.js.map +1 -1
  358. package/lib/elements/nodes/image.d.ts +9 -11
  359. package/lib/elements/nodes/image.js.map +1 -1
  360. package/lib/elements/nodes/polygon.d.ts +9 -8
  361. package/lib/elements/nodes/polygon.js +4 -1
  362. package/lib/elements/nodes/polygon.js.map +1 -1
  363. package/lib/elements/nodes/rect.d.ts +2 -3
  364. package/lib/elements/nodes/rect.js.map +1 -1
  365. package/lib/elements/nodes/star.d.ts +7 -10
  366. package/lib/elements/nodes/star.js.map +1 -1
  367. package/lib/elements/nodes/triangle.d.ts +7 -10
  368. package/lib/elements/nodes/triangle.js.map +1 -1
  369. package/lib/exports.d.ts +4 -2
  370. package/lib/exports.js +4 -1
  371. package/lib/exports.js.map +1 -1
  372. package/lib/layouts/index.d.ts +1 -1
  373. package/lib/layouts/index.js +2 -1
  374. package/lib/layouts/index.js.map +1 -1
  375. package/lib/layouts/types.d.ts +6 -6
  376. package/lib/palettes/index.d.ts +1 -0
  377. package/lib/palettes/index.js +13 -1
  378. package/lib/palettes/index.js.map +1 -1
  379. package/lib/plugins/history/events.d.ts +21 -0
  380. package/lib/plugins/history/events.js +19 -0
  381. package/lib/plugins/history/events.js.map +1 -0
  382. package/lib/plugins/history/index.d.ts +82 -0
  383. package/lib/plugins/history/index.js +175 -0
  384. package/lib/plugins/history/index.js.map +1 -0
  385. package/lib/plugins/history/utils.d.ts +31 -0
  386. package/lib/plugins/history/utils.js +84 -0
  387. package/lib/plugins/history/utils.js.map +1 -0
  388. package/lib/plugins/hull/index.d.ts +59 -0
  389. package/lib/plugins/hull/index.js +114 -0
  390. package/lib/plugins/hull/index.js.map +1 -0
  391. package/lib/plugins/hull/shape.d.ts +49 -0
  392. package/lib/plugins/hull/shape.js +39 -0
  393. package/lib/plugins/hull/shape.js.map +1 -0
  394. package/lib/plugins/hull/util.d.ts +12 -0
  395. package/lib/plugins/hull/util.js +207 -0
  396. package/lib/plugins/hull/util.js.map +1 -0
  397. package/lib/plugins/index.d.ts +4 -0
  398. package/lib/plugins/index.js +5 -1
  399. package/lib/plugins/index.js.map +1 -1
  400. package/lib/plugins/legend.js.map +1 -1
  401. package/lib/registry/build-in.js +15 -0
  402. package/lib/registry/build-in.js.map +1 -1
  403. package/lib/registry/extension/index.d.ts +1 -1
  404. package/lib/registry/index.js +1 -0
  405. package/lib/registry/index.js.map +1 -1
  406. package/lib/registry/types.d.ts +4 -0
  407. package/lib/runtime/batch.d.ts +11 -0
  408. package/lib/runtime/batch.js +35 -0
  409. package/lib/runtime/batch.js.map +1 -0
  410. package/lib/runtime/behavior.d.ts +1 -1
  411. package/lib/runtime/behavior.js.map +1 -1
  412. package/lib/runtime/canvas.d.ts +13 -3
  413. package/lib/runtime/canvas.js +34 -10
  414. package/lib/runtime/canvas.js.map +1 -1
  415. package/lib/runtime/data.d.ts +4 -4
  416. package/lib/runtime/data.js +22 -24
  417. package/lib/runtime/data.js.map +1 -1
  418. package/lib/runtime/element.d.ts +3 -19
  419. package/lib/runtime/element.js +16 -137
  420. package/lib/runtime/element.js.map +1 -1
  421. package/lib/runtime/graph.d.ts +40 -2
  422. package/lib/runtime/graph.js +57 -1
  423. package/lib/runtime/graph.js.map +1 -1
  424. package/lib/runtime/layout.d.ts +5 -11
  425. package/lib/runtime/layout.js +27 -73
  426. package/lib/runtime/layout.js.map +1 -1
  427. package/lib/runtime/plugin.d.ts +1 -1
  428. package/lib/runtime/plugin.js.map +1 -1
  429. package/lib/runtime/transform.d.ts +11 -0
  430. package/lib/runtime/transform.js +24 -0
  431. package/lib/runtime/transform.js.map +1 -0
  432. package/lib/runtime/types.d.ts +14 -0
  433. package/lib/spec/index.d.ts +1 -0
  434. package/lib/spec/spec.d.ts +7 -0
  435. package/lib/spec/transform.d.ts +12 -0
  436. package/lib/spec/transform.js +3 -0
  437. package/lib/spec/transform.js.map +1 -0
  438. package/lib/themes/base.js +9 -1
  439. package/lib/themes/base.js.map +1 -1
  440. package/lib/transforms/arrange-draw-order.d.ts +10 -0
  441. package/lib/transforms/arrange-draw-order.js +31 -0
  442. package/lib/transforms/arrange-draw-order.js.map +1 -0
  443. package/lib/transforms/base-transform.d.ts +7 -0
  444. package/lib/transforms/base-transform.js +11 -0
  445. package/lib/transforms/base-transform.js.map +1 -0
  446. package/lib/transforms/collapse-expand-combo.d.ts +10 -0
  447. package/lib/transforms/collapse-expand-combo.js +86 -0
  448. package/lib/transforms/collapse-expand-combo.js.map +1 -0
  449. package/lib/transforms/index.d.ts +6 -0
  450. package/lib/transforms/index.js +14 -0
  451. package/lib/transforms/index.js.map +1 -0
  452. package/lib/transforms/process-parallel-edges.d.ts +84 -0
  453. package/lib/transforms/process-parallel-edges.js +222 -0
  454. package/lib/transforms/process-parallel-edges.js.map +1 -0
  455. package/lib/transforms/types.d.ts +20 -0
  456. package/lib/transforms/types.js +15 -0
  457. package/lib/transforms/types.js.map +1 -0
  458. package/lib/transforms/update-related-edge.d.ts +9 -0
  459. package/lib/transforms/update-related-edge.js +24 -0
  460. package/lib/transforms/update-related-edge.js.map +1 -0
  461. package/lib/types/canvas.d.ts +1 -1
  462. package/lib/types/change.d.ts +27 -10
  463. package/lib/types/element.d.ts +6 -140
  464. package/lib/types/node.d.ts +3 -3
  465. package/lib/types/point.d.ts +1 -0
  466. package/lib/utils/animation.d.ts +1 -1
  467. package/lib/utils/animation.js +6 -0
  468. package/lib/utils/animation.js.map +1 -1
  469. package/lib/utils/behaviors/brush.d.ts +19 -0
  470. package/lib/utils/behaviors/brush.js +30 -0
  471. package/lib/utils/behaviors/brush.js.map +1 -0
  472. package/lib/utils/behaviors/lasso.d.ts +13 -0
  473. package/lib/utils/behaviors/lasso.js +116 -0
  474. package/lib/utils/behaviors/lasso.js.map +1 -0
  475. package/lib/utils/behaviors/utils.d.ts +21 -0
  476. package/lib/utils/behaviors/utils.js +47 -0
  477. package/lib/utils/behaviors/utils.js.map +1 -0
  478. package/lib/utils/change.d.ts +9 -1
  479. package/lib/utils/change.js +30 -1
  480. package/lib/utils/change.js.map +1 -1
  481. package/lib/utils/combo.d.ts +5 -4
  482. package/lib/utils/combo.js.map +1 -1
  483. package/lib/utils/edge.d.ts +11 -0
  484. package/lib/utils/edge.js +2 -1
  485. package/lib/utils/edge.js.map +1 -1
  486. package/lib/utils/event/events.d.ts +1 -1
  487. package/lib/utils/event/events.js.map +1 -1
  488. package/lib/utils/extension.d.ts +1 -1
  489. package/lib/utils/extension.js.map +1 -1
  490. package/lib/utils/id.d.ts +3 -8
  491. package/lib/utils/id.js +10 -4
  492. package/lib/utils/id.js.map +1 -1
  493. package/lib/utils/line.d.ts +21 -0
  494. package/lib/utils/line.js +46 -0
  495. package/lib/utils/line.js.map +1 -0
  496. package/lib/utils/path.d.ts +35 -0
  497. package/lib/utils/path.js +150 -0
  498. package/lib/utils/path.js.map +1 -0
  499. package/lib/utils/point.d.ts +74 -20
  500. package/lib/utils/point.js +178 -48
  501. package/lib/utils/point.js.map +1 -1
  502. package/lib/utils/polygon.d.ts +17 -0
  503. package/lib/utils/polygon.js +66 -0
  504. package/lib/utils/polygon.js.map +1 -0
  505. package/lib/utils/position.d.ts +14 -1
  506. package/lib/utils/position.js +18 -1
  507. package/lib/utils/position.js.map +1 -1
  508. package/lib/utils/prefix.d.ts +1 -1
  509. package/lib/utils/prefix.js.map +1 -1
  510. package/lib/utils/shortcut.d.ts +1 -0
  511. package/lib/utils/shortcut.js +12 -1
  512. package/lib/utils/shortcut.js.map +1 -1
  513. package/lib/utils/style.js.map +1 -1
  514. package/lib/utils/vector.d.ts +3 -2
  515. package/lib/utils/vector.js +10 -3
  516. package/lib/utils/vector.js.map +1 -1
  517. package/package.json +5 -6
  518. package/src/behaviors/brush-select.ts +306 -0
  519. package/src/behaviors/click-element.ts +182 -0
  520. package/src/behaviors/drag-element-force.ts +70 -0
  521. package/src/behaviors/drag-element.ts +27 -17
  522. package/src/behaviors/hover-element.ts +2 -3
  523. package/src/behaviors/index.ts +8 -0
  524. package/src/behaviors/lasso-select.ts +103 -0
  525. package/src/behaviors/types.ts +2 -0
  526. package/src/constants/change.ts +1 -1
  527. package/src/constants/events/graph.ts +8 -8
  528. package/src/constants/registry.ts +2 -0
  529. package/src/elements/combos/base-combo.ts +59 -10
  530. package/src/elements/combos/circle.ts +8 -11
  531. package/src/elements/combos/rect.ts +5 -8
  532. package/src/elements/edges/base-edge.ts +70 -13
  533. package/src/elements/edges/cubic-horizontal.ts +2 -2
  534. package/src/elements/edges/cubic-vertical.ts +2 -2
  535. package/src/elements/edges/cubic.ts +2 -2
  536. package/src/elements/edges/polyline.ts +2 -2
  537. package/src/elements/edges/quadratic.ts +2 -2
  538. package/src/elements/nodes/base-node.ts +115 -19
  539. package/src/elements/nodes/circle.ts +5 -7
  540. package/src/elements/nodes/diamond.ts +4 -6
  541. package/src/elements/nodes/ellipse.ts +6 -8
  542. package/src/elements/nodes/hexagon.ts +7 -9
  543. package/src/elements/nodes/image.ts +12 -13
  544. package/src/elements/nodes/polygon.ts +17 -11
  545. package/src/elements/nodes/rect.ts +3 -4
  546. package/src/elements/nodes/star.ts +9 -11
  547. package/src/elements/nodes/triangle.ts +7 -9
  548. package/src/exports.ts +4 -2
  549. package/src/layouts/index.ts +1 -0
  550. package/src/layouts/types.ts +7 -5
  551. package/src/palettes/index.ts +13 -0
  552. package/src/plugins/history/events.ts +25 -0
  553. package/src/plugins/history/index.ts +222 -0
  554. package/src/plugins/history/utils.ts +98 -0
  555. package/src/plugins/hull/index.ts +149 -0
  556. package/src/plugins/hull/shape.ts +96 -0
  557. package/src/plugins/hull/util.ts +222 -0
  558. package/src/plugins/index.ts +4 -0
  559. package/src/plugins/legend.ts +1 -1
  560. package/src/registry/build-in.ts +22 -2
  561. package/src/registry/extension/index.ts +1 -1
  562. package/src/registry/index.ts +1 -0
  563. package/src/registry/types.ts +2 -0
  564. package/src/runtime/batch.ts +38 -0
  565. package/src/runtime/behavior.ts +1 -1
  566. package/src/runtime/canvas.ts +51 -13
  567. package/src/runtime/data.ts +31 -36
  568. package/src/runtime/element.ts +28 -167
  569. package/src/runtime/graph.ts +65 -3
  570. package/src/runtime/layout.ts +48 -79
  571. package/src/runtime/plugin.ts +1 -1
  572. package/src/runtime/transform.ts +27 -0
  573. package/src/runtime/types.ts +14 -0
  574. package/src/spec/index.ts +1 -0
  575. package/src/spec/spec.ts +7 -0
  576. package/src/spec/transform.ts +15 -0
  577. package/src/themes/base.ts +9 -1
  578. package/src/transforms/arrange-draw-order.ts +36 -0
  579. package/src/transforms/base-transform.ts +11 -0
  580. package/src/transforms/collapse-expand-combo.ts +87 -0
  581. package/src/transforms/index.ts +7 -0
  582. package/src/transforms/process-parallel-edges.ts +286 -0
  583. package/src/transforms/types.ts +23 -0
  584. package/src/transforms/update-related-edge.ts +28 -0
  585. package/src/types/canvas.ts +1 -1
  586. package/src/types/change.ts +28 -10
  587. package/src/types/element.ts +6 -147
  588. package/src/types/node.ts +3 -3
  589. package/src/types/point.ts +1 -0
  590. package/src/utils/animation.ts +6 -0
  591. package/src/utils/behaviors/brush.ts +29 -0
  592. package/src/utils/behaviors/lasso.ts +127 -0
  593. package/src/utils/behaviors/utils.ts +47 -0
  594. package/src/utils/change.ts +42 -1
  595. package/src/utils/combo.ts +6 -5
  596. package/src/utils/edge.ts +6 -1
  597. package/src/utils/event/events.ts +3 -1
  598. package/src/utils/extension.ts +1 -1
  599. package/src/utils/id.ts +11 -2
  600. package/src/utils/line.ts +50 -0
  601. package/src/utils/path.ts +153 -0
  602. package/src/utils/point.ts +190 -51
  603. package/src/utils/polygon.ts +72 -0
  604. package/src/utils/position.ts +18 -1
  605. package/src/utils/prefix.ts +1 -1
  606. package/src/utils/shortcut.ts +13 -2
  607. package/src/utils/style.ts +1 -1
  608. package/src/utils/vector.ts +10 -3
  609. package/esm/elements/types.d.ts +0 -0
  610. package/esm/elements/types.js +0 -15
  611. package/esm/elements/types.js.map +0 -1
  612. package/lib/elements/types.d.ts +0 -0
  613. package/lib/elements/types.js +0 -15
  614. package/lib/elements/types.js.map +0 -1
  615. package/src/elements/types.ts +0 -21
@@ -10,7 +10,7 @@ import { orth } from '../../utils/router/orth';
10
10
  import type { BaseEdgeStyleProps, LoopStyleProps } from './base-edge';
11
11
  import { BaseEdge } from './base-edge';
12
12
 
13
- export type PolylineStyleProps = BaseEdgeStyleProps & {
13
+ export interface PolylineStyleProps extends BaseEdgeStyleProps {
14
14
  /**
15
15
  * <zh/> 圆角半径
16
16
  * <en/> The radius of the rounded corner
@@ -36,7 +36,7 @@ export type PolylineStyleProps = BaseEdgeStyleProps & {
36
36
  * <en/> Padding for routing calculation
37
37
  */
38
38
  routerPadding?: Padding;
39
- };
39
+ }
40
40
  type ParsedPolylineStyleProps = Required<PolylineStyleProps>;
41
41
 
42
42
  export class Polyline extends BaseEdge {
@@ -6,7 +6,7 @@ import { getCurveControlPoint, getQuadraticPath } from '../../utils/edge';
6
6
  import type { BaseEdgeStyleProps } from './base-edge';
7
7
  import { BaseEdge } from './base-edge';
8
8
 
9
- export type QuadraticStyleProps = BaseEdgeStyleProps & {
9
+ export interface QuadraticStyleProps extends BaseEdgeStyleProps {
10
10
  /**
11
11
  * <zh/> 控制点,用于定义曲线的形状。如果不指定,将会通过`curveOffset`和`curvePosition`来计算控制点
12
12
  * <en/> Control point. Used to define the shape of the curve. If not specified, it will be calculated using `curveOffset` and `curvePosition`.
@@ -22,7 +22,7 @@ export type QuadraticStyleProps = BaseEdgeStyleProps & {
22
22
  * <en/> The distance of the control point from the line
23
23
  */
24
24
  curveOffset?: number;
25
- };
25
+ }
26
26
 
27
27
  type ParsedQuadraticStyleProps = Required<QuadraticStyleProps>;
28
28
 
@@ -1,18 +1,22 @@
1
- import type { BaseStyleProps, DisplayObject, DisplayObjectConfig, Group } from '@antv/g';
1
+ import type { DisplayObject, DisplayObjectConfig, Group } from '@antv/g';
2
2
  import { Circle as GCircle } from '@antv/g';
3
+ import type { ID } from '@antv/graphlib';
3
4
  import { deepMix, isEmpty } from '@antv/util';
4
5
  import type { CategoricalPalette } from '../../palettes/types';
6
+ import type { NodeData } from '../../spec';
5
7
  import type {
6
8
  BadgePlacement,
7
- BaseNodeProps,
9
+ BaseElementStyleProps,
8
10
  Keyframe,
9
11
  LabelPlacement,
12
+ Node,
10
13
  Placement,
11
14
  Point,
12
15
  Port,
13
16
  PortPlacement,
14
17
  PortStyleProps,
15
18
  PrefixObject,
19
+ Size,
16
20
  } from '../../types';
17
21
  import { getPortXYByPlacement, getTextStyleByPlacement, isSimplePort } from '../../utils/element';
18
22
  import { getPaletteColors } from '../../utils/palette';
@@ -24,8 +28,108 @@ import { getWordWrapWidthByBox } from '../../utils/text';
24
28
  import type { BadgeStyleProps, IconStyleProps, LabelStyleProps } from '../shapes';
25
29
  import { Badge, BaseShape, Icon, Label } from '../shapes';
26
30
 
27
- export type BaseNodeStyleProps<H extends BaseStyleProps = BaseNodeProps> = BaseNodeProps &
28
- ShapeSwitch & {
31
+ export type BaseNodeStyleProps<T extends Record<string, unknown> = Record<string, any>> = T &
32
+ BaseElementStyleProps &
33
+ PrefixObject<NodeLabelStyleProps, 'label'> &
34
+ PrefixObject<T, 'halo'> &
35
+ PrefixObject<IconStyleProps, 'icon'> &
36
+ PrefixObject<BadgeStyleProps, 'badge'> &
37
+ PrefixObject<PortStyleProps, 'port'> & {
38
+ /**
39
+ * <zh/> x 坐标
40
+ *
41
+ * <en/> The x-coordinate of node
42
+ */
43
+ x?: number | string;
44
+ /**
45
+ * <zh/> y 坐标
46
+ *
47
+ * <en/> The y-coordinate of node
48
+ */
49
+ y?: number | string;
50
+ /**
51
+ * <zh/> z 坐标
52
+ *
53
+ * <en/> The z-coordinate of node
54
+ */
55
+ z?: number;
56
+ /**
57
+ * <zh/> 节点大小,快捷设置节点宽高
58
+ *
59
+ * <en/> The size of node, which is a shortcut to set the width and height of node
60
+ */
61
+ size?: Size;
62
+ /**
63
+ * <zh/> 主色
64
+ *
65
+ * <en/> Subject color
66
+ */
67
+ color?: string;
68
+ /**
69
+ * @deprecated
70
+ * <zh/> 解决类型 style.getPropertyValue 问题,不要使用该属性
71
+ *
72
+ * <en/> Solve the problem of style.getPropertyValue, do not use this property
73
+ * @description
74
+ * <zh/> 移除该属性会导致 Polygon 及其子类与 Node 不兼容
75
+ *
76
+ * <en/> Removing this property will cause Polygon and its subclasses to be incompatible with Node
77
+ * @ignore
78
+ */
79
+ points?: ([number, number] | [number, number, number])[];
80
+ /**
81
+ * <zh/> 父节点 id
82
+ * <en/> The id of the parent node/combo
83
+ */
84
+ parentId?: ID;
85
+ /**
86
+ * <zh/> 是否收起
87
+ *
88
+ * <en/> Indicates whether the node is collapsed
89
+ */
90
+ collapsed?: boolean;
91
+ /**
92
+ * <zh/> 子节点实例
93
+ *
94
+ * <en/> The instance of the child node
95
+ */
96
+ childrenNode?: Node[];
97
+ /**
98
+ * <zh/> 子节点数据
99
+ *
100
+ * <en/> The data of the child node
101
+ */
102
+ childrenData?: NodeData[];
103
+ /**
104
+ * <zh/> 是否显示节点标签
105
+ *
106
+ * <en/> Whether to show the node label
107
+ */
108
+ label?: boolean;
109
+ /**
110
+ * <zh/> 是否显示节点光环
111
+ *
112
+ * <en/> Whether to show the node halo
113
+ */
114
+ halo?: boolean;
115
+ /**
116
+ * <zh/> 是否显示节点图标
117
+ *
118
+ * <en/> Whether to show the node icon
119
+ */
120
+ icon?: boolean;
121
+ /**
122
+ * <zh/> 是否显示节点徽标
123
+ *
124
+ * <en/> Whether to show the node badge
125
+ */
126
+ badge?: boolean;
127
+ /**
128
+ * <zh/> 是否显示连接桩
129
+ *
130
+ * <en/> Whether to show the node port
131
+ */
132
+ port?: boolean;
29
133
  /**
30
134
  * <zh/> 连接桩
31
135
  * <en/> Port
@@ -41,11 +145,7 @@ export type BaseNodeStyleProps<H extends BaseStyleProps = BaseNodeProps> = BaseN
41
145
  * <en/> Badge background color palette
42
146
  */
43
147
  badgePalette?: string[] | CategoricalPalette;
44
- } & PrefixObject<NodeLabelStyleProps, 'label'> &
45
- PrefixObject<H, 'halo'> &
46
- PrefixObject<IconStyleProps, 'icon'> &
47
- PrefixObject<BadgeStyleProps, 'badge'> &
48
- PrefixObject<PortStyleProps, 'port'>;
148
+ };
49
149
 
50
150
  /**
51
151
  * Design document: https://www.yuque.com/antv/g6/gl1iof1xpzg6ed98
@@ -53,7 +153,7 @@ export type BaseNodeStyleProps<H extends BaseStyleProps = BaseNodeProps> = BaseN
53
153
  * The P is the StyleProps of Key Shape.
54
154
  * The KeyShape is the type of the key shape.
55
155
  */
56
- export abstract class BaseNode<S extends BaseNodeStyleProps = any> extends BaseShape<S> {
156
+ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps> extends BaseShape<S> {
57
157
  public type = 'node';
58
158
 
59
159
  static defaultStyleProps: Partial<BaseNodeStyleProps> = {
@@ -90,7 +190,11 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = any> extends BaseS
90
190
  super(deepMix({}, { style: BaseNode.defaultStyleProps }, options));
91
191
  }
92
192
 
93
- protected getSize(attributes = this.parsedAttributes) {
193
+ public get parsedAttributes() {
194
+ return this.attributes as Required<S>;
195
+ }
196
+
197
+ protected getSize(attributes = this.attributes) {
94
198
  const { size } = attributes;
95
199
  return parseSize(size);
96
200
  }
@@ -352,11 +456,3 @@ export type NodePortStyleProps = Partial<PortStyleProps> & {
352
456
  */
353
457
  placement: Placement;
354
458
  };
355
-
356
- type ShapeSwitch = {
357
- label?: boolean;
358
- halo?: boolean;
359
- icon?: boolean;
360
- badge?: boolean;
361
- port?: boolean;
362
- };
@@ -8,14 +8,12 @@ import type { IconStyleProps } from '../shapes';
8
8
  import type { BaseNodeStyleProps } from './base-node';
9
9
  import { BaseNode } from './base-node';
10
10
 
11
- export type CircleStyleProps = BaseNodeStyleProps<KeyStyleProps>;
12
- type ParsedCircleStyleProps = Required<CircleStyleProps>;
13
- type KeyStyleProps = GCircleStyleProps;
11
+ export type CircleStyleProps = BaseNodeStyleProps;
14
12
 
15
13
  /**
16
14
  * Draw circle based on BaseNode, override drawKeyShape.
17
15
  */
18
- export class Circle extends BaseNode<CircleStyleProps> {
16
+ export class Circle extends BaseNode {
19
17
  static defaultStyleProps: Partial<CircleStyleProps> = {
20
18
  size: 24,
21
19
  };
@@ -24,16 +22,16 @@ export class Circle extends BaseNode<CircleStyleProps> {
24
22
  super(deepMix({}, { style: Circle.defaultStyleProps }, options));
25
23
  }
26
24
 
27
- protected drawKeyShape(attributes: ParsedCircleStyleProps, container: Group) {
25
+ protected drawKeyShape(attributes: Required<CircleStyleProps>, container: Group) {
28
26
  return this.upsert('key', GCircle, this.getKeyStyle(attributes), container);
29
27
  }
30
28
 
31
- protected getKeyStyle(attributes: ParsedCircleStyleProps): KeyStyleProps {
29
+ protected getKeyStyle(attributes: Required<CircleStyleProps>): GCircleStyleProps {
32
30
  const keyStyle = super.getKeyStyle(attributes);
33
31
  return { ...keyStyle, r: Math.min(...this.getSize(attributes)) / 2 };
34
32
  }
35
33
 
36
- protected getIconStyle(attributes: ParsedCircleStyleProps): false | IconStyleProps {
34
+ protected getIconStyle(attributes: Required<CircleStyleProps>): false | IconStyleProps {
37
35
  const style = super.getIconStyle(attributes);
38
36
  const { r } = this.getKeyStyle(attributes);
39
37
  const size = (r as number) * 2 * ICON_SIZE_RATIO;
@@ -2,13 +2,11 @@ import type { DisplayObjectConfig } from '@antv/g';
2
2
  import type { Point } from '../../types';
3
3
  import { getDiamondPoints } from '../../utils/element';
4
4
  import { getPolygonIntersectPoint } from '../../utils/point';
5
- import type { ParsedPolygonStyleProps, PolygonStyleProps } from './polygon';
5
+ import type { PolygonStyleProps } from './polygon';
6
6
  import { Polygon } from './polygon';
7
7
 
8
8
  export type DiamondStyleProps = PolygonStyleProps;
9
9
 
10
- type ParsedDiamondStyleProps = ParsedPolygonStyleProps;
11
-
12
10
  /**
13
11
  * Draw diamond based on BaseNode, override drawKeyShape.
14
12
  */
@@ -17,14 +15,14 @@ export class Diamond extends Polygon {
17
15
  super(options);
18
16
  }
19
17
 
20
- protected getPoints(attributes: ParsedDiamondStyleProps): Point[] {
18
+ protected getPoints(attributes: Required<DiamondStyleProps>): Point[] {
21
19
  const [width, height] = this.getSize(attributes);
22
20
  return getDiamondPoints(width, height);
23
21
  }
24
22
 
25
23
  public getIntersectPoint(point: Point): Point {
26
- const { points } = this.getKeyStyle(this.attributes as ParsedDiamondStyleProps);
24
+ const { points } = this.getKeyStyle(this.parsedAttributes);
27
25
  const center = [this.attributes.x, this.attributes.y] as Point;
28
- return getPolygonIntersectPoint(point, center, points);
26
+ return getPolygonIntersectPoint(point, center, points).point;
29
27
  }
30
28
  }
@@ -8,11 +8,9 @@ import type { IconStyleProps } from '../shapes';
8
8
  import type { BaseNodeStyleProps } from './base-node';
9
9
  import { BaseNode } from './base-node';
10
10
 
11
- export type EllipseStyleProps = BaseNodeStyleProps<KeyStyleProps>;
12
- type ParsedEllipseStyleProps = Required<EllipseStyleProps>;
13
- type KeyStyleProps = GEllipseStyleProps;
11
+ export type EllipseStyleProps = BaseNodeStyleProps;
14
12
 
15
- export class Ellipse extends BaseNode<EllipseStyleProps> {
13
+ export class Ellipse extends BaseNode {
16
14
  static defaultStyleProps: Partial<EllipseStyleProps> = {
17
15
  size: [80, 40],
18
16
  };
@@ -21,11 +19,11 @@ export class Ellipse extends BaseNode<EllipseStyleProps> {
21
19
  super(deepMix({}, { style: Ellipse.defaultStyleProps }, options));
22
20
  }
23
21
 
24
- protected drawKeyShape(attributes: ParsedEllipseStyleProps, container: Group) {
22
+ protected drawKeyShape(attributes: Required<EllipseStyleProps>, container: Group) {
25
23
  return this.upsert('key', GEllipse, this.getKeyStyle(attributes), container);
26
24
  }
27
25
 
28
- protected getKeyStyle(attributes: ParsedEllipseStyleProps): KeyStyleProps {
26
+ protected getKeyStyle(attributes: Required<EllipseStyleProps>): GEllipseStyleProps {
29
27
  const keyStyle = super.getKeyStyle(attributes);
30
28
  const [majorAxis, minorAxis] = this.getSize(attributes);
31
29
  return {
@@ -35,10 +33,10 @@ export class Ellipse extends BaseNode<EllipseStyleProps> {
35
33
  };
36
34
  }
37
35
 
38
- protected getIconStyle(attributes: ParsedEllipseStyleProps): false | IconStyleProps {
36
+ protected getIconStyle(attributes: Required<EllipseStyleProps>): false | IconStyleProps {
39
37
  const style = super.getIconStyle(attributes);
40
38
  const { rx, ry } = this.getKeyStyle(attributes);
41
- const size = Math.min(rx as number, ry as number) * 2 * ICON_SIZE_RATIO;
39
+ const size = Math.min(+rx, +ry) * 2 * ICON_SIZE_RATIO;
42
40
 
43
41
  return style ? ({ width: size, height: size, ...style } as IconStyleProps) : false;
44
42
  }
@@ -3,33 +3,31 @@ import { ICON_SIZE_RATIO } from '../../constants/element';
3
3
  import type { Point } from '../../types';
4
4
  import { getHexagonPoints } from '../../utils/element';
5
5
  import type { IconStyleProps } from '../shapes';
6
- import type { ParsedPolygonStyleProps, PolygonStyleProps } from './polygon';
6
+ import type { PolygonStyleProps } from './polygon';
7
7
  import { Polygon } from './polygon';
8
8
 
9
- export type HexagonStyleProps = PolygonStyleProps & ExtendsStyleProps;
10
- type ParsedHexagonStyleProps = ParsedPolygonStyleProps & Required<HexagonStyleProps>;
11
- type ExtendsStyleProps = {
9
+ export type HexagonStyleProps = PolygonStyleProps<{
12
10
  /**
13
11
  * <zh/> 外半径
14
12
  * <en/> outer radius
15
13
  */
16
14
  outerR?: number;
17
- };
15
+ }>;
18
16
 
19
- export class Hexagon extends Polygon {
17
+ export class Hexagon extends Polygon<HexagonStyleProps> {
20
18
  constructor(options: DisplayObjectConfig<HexagonStyleProps>) {
21
19
  super(options);
22
20
  }
23
21
 
24
- private getOuterR(attributes: ParsedHexagonStyleProps): number {
22
+ private getOuterR(attributes: Required<HexagonStyleProps>): number {
25
23
  return attributes.outerR || Math.min(...this.getSize(attributes)) / 2;
26
24
  }
27
25
 
28
- protected getPoints(attributes: ParsedHexagonStyleProps): Point[] {
26
+ protected getPoints(attributes: Required<HexagonStyleProps>): Point[] {
29
27
  return getHexagonPoints(this.getOuterR(attributes));
30
28
  }
31
29
 
32
- protected getIconStyle(attributes: ParsedHexagonStyleProps): false | IconStyleProps {
30
+ protected getIconStyle(attributes: Required<HexagonStyleProps>): false | IconStyleProps {
33
31
  const style = super.getIconStyle(attributes);
34
32
  const size = this.getOuterR(attributes) * ICON_SIZE_RATIO;
35
33
  return style ? ({ width: size, height: size, ...style } as IconStyleProps) : false;
@@ -2,17 +2,16 @@ import type { DisplayObjectConfig, RectStyleProps as GRectStyleProps, Group } fr
2
2
  import { Image as GImage, ImageStyleProps as GImageStyleProps, Rect as GRect } from '@antv/g';
3
3
  import { deepMix } from '@antv/util';
4
4
  import { ICON_SIZE_RATIO } from '../../constants/element';
5
- import type { PrefixObject } from '../../types';
6
5
  import { subStyleProps } from '../../utils/prefix';
7
6
  import { add } from '../../utils/vector';
8
7
  import type { IconStyleProps } from '../shapes';
9
8
  import type { BaseNodeStyleProps } from './base-node';
10
9
  import { BaseNode } from './base-node';
11
10
 
12
- export type ImageStyleProps = BaseNodeStyleProps<KeyStyleProps>;
13
- type ParsedImageStyleProps = Required<ImageStyleProps>;
14
- type KeyStyleProps = GImageStyleProps & PrefixObject<HaloStyleProps, 'halo'>;
15
- type HaloStyleProps = GRectStyleProps;
11
+ export type ImageStyleProps = BaseNodeStyleProps<{
12
+ img?: string | HTMLImageElement;
13
+ src?: string | HTMLImageElement;
14
+ }>;
16
15
 
17
16
  export class Image extends BaseNode<ImageStyleProps> {
18
17
  static defaultStyleProps: Partial<ImageStyleProps> = {
@@ -23,9 +22,9 @@ export class Image extends BaseNode<ImageStyleProps> {
23
22
  super(deepMix({}, { style: Image.defaultStyleProps }, options));
24
23
  }
25
24
 
26
- protected getKeyStyle(attributes: ParsedImageStyleProps): KeyStyleProps {
25
+ protected getKeyStyle(attributes: Required<ImageStyleProps>): GImageStyleProps {
27
26
  const [width, height] = this.getSize(attributes);
28
- const keyStyle = super.getKeyStyle(attributes) as unknown as ParsedImageStyleProps;
27
+ const keyStyle = super.getKeyStyle(attributes);
29
28
  return {
30
29
  ...keyStyle,
31
30
  width,
@@ -34,18 +33,18 @@ export class Image extends BaseNode<ImageStyleProps> {
34
33
  };
35
34
  }
36
35
 
37
- protected getHaloStyle(attributes: ParsedImageStyleProps): false | HaloStyleProps {
36
+ protected getHaloStyle(attributes: Required<ImageStyleProps>): false | GRectStyleProps {
38
37
  if (attributes.halo === false) return false;
39
38
  const { fill: keyStyleFill, stroke: keyStyleStroke, ...keyStyle } = this.getKeyStyle(attributes);
40
- const haloStyle = subStyleProps<ImageStyleProps>(this.getGraphicStyle(attributes), 'halo');
39
+ const haloStyle = subStyleProps(this.getGraphicStyle(attributes), 'halo');
41
40
  const haloLineWidth = Number(haloStyle.lineWidth);
42
41
  const [width, height] = add(this.getSize(attributes), [haloLineWidth, haloLineWidth]);
43
42
  const fill = 'transparent';
44
43
 
45
- return { ...keyStyle, ...haloStyle, width, height, fill } as unknown as HaloStyleProps;
44
+ return { ...keyStyle, ...haloStyle, width, height, fill };
46
45
  }
47
46
 
48
- protected getIconStyle(attributes: ParsedImageStyleProps): false | IconStyleProps {
47
+ protected getIconStyle(attributes: Required<ImageStyleProps>): false | IconStyleProps {
49
48
  const style = super.getIconStyle(attributes);
50
49
  const [width, height] = this.getSize(attributes);
51
50
 
@@ -58,11 +57,11 @@ export class Image extends BaseNode<ImageStyleProps> {
58
57
  : false;
59
58
  }
60
59
 
61
- protected drawKeyShape(attributes: ParsedImageStyleProps, container: Group): GImage | undefined {
60
+ protected drawKeyShape(attributes: Required<ImageStyleProps>, container: Group): GImage | undefined {
62
61
  return this.upsert('key', GImage, this.getKeyStyle(attributes), container);
63
62
  }
64
63
 
65
- protected drawHaloShape(attributes: ParsedImageStyleProps, container: Group): void {
64
+ protected drawHaloShape(attributes: Required<ImageStyleProps>, container: Group): void {
66
65
  this.upsert('halo', GRect, this.getHaloStyle(attributes), container);
67
66
  }
68
67
  }
@@ -5,32 +5,38 @@ import { getPolygonIntersectPoint } from '../../utils/point';
5
5
  import type { BaseNodeStyleProps } from './base-node';
6
6
  import { BaseNode } from './base-node';
7
7
 
8
- export type PolygonStyleProps = BaseNodeStyleProps<PolygonKeyStyleProps>;
9
- export type ParsedPolygonStyleProps = Required<PolygonStyleProps>;
10
- export type PolygonKeyStyleProps = GPolygonStyleProps;
8
+ export type PolygonStyleProps<T extends Record<string, unknown> = Record<string, any>> = BaseNodeStyleProps<
9
+ T & {
10
+ points: ([number, number] | [number, number, number])[];
11
+ }
12
+ >;
11
13
 
12
14
  /**
13
15
  * Abstract class for polygon nodes,i.e triangle, diamond, hexagon, etc.
14
16
  */
15
- export abstract class Polygon extends BaseNode<PolygonStyleProps> {
16
- constructor(options: DisplayObjectConfig<PolygonStyleProps>) {
17
+ export abstract class Polygon<T extends PolygonStyleProps = PolygonStyleProps> extends BaseNode<T> {
18
+ constructor(options: DisplayObjectConfig<PolygonStyleProps<T>>) {
17
19
  super(options);
18
20
  }
19
21
 
20
- protected drawKeyShape(attributes: ParsedPolygonStyleProps, container: Group) {
22
+ public get parsedAttributes() {
23
+ return this.attributes as unknown as Required<PolygonStyleProps<T>>;
24
+ }
25
+
26
+ protected drawKeyShape(attributes: Required<PolygonStyleProps<T>>, container: Group) {
21
27
  return this.upsert('key', GPolygon, this.getKeyStyle(attributes), container);
22
28
  }
23
29
 
24
- protected getKeyStyle(attributes: ParsedPolygonStyleProps): PolygonKeyStyleProps {
30
+ protected getKeyStyle(attributes: Required<PolygonStyleProps<T>>): GPolygonStyleProps {
25
31
  const keyStyle = super.getKeyStyle(attributes);
26
- return { ...keyStyle, points: this.getPoints(attributes) } as PolygonKeyStyleProps;
32
+ return { ...keyStyle, points: this.getPoints(attributes) };
27
33
  }
28
34
 
29
- protected abstract getPoints(attributes: ParsedPolygonStyleProps): Point[];
35
+ protected abstract getPoints(attributes: Required<PolygonStyleProps<T>>): Point[];
30
36
 
31
37
  public getIntersectPoint(point: Point): Point {
32
- const { points } = this.getKeyStyle(this.parsedAttributes as ParsedPolygonStyleProps);
38
+ const { points } = this.getKeyStyle(this.parsedAttributes as Required<PolygonStyleProps<T>>);
33
39
  const center: Point = [+(this.attributes?.x || 0), +(this.attributes?.y || 0)];
34
- return getPolygonIntersectPoint(point, center, points!);
40
+ return getPolygonIntersectPoint(point, center, points!).point;
35
41
  }
36
42
  }
@@ -6,9 +6,8 @@ import type { IconStyleProps } from '../shapes';
6
6
  import type { BaseNodeStyleProps } from './base-node';
7
7
  import { BaseNode } from './base-node';
8
8
 
9
- export type RectStyleProps = BaseNodeStyleProps<KeyStyleProps>;
9
+ export type RectStyleProps = BaseNodeStyleProps;
10
10
  type ParsedRectStyleProps = Required<RectStyleProps>;
11
- type KeyStyleProps = GRectStyleProps;
12
11
 
13
12
  /**
14
13
  * Draw Rect based on BaseNode, override drawKeyShape.
@@ -23,10 +22,10 @@ export class Rect extends BaseNode<RectStyleProps> {
23
22
  super(deepMix({}, { style: Rect.defaultStyleProps }, options));
24
23
  }
25
24
 
26
- protected getKeyStyle(attributes: ParsedRectStyleProps): KeyStyleProps {
25
+ protected getKeyStyle(attributes: ParsedRectStyleProps): GRectStyleProps {
27
26
  const [width, height] = this.getSize(attributes);
28
27
  return {
29
- ...(super.getKeyStyle(attributes) as KeyStyleProps),
28
+ ...super.getKeyStyle(attributes),
30
29
  width,
31
30
  height,
32
31
  };
@@ -4,43 +4,41 @@ import type { Point, StarPortPlacement } from '../../types';
4
4
  import { getPortXYByPlacement, getStarPoints, getStarPorts } from '../../utils/element';
5
5
  import type { IconStyleProps } from '../shapes';
6
6
  import { NodePortStyleProps } from './base-node';
7
- import type { ParsedPolygonStyleProps, PolygonStyleProps } from './polygon';
7
+ import type { PolygonStyleProps } from './polygon';
8
8
  import { Polygon } from './polygon';
9
9
 
10
- export type StarStyleProps = PolygonStyleProps & ExtendsStyleProps;
11
- type ParsedStarStyleProps = ParsedPolygonStyleProps & Required<ExtendsStyleProps>;
12
- type ExtendsStyleProps = {
10
+ export type StarStyleProps = PolygonStyleProps<{
13
11
  /**
14
12
  * <zh/> 内半径
15
13
  * <en/> Inner radius
16
14
  */
17
15
  innerR?: number;
18
- };
16
+ }>;
19
17
 
20
- export class Star extends Polygon {
18
+ export class Star extends Polygon<StarStyleProps> {
21
19
  constructor(options: DisplayObjectConfig<StarStyleProps>) {
22
20
  super(options);
23
21
  }
24
22
 
25
- private getInnerR(attributes: ParsedStarStyleProps): number {
23
+ private getInnerR(attributes: Required<StarStyleProps>): number {
26
24
  return attributes.innerR || (this.getOuterR(attributes) * 3) / 8;
27
25
  }
28
26
 
29
- private getOuterR(attributes: ParsedStarStyleProps): number {
27
+ private getOuterR(attributes: Required<StarStyleProps>): number {
30
28
  return Math.min(...this.getSize(attributes)) / 2;
31
29
  }
32
30
 
33
- protected getPoints(attributes: ParsedStarStyleProps): Point[] {
31
+ protected getPoints(attributes: Required<StarStyleProps>): Point[] {
34
32
  return getStarPoints(this.getOuterR(attributes), this.getInnerR(attributes));
35
33
  }
36
34
 
37
- protected getIconStyle(attributes: ParsedStarStyleProps): false | IconStyleProps {
35
+ protected getIconStyle(attributes: Required<StarStyleProps>): false | IconStyleProps {
38
36
  const style = super.getIconStyle(attributes);
39
37
  const size = this.getInnerR(attributes) * 2 * ICON_SIZE_RATIO;
40
38
  return style ? ({ width: size, height: size, ...style } as IconStyleProps) : false;
41
39
  }
42
40
 
43
- protected getPortXY(attributes: ParsedStarStyleProps, style: NodePortStyleProps): Point {
41
+ protected getPortXY(attributes: Required<StarStyleProps>, style: NodePortStyleProps): Point {
44
42
  const { placement = 'top' } = style;
45
43
  const bbox = this.getKey().getLocalBounds();
46
44
  const ports = getStarPorts(this.getOuterR(attributes), this.getInnerR(attributes));
@@ -7,21 +7,19 @@ import { getPortXYByPlacement, getTrianglePoints, getTrianglePorts } from '../..
7
7
  import { subStyleProps } from '../../utils/prefix';
8
8
  import { IconStyleProps } from '../shapes';
9
9
  import type { NodePortStyleProps } from './base-node';
10
- import type { ParsedPolygonStyleProps, PolygonStyleProps } from './polygon';
10
+ import type { PolygonStyleProps } from './polygon';
11
11
  import { Polygon } from './polygon';
12
12
 
13
- export type TriangleStyleProps = PolygonStyleProps & ExtendsStyleProps;
14
- type ParsedTriangleStyleProps = ParsedPolygonStyleProps & Required<ExtendsStyleProps>;
15
- type ExtendsStyleProps = {
13
+ export type TriangleStyleProps = PolygonStyleProps<{
16
14
  /**
17
15
  * <zh/> 三角形的方向
18
16
  * <en/> The direction of the triangle
19
17
  */
20
18
  direction?: TriangleDirection;
21
- };
19
+ }>;
22
20
  export type TriangleDirection = 'up' | 'left' | 'right' | 'down';
23
21
 
24
- export class Triangle extends Polygon {
22
+ export class Triangle extends Polygon<TriangleStyleProps> {
25
23
  static defaultStyleProps: Partial<TriangleStyleProps> = {
26
24
  size: 40,
27
25
  direction: 'up',
@@ -31,13 +29,13 @@ export class Triangle extends Polygon {
31
29
  super(deepMix({}, { style: Triangle.defaultStyleProps }, options));
32
30
  }
33
31
 
34
- protected getPoints(attributes: ParsedTriangleStyleProps): Point[] {
32
+ protected getPoints(attributes: Required<TriangleStyleProps>): Point[] {
35
33
  const { direction } = attributes;
36
34
  const [width, height] = this.getSize(attributes);
37
35
  return getTrianglePoints(width, height, direction);
38
36
  }
39
37
 
40
- protected getPortXY(attributes: ParsedTriangleStyleProps, style: NodePortStyleProps): Point {
38
+ protected getPortXY(attributes: Required<TriangleStyleProps>, style: NodePortStyleProps): Point {
41
39
  const { direction } = attributes;
42
40
  const { placement = 'top' } = style;
43
41
  const bbox = this.getKey().getLocalBounds();
@@ -48,7 +46,7 @@ export class Triangle extends Polygon {
48
46
 
49
47
  // icon 处于内切三角形的重心
50
48
  // icon is at the centroid of the triangle
51
- protected getIconStyle(attributes: ParsedTriangleStyleProps): false | IconStyleProps {
49
+ protected getIconStyle(attributes: Required<TriangleStyleProps>): false | IconStyleProps {
52
50
  const { icon, iconText, iconSrc, direction } = attributes;
53
51
 
54
52
  if (icon === false || isEmpty(iconText || iconSrc)) return false;
package/src/exports.ts CHANGED
@@ -18,9 +18,10 @@ export { BaseCombo, CircleCombo, RectCombo } from './elements/combos';
18
18
  export { BaseEdge, Cubic, CubicHorizontal, CubicVertical, Line, Polyline, Quadratic } from './elements/edges';
19
19
  export { BaseNode, Circle, Diamond, Ellipse, Hexagon, Image, Rect, Star, Triangle } from './elements/nodes';
20
20
  export { BaseShape } from './elements/shapes';
21
- export { BasePlugin, CameraSetting } from './plugins';
21
+ export { BasePlugin, CameraSetting, History } from './plugins';
22
22
  export { getExtension, getExtensions, register } from './registry';
23
23
  export { Graph } from './runtime/graph';
24
+ export { BaseTransform } from './transforms';
24
25
  export { Shortcut } from './utils/shortcut';
25
26
 
26
27
  export type { BaseBehaviorOptions, DragCanvasOptions, ZoomCanvasOptions } from './behaviors';
@@ -46,7 +47,7 @@ export type {
46
47
  TriangleStyleProps,
47
48
  } from './elements/nodes';
48
49
  export type { BaseShapeStyleProps } from './elements/shapes';
49
- export type { BasePluginOptions, CameraSettingOptions } from './plugins';
50
+ export type { BasePluginOptions, CameraSettingOptions, Hull } from './plugins';
50
51
  export type { RuntimeContext } from './runtime/types';
51
52
  export type {
52
53
  BehaviorOptions,
@@ -64,6 +65,7 @@ export type {
64
65
  ThemeOptions,
65
66
  ViewportOptions,
66
67
  } from './spec';
68
+ export type { BaseTransformOptions } from './transforms';
67
69
  export type {
68
70
  IAnimateEvent,
69
71
  IDragEvent,
@@ -4,6 +4,7 @@ export {
4
4
  CircularLayout,
5
5
  ComboCombinedLayout,
6
6
  ConcentricLayout,
7
+ D3Force3DLayout,
7
8
  D3ForceLayout,
8
9
  DagreLayout,
9
10
  ForceAtlas2Layout,