@antv/g6 5.0.0-beta.34 → 5.0.0-beta.35

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 (352) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/animations/types.d.ts +3 -4
  3. package/dist/lib/behaviors/base-behavior.d.ts +2 -1
  4. package/dist/lib/behaviors/brush-select.d.ts +31 -13
  5. package/dist/lib/behaviors/click-element.d.ts +28 -5
  6. package/dist/lib/behaviors/collapse-expand.d.ts +2 -0
  7. package/dist/lib/behaviors/drag-canvas.d.ts +7 -0
  8. package/dist/lib/behaviors/drag-element.d.ts +2 -2
  9. package/dist/lib/behaviors/index.d.ts +2 -0
  10. package/dist/lib/behaviors/lasso-select.d.ts +2 -1
  11. package/dist/lib/behaviors/scroll-canvas.d.ts +64 -0
  12. package/dist/lib/behaviors/types.d.ts +2 -1
  13. package/dist/lib/behaviors/zoom-canvas.d.ts +1 -1
  14. package/dist/lib/constants/events/graph.d.ts +5 -1
  15. package/dist/lib/elements/combos/base-combo.d.ts +1 -1
  16. package/dist/lib/elements/edges/base-edge.d.ts +0 -5
  17. package/dist/lib/elements/nodes/base-node.d.ts +1 -7
  18. package/dist/lib/elements/shapes/badge.d.ts +1 -1
  19. package/dist/lib/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
  20. package/dist/lib/elements/shapes/index.d.ts +2 -0
  21. package/dist/lib/exports.d.ts +12 -20
  22. package/dist/lib/plugins/bubble-sets.d.ts +45 -0
  23. package/dist/lib/plugins/camera-setting.d.ts +4 -2
  24. package/dist/lib/plugins/contextmenu.d.ts +1 -0
  25. package/dist/lib/plugins/grid-line.d.ts +51 -8
  26. package/dist/lib/plugins/hull/index.d.ts +43 -11
  27. package/dist/lib/plugins/index.d.ts +4 -0
  28. package/dist/lib/plugins/timebar.d.ts +225 -0
  29. package/dist/lib/plugins/tooltip.d.ts +2 -2
  30. package/dist/lib/registry/index.d.ts +1 -1
  31. package/dist/lib/runtime/data.d.ts +9 -3
  32. package/dist/lib/runtime/element.d.ts +3 -7
  33. package/dist/lib/runtime/graph.d.ts +530 -42
  34. package/dist/lib/runtime/types.d.ts +3 -3
  35. package/dist/lib/runtime/viewport.d.ts +2 -2
  36. package/dist/lib/spec/canvas.d.ts +6 -2
  37. package/{lib/spec/spec.d.ts → dist/lib/spec/graph.d.ts} +12 -4
  38. package/dist/lib/spec/index.d.ts +1 -1
  39. package/dist/lib/spec/theme.d.ts +1 -4
  40. package/dist/lib/spec/viewport.d.ts +1 -1
  41. package/dist/lib/themes/types.d.ts +0 -1
  42. package/dist/lib/transforms/process-parallel-edges.d.ts +1 -1
  43. package/dist/lib/types/data.d.ts +2 -2
  44. package/dist/lib/types/viewport.d.ts +4 -4
  45. package/dist/lib/utils/animation.d.ts +5 -5
  46. package/dist/lib/utils/data.d.ts +2 -2
  47. package/dist/lib/utils/element.d.ts +1 -1
  48. package/dist/lib/utils/event/events.d.ts +1 -1
  49. package/dist/lib/utils/event/index.d.ts +1 -1
  50. package/dist/lib/utils/palette.d.ts +1 -1
  51. package/dist/lib/utils/relation.d.ts +2 -2
  52. package/dist/lib/utils/visibility.d.ts +1 -1
  53. package/esm/animations/types.d.ts +3 -4
  54. package/esm/behaviors/base-behavior.d.ts +2 -1
  55. package/esm/behaviors/brush-select.d.ts +31 -13
  56. package/esm/behaviors/brush-select.js +7 -2
  57. package/esm/behaviors/brush-select.js.map +1 -1
  58. package/esm/behaviors/click-element.d.ts +28 -5
  59. package/esm/behaviors/click-element.js +11 -0
  60. package/esm/behaviors/click-element.js.map +1 -1
  61. package/esm/behaviors/collapse-expand.d.ts +2 -0
  62. package/esm/behaviors/collapse-expand.js +2 -2
  63. package/esm/behaviors/collapse-expand.js.map +1 -1
  64. package/esm/behaviors/drag-canvas.d.ts +7 -0
  65. package/esm/behaviors/drag-canvas.js.map +1 -1
  66. package/esm/behaviors/drag-element.d.ts +2 -2
  67. package/esm/behaviors/index.d.ts +2 -0
  68. package/esm/behaviors/index.js +1 -0
  69. package/esm/behaviors/index.js.map +1 -1
  70. package/esm/behaviors/lasso-select.d.ts +2 -1
  71. package/esm/behaviors/lasso-select.js +1 -1
  72. package/esm/behaviors/lasso-select.js.map +1 -1
  73. package/esm/behaviors/scroll-canvas.d.ts +64 -0
  74. package/esm/behaviors/scroll-canvas.js +80 -0
  75. package/esm/behaviors/scroll-canvas.js.map +1 -0
  76. package/esm/behaviors/types.d.ts +2 -1
  77. package/esm/behaviors/zoom-canvas.d.ts +1 -1
  78. package/esm/constants/events/graph.d.ts +5 -1
  79. package/esm/constants/events/graph.js +4 -0
  80. package/esm/constants/events/graph.js.map +1 -1
  81. package/esm/elements/combos/base-combo.d.ts +1 -1
  82. package/esm/elements/edges/base-edge.d.ts +0 -5
  83. package/esm/elements/edges/base-edge.js +1 -2
  84. package/esm/elements/edges/base-edge.js.map +1 -1
  85. package/esm/elements/nodes/base-node.d.ts +1 -7
  86. package/esm/elements/nodes/base-node.js +2 -2
  87. package/esm/elements/nodes/base-node.js.map +1 -1
  88. package/esm/elements/shapes/badge.d.ts +1 -1
  89. package/{lib/plugins/hull/shape.d.ts → esm/elements/shapes/contour.d.ts} +17 -17
  90. package/esm/{plugins/hull/shape.js → elements/shapes/contour.js} +12 -11
  91. package/esm/elements/shapes/contour.js.map +1 -0
  92. package/esm/elements/shapes/index.d.ts +2 -0
  93. package/esm/elements/shapes/index.js +1 -0
  94. package/esm/elements/shapes/index.js.map +1 -1
  95. package/esm/exports.d.ts +12 -20
  96. package/esm/exports.js +6 -17
  97. package/esm/exports.js.map +1 -1
  98. package/esm/plugins/bubble-sets.d.ts +45 -0
  99. package/esm/plugins/bubble-sets.js +212 -0
  100. package/esm/plugins/bubble-sets.js.map +1 -0
  101. package/esm/plugins/camera-setting.d.ts +4 -2
  102. package/esm/plugins/camera-setting.js.map +1 -1
  103. package/esm/plugins/contextmenu.d.ts +1 -0
  104. package/esm/plugins/contextmenu.js +1 -0
  105. package/esm/plugins/contextmenu.js.map +1 -1
  106. package/esm/plugins/grid-line.d.ts +51 -8
  107. package/esm/plugins/grid-line.js.map +1 -1
  108. package/esm/plugins/history/utils.js +6 -2
  109. package/esm/plugins/history/utils.js.map +1 -1
  110. package/esm/plugins/hull/index.d.ts +43 -11
  111. package/esm/plugins/hull/index.js +46 -16
  112. package/esm/plugins/hull/index.js.map +1 -1
  113. package/esm/plugins/index.d.ts +4 -0
  114. package/esm/plugins/index.js +2 -0
  115. package/esm/plugins/index.js.map +1 -1
  116. package/esm/plugins/legend.js +2 -1
  117. package/esm/plugins/legend.js.map +1 -1
  118. package/esm/plugins/timebar.d.ts +225 -0
  119. package/esm/plugins/timebar.js +253 -0
  120. package/esm/plugins/timebar.js.map +1 -0
  121. package/esm/plugins/tooltip.d.ts +2 -2
  122. package/esm/registry/build-in.js +10 -7
  123. package/esm/registry/build-in.js.map +1 -1
  124. package/esm/registry/index.d.ts +1 -1
  125. package/esm/registry/index.js +1 -1
  126. package/esm/runtime/canvas.js +2 -2
  127. package/esm/runtime/canvas.js.map +1 -1
  128. package/esm/runtime/data.d.ts +9 -3
  129. package/esm/runtime/data.js +20 -3
  130. package/esm/runtime/data.js.map +1 -1
  131. package/esm/runtime/element.d.ts +3 -7
  132. package/esm/runtime/element.js +6 -4
  133. package/esm/runtime/element.js.map +1 -1
  134. package/esm/runtime/graph.d.ts +530 -42
  135. package/esm/runtime/graph.js +409 -33
  136. package/esm/runtime/graph.js.map +1 -1
  137. package/esm/runtime/types.d.ts +3 -3
  138. package/esm/runtime/viewport.d.ts +2 -2
  139. package/esm/runtime/viewport.js +2 -2
  140. package/esm/spec/canvas.d.ts +6 -2
  141. package/{dist/lib/spec/spec.d.ts → esm/spec/graph.d.ts} +12 -4
  142. package/esm/spec/graph.js +2 -0
  143. package/esm/spec/graph.js.map +1 -0
  144. package/esm/spec/index.d.ts +1 -1
  145. package/esm/spec/theme.d.ts +1 -4
  146. package/esm/spec/viewport.d.ts +1 -1
  147. package/esm/themes/base.js +9 -9
  148. package/esm/themes/base.js.map +1 -1
  149. package/esm/themes/types.d.ts +0 -1
  150. package/esm/transforms/process-parallel-edges.d.ts +1 -1
  151. package/esm/types/data.d.ts +2 -2
  152. package/esm/types/viewport.d.ts +4 -4
  153. package/esm/utils/animation.d.ts +5 -5
  154. package/esm/utils/animation.js +2 -2
  155. package/esm/utils/animation.js.map +1 -1
  156. package/esm/utils/change.js +8 -1
  157. package/esm/utils/change.js.map +1 -1
  158. package/esm/utils/data.d.ts +2 -2
  159. package/esm/utils/data.js +2 -2
  160. package/esm/utils/element.d.ts +1 -1
  161. package/esm/utils/element.js +2 -2
  162. package/esm/utils/event/events.d.ts +1 -1
  163. package/esm/utils/event/events.js.map +1 -1
  164. package/esm/utils/event/index.d.ts +1 -1
  165. package/esm/utils/event/index.js +1 -1
  166. package/esm/utils/palette.d.ts +1 -1
  167. package/esm/utils/palette.js +1 -1
  168. package/esm/utils/relation.d.ts +2 -2
  169. package/esm/utils/relation.js +2 -2
  170. package/esm/utils/visibility.d.ts +1 -1
  171. package/esm/utils/visibility.js +1 -1
  172. package/lib/animations/types.d.ts +3 -4
  173. package/lib/behaviors/base-behavior.d.ts +2 -1
  174. package/lib/behaviors/brush-select.d.ts +31 -13
  175. package/lib/behaviors/brush-select.js +7 -2
  176. package/lib/behaviors/brush-select.js.map +1 -1
  177. package/lib/behaviors/click-element.d.ts +28 -5
  178. package/lib/behaviors/click-element.js +11 -0
  179. package/lib/behaviors/click-element.js.map +1 -1
  180. package/lib/behaviors/collapse-expand.d.ts +2 -0
  181. package/lib/behaviors/collapse-expand.js +2 -2
  182. package/lib/behaviors/collapse-expand.js.map +1 -1
  183. package/lib/behaviors/drag-canvas.d.ts +7 -0
  184. package/lib/behaviors/drag-canvas.js.map +1 -1
  185. package/lib/behaviors/drag-element.d.ts +2 -2
  186. package/lib/behaviors/index.d.ts +2 -0
  187. package/lib/behaviors/index.js +3 -1
  188. package/lib/behaviors/index.js.map +1 -1
  189. package/lib/behaviors/lasso-select.d.ts +2 -1
  190. package/lib/behaviors/lasso-select.js +1 -1
  191. package/lib/behaviors/lasso-select.js.map +1 -1
  192. package/lib/behaviors/scroll-canvas.d.ts +64 -0
  193. package/lib/behaviors/scroll-canvas.js +84 -0
  194. package/lib/behaviors/scroll-canvas.js.map +1 -0
  195. package/lib/behaviors/types.d.ts +2 -1
  196. package/lib/behaviors/zoom-canvas.d.ts +1 -1
  197. package/lib/constants/events/graph.d.ts +5 -1
  198. package/lib/constants/events/graph.js +4 -0
  199. package/lib/constants/events/graph.js.map +1 -1
  200. package/lib/elements/combos/base-combo.d.ts +1 -1
  201. package/lib/elements/edges/base-edge.d.ts +0 -5
  202. package/lib/elements/edges/base-edge.js +1 -2
  203. package/lib/elements/edges/base-edge.js.map +1 -1
  204. package/lib/elements/nodes/base-node.d.ts +1 -7
  205. package/lib/elements/nodes/base-node.js +2 -2
  206. package/lib/elements/nodes/base-node.js.map +1 -1
  207. package/lib/elements/shapes/badge.d.ts +1 -1
  208. package/{esm/plugins/hull/shape.d.ts → lib/elements/shapes/contour.d.ts} +17 -17
  209. package/lib/{plugins/hull/shape.js → elements/shapes/contour.js} +15 -14
  210. package/lib/elements/shapes/contour.js.map +1 -0
  211. package/lib/elements/shapes/index.d.ts +2 -0
  212. package/lib/elements/shapes/index.js +3 -1
  213. package/lib/elements/shapes/index.js.map +1 -1
  214. package/lib/exports.d.ts +12 -20
  215. package/lib/exports.js +46 -17
  216. package/lib/exports.js.map +1 -1
  217. package/lib/plugins/bubble-sets.d.ts +45 -0
  218. package/lib/plugins/bubble-sets.js +216 -0
  219. package/lib/plugins/bubble-sets.js.map +1 -0
  220. package/lib/plugins/camera-setting.d.ts +4 -2
  221. package/lib/plugins/camera-setting.js.map +1 -1
  222. package/lib/plugins/contextmenu.d.ts +1 -0
  223. package/lib/plugins/contextmenu.js +1 -0
  224. package/lib/plugins/contextmenu.js.map +1 -1
  225. package/lib/plugins/grid-line.d.ts +51 -8
  226. package/lib/plugins/grid-line.js.map +1 -1
  227. package/lib/plugins/history/utils.js +6 -2
  228. package/lib/plugins/history/utils.js.map +1 -1
  229. package/lib/plugins/hull/index.d.ts +43 -11
  230. package/lib/plugins/hull/index.js +46 -16
  231. package/lib/plugins/hull/index.js.map +1 -1
  232. package/lib/plugins/index.d.ts +4 -0
  233. package/lib/plugins/index.js +5 -1
  234. package/lib/plugins/index.js.map +1 -1
  235. package/lib/plugins/legend.js +2 -1
  236. package/lib/plugins/legend.js.map +1 -1
  237. package/lib/plugins/timebar.d.ts +225 -0
  238. package/lib/plugins/timebar.js +257 -0
  239. package/lib/plugins/timebar.js.map +1 -0
  240. package/lib/plugins/tooltip.d.ts +2 -2
  241. package/lib/registry/build-in.js +8 -5
  242. package/lib/registry/build-in.js.map +1 -1
  243. package/lib/registry/index.d.ts +1 -1
  244. package/lib/registry/index.js +1 -1
  245. package/lib/runtime/canvas.js +2 -2
  246. package/lib/runtime/canvas.js.map +1 -1
  247. package/lib/runtime/data.d.ts +9 -3
  248. package/lib/runtime/data.js +20 -3
  249. package/lib/runtime/data.js.map +1 -1
  250. package/lib/runtime/element.d.ts +3 -7
  251. package/lib/runtime/element.js +6 -4
  252. package/lib/runtime/element.js.map +1 -1
  253. package/lib/runtime/graph.d.ts +530 -42
  254. package/lib/runtime/graph.js +409 -33
  255. package/lib/runtime/graph.js.map +1 -1
  256. package/lib/runtime/types.d.ts +3 -3
  257. package/lib/runtime/viewport.d.ts +2 -2
  258. package/lib/runtime/viewport.js +2 -2
  259. package/lib/spec/canvas.d.ts +6 -2
  260. package/{esm/spec/spec.d.ts → lib/spec/graph.d.ts} +12 -4
  261. package/lib/spec/{spec.js → graph.js} +1 -1
  262. package/lib/spec/graph.js.map +1 -0
  263. package/lib/spec/index.d.ts +1 -1
  264. package/lib/spec/theme.d.ts +1 -4
  265. package/lib/spec/viewport.d.ts +1 -1
  266. package/lib/themes/base.js +9 -9
  267. package/lib/themes/base.js.map +1 -1
  268. package/lib/themes/types.d.ts +0 -1
  269. package/lib/transforms/process-parallel-edges.d.ts +1 -1
  270. package/lib/types/data.d.ts +2 -2
  271. package/lib/types/viewport.d.ts +4 -4
  272. package/lib/utils/animation.d.ts +5 -5
  273. package/lib/utils/animation.js +2 -2
  274. package/lib/utils/animation.js.map +1 -1
  275. package/lib/utils/change.js +8 -1
  276. package/lib/utils/change.js.map +1 -1
  277. package/lib/utils/data.d.ts +2 -2
  278. package/lib/utils/data.js +2 -2
  279. package/lib/utils/element.d.ts +1 -1
  280. package/lib/utils/element.js +2 -2
  281. package/lib/utils/event/events.d.ts +1 -1
  282. package/lib/utils/event/events.js.map +1 -1
  283. package/lib/utils/event/index.d.ts +1 -1
  284. package/lib/utils/event/index.js +1 -1
  285. package/lib/utils/palette.d.ts +1 -1
  286. package/lib/utils/palette.js +1 -1
  287. package/lib/utils/relation.d.ts +2 -2
  288. package/lib/utils/relation.js +2 -2
  289. package/lib/utils/visibility.d.ts +1 -1
  290. package/lib/utils/visibility.js +1 -1
  291. package/package.json +2 -1
  292. package/src/animations/types.ts +3 -4
  293. package/src/behaviors/base-behavior.ts +1 -1
  294. package/src/behaviors/brush-select.ts +33 -14
  295. package/src/behaviors/click-element.ts +28 -5
  296. package/src/behaviors/collapse-expand.ts +4 -2
  297. package/src/behaviors/drag-canvas.ts +7 -0
  298. package/src/behaviors/drag-element.ts +2 -2
  299. package/src/behaviors/index.ts +2 -0
  300. package/src/behaviors/lasso-select.ts +2 -2
  301. package/src/behaviors/scroll-canvas.ts +143 -0
  302. package/src/behaviors/types.ts +2 -1
  303. package/src/behaviors/zoom-canvas.ts +1 -1
  304. package/src/constants/events/graph.ts +4 -0
  305. package/src/elements/combos/base-combo.ts +1 -1
  306. package/src/elements/edges/base-edge.ts +1 -7
  307. package/src/elements/nodes/base-node.ts +3 -12
  308. package/src/{plugins/hull/shape.ts → elements/shapes/contour.ts} +27 -34
  309. package/src/elements/shapes/index.ts +2 -0
  310. package/src/exports.ts +104 -24
  311. package/src/plugins/bubble-sets.ts +268 -0
  312. package/src/plugins/camera-setting.ts +4 -2
  313. package/src/plugins/contextmenu.ts +1 -0
  314. package/src/plugins/grid-line.ts +51 -8
  315. package/src/plugins/history/utils.ts +6 -2
  316. package/src/plugins/hull/index.ts +57 -20
  317. package/src/plugins/index.ts +4 -0
  318. package/src/plugins/legend.ts +3 -1
  319. package/src/plugins/timebar.ts +450 -0
  320. package/src/plugins/tooltip.ts +2 -2
  321. package/src/registry/build-in.ts +21 -6
  322. package/src/registry/index.ts +1 -1
  323. package/src/runtime/canvas.ts +2 -2
  324. package/src/runtime/data.ts +21 -3
  325. package/src/runtime/element.ts +5 -4
  326. package/src/runtime/graph.ts +543 -48
  327. package/src/runtime/types.ts +3 -3
  328. package/src/runtime/viewport.ts +2 -2
  329. package/src/spec/canvas.ts +6 -2
  330. package/src/spec/{spec.ts → graph.ts} +12 -4
  331. package/src/spec/index.ts +1 -1
  332. package/src/spec/theme.ts +1 -5
  333. package/src/spec/viewport.ts +1 -1
  334. package/src/themes/base.ts +9 -9
  335. package/src/themes/types.ts +0 -2
  336. package/src/transforms/process-parallel-edges.ts +1 -1
  337. package/src/types/data.ts +2 -2
  338. package/src/types/viewport.ts +4 -4
  339. package/src/utils/animation.ts +4 -4
  340. package/src/utils/change.ts +6 -1
  341. package/src/utils/data.ts +2 -2
  342. package/src/utils/element.ts +2 -2
  343. package/src/utils/event/events.ts +3 -1
  344. package/src/utils/event/index.ts +1 -1
  345. package/src/utils/palette.ts +1 -1
  346. package/src/utils/relation.ts +2 -2
  347. package/src/utils/visibility.ts +1 -1
  348. package/esm/plugins/hull/shape.js.map +0 -1
  349. package/esm/spec/spec.js +0 -2
  350. package/esm/spec/spec.js.map +0 -1
  351. package/lib/plugins/hull/shape.js.map +0 -1
  352. package/lib/spec/spec.js.map +0 -1
