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

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 (264) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/behaviors/collapse-expand.d.ts +4 -5
  3. package/dist/lib/behaviors/create-edge.d.ts +55 -0
  4. package/dist/lib/behaviors/drag-canvas.d.ts +6 -6
  5. package/dist/lib/behaviors/drag-element.d.ts +5 -3
  6. package/dist/lib/behaviors/focus-element.d.ts +4 -3
  7. package/dist/lib/behaviors/hover-element.d.ts +4 -5
  8. package/dist/lib/behaviors/index.d.ts +2 -0
  9. package/dist/lib/behaviors/zoom-canvas.d.ts +7 -6
  10. package/dist/lib/constants/events/graph.d.ts +5 -13
  11. package/dist/lib/constants/index.d.ts +1 -0
  12. package/dist/lib/constants/registry.d.ts +20 -0
  13. package/dist/lib/elements/combos/base-combo.d.ts +21 -0
  14. package/dist/lib/elements/edges/base-edge.d.ts +21 -0
  15. package/dist/lib/elements/nodes/base-node.d.ts +22 -1
  16. package/dist/lib/exports.d.ts +16 -14
  17. package/dist/lib/plugins/camera-setting.d.ts +95 -0
  18. package/dist/lib/plugins/contextmenu.d.ts +8 -5
  19. package/dist/lib/plugins/index.d.ts +4 -0
  20. package/dist/lib/plugins/legend.d.ts +49 -0
  21. package/dist/lib/plugins/tooltip.d.ts +12 -10
  22. package/dist/lib/registry/extension/index.d.ts +2 -2
  23. package/dist/lib/registry/index.d.ts +6 -4
  24. package/dist/lib/registry/types.d.ts +0 -6
  25. package/dist/lib/runtime/canvas.d.ts +2 -1
  26. package/dist/lib/runtime/data.d.ts +1 -1
  27. package/dist/lib/runtime/element.d.ts +4 -5
  28. package/dist/lib/runtime/graph.d.ts +31 -4
  29. package/dist/lib/runtime/plugin.d.ts +1 -0
  30. package/dist/lib/types/event.d.ts +42 -7
  31. package/dist/lib/types/index.d.ts +0 -1
  32. package/dist/lib/utils/bbox.d.ts +1 -1
  33. package/dist/lib/utils/element.d.ts +19 -11
  34. package/dist/lib/utils/event/events.d.ts +8 -13
  35. package/dist/lib/utils/shortcut.d.ts +10 -0
  36. package/esm/behaviors/collapse-expand.d.ts +4 -5
  37. package/esm/behaviors/collapse-expand.js +8 -4
  38. package/esm/behaviors/collapse-expand.js.map +1 -1
  39. package/esm/behaviors/create-edge.d.ts +55 -0
  40. package/esm/behaviors/create-edge.js +141 -0
  41. package/esm/behaviors/create-edge.js.map +1 -0
  42. package/esm/behaviors/drag-canvas.d.ts +6 -6
  43. package/esm/behaviors/drag-canvas.js +15 -7
  44. package/esm/behaviors/drag-canvas.js.map +1 -1
  45. package/esm/behaviors/drag-element.d.ts +5 -3
  46. package/esm/behaviors/drag-element.js.map +1 -1
  47. package/esm/behaviors/focus-element.d.ts +4 -3
  48. package/esm/behaviors/focus-element.js.map +1 -1
  49. package/esm/behaviors/hover-element.d.ts +4 -5
  50. package/esm/behaviors/hover-element.js.map +1 -1
  51. package/esm/behaviors/index.d.ts +2 -0
  52. package/esm/behaviors/index.js +1 -0
  53. package/esm/behaviors/index.js.map +1 -1
  54. package/esm/behaviors/zoom-canvas.d.ts +7 -6
  55. package/esm/behaviors/zoom-canvas.js +6 -2
  56. package/esm/behaviors/zoom-canvas.js.map +1 -1
  57. package/esm/constants/events/graph.d.ts +5 -13
  58. package/esm/constants/events/graph.js +4 -12
  59. package/esm/constants/events/graph.js.map +1 -1
  60. package/esm/constants/index.d.ts +1 -0
  61. package/esm/constants/index.js +1 -0
  62. package/esm/constants/index.js.map +1 -1
  63. package/esm/constants/registry.d.ts +20 -0
  64. package/esm/constants/registry.js +22 -0
  65. package/esm/constants/registry.js.map +1 -0
  66. package/esm/elements/combos/base-combo.d.ts +21 -0
  67. package/esm/elements/combos/base-combo.js +21 -0
  68. package/esm/elements/combos/base-combo.js.map +1 -1
  69. package/esm/elements/edges/base-edge.d.ts +21 -0
  70. package/esm/elements/edges/base-edge.js +21 -0
  71. package/esm/elements/edges/base-edge.js.map +1 -1
  72. package/esm/elements/nodes/base-node.d.ts +22 -1
  73. package/esm/elements/nodes/base-node.js +21 -0
  74. package/esm/elements/nodes/base-node.js.map +1 -1
  75. package/esm/exports.d.ts +16 -14
  76. package/esm/exports.js +7 -6
  77. package/esm/exports.js.map +1 -1
  78. package/esm/plugins/camera-setting.d.ts +95 -0
  79. package/esm/plugins/camera-setting.js +65 -0
  80. package/esm/plugins/camera-setting.js.map +1 -0
  81. package/esm/plugins/contextmenu.d.ts +8 -5
  82. package/esm/plugins/contextmenu.js.map +1 -1
  83. package/esm/plugins/index.d.ts +4 -0
  84. package/esm/plugins/index.js +2 -0
  85. package/esm/plugins/index.js.map +1 -1
  86. package/esm/plugins/legend.d.ts +49 -0
  87. package/esm/plugins/legend.js +267 -0
  88. package/esm/plugins/legend.js.map +1 -0
  89. package/esm/plugins/tooltip.d.ts +12 -10
  90. package/esm/plugins/tooltip.js +0 -1
  91. package/esm/plugins/tooltip.js.map +1 -1
  92. package/esm/preset.js +2 -5
  93. package/esm/preset.js.map +1 -1
  94. package/esm/registry/build-in.js +4 -2
  95. package/esm/registry/build-in.js.map +1 -1
  96. package/esm/registry/extension/index.d.ts +2 -2
  97. package/esm/registry/extension/index.js.map +1 -1
  98. package/esm/registry/index.d.ts +6 -4
  99. package/esm/registry/index.js.map +1 -1
  100. package/esm/registry/types.d.ts +0 -6
  101. package/esm/runtime/behavior.js +3 -2
  102. package/esm/runtime/behavior.js.map +1 -1
  103. package/esm/runtime/canvas.d.ts +2 -1
  104. package/esm/runtime/canvas.js +68 -30
  105. package/esm/runtime/canvas.js.map +1 -1
  106. package/esm/runtime/data.d.ts +1 -1
  107. package/esm/runtime/element.d.ts +4 -5
  108. package/esm/runtime/element.js +32 -13
  109. package/esm/runtime/element.js.map +1 -1
  110. package/esm/runtime/graph.d.ts +31 -4
  111. package/esm/runtime/graph.js +48 -9
  112. package/esm/runtime/graph.js.map +1 -1
  113. package/esm/runtime/plugin.d.ts +1 -0
  114. package/esm/runtime/plugin.js +3 -0
  115. package/esm/runtime/plugin.js.map +1 -1
  116. package/esm/types/event.d.ts +42 -7
  117. package/esm/types/index.d.ts +0 -1
  118. package/esm/utils/bbox.d.ts +1 -1
  119. package/esm/utils/element.d.ts +19 -11
  120. package/esm/utils/element.js +19 -9
  121. package/esm/utils/element.js.map +1 -1
  122. package/esm/utils/event/events.d.ts +8 -13
  123. package/esm/utils/event/events.js +3 -8
  124. package/esm/utils/event/events.js.map +1 -1
  125. package/esm/utils/shortcut.d.ts +10 -0
  126. package/esm/utils/shortcut.js +24 -3
  127. package/esm/utils/shortcut.js.map +1 -1
  128. package/lib/behaviors/collapse-expand.d.ts +4 -5
  129. package/lib/behaviors/collapse-expand.js +8 -4
  130. package/lib/behaviors/collapse-expand.js.map +1 -1
  131. package/lib/behaviors/create-edge.d.ts +55 -0
  132. package/lib/behaviors/create-edge.js +145 -0
  133. package/lib/behaviors/create-edge.js.map +1 -0
  134. package/lib/behaviors/drag-canvas.d.ts +6 -6
  135. package/lib/behaviors/drag-canvas.js +15 -7
  136. package/lib/behaviors/drag-canvas.js.map +1 -1
  137. package/lib/behaviors/drag-element.d.ts +5 -3
  138. package/lib/behaviors/drag-element.js.map +1 -1
  139. package/lib/behaviors/focus-element.d.ts +4 -3
  140. package/lib/behaviors/focus-element.js.map +1 -1
  141. package/lib/behaviors/hover-element.d.ts +4 -5
  142. package/lib/behaviors/hover-element.js.map +1 -1
  143. package/lib/behaviors/index.d.ts +2 -0
  144. package/lib/behaviors/index.js +3 -1
  145. package/lib/behaviors/index.js.map +1 -1
  146. package/lib/behaviors/zoom-canvas.d.ts +7 -6
  147. package/lib/behaviors/zoom-canvas.js +6 -2
  148. package/lib/behaviors/zoom-canvas.js.map +1 -1
  149. package/lib/constants/events/graph.d.ts +5 -13
  150. package/lib/constants/events/graph.js +4 -12
  151. package/lib/constants/events/graph.js.map +1 -1
  152. package/lib/constants/index.d.ts +1 -0
  153. package/lib/constants/index.js +1 -0
  154. package/lib/constants/index.js.map +1 -1
  155. package/lib/constants/registry.d.ts +20 -0
  156. package/lib/constants/registry.js +25 -0
  157. package/lib/constants/registry.js.map +1 -0
  158. package/lib/elements/combos/base-combo.d.ts +21 -0
  159. package/lib/elements/combos/base-combo.js +21 -0
  160. package/lib/elements/combos/base-combo.js.map +1 -1
  161. package/lib/elements/edges/base-edge.d.ts +21 -0
  162. package/lib/elements/edges/base-edge.js +21 -0
  163. package/lib/elements/edges/base-edge.js.map +1 -1
  164. package/lib/elements/nodes/base-node.d.ts +22 -1
  165. package/lib/elements/nodes/base-node.js +21 -0
  166. package/lib/elements/nodes/base-node.js.map +1 -1
  167. package/lib/exports.d.ts +16 -14
  168. package/lib/exports.js +23 -1
  169. package/lib/exports.js.map +1 -1
  170. package/lib/plugins/camera-setting.d.ts +95 -0
  171. package/lib/plugins/camera-setting.js +69 -0
  172. package/lib/plugins/camera-setting.js.map +1 -0
  173. package/lib/plugins/contextmenu.d.ts +8 -5
  174. package/lib/plugins/contextmenu.js.map +1 -1
  175. package/lib/plugins/index.d.ts +4 -0
  176. package/lib/plugins/index.js +5 -1
  177. package/lib/plugins/index.js.map +1 -1
  178. package/lib/plugins/legend.d.ts +49 -0
  179. package/lib/plugins/legend.js +271 -0
  180. package/lib/plugins/legend.js.map +1 -0
  181. package/lib/plugins/tooltip.d.ts +12 -10
  182. package/lib/plugins/tooltip.js +0 -1
  183. package/lib/plugins/tooltip.js.map +1 -1
  184. package/lib/preset.js +2 -5
  185. package/lib/preset.js.map +1 -1
  186. package/lib/registry/build-in.js +2 -0
  187. package/lib/registry/build-in.js.map +1 -1
  188. package/lib/registry/extension/index.d.ts +2 -2
  189. package/lib/registry/extension/index.js.map +1 -1
  190. package/lib/registry/index.d.ts +6 -4
  191. package/lib/registry/index.js.map +1 -1
  192. package/lib/registry/types.d.ts +0 -6
  193. package/lib/runtime/behavior.js +3 -2
  194. package/lib/runtime/behavior.js.map +1 -1
  195. package/lib/runtime/canvas.d.ts +2 -1
  196. package/lib/runtime/canvas.js +68 -30
  197. package/lib/runtime/canvas.js.map +1 -1
  198. package/lib/runtime/data.d.ts +1 -1
  199. package/lib/runtime/element.d.ts +4 -5
  200. package/lib/runtime/element.js +31 -12
  201. package/lib/runtime/element.js.map +1 -1
  202. package/lib/runtime/graph.d.ts +31 -4
  203. package/lib/runtime/graph.js +47 -8
  204. package/lib/runtime/graph.js.map +1 -1
  205. package/lib/runtime/plugin.d.ts +1 -0
  206. package/lib/runtime/plugin.js +3 -0
  207. package/lib/runtime/plugin.js.map +1 -1
  208. package/lib/types/event.d.ts +42 -7
  209. package/lib/types/index.d.ts +0 -1
  210. package/lib/utils/bbox.d.ts +1 -1
  211. package/lib/utils/element.d.ts +19 -11
  212. package/lib/utils/element.js +21 -10
  213. package/lib/utils/element.js.map +1 -1
  214. package/lib/utils/event/events.d.ts +8 -13
  215. package/lib/utils/event/events.js +4 -10
  216. package/lib/utils/event/events.js.map +1 -1
  217. package/lib/utils/shortcut.d.ts +10 -0
  218. package/lib/utils/shortcut.js +24 -3
  219. package/lib/utils/shortcut.js.map +1 -1
  220. package/package.json +2 -2
  221. package/src/behaviors/collapse-expand.ts +13 -11
  222. package/src/behaviors/create-edge.ts +206 -0
  223. package/src/behaviors/drag-canvas.ts +22 -14
  224. package/src/behaviors/drag-element.ts +8 -11
  225. package/src/behaviors/focus-element.ts +7 -6
  226. package/src/behaviors/hover-element.ts +14 -10
  227. package/src/behaviors/index.ts +2 -0
  228. package/src/behaviors/zoom-canvas.ts +14 -9
  229. package/src/constants/events/graph.ts +4 -12
  230. package/src/constants/index.ts +1 -0
  231. package/src/constants/registry.ts +20 -0
  232. package/src/elements/combos/base-combo.ts +24 -0
  233. package/src/elements/edges/base-edge.ts +25 -1
  234. package/src/elements/nodes/base-node.ts +25 -1
  235. package/src/exports.ts +55 -12
  236. package/src/plugins/camera-setting.ts +153 -0
  237. package/src/plugins/contextmenu.ts +10 -7
  238. package/src/plugins/index.ts +4 -0
  239. package/src/plugins/legend.ts +321 -0
  240. package/src/plugins/tooltip.ts +16 -15
  241. package/src/preset.ts +2 -6
  242. package/src/registry/build-in.ts +12 -2
  243. package/src/registry/extension/index.ts +4 -4
  244. package/src/registry/index.ts +10 -4
  245. package/src/registry/types.ts +0 -7
  246. package/src/runtime/behavior.ts +3 -2
  247. package/src/runtime/canvas.ts +80 -40
  248. package/src/runtime/element.ts +52 -20
  249. package/src/runtime/graph.ts +56 -12
  250. package/src/runtime/plugin.ts +4 -0
  251. package/src/types/event.ts +62 -7
  252. package/src/types/index.ts +0 -1
  253. package/src/utils/bbox.ts +1 -1
  254. package/src/utils/element.ts +22 -11
  255. package/src/utils/event/events.ts +15 -17
  256. package/src/utils/shortcut.ts +28 -3
  257. package/dist/lib/types/behavior.d.ts +0 -5
  258. package/esm/types/behavior.d.ts +0 -5
  259. package/esm/types/behavior.js +0 -2
  260. package/esm/types/behavior.js.map +0 -1
  261. package/lib/types/behavior.d.ts +0 -5
  262. package/lib/types/behavior.js +0 -3
  263. package/lib/types/behavior.js.map +0 -1
  264. package/src/types/behavior.ts +0 -6