@@ -92,7 +92,7 @@ export declare function findPorts(sourceNode: Node, targetNode: Node, sourcePort
92
92
  * <zh/> 查找节点上的最有可能连接的连接桩
93
93
  *
94
94
  * <en/> Find the most likely connected port on the node
95
- * @description
95
+ * @remarks
96
96
  * 1. If `portKey` is specified, return the port.
97
97
  * 2. If `portKey` is not specified, return the port closest to the opposite connection points.
98
98
  * 3. If the node has no ports, return undefined.
@@ -153,7 +153,7 @@ exports.findPorts = findPorts;
153
153
  * <zh/> 查找节点上的最有可能连接的连接桩
154
154
  *
155
155
  * <en/> Find the most likely connected port on the node
156
- * @description
156
+ * @remarks
157
157
  * 1. If `portKey` is specified, return the port.
158
158
  * 2. If `portKey` is not specified, return the port closest to the opposite connection points.
159
159
  * 3. If the node has no ports, return undefined.
@@ -180,7 +180,7 @@ exports.findPort = findPort;
180
180
  * <zh/> 寻找节点上所有可能的连接点
181
181
  *
182
182
  * <en/> Find all possible connection points on the node
183
- * @description
183
+ * @remarks
184
184
  * 1. If `portKey` is specified, return the position of the port.
185
185
  * 2. If `portKey` is not specified, return positions of all ports.
186
186
  * 3. If the node has no ports, return the center of the node.
@@ -7,7 +7,7 @@ export declare class BaseEvent {
7
7
  }
8
8
  export declare class GraphLifeCycleEvent extends BaseEvent implements IGraphLifeCycleEvent {
9
9
  data?: any;
10
- constructor(type: GraphEvent.BEFORE_RENDER | GraphEvent.AFTER_RENDER | GraphEvent.BEFORE_DRAW | GraphEvent.AFTER_DRAW | GraphEvent.BEFORE_LAYOUT | GraphEvent.AFTER_LAYOUT | GraphEvent.BEFORE_SIZE_CHANGE | GraphEvent.AFTER_SIZE_CHANGE | GraphEvent.BATCH_START | GraphEvent.BATCH_END, data?: any);
10
+ constructor(type: GraphEvent.BEFORE_RENDER | GraphEvent.AFTER_RENDER | GraphEvent.BEFORE_DRAW | GraphEvent.AFTER_DRAW | GraphEvent.BEFORE_LAYOUT | GraphEvent.AFTER_LAYOUT | GraphEvent.BEFORE_SIZE_CHANGE | GraphEvent.AFTER_SIZE_CHANGE | GraphEvent.BATCH_START | GraphEvent.BATCH_END | GraphEvent.BEFORE_DESTROY | GraphEvent.AFTER_DESTROY, data?: any);
11
11
  }
12
12
  export declare class AnimateEvent extends BaseEvent implements IAnimateEvent {
13
13
  animationType: AnimationType;
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"src/","sources":["utils/event/events.ts"],"names":[],"mappings":";;;AAYA,MAAa,SAAS;IACD;IAAnB,YAAmB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;CACpC;AAFD,8BAEC;AAED,MAAa,mBAAoB,SAAQ,SAAS;IAavC;IAZT,YACE,IAUwB,EACjB,IAAU;QAEjB,KAAK,CAAC,IAAI,CAAC,CAAC;QAFL,SAAI,GAAJ,IAAI,CAAM;IAGnB,CAAC;CACF;AAjBD,kDAiBC;AAED,MAAa,YAAa,SAAQ,SAAS;IAGhC;IACA;IACA;IAJT,YACE,IAA0D,EACnD,aAA4B,EAC5B,SAA4B,EAC5B,IAAU;QAEjB,KAAK,CAAC,IAAI,CAAC,CAAC;QAJL,kBAAa,GAAb,aAAa,CAAe;QAC5B,cAAS,GAAT,SAAS,CAAmB;QAC5B,SAAI,GAAJ,IAAI,CAAM;IAGnB,CAAC;CACF;AATD,oCASC;AAED,MAAa,qBAAsB,SAAQ,SAAS;IASzC;IACA;IATT,YACE,IAMoC,EAC7B,WAAwB,EACxB,IAAkB;QAEzB,KAAK,CAAC,IAAI,CAAC,CAAC;QAHL,gBAAW,GAAX,WAAW,CAAa;QACxB,SAAI,GAAJ,IAAI,CAAc;IAG3B,CAAC;CACF;AAdD,sDAcC;AAED,MAAa,aAAc,SAAQ,SAAS;IAGjC;IAFT,YACE,IAA8D,EACvD,IAAsB;QAE7B,KAAK,CAAC,IAAI,CAAC,CAAC;QAFL,SAAI,GAAJ,IAAI,CAAkB;IAG/B,CAAC;CACF;AAPD,sCAOC"}
1
+ {"version":3,"file":"events.js","sourceRoot":"src/","sources":["utils/event/events.ts"],"names":[],"mappings":";;;AAYA,MAAa,SAAS;IACD;IAAnB,YAAmB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;CACpC;AAFD,8BAEC;AAED,MAAa,mBAAoB,SAAQ,SAAS;IAevC;IAdT,YACE,IAY4B,EACrB,IAAU;QAEjB,KAAK,CAAC,IAAI,CAAC,CAAC;QAFL,SAAI,GAAJ,IAAI,CAAM;IAGnB,CAAC;CACF;AAnBD,kDAmBC;AAED,MAAa,YAAa,SAAQ,SAAS;IAGhC;IACA;IACA;IAJT,YACE,IAA0D,EACnD,aAA4B,EAC5B,SAA4B,EAC5B,IAAU;QAEjB,KAAK,CAAC,IAAI,CAAC,CAAC;QAJL,kBAAa,GAAb,aAAa,CAAe;QAC5B,cAAS,GAAT,SAAS,CAAmB;QAC5B,SAAI,GAAJ,IAAI,CAAM;IAGnB,CAAC;CACF;AATD,oCASC;AAED,MAAa,qBAAsB,SAAQ,SAAS;IASzC;IACA;IATT,YACE,IAMoC,EAC7B,WAAwB,EACxB,IAAkB;QAEzB,KAAK,CAAC,IAAI,CAAC,CAAC;QAHL,gBAAW,GAAX,WAAW,CAAa;QACxB,SAAI,GAAJ,IAAI,CAAc;IAG3B,CAAC;CACF;AAdD,sDAcC;AAED,MAAa,aAAc,SAAQ,SAAS;IAGjC;IAFT,YACE,IAA8D,EACvD,IAAsB;QAE7B,KAAK,CAAC,IAAI,CAAC,CAAC;QAFL,SAAI,GAAJ,IAAI,CAAkB;IAG/B,CAAC;CACF;AAPD,sCAOC"}
@@ -18,7 +18,7 @@ export declare function emit(emitter: EventEmitter, event: BaseEvent): void;
18
18
  * <en/> Get the event target element
19
19
  * @param shape - <zh/> 事件图形 | <en/> event shape
20
20
  * @returns <zh/> 目标元素 | <en/> target element
21
- * @description
21
+ * @remarks
22
22
  * <zh/> 事件响应大多数情况会命中元素的内部图形,通过该方法可以获取到其所属元素
23
23
  *
24
24
  * <en/> Most of the event responses will hit the internal graphics of the element, and this method can be used to get the element to which it belongs
@@ -35,7 +35,7 @@ exports.emit = emit;
35
35
  * <en/> Get the event target element
36
36
  * @param shape - <zh/> 事件图形 | <en/> event shape
37
37
  * @returns <zh/> 目标元素 | <en/> target element
38
- * @description
38
+ * @remarks
39
39
  * <zh/> 事件响应大多数情况会命中元素的内部图形,通过该方法可以获取到其所属元素
40
40
  *
41
41
  * <en/> Most of the event responses will hit the internal graphics of the element, and this method can be used to get the element to which it belongs
@@ -16,7 +16,7 @@ export declare function parsePalette(palette?: PaletteOptions): STDPaletteOption
16
16
  * @param data - <zh/> 元素数据 | <en/> Element data
17
17
  * @param palette - <zh/> 色板配置 | <en/> PaletteOptions options
18
18
  * @returns <zh/> 元素颜色 | <en/> Element color
19
- * @description
19
+ * @remarks
20
20
  * <zh/> 返回值结果是一个以元素 id 为 key,颜色值为 value 的对象
21
21
  *
22
22
  * <en/> The return value is an object with element id as key and color value as value
@@ -40,7 +40,7 @@ exports.parsePalette = parsePalette;
40
40
  * @param data - <zh/> 元素数据 | <en/> Element data
41
41
  * @param palette - <zh/> 色板配置 | <en/> PaletteOptions options
42
42
  * @returns <zh/> 元素颜色 | <en/> Element color
43
- * @description
43
+ * @remarks
44
44
  * <zh/> 返回值结果是一个以元素 id 为 key,颜色值为 value 的对象
45
45
  *
46
46
  * <en/> The return value is an object with element id as key and color value as value
@@ -4,7 +4,7 @@ import type { ElementType, ID } from '../types';
4
4
  * <zh/> 获取指定元素在 n 度关系内的所有元素的 ID
5
5
  *
6
6
  * <en/> Get the IDs of all elements within an n-degree relationship from the specified element
7
- * @description
7
+ * @remarks
8
8
  * <zh/> 对于节点,0 度关系是节点本身,1 度关系包括节点的直接相邻节点和边,以此类推。
9
9
  * 对于边,0 度关系是边本身,1 度关系包括边本身及其两个端点,以此类推。
10
10
  *
@@ -21,7 +21,7 @@ export declare function getElementNthDegreeIds(graph: Graph, elementType: Elemen
21
21
  * <zh/> 获取指定节点在 n 度关系内的所有元素的 ID
22
22
  *
23
23
  * <en/> Get all elements IDs within n-degree relationship of the specified node
24
- * @description
24
+ * @remarks
25
25
  * <zh/> 节点的 0 度关系是节点本身,1 度关系是节点的直接相邻节点和边,以此类推
26
26
  *
27
27
  * <en/> 0-degree relationship of a node is the node itself; 1-degree relationship is the node's neighboring nodes and related edges, etc
@@ -7,7 +7,7 @@ const traverse_1 = require("./traverse");
7
7
  * <zh/> 获取指定元素在 n 度关系内的所有元素的 ID
8
8
  *
9
9
  * <en/> Get the IDs of all elements within an n-degree relationship from the specified element
10
- * @description
10
+ * @remarks
11
11
  * <zh/> 对于节点,0 度关系是节点本身,1 度关系包括节点的直接相邻节点和边,以此类推。
12
12
  * 对于边,0 度关系是边本身,1 度关系包括边本身及其两个端点,以此类推。
13
13
  *
@@ -35,7 +35,7 @@ exports.getElementNthDegreeIds = getElementNthDegreeIds;
35
35
  * <zh/> 获取指定节点在 n 度关系内的所有元素的 ID
36
36
  *
37
37
  * <en/> Get all elements IDs within n-degree relationship of the specified node
38
- * @description
38
+ * @remarks
39
39
  * <zh/> 节点的 0 度关系是节点本身,1 度关系是节点的直接相邻节点和边,以此类推
40
40
  *
41
41
  * <en/> 0-degree relationship of a node is the node itself; 1-degree relationship is the node's neighboring nodes and related edges, etc
@@ -5,7 +5,7 @@ import type { BaseStyleProps, DisplayObject } from '@antv/g';
5
5
  * <en/> Set the visibility of the shape instance
6
6
  * @param shape - <zh/> 图形实例 | <en/> shape instance
7
7
  * @param visibility - <zh/> 可见性 | <en/> visibility
8
- * @description
8
+ * @remarks
9
9
  * <zh/> 在设置 enableCSSParsing 为 false 的情况下,复合图形无法继承父属性,因此需要对所有子图形应用相同的可见性
10
10
  *
11
11
  * <en/> After setting enableCSSParsing to false, the compound shape cannot inherit the parent attribute, so the same visibility needs to be applied to all child shapes
@@ -10,7 +10,7 @@ const PropertyKey = 'visibility';
10
10
  * <en/> Set the visibility of the shape instance
11
11
  * @param shape - <zh/> 图形实例 | <en/> shape instance
12
12
  * @param visibility - <zh/> 可见性 | <en/> visibility
13
- * @description
13
+ * @remarks
14
14
  * <zh/> 在设置 enableCSSParsing 为 false 的情况下,复合图形无法继承父属性,因此需要对所有子图形应用相同的可见性
15
15
  *
16
16
  * <en/> After setting enableCSSParsing to false, the compound shape cannot inherit the parent attribute, so the same visibility needs to be applied to all child shapes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g6",
3
- "version": "5.0.0-beta.34",
3
+ "version": "5.0.0-beta.35",
4
4
  "description": "A Graph Visualization Framework in JavaScript",
5
5
  "keywords": [
6
6
  "antv",
@@ -64,6 +64,7 @@
64
64
  "@antv/hierarchy": "latest",
65
65
  "@antv/layout": "^1.2.14-beta.3",
66
66
  "@antv/util": "^3.3.7",
67
+ "bubblesets-js": "^2.3.2",
67
68
  "hull.js": "^1.0.5"
68
69
  },
69
70
  "devDependencies": {
@@ -2,7 +2,6 @@ import type { DisplayObject, IAnimation, IAnimationEffectTiming } from '@antv/g'
2
2
  import type { State } from '../types';
3
3
 
4
4
  /**
5
- * @description
6
5
  * <zh/> 为 string 时,会从注册的动画中获取
7
6
  *
8
7
  * <en/> When it is a string, it will be obtained from the registered animation
@@ -22,7 +21,7 @@ export interface AnimationContext {
22
21
  * <zh/> 动画的源样式
23
22
  *
24
23
  * <en/> Source style of animation
25
- * @description
24
+ * @remarks
26
25
  * <zh/> 用于在动画执行前将 shape 的样式设置为源样式,例如 move-to 动画,需要将 shape 的 x, y 设置为源样式
27
26
  *
28
27
  * <en/> Used to set the style of shape to the source style before the animation is executed. For example, the move-to animation needs to set the x and y of shape to the source style
@@ -32,7 +31,7 @@ export interface AnimationContext {
32
31
  * <zh/> 额外的动画终态样式
33
32
  *
34
33
  * <en/> Additional animation final state style
35
- * @description
34
+ * @remarks
36
35
  * <zh/> 例如元素销毁前,需要将元素的终态透明度设置为 0
37
36
  *
38
37
  * <en/> For example, before the element is destroyed, the final state opacity of the element needs to be set to 0
@@ -42,7 +41,7 @@ export interface AnimationContext {
42
41
  * <zh/> 动画配置过滤
43
42
  *
44
43
  * <en/> Animation configuration filter
45
- * @description
44
+ * @remarks
46
45
  * <zh/> 某些情况下,需要过滤掉一些动画配置,例如位移动画只会作用于元素根节点图形,不会作用于子图形。这项配置通常用于优化动画性能,避免不必要的动画执行
47
46
  *
48
47
  * <en/> In some cases, it is necessary to filter out some animation configurations. For example, the displacement animation will only affect the root node shape of the element, not the child shape. This configuration is usually used to optimize animation performance and avoid unnecessary animation execution
@@ -1,6 +1,6 @@
1
1
  import { BaseExtension } from '../registry/extension';
2
2
  import type { CustomBehaviorOption } from '../spec/behavior';
3
3
 
4
- export type BaseBehaviorOptions = CustomBehaviorOption;
4
+ export interface BaseBehaviorOptions extends CustomBehaviorOption {}
5
5
 
6
6
  export abstract class BaseBehavior<T extends BaseBehaviorOptions> extends BaseExtension<T> {}
@@ -15,59 +15,70 @@ import type { BaseBehaviorOptions } from './base-behavior';
15
15
 
16
16
  const SHOW_RECT_ID = 'g6-brush-select-rect-id';
17
17
 
18
- type SELECT_MODE = 'union' | 'intersect' | 'diff' | 'default';
19
-
20
18
  export type States = Record<ID, State | State[]>;
21
19
 
20
+ /**
21
+ * <zh/> 框选配置项
22
+ *
23
+ * <en/> Brush select options
24
+ */
22
25
  export interface BrushSelectOptions extends BaseBehaviorOptions {
23
26
  /**
24
27
  * <zh/> 是否启用框选功能
25
28
  *
26
29
  * <en/> Whether to enable Brush select element function.
30
+ * @defaultValue true
27
31
  */
28
32
  enable?: boolean | ((event: IPointerEvent) => boolean);
29
33
  /**
30
34
  * <zh/> 可框选的元素类型
31
35
  *
32
36
  * <en/> Enable Elements type.
37
+ * @defaultValue ['node', 'combo', 'edge']
33
38
  */
34
39
  enableElements?: ElementType[];
35
40
  /**
36
41
  * <zh/> 是否启用动画
37
42
  *
38
43
  * <en/> Whether to enable animation.
44
+ * @defaultValue false
39
45
  */
40
46
  animation?: boolean;
41
47
  /**
42
48
  * <zh/> 交互配置 按键拖拽 或 直接拖拽
43
49
  *
44
50
  * <en/> Trigger click or drag.
51
+ * @defaultValue ['drag']
45
52
  */
46
53
  trigger?: ShortcutKey;
47
54
  /**
48
55
  * <zh/> 框选选中模式
49
- * union : 选中元素添加 state 状态
50
- * intersect : 进一步筛选已经 state 开启的元素
51
- * diff : 反转选中元素的 state 状态
52
- * default : 选中元素添加 state 状态, 其他元素 state 关闭
56
+ * - union : 选中元素添加 state 状态
57
+ * - intersect : 进一步筛选已经 state 开启的元素
58
+ * - diff : 反转选中元素的 state 状态
59
+ * - default : 选中元素添加 state 状态, 其他元素 state 关闭
53
60
  *
54
61
  * <en/> Box Select Select the mode.
55
- * union : Select element add state.
56
- * intersect : Further filter the elements that are already state enabled.
57
- * diff : Inverts the state of the selected element.
58
- * default : Check element state to turn on and other elements state to turn off.
62
+ * - union : Select element add state.
63
+ * - intersect : Further filter the elements that are already state enabled.
64
+ * - diff : Inverts the state of the selected element.
65
+ * - default : Check element state to turn on and other elements state to turn off.
66
+ * @defaultValue 'default'
59
67
  */
60
- mode?: SELECT_MODE;
68
+ mode?: 'union' | 'intersect' | 'diff' | 'default';
61
69
  /**
62
70
  * <zh/> 选中 state 状态
63
71
  *
64
72
  * <en/> Check state status.
73
+ * @defaultValue 'selected'
65
74
  */
66
- state?: 'selected' | 'active'; // TODO: Enum
75
+ state?: State;
67
76
  /**
68
77
  * <zh/> 及时框选, 在框选模式为 default 时,才能使用
69
78
  *
79
+ // * TODO fixme
70
80
  * <en/> Timely screening.
81
+ * @defaultValue false
71
82
  */
72
83
  immediately?: boolean;
73
84
  /**
@@ -80,17 +91,25 @@ export interface BrushSelectOptions extends BaseBehaviorOptions {
80
91
  * <zh/> 框选元素状态回调。
81
92
  *
82
93
  * <en/> Callback when brush select elements.
94
+ * @param states - 选中的元素状态
95
+ * @returns 选中的元素状态
83
96
  */
84
97
  onSelect?: (states: States) => States;
85
98
  }
86
99
 
87
100
  export const DEFAULT_STYLE = {
88
101
  lineWidth: 1,
89
- color: '#EEF6FF',
102
+ fill: '#EEF6FF',
90
103
  stroke: '#DDEEFE',
91
104
  fillOpacity: 0.4,
92
105
  zIndex: 2,
93
106
  };
107
+
108
+ /**
109
+ * <zh/> 框选一组元素
110
+ *
111
+ * <en/> Brush select elements
112
+ */
94
113
  export class BrushSelect<T extends BaseBehaviorOptions = BrushSelectOptions> extends BaseBehavior<T> {
95
114
  static defaultOptions: Partial<BrushSelectOptions> = {
96
115
  enable: true,
@@ -133,7 +152,7 @@ export class BrushSelect<T extends BaseBehaviorOptions = BrushSelectOptions> ext
133
152
  id: SHOW_RECT_ID,
134
153
  style: {
135
154
  ...BrushSelect.defaultOptions.style,
136
- fill: style.color || DEFAULT_STYLE.color,
155
+ fill: style.fill || DEFAULT_STYLE.fill,
137
156
  ...style,
138
157
  pointerEvents: 'none',
139
158
  },
@@ -10,48 +10,60 @@ import { Shortcut } from '../utils/shortcut';
10
10
  import type { BaseBehaviorOptions } from './base-behavior';
11
11
  import { BaseBehavior } from './base-behavior';
12
12
 
13
+ /**
14
+ * <zh/> 点击元素交互配置项
15
+ *
16
+ * <en/> Click element behavior options
17
+ */
13
18
  export interface ClickElementOptions extends BaseBehaviorOptions {
14
19
  /**
15
20
  * <zh/> 是否启用动画
16
21
  *
17
22
  * <en/> Whether to enable animation
23
+ * @defaultValue true
18
24
  */
19
25
  animation?: boolean;
20
26
  /**
21
27
  * <zh/> 是否启用点击元素的功能
22
28
  *
23
29
  * <en/> Whether to enable the function of clicking the element
30
+ * @defaultValue true
24
31
  */
25
32
  enable?: boolean | ((event: IPointerEvent) => boolean);
26
33
  /**
27
34
  * <zh/> 是否允许多选
28
35
  *
29
36
  * <en/> Whether to allow multiple selection
37
+ * @defaultValue false
30
38
  */
31
39
  multiple?: boolean;
32
40
  /**
33
41
  * <zh/> 按下该快捷键配合鼠标点击进行多选
34
42
  *
35
43
  * <en/> Press this shortcut key to apply multiple selection with mouse click
44
+ * @defaultValue ['shift']
36
45
  */
37
46
  trigger?: ShortcutKey;
38
47
  /**
39
- * <zh/> 选中时应用的状态,默认为 selected
48
+ * <zh/> 选中时应用的状态
40
49
  *
41
50
  * <en/> The state to be applied when select.
51
+ * @defaultValue 'selected'
42
52
  */
43
- selectedState: State;
53
+ selectedState?: State;
44
54
  /**
45
- * <zh/> 当有元素被选中时,其他未选中的元素应用的状态,默认为 undefined
55
+ * <zh/> 当有元素被选中时,其他未选中的元素应用的状态
46
56
  *
47
57
  * <en/> The state to be applied on other unselected elements when some elements are selected
58
+ * @defaultValue undefined
48
59
  */
49
- unselectedState: State;
60
+ unselectedState?: State;
50
61
  /**
51
62
  * <zh/> 选中元素的度,即决定了影响范围
52
63
  *
53
64
  * <en/> The degree to determine the scope of influence
54
- * @description
65
+ * @defaultValue 0
66
+ * @remarks
55
67
  * <zh/> 对于节点来说,
56
68
  * - 0 表示只选中当前节点
57
69
  * - 1 表示选中当前节点及其直接相邻的节点和边,以此类推
@@ -69,6 +81,17 @@ export interface ClickElementOptions extends BaseBehaviorOptions {
69
81
  degree?: number;
70
82
  }
71
83
 
84
+ /**
85
+ * <zh/> 点击元素
86
+ *
87
+ * <en/> Click Element
88
+ * @remarks
89
+ * ```typescript
90
+ * const graph = new Graph({
91
+ * behaviors: ['click-element'],
92
+ * });
93
+ * ```
94
+ */
72
95
  export class ClickElement extends BaseBehavior<ClickElementOptions> {
73
96
  private selectedElementIds: ID[] = [];
74
97
 
@@ -11,12 +11,14 @@ export interface CollapseExpandOptions extends BaseBehaviorOptions {
11
11
  * <zh/> 是否启用动画
12
12
  *
13
13
  * <en/> Whether to enable animation
14
+ * @defaultValue true
14
15
  */
15
16
  animation: boolean;
16
17
  /**
17
18
  * <zh/> 是否启用展开/收起功能
18
19
  *
19
20
  * <en/> Whether to enable the expand/collapse function
21
+ * @defaultValue true
20
22
  */
21
23
  enable?: boolean | ((event: IPointerEvent) => boolean);
22
24
  /**
@@ -70,10 +72,10 @@ export class CollapseExpand extends BaseBehavior<CollapseExpandOptions> {
70
72
  const { onCollapse, onExpand, animation } = this.options;
71
73
  const isCollapse = data.style?.collapsed;
72
74
  if (isCollapse) {
73
- await graph.expand(id, animation);
75
+ await graph.expandElement(id, animation);
74
76
  onExpand?.(id);
75
77
  } else {
76
- await graph.collapse(id, animation);
78
+ await graph.collapseElement(id, animation);
77
79
  onCollapse?.(id);
78
80
  }
79
81
  };
@@ -9,6 +9,11 @@ import { multiply } from '../utils/vector';
9
9
  import type { BaseBehaviorOptions } from './base-behavior';
10
10
  import { BaseBehavior } from './base-behavior';
11
11
 
12
+ /**
13
+ * <zh/> 拖拽画布交互配置项
14
+ *
15
+ * <en/> Drag canvas behavior options
16
+ */
12
17
  export interface DragCanvasOptions extends BaseBehaviorOptions {
13
18
  /**
14
19
  * <zh/> 是否启用拖拽动画,仅在使用按键移动时有效
@@ -20,6 +25,7 @@ export interface DragCanvasOptions extends BaseBehaviorOptions {
20
25
  * <zh/> 是否启用拖拽画布的功能
21
26
  *
22
27
  * <en/> Whether to enable the function of dragging the canvas
28
+ * @defaultValue true
23
29
  */
24
30
  enable?: boolean | ((event: IPointerEvent | IKeyboardEvent) => boolean);
25
31
  /**
@@ -32,6 +38,7 @@ export interface DragCanvasOptions extends BaseBehaviorOptions {
32
38
  * <zh/> 触发一次按键移动的距离
33
39
  *
34
40
  * <en/> The distance of a single key movement
41
+ * @defaultValue 10
35
42
  */
36
43
  sensitivity?: number;
37
44
  /**
@@ -34,7 +34,7 @@ export interface DragElementOptions extends BaseBehaviorOptions, PrefixObject<Ba
34
34
  * - link: Place the drag element as a child element of the target element
35
35
  * - move: Move the element and update the parent element size
36
36
  * - none: Only update the drag target position, no additional operations
37
- * @description
37
+ * @remarks
38
38
  * <zh/> combo 元素可作为元素容器置入 node 或 combo 元素
39
39
  *
40
40
  * <en/> The combo element can be placed as an element container into the node or combo element
@@ -60,7 +60,7 @@ export interface DragElementOptions extends BaseBehaviorOptions, PrefixObject<Ba
60
60
  * - in: hide the edges with the node as the target node
61
61
  * - both: hide all edges related to the node
62
62
  * - all: hide all edges in the graph
63
- * @description
63
+ * @remarks
64
64
  * <zh/> 使用幽灵节点时不会隐藏边
65
65
  *
66
66
  * <en/> Edges will not be hidden when using the drag shadow
@@ -9,6 +9,7 @@ export { DragElementForce } from './drag-element-force';
9
9
  export { FocusElement } from './focus-element';
10
10
  export { HoverElement } from './hover-element';
11
11
  export { LassoSelect } from './lasso-select';
12
+ export { ScrollCanvas } from './scroll-canvas';
12
13
  export { ZoomCanvas } from './zoom-canvas';
13
14
 
14
15
  export type { BaseBehaviorOptions } from './base-behavior';
@@ -22,4 +23,5 @@ export type { DragElementForceOptions } from './drag-element-force';
22
23
  export type { FocusElementOptions } from './focus-element';
23
24
  export type { HoverElementOptions } from './hover-element';
24
25
  export type { LassoSelectOptions } from './lasso-select';
26
+ export type { ScrollCanvasOptions } from './scroll-canvas';
25
27
  export type { ZoomCanvasOptions } from './zoom-canvas';
@@ -12,7 +12,7 @@ const SHOW_PATH_ID = 'g6-lasso-select-path-id';
12
12
 
13
13
  export type States = Record<ID, State | State[]>;
14
14
 
15
- export type LassoSelectOptions = BrushSelectOptions;
15
+ export interface LassoSelectOptions extends BrushSelectOptions {}
16
16
 
17
17
  export class LassoSelect extends BrushSelect<LassoSelectOptions> {
18
18
  static defaultOptions: Partial<LassoSelectOptions> = {
@@ -42,7 +42,7 @@ export class LassoSelect extends BrushSelect<LassoSelectOptions> {
42
42
  id: SHOW_PATH_ID,
43
43
  style: {
44
44
  ...LassoSelect.defaultOptions.style,
45
- fill: style.color || DEFAULT_STYLE.color,
45
+ fill: style.fill || DEFAULT_STYLE.fill,
46
46
  ...style,
47
47
  pointerEvents: 'none',
48
48
  },
@@ -0,0 +1,143 @@
1
+ import { isFunction, isObject } from '@antv/util';
2
+ import { CanvasEvent } from '../constants';
3
+ import type { RuntimeContext } from '../runtime/types';
4
+ import type { IKeyboardEvent, Point } from '../types';
5
+ import { Shortcut, ShortcutKey } from '../utils/shortcut';
6
+ import type { BaseBehaviorOptions } from './base-behavior';
7
+ import { BaseBehavior } from './base-behavior';
8
+
9
+ export interface ScrollCanvasOptions extends BaseBehaviorOptions {
10
+ /**
11
+ * <zh/> 是否启用滚动画布的功能
12
+ *
13
+ * <en/> Whether to enable the function of scrolling the canvas
14
+ * @defaultValue true
15
+ */
16
+ enable?: boolean | ((event: WheelEvent | IKeyboardEvent) => boolean);
17
+ /**
18
+ * <zh/> 触发滚动的方式,默认使用指针滚动
19
+ *
20
+ * <en/> The way to trigger scrolling, default to scrolling with the pointer pressed
21
+ */
22
+ trigger?: CombinationKey;
23
+ /**
24
+ * <zh/> 允许的滚动方向
25
+ * - 默认情况下没有限制
26
+ * - x : 只允许水平滚动
27
+ * - y : 只允许垂直滚动
28
+ *
29
+ * <en/> The allowed rolling direction
30
+ * - by default, there is no restriction
31
+ * - x: only allow horizontal scrolling
32
+ * - y: only allow vertical scrolling
33
+ */
34
+ direction?: 'x' | 'y';
35
+ /**
36
+ * <zh/> 滚动灵敏度
37
+ *
38
+ * <en/> Scroll sensitivity
39
+ * @defaultValue 1
40
+ */
41
+ sensitivity?: number;
42
+ /**
43
+ * <zh/> 完成滚动时的回调
44
+ *
45
+ * <en/> Callback when scrolling is completed
46
+ */
47
+ onFinish?: () => void;
48
+ }
49
+
50
+ type CombinationKey = {
51
+ up: ShortcutKey;
52
+ down: ShortcutKey;
53
+ left: ShortcutKey;
54
+ right: ShortcutKey;
55
+ };
56
+
57
+ export class ScrollCanvas extends BaseBehavior<ScrollCanvasOptions> {
58
+ static defaultOptions: ScrollCanvasOptions = {
59
+ enable: true,
60
+ sensitivity: 1,
61
+ };
62
+
63
+ private shortcut: Shortcut;
64
+
65
+ constructor(context: RuntimeContext, options: ScrollCanvasOptions) {
66
+ super(context, Object.assign({}, ScrollCanvas.defaultOptions, options));
67
+
68
+ this.shortcut = new Shortcut(context.graph);
69
+
70
+ this.bindEvents();
71
+ }
72
+
73
+ private bindEvents() {
74
+ const { trigger } = this.options;
75
+ this.shortcut.unbindAll();
76
+ const { graph } = this.context;
77
+ if (isObject(trigger)) {
78
+ graph.off(CanvasEvent.WHEEL, this.onWheel);
79
+ const { up = [], down = [], left = [], right = [] } = trigger;
80
+
81
+ this.shortcut.bind(up, (event) => this.scroll([0, -10], event));
82
+ this.shortcut.bind(down, (event) => this.scroll([0, 10], event));
83
+ this.shortcut.bind(left, (event) => this.scroll([-10, 0], event));
84
+ this.shortcut.bind(right, (event) => this.scroll([10, 0], event));
85
+ } else {
86
+ /**
87
+ * 这里必需在原生canvas上绑定wheel事件,参考:
88
+ * https://g.antv.antgroup.com/api/event/faq#%E5%9C%A8-chrome-%E4%B8%AD%E7%A6%81%E6%AD%A2%E9%A1%B5%E9%9D%A2%E9%BB%98%E8%AE%A4%E6%BB%9A%E5%8A%A8%E8%A1%8C%E4%B8%BA
89
+ */
90
+ this.graphDom?.addEventListener(CanvasEvent.WHEEL, this.onWheel, { passive: false });
91
+ }
92
+ }
93
+
94
+ get graphDom() {
95
+ return this.context.graph.getCanvas().getContextService().getDomElement();
96
+ }
97
+
98
+ private onWheel = async (event: WheelEvent) => {
99
+ event.preventDefault();
100
+ const diffX = event.deltaX;
101
+ const diffY = event.deltaY;
102
+
103
+ await this.scroll([-diffX, -diffY], event);
104
+ };
105
+
106
+ private formatDisplacement([dx, dy]: Point) {
107
+ const { direction, sensitivity } = this.options;
108
+
109
+ dx = dx * sensitivity;
110
+ dy = dy * sensitivity;
111
+
112
+ if (direction === 'x') {
113
+ dy = 0;
114
+ } else if (direction === 'y') {
115
+ dx = 0;
116
+ }
117
+
118
+ return [dx, dy] as Point;
119
+ }
120
+
121
+ private async scroll(value: Point, event: WheelEvent | IKeyboardEvent) {
122
+ if (!this.validate(event)) return;
123
+ const { onFinish } = this.options;
124
+ const graph = this.context.graph;
125
+ const formattedValue = this.formatDisplacement(value);
126
+ await graph.translateBy(formattedValue, false);
127
+ onFinish?.();
128
+ }
129
+
130
+ private validate(event: WheelEvent | IKeyboardEvent) {
131
+ if (this.destroyed) return false;
132
+
133
+ const { enable } = this.options;
134
+ if (isFunction(enable)) return enable(event);
135
+ return !!enable;
136
+ }
137
+
138
+ public destroy(): void {
139
+ this.shortcut.destroy();
140
+ this.graphDom?.removeEventListener(CanvasEvent.WHEEL, this.onWheel);
141
+ super.destroy();
142
+ }
143
+ }