@@ -1,7 +1,6 @@
1
- import type { FederatedMouseEvent } from '@antv/g';
2
1
  import type { ID } from '@antv/graphlib';
3
2
  import type { RuntimeContext } from '../runtime/types';
4
- import { BehaviorEvent } from '../types';
3
+ import type { IPointerEvent } from '../types';
5
4
  import type { BaseBehaviorOptions } from './base-behavior';
6
5
  import { BaseBehavior } from './base-behavior';
7
6
  export interface CollapseExpandOptions extends BaseBehaviorOptions {
@@ -16,19 +15,19 @@ export interface CollapseExpandOptions extends BaseBehaviorOptions {
16
15
  *
17
16
  * <en/> Whether to enable the expand/collapse function
18
17
  */
19
- enable?: boolean | ((event: BehaviorEvent<FederatedMouseEvent>) => boolean);
18
+ enable?: boolean | ((event: IPointerEvent) => boolean);
20
19
  /**
21
20
  * <zh/> 完成收起时的回调
22
21
  *
23
22
  * <en/> Callback when collapse is completed
24
23
  */
25
- oncollapse?: (id: ID) => void;
24
+ onCollapse?: (id: ID) => void;
26
25
  /**
27
26
  * <zh/> 完成展开时的回调
28
27
  *
29
28
  * <en/> Callback when expand is completed
30
29
  */
31
- onexpand?: (id: ID) => void;
30
+ onExpand?: (id: ID) => void;
32
31
  }
33
32
  export declare class CollapseExpand extends BaseBehavior<CollapseExpandOptions> {
34
33
  static defaultOptions: Partial<CollapseExpandOptions>;
@@ -0,0 +1,55 @@
1
+ import type { ID } from '@antv/graphlib';
2
+ import type { RuntimeContext } from '../runtime/types';
3
+ import type { EdgeData } from '../spec';
4
+ import type { EdgeStyle } from '../spec/element/edge';
5
+ import type { IPointerEvent } from '../types';
6
+ import type { BaseBehaviorOptions } from './base-behavior';
7
+ import { BaseBehavior } from './base-behavior';
8
+ export interface CreateEdgeOptions extends BaseBehaviorOptions {
9
+ /**
10
+ * <zh/> 是否启用悬浮元素的功能
11
+ *
12
+ * <en/> Whether to enable hover element function.
13
+ */
14
+ enable?: boolean | ((event: IPointerEvent) => boolean);
15
+ /**
16
+ * <zh/> 边配置
17
+ *
18
+ * <en/> edge config.
19
+ */
20
+ style?: EdgeStyle;
21
+ /**
22
+ * <zh/> 交互配置 点击 或 拖拽
23
+ *
24
+ * <en/> trigger click or drag.
25
+ */
26
+ trigger?: 'click' | 'drag';
27
+ /**
28
+ * <zh/> 成功创建边回调
29
+ *
30
+ * <en/> Callback when create is completed.
31
+ */
32
+ onFinish?: (edge: EdgeData) => void;
33
+ /**
34
+ * <zh/> 创建边回调,返回边数据
35
+ *
36
+ * <en/> Callback when create edge, return EdgeData.
37
+ */
38
+ onCreate?: (edge: EdgeData) => EdgeData;
39
+ }
40
+ export declare class CreateEdge extends BaseBehavior<CreateEdgeOptions> {
41
+ static defaultOptions: Partial<CreateEdgeOptions>;
42
+ source?: ID;
43
+ constructor(context: RuntimeContext, options: CreateEdgeOptions);
44
+ update(options: Partial<CreateEdgeOptions>): void;
45
+ private bindEvents;
46
+ private drop;
47
+ private handleCreateEdge;
48
+ private updateAssistEdge;
49
+ private createEdge;
50
+ private cancelEdge;
51
+ private getSelectedNodeIDs;
52
+ private validate;
53
+ private unbindEvents;
54
+ destroy(): void;
55
+ }
@@ -1,6 +1,5 @@
1
- import type { FederatedMouseEvent } from '@antv/g';
2
- import { RuntimeContext } from '../runtime/types';
3
- import type { BehaviorEvent, ViewportAnimationEffectTiming } from '../types';
1
+ import type { RuntimeContext } from '../runtime/types';
2
+ import type { IKeyboardEvent, IPointerEvent, Vector2, ViewportAnimationEffectTiming } from '../types';
4
3
  import type { ShortcutKey } from '../utils/shortcut';
5
4
  import type { BaseBehaviorOptions } from './base-behavior';
6
5
  import { BaseBehavior } from './base-behavior';
@@ -16,7 +15,7 @@ export interface DragCanvasOptions extends BaseBehaviorOptions {
16
15
  *
17
16
  * <en/> Whether to enable the function of dragging the canvas
18
17
  */
19
- enable?: boolean | ((event: BehaviorEvent<FederatedMouseEvent> | BehaviorEvent<KeyboardEvent>) => boolean);
18
+ enable?: boolean | ((event: IPointerEvent | IKeyboardEvent) => boolean);
20
19
  /**
21
20
  * <zh/> 触发拖拽的方式,默认使用指针按下拖拽
22
21
  *
@@ -34,7 +33,7 @@ export interface DragCanvasOptions extends BaseBehaviorOptions {
34
33
  *
35
34
  * <en/> Callback when dragging is completed
36
35
  */
37
- onfinish?: () => void;
36
+ onFinish?: () => void;
38
37
  }
39
38
  type CombinationKey = {
40
39
  up: ShortcutKey;
@@ -49,7 +48,8 @@ export declare class DragCanvas extends BaseBehavior<DragCanvasOptions> {
49
48
  constructor(context: RuntimeContext, options: DragCanvasOptions);
50
49
  private bindEvents;
51
50
  private onDrag;
52
- private translate;
51
+ private onTranslate;
52
+ protected translate(offset: Vector2, animation?: ViewportAnimationEffectTiming): Promise<void>;
53
53
  private validate;
54
54
  destroy(): void;
55
55
  }
@@ -1,7 +1,7 @@
1
- import type { BaseStyleProps, FederatedMouseEvent } from '@antv/g';
1
+ import type { BaseStyleProps } from '@antv/g';
2
2
  import { ID } from '@antv/graphlib';
3
3
  import { RuntimeContext } from '../runtime/types';
4
- import type { BehaviorEvent, EdgeDirection, PrefixObject } from '../types';
4
+ import type { EdgeDirection, Element, IDragEvent, PrefixObject } from '../types';
5
5
  import type { BaseBehaviorOptions } from './base-behavior';
6
6
  import { BaseBehavior } from './base-behavior';
7
7
  export interface DragElementOptions extends BaseBehaviorOptions, PrefixObject<BaseStyleProps, 'shadow'> {
@@ -16,7 +16,7 @@ export interface DragElementOptions extends BaseBehaviorOptions, PrefixObject<Ba
16
16
  *
17
17
  * <en/> Whether to enable the function of dragging the node
18
18
  */
19
- enable?: boolean | ((event: BehaviorEvent<FederatedMouseEvent> | BehaviorEvent<KeyboardEvent>) => boolean);
19
+ enable?: boolean | ((event: IElementDragEvent) => boolean);
20
20
  /**
21
21
  * <zh/> 拖拽操作效果
22
22
  * - link: 将拖拽元素置入为目标元素的子元素
@@ -98,3 +98,5 @@ export declare class DragElement extends BaseBehavior<DragElementOptions> {
98
98
  private unbindEvents;
99
99
  destroy(): void;
100
100
  }
101
+ type IElementDragEvent = IDragEvent<Element>;
102
+ export {};
@@ -1,6 +1,5 @@
1
- import type { FederatedMouseEvent } from '@antv/g';
2
1
  import type { RuntimeContext } from '../runtime/types';
3
- import type { BehaviorEvent, ViewportAnimationEffectTiming } from '../types';
2
+ import type { Element, IPointerEvent, ViewportAnimationEffectTiming } from '../types';
4
3
  import type { BaseBehaviorOptions } from './base-behavior';
5
4
  import { BaseBehavior } from './base-behavior';
6
5
  export interface FocusElementOptions extends BaseBehaviorOptions {
@@ -15,7 +14,7 @@ export interface FocusElementOptions extends BaseBehaviorOptions {
15
14
  *
16
15
  * <en/> Whether to enable the function of dragging the node
17
16
  */
18
- enable?: boolean | ((event: BehaviorEvent<FederatedMouseEvent> | BehaviorEvent<KeyboardEvent>) => boolean);
17
+ enable?: boolean | ((event: IElementEvent) => boolean);
19
18
  }
20
19
  export declare class FocusElement extends BaseBehavior<FocusElementOptions> {
21
20
  static defaultOptions: Partial<FocusElementOptions>;
@@ -27,3 +26,5 @@ export declare class FocusElement extends BaseBehavior<FocusElementOptions> {
27
26
  private unbindEvents;
28
27
  destroy(): void;
29
28
  }
29
+ type IElementEvent = IPointerEvent<Element>;
30
+ export {};
@@ -1,6 +1,5 @@
1
- import type { FederatedMouseEvent } from '@antv/g';
2
1
  import type { RuntimeContext } from '../runtime/types';
3
- import type { BehaviorEvent, State } from '../types';
2
+ import type { IPointerEvent, State } from '../types';
4
3
  import type { BaseBehaviorOptions } from './base-behavior';
5
4
  import { BaseBehavior } from './base-behavior';
6
5
  export interface HoverElementOptions extends BaseBehaviorOptions {
@@ -15,7 +14,7 @@ export interface HoverElementOptions extends BaseBehaviorOptions {
15
14
  *
16
15
  * <en/> Whether to enable hover element function
17
16
  */
18
- enable?: boolean | ((event: BehaviorEvent<FederatedMouseEvent>) => boolean);
17
+ enable?: boolean | ((event: IPointerEvent) => boolean);
19
18
  /**
20
19
  * <zh/> 激活元素的n度关系,默认为0,表示只激活当前节点,1表示激活当前节点及其直接相邻的节点和边,以此类推
21
20
  *
@@ -39,13 +38,13 @@ export interface HoverElementOptions extends BaseBehaviorOptions {
39
38
  *
40
39
  * <en/> Callback when the element is hovered
41
40
  */
42
- onHover?: (event: BehaviorEvent<FederatedMouseEvent>) => void;
41
+ onHover?: (event: IPointerEvent) => void;
43
42
  /**
44
43
  * <zh/> 当悬停结束时的回调
45
44
  *
46
45
  * <en/> Callback when the hover ends
47
46
  */
48
- onHoverEnd?: (event: BehaviorEvent<FederatedMouseEvent>) => void;
47
+ onHoverEnd?: (event: IPointerEvent) => void;
49
48
  }
50
49
  export declare class HoverElement extends BaseBehavior<HoverElementOptions> {
51
50
  static defaultOptions: Partial<HoverElementOptions>;
@@ -1,5 +1,6 @@
1
1
  export { BaseBehavior } from './base-behavior';
2
2
  export { CollapseExpand } from './collapse-expand';
3
+ export { CreateEdge } from './create-edge';
3
4
  export { DragCanvas } from './drag-canvas';
4
5
  export { DragElement } from './drag-element';
5
6
  export { FocusElement } from './focus-element';
@@ -7,6 +8,7 @@ export { HoverElement } from './hover-element';
7
8
  export { ZoomCanvas } from './zoom-canvas';
8
9
  export type { BaseBehaviorOptions } from './base-behavior';
9
10
  export type { CollapseExpandOptions } from './collapse-expand';
11
+ export type { CreateEdgeOptions } from './create-edge';
10
12
  export type { DragCanvasOptions } from './drag-canvas';
11
13
  export type { DragElementOptions } from './drag-element';
12
14
  export type { FocusElementOptions } from './focus-element';
@@ -1,5 +1,5 @@
1
1
  import type { RuntimeContext } from '../runtime/types';
2
- import type { BehaviorEvent, ViewportAnimationEffectTiming } from '../types';
2
+ import type { IKeyboardEvent, IWheelEvent, ViewportAnimationEffectTiming } from '../types';
3
3
  import type { ShortcutKey } from '../utils/shortcut';
4
4
  import type { BaseBehaviorOptions } from './base-behavior';
5
5
  import { BaseBehavior } from './base-behavior';
@@ -15,7 +15,7 @@ export interface ZoomCanvasOptions extends BaseBehaviorOptions {
15
15
  *
16
16
  * <en/> Whether to enable the function of zooming the canvas
17
17
  */
18
- enable?: boolean | ((event: BehaviorEvent<WheelEvent> | BehaviorEvent<KeyboardEvent>) => boolean);
18
+ enable?: boolean | ((event: IWheelEvent | IKeyboardEvent) => boolean);
19
19
  /**
20
20
  * <zh/> 触发缩放的方式
21
21
  *
@@ -41,7 +41,7 @@ export interface ZoomCanvasOptions extends BaseBehaviorOptions {
41
41
  *
42
42
  * <en/> Callback when zooming is completed
43
43
  */
44
- onfinish?: () => void;
44
+ onFinish?: () => void;
45
45
  }
46
46
  type CombinationKey = {
47
47
  zoomIn: ShortcutKey;
@@ -62,9 +62,10 @@ export declare class ZoomCanvas extends BaseBehavior<ZoomCanvasOptions> {
62
62
  * @param event - <zh/> 事件对象 | <en/> Event object
63
63
  * @param animation - <zh/> 缩放动画配置 | <en/> Zoom animation configuration
64
64
  */
65
- private zoom;
66
- private onReset;
67
- private validate;
65
+ protected zoom: (value: number, event: IWheelEvent | IKeyboardEvent, animation: ZoomCanvasOptions['animation']) => Promise<void>;
66
+ protected onReset: () => Promise<void>;
67
+ protected validate(event: IWheelEvent | IKeyboardEvent): boolean;
68
68
  private preventDefault;
69
+ destroy(): void;
69
70
  }
70
71
  export {};
@@ -1,4 +1,8 @@
1
1
  export declare enum GraphEvent {
2
+ /** <zh/> 画布初始化之前 | <en/> Before the canvas is initialized */
3
+ BEFORE_CANVAS_INIT = "beforecanvasinit",
4
+ /** <zh/> 画布初始化之后 | <en/> After the canvas is initialized */
5
+ AFTER_CANVAS_INIT = "aftercanvasinit",
2
6
  /** <zh/> 视口尺寸变更之前 | <en/> Before the viewport size changes */
3
7
  BEFORE_SIZE_CHANGE = "beforesizechange",
4
8
  /** <zh/> 视口尺寸变更之后 | <en/> After the viewport size changes */
@@ -38,19 +42,7 @@ export declare enum GraphEvent {
38
42
  /** <zh/> 可视区域变化之前 | <en/> Before the visible area changes */
39
43
  BEFORE_TRANSFORM = "beforetransform",
40
44
  /** <zh/> 可视区域变化之后 | <en/> After the visible area changes */
41
- AFTER_TRANSFORM = "aftertransform",
42
- /** <zh/> 元素可见性变化之前 | <en/> Before the visibility of the element changes */
43
- BEFORE_ELEMENT_VISIBILITY_CHANGE = "beforeelementvisibilitychange",
44
- /** <zh/> 元素可见性变化之后 | <en/> After the visibility of the element changes */
45
- AFTER_ELEMENT_VISIBILITY_CHANGE = "afterelementvisibilitychange",
46
- /** <zh/> 元素层级变化之前 | <en/> Before the layer of the element changes */
47
- BEFORE_ELEMENT_Z_INDEX_CHANGE = "beforeelementzindexchange",
48
- /** <zh/> 元素层级变化之后 | <en/> After the layer of the element changes */
49
- AFTER_ELEMENT_Z_INDEX_CHANGE = "afterelementzindexchange",
50
- /** <zh/> 状态变化之前 | <en/> Before the state changes */
51
- BEFORE_ELEMENT_STATE_CHANGE = "beforeelementstatechange",
52
- /** <zh/> 状态变化之后 | <en/> After the state changes */
53
- AFTER_ELEMENT_STATE_CHANGE = "afterelementstatechange"
45
+ AFTER_TRANSFORM = "aftertransform"
54
46
  }
55
47
  export declare const enum AnimationTypeEnum {
56
48
  DRAW = "draw",
@@ -2,3 +2,4 @@ export * from './animation';
2
2
  export * from './change';
3
3
  export * from './events';
4
4
  export * from './graphlib';
5
+ export * from './registry';
@@ -0,0 +1,20 @@
1
+ export declare enum ExtensionCategory {
2
+ /** <zh/> 节点元素 | <en/> Node element */
3
+ NODE = "node",
4
+ /** <zh/> 边元素 | <en/> Edge element */
5
+ EDGE = "edge",
6
+ /** <zh/> 组合元素 | <en/> Combination element */
7
+ COMBO = "combo",
8
+ /** <zh/> 主题 | <en/> Theme */
9
+ THEME = "theme",
10
+ /** <zh/> 色板 | <en/> Palette */
11
+ PALETTE = "palette",
12
+ /** <zh/> 布局 | <en/> Layout */
13
+ LAYOUT = "layout",
14
+ /** <zh/> 交互 | <en/> Behavior */
15
+ BEHAVIOR = "behavior",
16
+ /** <zh/> 插件 | <en/> Plugin */
17
+ PLUGIN = "plugin",
18
+ /** <zh/> 动画 | <en/> Animation */
19
+ ANIMATION = "animation"
20
+ }
@@ -44,4 +44,25 @@ export declare abstract class BaseCombo<S extends BaseComboStyleProps = BaseComb
44
44
  zIndex: number;
45
45
  };
46
46
  render(attributes: Required<S>, container?: Group): void;
47
+ /**
48
+ * <zh/> 在元素完成创建并执行完入场动画后调用
49
+ *
50
+ * <en/> Called after the element is created and the entrance animation is completed
51
+ * @override
52
+ */
53
+ onCreate(): void;
54
+ /**
55
+ * <zh/> 在元素更新并执行完过渡动画后调用
56
+ *
57
+ * <en/> Called after the element is updated and the transition animation is completed
58
+ * @override
59
+ */
60
+ onUpdate(): void;
61
+ /**
62
+ * <zh/> 在元素完成退场动画并销毁后调用
63
+ *
64
+ * <en/> Called after the element completes the exit animation and is destroyed
65
+ * @override
66
+ */
67
+ onDestroy(): void;
47
68
  }
@@ -23,6 +23,27 @@ export declare abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
23
23
  protected drawHaloShape(attributes: ParsedBaseEdgeStyleProps, container: Group): void;
24
24
  protected drawKeyShape(attributes: ParsedBaseEdgeStyleProps, container: Group): Path | undefined;
25
25
  render(attributes?: Required<BaseEdgeStyleProps>, container?: Group): void;
26
+ /**
27
+ * <zh/> 在元素完成创建并执行完入场动画后调用
28
+ *
29
+ * <en/> Called after the element is created and the entrance animation is completed
30
+ * @override
31
+ */
32
+ onCreate(): void;
33
+ /**
34
+ * <zh/> 在元素更新并执行完过渡动画后调用
35
+ *
36
+ * <en/> Called after the element is updated and the transition animation is completed
37
+ * @override
38
+ */
39
+ onUpdate(): void;
40
+ /**
41
+ * <zh/> 在元素完成退场动画并销毁后调用
42
+ *
43
+ * <en/> Called after the element completes the exit animation and is destroyed
44
+ * @override
45
+ */
46
+ onDestroy(): void;
26
47
  animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions): import("@antv/g").IAnimation | null;
27
48
  }
28
49
  type SymbolName = 'triangle' | 'circle' | 'diamond' | 'vee' | 'rect' | 'triangleRect' | 'simple';
@@ -30,7 +30,7 @@ export declare abstract class BaseNode<S extends BaseNodeStyleProps = any> exten
30
30
  type: string;
31
31
  static defaultStyleProps: Partial<BaseNodeStyleProps>;
32
32
  constructor(options: DisplayObjectConfig<S>);
33
- protected getSize(attributes?: Required<S>): import("src/types/vector").Vector3;
33
+ protected getSize(attributes?: Required<S>): import("../../types").Vector3;
34
34
  protected getKeyStyle(attributes: Required<S>): any;
35
35
  protected getLabelStyle(attributes: Required<S>): false | LabelStyleProps;
36
36
  protected getHaloStyle(attributes: Required<S>): any;
@@ -65,6 +65,27 @@ export declare abstract class BaseNode<S extends BaseNodeStyleProps = any> exten
65
65
  protected drawPortShapes(attributes: Required<S>, container: Group): void;
66
66
  protected abstract drawKeyShape(attributes: Required<S>, container: Group): DisplayObject | undefined;
67
67
  render(attributes?: Required<S>, container?: Group): void;
68
+ /**
69
+ * <zh/> 在元素完成创建并执行完入场动画后调用
70
+ *
71
+ * <en/> Called after the element is created and the entrance animation is completed
72
+ * @override
73
+ */
74
+ onCreate(): void;
75
+ /**
76
+ * <zh/> 在元素更新并执行完过渡动画后调用
77
+ *
78
+ * <en/> Called after the element is updated and the transition animation is completed
79
+ * @override
80
+ */
81
+ onUpdate(): void;
82
+ /**
83
+ * <zh/> 在元素完成退场动画并销毁后调用
84
+ *
85
+ * <en/> Called after the element completes the exit animation and is destroyed
86
+ * @override
87
+ */
88
+ onDestroy(): void;
68
89
  animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions): import("@antv/g").IAnimation | null;
69
90
  }
70
91
  type NodeLabelStyleProps = LabelStyleProps & {
@@ -1,24 +1,26 @@
1
1
  import { idOf } from './utils/id';
2
2
  import { omitStyleProps, subStyleProps } from './utils/prefix';
3
3
  import { treeToGraphData } from './utils/tree';
4
- export { BaseBehavior } from './behaviors';
5
- export { CanvasEvent, ComboEvent, CommonEvent, ContainerEvent, EdgeEvent, GraphEvent, NodeEvent } from './constants';
6
- export { BaseCombo } from './elements/combos';
7
- export { BaseEdge } from './elements/edges';
8
- export { BaseNode } from './elements/nodes';
4
+ export { BaseBehavior, DragCanvas, ZoomCanvas } from './behaviors';
5
+ export { CanvasEvent, ComboEvent, CommonEvent, ContainerEvent, EdgeEvent, ExtensionCategory, GraphEvent, NodeEvent, } from './constants';
6
+ export { BaseCombo, CircleCombo, RectCombo } from './elements/combos';
7
+ export { BaseEdge, Cubic, CubicHorizontal, CubicVertical, Line, Polyline, Quadratic } from './elements/edges';
8
+ export { BaseNode, Circle, Diamond, Ellipse, Hexagon, Image, Rect, Star, Triangle } from './elements/nodes';
9
9
  export { BaseShape } from './elements/shapes';
10
- export { BasePlugin } from './plugins';
10
+ export { BasePlugin, CameraSetting } from './plugins';
11
11
  export { getExtension, getExtensions, register } from './registry';
12
12
  export { Graph } from './runtime/graph';
13
- export type { BaseBehaviorOptions } from './behaviors';
14
- export type { BaseComboStyleProps } from './elements/combos';
15
- export type { BaseEdgeStyleProps } from './elements/edges';
16
- export type { BaseNodeStyleProps } from './elements/nodes';
13
+ export { Shortcut } from './utils/shortcut';
14
+ export type { BaseBehaviorOptions, DragCanvasOptions, ZoomCanvasOptions } from './behaviors';
15
+ export type { BaseComboStyleProps, CircleComboStyleProps, RectComboStyleProps } from './elements/combos';
16
+ export type { BaseEdgeStyleProps, CubicHorizontalStyleProps, CubicStyleProps, CubicVerticalStyleProps, LineStyleProps, PolylineStyleProps, QuadraticStyleProps, } from './elements/edges';
17
+ export type { BaseNodeStyleProps, CircleStyleProps, DiamondStyleProps, EllipseStyleProps, HexagonStyleProps, ImageStyleProps, RectStyleProps, StarStyleProps, TriangleStyleProps, } from './elements/nodes';
17
18
  export type { BaseShapeStyleProps } from './elements/shapes';
18
- export type { BasePluginOptions } from './plugins';
19
+ export type { BasePluginOptions, CameraSettingOptions } from './plugins';
19
20
  export type { RuntimeContext } from './runtime/types';
20
21
  export type { BehaviorOptions, CanvasOptions, ComboData, ComboOptions, EdgeData, EdgeOptions, G6Spec, GraphData, LayoutOptions, NodeData, NodeOptions, PluginOptions, ThemeOptions, ViewportOptions, } from './spec';
21
- export type { Point, Vector2, Vector3 } from './types';
22
+ export type { IAnimateEvent, IDragEvent, IElementLifeCycleEvent, IEvent, IGraphLifeCycleEvent, IKeyboardEvent, IPointerEvent, IViewportEvent, IWheelEvent, Point, Vector2, Vector3, ViewportAnimationEffectTiming, } from './types';
23
+ export type { ShortcutKey } from './utils/shortcut';
22
24
  declare const Utils: {
23
25
  idOf: typeof idOf;
24
26
  treeToGraphData: typeof treeToGraphData;
@@ -26,7 +28,7 @@ declare const Utils: {
26
28
  omitStyleProps: typeof omitStyleProps;
27
29
  };
28
30
  declare const Theme: {
29
- dark: import("src/themes/types").Theme;
30
- light: import("src/themes/types").Theme;
31
+ dark: import("./themes/types").Theme;
32
+ light: import("./themes/types").Theme;
31
33
  };
32
34
  export { Theme, Utils };
@@ -0,0 +1,95 @@
1
+ import type { RuntimeContext } from '../runtime/types';
2
+ import type { BasePluginOptions } from './base-plugin';
3
+ import { BasePlugin } from './base-plugin';
4
+ export interface CameraSettingOptions extends BasePluginOptions {
5
+ /**
6
+ * <zh/> 投影模式,透视投影仅在 3D 场景下有效
7
+ *
8
+ * <en/> Projection mode, perspective projection is only valid in 3D scenes
9
+ */
10
+ projectionMode?: 'perspective' | 'orthographic';
11
+ /**
12
+ * <zh/> 相机类型
13
+ * - orbiting: 固定视点,改变相机位置
14
+ * - exploring: 类似 orbiting,但允许相机在北极和南极之间旋转
15
+ * - tracking: 固定相机位置,改变视点
16
+ *
17
+ * <en/> Camera type
18
+ * - orbiting: Fixed viewpoint, change camera position
19
+ * - exploring: Similar to orbiting, but allows the camera to rotate between the North Pole and the South Pole
20
+ * - tracking: Fixed camera position, change viewpoint
21
+ */
22
+ cameraType?: 'orbiting' | 'exploring' | 'tracking';
23
+ /**
24
+ * <zh/> 近平面位置
25
+ *
26
+ * <en/> The position of the near plane
27
+ */
28
+ near?: number;
29
+ /**
30
+ * <zh/> 远平面位置
31
+ *
32
+ * <en/> The position of the far plane
33
+ */
34
+ far?: number;
35
+ /**
36
+ * <zh/> 相机视角,仅在透视相机下有效
37
+ *
38
+ * <en/> Camera field of view, only valid in perspective camera
39
+ */
40
+ fov?: number;
41
+ /**
42
+ * <zh/> 相机视口宽高比,仅在透视相机下有效。设置为 'auto' 时,会自动根据画布宽高比设置
43
+ *
44
+ * <en/> Camera viewport aspect ratio, only valid in perspective camera. When set to 'auto', it will be automatically set according to the canvas aspect ratio
45
+ */
46
+ aspect?: number | 'auto';
47
+ /**
48
+ * <zh/> 相机距离目标的距离,默认为 500
49
+ *
50
+ * <en/> The distance from the camera to the target, default is 100.
51
+ */
52
+ distance?: number;
53
+ /**
54
+ * <zh/> 最小视距
55
+ *
56
+ * <en/> Minimum distance
57
+ */
58
+ minDistance?: number;
59
+ /**
60
+ * <zh/> 最大视距
61
+ *
62
+ * <en/> Maximum distance
63
+ */
64
+ maxDistance?: number;
65
+ /**
66
+ * <zh/> 滚转角
67
+ *
68
+ * <en/> Roll
69
+ */
70
+ roll?: number;
71
+ /**
72
+ * <zh/> 仰角
73
+ *
74
+ * <en/> Elevation
75
+ */
76
+ elevation?: number;
77
+ /**
78
+ * <zh/> 方位角
79
+ *
80
+ * <en/> Azimuth
81
+ */
82
+ azimuth?: number;
83
+ }
84
+ /**
85
+ * <zh/> 配置相机参数
86
+ *
87
+ * <en/> Configure camera parameters
88
+ */
89
+ export declare class CameraSetting extends BasePlugin<CameraSettingOptions> {
90
+ constructor(context: RuntimeContext, options: CameraSettingOptions);
91
+ update(options: Partial<CameraSettingOptions>): void;
92
+ private bindEvents;
93
+ private setOptions;
94
+ private getCanvasAspect;
95
+ }
@@ -1,5 +1,6 @@
1
1
  import type { RuntimeContext } from '../runtime/types';
2
- import type { ElementEvent } from '../types/event';
2
+ import type { Element } from '../types';
3
+ import type { IPointerEvent } from '../types/event';
3
4
  import type { Item } from '../utils/contextmenu';
4
5
  import type { BasePluginOptions } from './base-plugin';
5
6
  import { BasePlugin } from './base-plugin';
@@ -32,12 +33,12 @@ export type ContextmenuOptions = BasePluginOptions & {
32
33
  * <zh/> 返回菜单的项目列表,支持 `Promise` 类型的返回值。是 `getContent` 的快捷配置。
33
34
  * <en/> Return the list of menu items, support the `Promise` type return value. It is a shortcut configuration of `getContent`.
34
35
  */
35
- getItems?: (event: ElementEvent) => Item[] | Promise<Item[]>;
36
+ getItems?: (event: IElementEvent) => Item[] | Promise<Item[]>;
36
37
  /**
37
38
  * <zh/> 返回菜单的内容,支持 `Promise` 类型的返回值,也可以使用 `getItems` 来快捷配置。
38
39
  * <en/> Return the content of menu, support the `Promise` type return value, you can also use `getItems` for shortcut configuration.
39
40
  */
40
- getContent?: (event: ElementEvent) => HTMLElement | string | Promise<HTMLElement | string>;
41
+ getContent?: (event: IElementEvent) => HTMLElement | string | Promise<HTMLElement | string>;
41
42
  /**
42
43
  * <zh/> Loading 时候的菜单内容,用于 getContent 返回 Promise 的时候。
43
44
  * <en/> The menu content when loading is used when getContent returns a Promise.
@@ -47,7 +48,7 @@ export type ContextmenuOptions = BasePluginOptions & {
47
48
  * <zh/> 插件是否可用,通过参数来判断是否支持右键菜单,默认全部可用。
48
49
  * <en/> Whether the plugin is available, determine whether the right-click menu is supported through parameters, The default is all available.
49
50
  */
50
- enable?: boolean | ((event: ElementEvent) => boolean);
51
+ enable?: boolean | ((event: IElementEvent) => boolean);
51
52
  };
52
53
  /**
53
54
  * <zh/> 支持处理事件,并显示右键菜单,在菜单点击之后,可以触发相应的事件。
@@ -63,7 +64,7 @@ export declare class Contextmenu extends BasePlugin<ContextmenuOptions> {
63
64
  * <en/> Display the right-click menu based on the incoming element.
64
65
  * @param e - 事件
65
66
  */
66
- showContextmenu(e: ElementEvent): Promise<void>;
67
+ showContextmenu(e: IElementEvent): Promise<void>;
67
68
  /**
68
69
  * <zh/> 隐藏右键菜单。
69
70
  * <en/> Hide the right-click menu.
@@ -86,3 +87,5 @@ export declare class Contextmenu extends BasePlugin<ContextmenuOptions> {
86
87
  private onTriggerEvent;
87
88
  private onMenuItemClick;
88
89
  }
90
+ type IElementEvent = IPointerEvent<Element>;
91
+ export {};
@@ -1,12 +1,16 @@
1
1
  export { BasePlugin } from './base-plugin';
2
+ export { CameraSetting } from './camera-setting';
2
3
  export { Contextmenu } from './contextmenu';
3
4
  export { GridLine } from './grid-line';
5
+ export { Legend } from './legend';
4
6
  export { Toolbar } from './toolbar';
5
7
  export { Tooltip } from './tooltip';
6
8
  export { Watermark } from './watermark';
7
9
  export type { BasePluginOptions } from './base-plugin';
10
+ export type { CameraSettingOptions } from './camera-setting';
8
11
  export type { ContextmenuOptions } from './contextmenu';
9
12
  export type { GridLineOptions } from './grid-line';
13
+ export type { LegendOptions } from './legend';
10
14
  export type { ToolbarOptions } from './toolbar';
11
15
  export type { TooltipOptions } from './tooltip';
12
16
  export type { WatermarkOptions } from './watermark';