@antv/g6 5.0.20 → 5.0.21

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 (248) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/dist/lib/behaviors/base-behavior.d.ts +10 -0
  3. package/dist/lib/behaviors/hover-activate.d.ts +3 -2
  4. package/dist/lib/elements/edges/line.d.ts +0 -2
  5. package/dist/lib/elements/shapes/base-shape.d.ts +29 -14
  6. package/dist/lib/exports.d.ts +2 -2
  7. package/dist/lib/layouts/base-layout.d.ts +5 -0
  8. package/dist/lib/plugins/background/index.d.ts +1 -0
  9. package/dist/lib/plugins/base-plugin.d.ts +5 -0
  10. package/dist/lib/plugins/bubble-sets.d.ts +1 -0
  11. package/dist/lib/plugins/contextmenu/index.d.ts +1 -0
  12. package/dist/lib/plugins/grid-line.d.ts +1 -0
  13. package/dist/lib/plugins/history/index.d.ts +1 -0
  14. package/dist/lib/plugins/hull/index.d.ts +1 -0
  15. package/dist/lib/plugins/legend.d.ts +1 -0
  16. package/dist/lib/plugins/minimap/index.d.ts +8 -2
  17. package/dist/lib/plugins/snapline/index.d.ts +10 -0
  18. package/dist/lib/plugins/timebar.d.ts +1 -0
  19. package/dist/lib/plugins/toolbar/index.d.ts +1 -0
  20. package/dist/lib/plugins/tooltip.d.ts +11 -0
  21. package/dist/lib/plugins/watermark/index.d.ts +1 -0
  22. package/dist/lib/transforms/base-transform.d.ts +5 -0
  23. package/dist/lib/transforms/process-parallel-edges.d.ts +7 -9
  24. package/dist/lib/transforms/utils.d.ts +5 -5
  25. package/dist/lib/utils/bbox.d.ts +12 -3
  26. package/dist/lib/utils/padding.d.ts +4 -4
  27. package/dist/lib/utils/prefix.d.ts +1 -1
  28. package/dist/lib/utils/router/orth.d.ts +1 -1
  29. package/dist/lib/utils/size.d.ts +3 -1
  30. package/dist/lib/utils/transform.d.ts +5 -5
  31. package/dist/lib/version.d.ts +1 -1
  32. package/esm/behaviors/base-behavior.d.ts +10 -0
  33. package/esm/behaviors/base-behavior.js +5 -0
  34. package/esm/behaviors/base-behavior.js.map +1 -1
  35. package/esm/behaviors/hover-activate.d.ts +3 -2
  36. package/esm/behaviors/hover-activate.js +16 -7
  37. package/esm/behaviors/hover-activate.js.map +1 -1
  38. package/esm/elements/edges/line.d.ts +0 -2
  39. package/esm/elements/edges/line.js +0 -2
  40. package/esm/elements/edges/line.js.map +1 -1
  41. package/esm/elements/edges/polyline.js.map +1 -1
  42. package/esm/elements/nodes/html.js +4 -1
  43. package/esm/elements/nodes/html.js.map +1 -1
  44. package/esm/elements/shapes/base-shape.d.ts +29 -14
  45. package/esm/elements/shapes/base-shape.js +27 -12
  46. package/esm/elements/shapes/base-shape.js.map +1 -1
  47. package/esm/exports.d.ts +2 -2
  48. package/esm/exports.js +1 -1
  49. package/esm/exports.js.map +1 -1
  50. package/esm/layouts/base-layout.d.ts +5 -0
  51. package/esm/layouts/base-layout.js +5 -0
  52. package/esm/layouts/base-layout.js.map +1 -1
  53. package/esm/plugins/background/index.d.ts +1 -0
  54. package/esm/plugins/background/index.js +1 -0
  55. package/esm/plugins/background/index.js.map +1 -1
  56. package/esm/plugins/base-plugin.d.ts +5 -0
  57. package/esm/plugins/base-plugin.js +5 -0
  58. package/esm/plugins/base-plugin.js.map +1 -1
  59. package/esm/plugins/bubble-sets.d.ts +1 -0
  60. package/esm/plugins/bubble-sets.js +1 -0
  61. package/esm/plugins/bubble-sets.js.map +1 -1
  62. package/esm/plugins/contextmenu/index.d.ts +1 -0
  63. package/esm/plugins/contextmenu/index.js +1 -0
  64. package/esm/plugins/contextmenu/index.js.map +1 -1
  65. package/esm/plugins/grid-line.d.ts +1 -0
  66. package/esm/plugins/grid-line.js +1 -0
  67. package/esm/plugins/grid-line.js.map +1 -1
  68. package/esm/plugins/history/index.d.ts +1 -0
  69. package/esm/plugins/history/index.js +1 -0
  70. package/esm/plugins/history/index.js.map +1 -1
  71. package/esm/plugins/hull/index.d.ts +1 -0
  72. package/esm/plugins/hull/index.js +1 -0
  73. package/esm/plugins/hull/index.js.map +1 -1
  74. package/esm/plugins/legend.d.ts +1 -0
  75. package/esm/plugins/legend.js +1 -0
  76. package/esm/plugins/legend.js.map +1 -1
  77. package/esm/plugins/minimap/index.d.ts +8 -2
  78. package/esm/plugins/minimap/index.js +5 -0
  79. package/esm/plugins/minimap/index.js.map +1 -1
  80. package/esm/plugins/snapline/index.d.ts +10 -0
  81. package/esm/plugins/snapline/index.js +5 -0
  82. package/esm/plugins/snapline/index.js.map +1 -1
  83. package/esm/plugins/timebar.d.ts +1 -0
  84. package/esm/plugins/timebar.js +1 -0
  85. package/esm/plugins/timebar.js.map +1 -1
  86. package/esm/plugins/toolbar/index.d.ts +1 -0
  87. package/esm/plugins/toolbar/index.js +1 -0
  88. package/esm/plugins/toolbar/index.js.map +1 -1
  89. package/esm/plugins/tooltip.d.ts +11 -0
  90. package/esm/plugins/tooltip.js +6 -0
  91. package/esm/plugins/tooltip.js.map +1 -1
  92. package/esm/plugins/watermark/index.d.ts +1 -0
  93. package/esm/plugins/watermark/index.js +1 -0
  94. package/esm/plugins/watermark/index.js.map +1 -1
  95. package/esm/transforms/base-transform.d.ts +5 -0
  96. package/esm/transforms/base-transform.js +5 -0
  97. package/esm/transforms/base-transform.js.map +1 -1
  98. package/esm/transforms/process-parallel-edges.d.ts +7 -9
  99. package/esm/transforms/process-parallel-edges.js.map +1 -1
  100. package/esm/transforms/utils.d.ts +5 -5
  101. package/esm/transforms/utils.js +5 -5
  102. package/esm/utils/bbox.d.ts +12 -3
  103. package/esm/utils/bbox.js +16 -4
  104. package/esm/utils/bbox.js.map +1 -1
  105. package/esm/utils/edge.js +4 -4
  106. package/esm/utils/edge.js.map +1 -1
  107. package/esm/utils/padding.d.ts +4 -4
  108. package/esm/utils/padding.js +4 -4
  109. package/esm/utils/point.js +3 -0
  110. package/esm/utils/point.js.map +1 -1
  111. package/esm/utils/prefix.d.ts +1 -1
  112. package/esm/utils/prefix.js +1 -1
  113. package/esm/utils/router/orth.d.ts +1 -1
  114. package/esm/utils/router/orth.js +27 -11
  115. package/esm/utils/router/orth.js.map +1 -1
  116. package/esm/utils/size.d.ts +3 -1
  117. package/esm/utils/size.js +3 -1
  118. package/esm/utils/size.js.map +1 -1
  119. package/esm/utils/transform.d.ts +5 -5
  120. package/esm/utils/transform.js +5 -5
  121. package/esm/version.d.ts +1 -1
  122. package/esm/version.js +1 -1
  123. package/lib/behaviors/base-behavior.d.ts +10 -0
  124. package/lib/behaviors/base-behavior.js +5 -0
  125. package/lib/behaviors/base-behavior.js.map +1 -1
  126. package/lib/behaviors/hover-activate.d.ts +3 -2
  127. package/lib/behaviors/hover-activate.js +16 -7
  128. package/lib/behaviors/hover-activate.js.map +1 -1
  129. package/lib/elements/edges/line.d.ts +0 -2
  130. package/lib/elements/edges/line.js +0 -2
  131. package/lib/elements/edges/line.js.map +1 -1
  132. package/lib/elements/edges/polyline.js.map +1 -1
  133. package/lib/elements/nodes/html.js +3 -0
  134. package/lib/elements/nodes/html.js.map +1 -1
  135. package/lib/elements/shapes/base-shape.d.ts +29 -14
  136. package/lib/elements/shapes/base-shape.js +27 -12
  137. package/lib/elements/shapes/base-shape.js.map +1 -1
  138. package/lib/exports.d.ts +2 -2
  139. package/lib/exports.js +3 -2
  140. package/lib/exports.js.map +1 -1
  141. package/lib/layouts/base-layout.d.ts +5 -0
  142. package/lib/layouts/base-layout.js +5 -0
  143. package/lib/layouts/base-layout.js.map +1 -1
  144. package/lib/plugins/background/index.d.ts +1 -0
  145. package/lib/plugins/background/index.js +1 -0
  146. package/lib/plugins/background/index.js.map +1 -1
  147. package/lib/plugins/base-plugin.d.ts +5 -0
  148. package/lib/plugins/base-plugin.js +5 -0
  149. package/lib/plugins/base-plugin.js.map +1 -1
  150. package/lib/plugins/bubble-sets.d.ts +1 -0
  151. package/lib/plugins/bubble-sets.js +1 -0
  152. package/lib/plugins/bubble-sets.js.map +1 -1
  153. package/lib/plugins/contextmenu/index.d.ts +1 -0
  154. package/lib/plugins/contextmenu/index.js +1 -0
  155. package/lib/plugins/contextmenu/index.js.map +1 -1
  156. package/lib/plugins/grid-line.d.ts +1 -0
  157. package/lib/plugins/grid-line.js +1 -0
  158. package/lib/plugins/grid-line.js.map +1 -1
  159. package/lib/plugins/history/index.d.ts +1 -0
  160. package/lib/plugins/history/index.js +1 -0
  161. package/lib/plugins/history/index.js.map +1 -1
  162. package/lib/plugins/hull/index.d.ts +1 -0
  163. package/lib/plugins/hull/index.js +1 -0
  164. package/lib/plugins/hull/index.js.map +1 -1
  165. package/lib/plugins/legend.d.ts +1 -0
  166. package/lib/plugins/legend.js +1 -0
  167. package/lib/plugins/legend.js.map +1 -1
  168. package/lib/plugins/minimap/index.d.ts +8 -2
  169. package/lib/plugins/minimap/index.js +5 -0
  170. package/lib/plugins/minimap/index.js.map +1 -1
  171. package/lib/plugins/snapline/index.d.ts +10 -0
  172. package/lib/plugins/snapline/index.js +5 -0
  173. package/lib/plugins/snapline/index.js.map +1 -1
  174. package/lib/plugins/timebar.d.ts +1 -0
  175. package/lib/plugins/timebar.js +1 -0
  176. package/lib/plugins/timebar.js.map +1 -1
  177. package/lib/plugins/toolbar/index.d.ts +1 -0
  178. package/lib/plugins/toolbar/index.js +1 -0
  179. package/lib/plugins/toolbar/index.js.map +1 -1
  180. package/lib/plugins/tooltip.d.ts +11 -0
  181. package/lib/plugins/tooltip.js +6 -0
  182. package/lib/plugins/tooltip.js.map +1 -1
  183. package/lib/plugins/watermark/index.d.ts +1 -0
  184. package/lib/plugins/watermark/index.js +1 -0
  185. package/lib/plugins/watermark/index.js.map +1 -1
  186. package/lib/transforms/base-transform.d.ts +5 -0
  187. package/lib/transforms/base-transform.js +5 -0
  188. package/lib/transforms/base-transform.js.map +1 -1
  189. package/lib/transforms/process-parallel-edges.d.ts +7 -9
  190. package/lib/transforms/process-parallel-edges.js.map +1 -1
  191. package/lib/transforms/utils.d.ts +5 -5
  192. package/lib/transforms/utils.js +5 -5
  193. package/lib/utils/bbox.d.ts +12 -3
  194. package/lib/utils/bbox.js +19 -6
  195. package/lib/utils/bbox.js.map +1 -1
  196. package/lib/utils/edge.js +3 -3
  197. package/lib/utils/edge.js.map +1 -1
  198. package/lib/utils/padding.d.ts +4 -4
  199. package/lib/utils/padding.js +4 -4
  200. package/lib/utils/point.js +3 -0
  201. package/lib/utils/point.js.map +1 -1
  202. package/lib/utils/prefix.d.ts +1 -1
  203. package/lib/utils/prefix.js +1 -1
  204. package/lib/utils/router/orth.d.ts +1 -1
  205. package/lib/utils/router/orth.js +25 -9
  206. package/lib/utils/router/orth.js.map +1 -1
  207. package/lib/utils/size.d.ts +3 -1
  208. package/lib/utils/size.js +3 -1
  209. package/lib/utils/size.js.map +1 -1
  210. package/lib/utils/transform.d.ts +5 -5
  211. package/lib/utils/transform.js +5 -5
  212. package/lib/version.d.ts +1 -1
  213. package/lib/version.js +1 -1
  214. package/package.json +9 -9
  215. package/src/behaviors/base-behavior.ts +10 -0
  216. package/src/behaviors/hover-activate.ts +24 -8
  217. package/src/elements/edges/line.ts +0 -2
  218. package/src/elements/edges/polyline.ts +2 -0
  219. package/src/elements/nodes/html.ts +4 -1
  220. package/src/elements/shapes/base-shape.ts +29 -14
  221. package/src/exports.ts +2 -0
  222. package/src/layouts/base-layout.ts +5 -0
  223. package/src/plugins/background/index.ts +1 -0
  224. package/src/plugins/base-plugin.ts +5 -0
  225. package/src/plugins/bubble-sets.ts +1 -0
  226. package/src/plugins/contextmenu/index.ts +1 -0
  227. package/src/plugins/grid-line.ts +1 -0
  228. package/src/plugins/history/index.ts +1 -0
  229. package/src/plugins/hull/index.ts +1 -0
  230. package/src/plugins/legend.ts +1 -0
  231. package/src/plugins/minimap/index.ts +8 -2
  232. package/src/plugins/snapline/index.ts +10 -0
  233. package/src/plugins/timebar.ts +1 -0
  234. package/src/plugins/toolbar/index.ts +1 -0
  235. package/src/plugins/tooltip.ts +11 -0
  236. package/src/plugins/watermark/index.ts +1 -0
  237. package/src/transforms/base-transform.ts +5 -0
  238. package/src/transforms/process-parallel-edges.ts +7 -9
  239. package/src/transforms/utils.ts +5 -5
  240. package/src/utils/bbox.ts +17 -4
  241. package/src/utils/edge.ts +4 -4
  242. package/src/utils/padding.ts +4 -4
  243. package/src/utils/point.ts +2 -0
  244. package/src/utils/prefix.ts +1 -1
  245. package/src/utils/router/orth.ts +29 -11
  246. package/src/utils/size.ts +3 -1
  247. package/src/utils/transform.ts +5 -5
  248. package/src/version.ts +1 -1
@@ -1,6 +1,16 @@
1
1
  import { BaseExtension } from '../registry/extension';
2
2
  import type { CustomBehaviorOption } from '../spec/behavior';
3
+ /**
4
+ * <zh/> 交互通用配置项
5
+ *
6
+ * <en/> Base options for behaviors
7
+ */
3
8
  export interface BaseBehaviorOptions extends CustomBehaviorOption {
4
9
  }
10
+ /**
11
+ * <zh/> 交互的基类
12
+ *
13
+ * <en/> Base class for behaviors
14
+ */
5
15
  export declare abstract class BaseBehavior<T extends BaseBehaviorOptions = BaseBehaviorOptions> extends BaseExtension<T> {
6
16
  }
@@ -1,5 +1,5 @@
1
1
  import type { RuntimeContext } from '../runtime/types';
2
- import type { EdgeDirection, IPointerEvent, State } from '../types';
2
+ import type { EdgeDirection, Element, IPointerEvent, State } from '../types';
3
3
  import type { BaseBehaviorOptions } from './base-behavior';
4
4
  import { BaseBehavior } from './base-behavior';
5
5
  /**
@@ -32,7 +32,7 @@ export interface HoverActivateOptions extends BaseBehaviorOptions {
32
32
  * - `1` means the current node and its directly adjacent nodes and edges are activated, etc
33
33
  * @defaultValue 0
34
34
  */
35
- degree?: number;
35
+ degree?: number | ((event: IPointerEvent) => number);
36
36
  /**
37
37
  * <zh/> 指定边的方向
38
38
  * - `'both'`: 表示激活当前节点的所有关系
@@ -88,6 +88,7 @@ export declare class HoverActivate extends BaseBehavior<HoverActivateOptions> {
88
88
  private toggleFrozen;
89
89
  private bindEvents;
90
90
  private hoverElement;
91
+ protected getActiveIds(event: IPointerEvent<Element>): string[];
91
92
  private updateElementsState;
92
93
  private getElementsState;
93
94
  private validate;
@@ -14,8 +14,6 @@ type ParsedLineStyleProps = Required<LineStyleProps>;
14
14
  * <zh/> 直线
15
15
  *
16
16
  * <en/> Line
17
- * @remarks
18
- * <img width="300" src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*YbpvTa4liAEAAAAAAAAAAAAADmJ7AQ/original" />
19
17
  */
20
18
  export declare class Line extends BaseEdge {
21
19
  static defaultStyleProps: Partial<LineStyleProps>;
@@ -3,31 +3,45 @@ import { CustomElement } from '@antv/g';
3
3
  import type { Keyframe } from '../../types';
4
4
  export interface BaseShapeStyleProps extends BaseStyleProps {
5
5
  }
6
+ /**
7
+ * <zh/> 图形基类
8
+ *
9
+ * <en/> Base class for shapes
10
+ */
6
11
  export declare abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends CustomElement<StyleProps> {
7
12
  constructor(options: DisplayObjectConfig<StyleProps>);
13
+ /**
14
+ * <zh/> 解析后的属性
15
+ *
16
+ * <en/> parsed attributes
17
+ * @returns <zh/> 解析后的属性 | <en/> parsed attributes
18
+ * @internal
19
+ */
8
20
  protected get parsedAttributes(): Required<StyleProps>;
9
21
  /**
10
- * <zh> 图形实例映射表
22
+ * <zh/> 图形实例映射表
11
23
  *
12
- * <en> shape instance map
24
+ * <en/> shape instance map
25
+ * @internal
13
26
  */
14
27
  protected shapeMap: Record<string, DisplayObject>;
15
28
  /**
16
- * <zh> 动画实例映射表
29
+ * <zh/> 动画实例映射表
17
30
  *
18
- * <en> animation instance map
31
+ * <en/> animation instance map
32
+ * @internal
19
33
  */
20
34
  protected animateMap: Record<string, IAnimation>;
21
35
  /**
22
- * <zh> 创建、更新或删除图形
36
+ * <zh/> 创建、更新或删除图形
23
37
  *
24
- * <en> create, update or remove shape
25
- * @param className - <zh> 图形名称 | <en> shape name
26
- * @param Ctor - <zh> 图形类型 | <en> shape type
27
- * @param style - <zh> 图形样式。若要删除图形,传入 false | <en> shape style. Pass false to remove the shape
28
- * @param container - <zh> 容器 | <en> container
29
- * @param hooks - <zh> 钩子函数 | <en> hooks
30
- * @returns <zh> 图形实例 | <en> shape instance
38
+ * <en/> create, update or remove shape
39
+ * @param className - <zh/> 图形名称 | <en/> shape name
40
+ * @param Ctor - <zh/> 图形类型 | <en/> shape type
41
+ * @param style - <zh/> 图形样式。若要删除图形,传入 false | <en/> shape style. Pass false to remove the shape
42
+ * @param container - <zh/> 容器 | <en/> container
43
+ * @param hooks - <zh/> 钩子函数 | <en/> hooks
44
+ * @returns <zh/> 图形实例 | <en/> shape instance
31
45
  */
32
46
  protected upsert<T extends DisplayObject>(className: string, Ctor: string | {
33
47
  new (...args: any[]): T;
@@ -41,9 +55,9 @@ export declare abstract class BaseShape<StyleProps extends BaseShapeStyleProps>
41
55
  protected transformPosition(attributes: Partial<StyleProps>): void;
42
56
  update(attr?: Partial<StyleProps>): void;
43
57
  /**
44
- * <zh> 在初始化时会被自动调用
58
+ * <zh/> 在初始化时会被自动调用
45
59
  *
46
- * <en> will be called automatically when initializing
60
+ * <en/> will be called automatically when initializing
47
61
  * @param attributes
48
62
  * @param container
49
63
  */
@@ -61,6 +75,7 @@ export declare abstract class BaseShape<StyleProps extends BaseShapeStyleProps>
61
75
  /**
62
76
  * Get the prefix pairs for composite shapes used to handle animation
63
77
  * @returns tuples array where each tuple contains a key corresponding to a method `get${key}Style` and its shape prefix
78
+ * @internal
64
79
  */
65
80
  protected get compositeShapes(): [string, string][];
66
81
  animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions): IAnimation | null;
@@ -6,7 +6,7 @@ export { effect } from './elements/effect';
6
6
  export { BaseNode, Circle, Diamond, Donut, Ellipse, HTML, Hexagon, Image, Rect, Star, Triangle, } from './elements/nodes';
7
7
  export { Badge, BaseShape, Icon, Label } from './elements/shapes';
8
8
  export { AntVDagreLayout, BaseLayout, CircularLayout, ComboCombinedLayout, compactBox as CompactBoxLayout, ConcentricLayout, D3ForceLayout, DagreLayout, dendrogram as DendrogramLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout, indented as IndentedLayout, MDSLayout, mindmap as MindmapLayout, RadialLayout, RandomLayout, } from './layouts';
9
- export { BasePlugin, BubbleSets, CameraSetting, Contextmenu, EdgeFilterLens, Fisheye, Fullscreen, GridLine, History, Hull, Legend, Minimap, Snapline, Timebar, Toolbar, Tooltip, Watermark, } from './plugins';
9
+ export { Background, BasePlugin, BubbleSets, CameraSetting, Contextmenu, EdgeFilterLens, Fisheye, Fullscreen, GridLine, History, Hull, Legend, Minimap, Snapline, Timebar, Toolbar, Tooltip, Watermark, } from './plugins';
10
10
  export { getExtension, getExtensions } from './registry/get';
11
11
  export { register } from './registry/register';
12
12
  export { Graph } from './runtime/graph';
@@ -34,7 +34,7 @@ export type { UpsertHooks } from './elements/shapes/base-shape';
34
34
  export type { ContourLabelStyleProps, ContourStyleProps } from './elements/shapes/contour';
35
35
  export type { BaseLayoutOptions, WebWorkerLayoutOptions } from './layouts/types';
36
36
  export type { CategoricalPalette } from './palettes/types';
37
- export type { BasePluginOptions, BubbleSetsOptions, CameraSettingOptions, ContextmenuOptions, EdgeFilterLensOptions, FisheyeOptions, FullscreenOptions, GridLineOptions, HistoryOptions, HullOptions, LegendOptions, MinimapOptions, SnaplineOptions, TimebarOptions, ToolbarOptions, TooltipOptions, WatermarkOptions, } from './plugins';
37
+ export type { BackgroundOptions, BasePluginOptions, BubbleSetsOptions, CameraSettingOptions, ContextmenuOptions, EdgeFilterLensOptions, FisheyeOptions, FullscreenOptions, GridLineOptions, HistoryOptions, HullOptions, LegendOptions, MinimapOptions, SnaplineOptions, TimebarOptions, ToolbarOptions, TooltipOptions, WatermarkOptions, } from './plugins';
38
38
  export type { DataURLOptions } from './runtime/canvas';
39
39
  export type { RuntimeContext } from './runtime/types';
40
40
  export type { BehaviorOptions, CanvasOptions, ComboData, ComboOptions, EdgeData, EdgeOptions, GraphData, GraphOptions, NodeData, NodeOptions, PluginOptions, ThemeOptions, ViewportOptions, } from './spec';
@@ -1,6 +1,11 @@
1
1
  import type { RuntimeContext } from '../runtime/types';
2
2
  import type { GraphData } from '../spec';
3
3
  import type { BaseLayoutOptions } from './types';
4
+ /**
5
+ * <zh/> 布局的基类
6
+ *
7
+ * <en/> Base class for layout
8
+ */
4
9
  export declare abstract class BaseLayout<O extends BaseLayoutOptions = any> {
5
10
  abstract id: string;
6
11
  options: O;
@@ -33,6 +33,7 @@ export declare class Background extends BasePlugin<BackgroundOptions> {
33
33
  * <zh/> 销毁背景图
34
34
  *
35
35
  * <en/> Destroy the background image
36
+ * @internal
36
37
  */
37
38
  destroy(): void;
38
39
  }
@@ -2,5 +2,10 @@ import { BaseExtension } from '../registry/extension';
2
2
  import type { CustomPluginOption } from '../spec/plugin';
3
3
  export interface BasePluginOptions extends CustomPluginOption {
4
4
  }
5
+ /**
6
+ * <zh/> 插件的基类
7
+ *
8
+ * <en/> Base class for plugins
9
+ */
5
10
  export declare abstract class BasePlugin<T extends BasePluginOptions> extends BaseExtension<T> {
6
11
  }
@@ -111,6 +111,7 @@ export declare class BubbleSets extends BasePlugin<BubbleSetsOptions> {
111
111
  * <zh/> 销毁
112
112
  *
113
113
  * <en/> Destroy
114
+ * @internal
114
115
  */
115
116
  destroy(): void;
116
117
  }
@@ -108,6 +108,7 @@ export declare class Contextmenu extends BasePlugin<ContextmenuOptions> {
108
108
  * <zh/> 销毁上下文菜单
109
109
  *
110
110
  * <en/> Destroy the contextmenu
111
+ * @internal
111
112
  */
112
113
  destroy(): void;
113
114
  private getDOMContent;
@@ -101,6 +101,7 @@ export declare class GridLine extends BasePlugin<GridLineOptions> {
101
101
  * <zh/> 销毁网格线
102
102
  *
103
103
  * <en/> Destroy the grid line
104
+ * @internal
104
105
  */
105
106
  destroy(): void;
106
107
  }
@@ -114,6 +114,7 @@ export declare class History extends BasePlugin<HistoryOptions> {
114
114
  * <zh/> 销毁
115
115
  *
116
116
  * <en/> Destroy
117
+ * @internal
117
118
  */
118
119
  destroy(): void;
119
120
  }
@@ -109,6 +109,7 @@ export declare class Hull extends BasePlugin<HullOptions> {
109
109
  * <zh/> 销毁 Hull
110
110
  *
111
111
  * <en/> Destroy Hull
112
+ * @internal
112
113
  */
113
114
  destroy(): void;
114
115
  }
@@ -124,6 +124,7 @@ export declare class Legend extends BasePlugin<LegendOptions> {
124
124
  * <zh/>销毁图例
125
125
  *
126
126
  * <en/> Destroy the legend
127
+ * @internal
127
128
  */
128
129
  destroy(): void;
129
130
  }
@@ -4,15 +4,16 @@ import type { ElementType, Padding, Placement } from '../../types';
4
4
  import type { BasePluginOptions } from '../base-plugin';
5
5
  import { BasePlugin } from '../base-plugin';
6
6
  /**
7
- * <zh/> 缩略图插件的配置项
7
+ * <zh/> 缩略图插件配置项
8
8
  *
9
- * <en/> The configuration item of the Minimap plugin
9
+ * <en/> Minimap plugin options
10
10
  */
11
11
  export interface MinimapOptions extends BasePluginOptions {
12
12
  /**
13
13
  * <zh/> 宽度和高度
14
14
  *
15
15
  * <en/> Width and height
16
+ * @defaultValue [240, 160]
16
17
  */
17
18
  size?: [number, number];
18
19
  /**
@@ -84,6 +85,11 @@ export interface MinimapOptions extends BasePluginOptions {
84
85
  */
85
86
  renderer?: IRenderer;
86
87
  }
88
+ /**
89
+ * <zh/> 缩略图插件
90
+ *
91
+ * <en/> Minimap plugin
92
+ */
87
93
  export declare class Minimap extends BasePlugin<MinimapOptions> {
88
94
  static defaultOptions: Partial<MinimapOptions>;
89
95
  private canvas;
@@ -3,6 +3,11 @@ import type { RuntimeContext } from '../../runtime/types';
3
3
  import type { IDragEvent, Node } from '../../types';
4
4
  import type { BasePluginOptions } from '../base-plugin';
5
5
  import { BasePlugin } from '../base-plugin';
6
+ /**
7
+ * <zh/> 对齐线插件配置项
8
+ *
9
+ * <en/> Snapline plugin options
10
+ */
6
11
  export interface SnaplineOptions extends BasePluginOptions {
7
12
  /**
8
13
  * <zh/> 对齐精度,即移动节点时与目标位置的距离小于 tolerance 时触发显示对齐线
@@ -62,6 +67,11 @@ export interface SnaplineOptions extends BasePluginOptions {
62
67
  */
63
68
  filter?: (node: Node) => boolean;
64
69
  }
70
+ /**
71
+ * <zh/> 对齐线插件
72
+ *
73
+ * <en/> Snapline plugin
74
+ */
65
75
  export declare class Snapline extends BasePlugin<SnaplineOptions> {
66
76
  static defaultOptions: Partial<SnaplineOptions>;
67
77
  private horizontalLine;
@@ -236,6 +236,7 @@ export declare class Timebar extends BasePlugin<TimebarOptions> {
236
236
  * <zh/> 销毁时间条
237
237
  *
238
238
  * <en/> Destroy the timebar
239
+ * @internal
239
240
  */
240
241
  destroy(): void;
241
242
  }
@@ -62,6 +62,7 @@ export declare class Toolbar extends BasePlugin<ToolbarOptions> {
62
62
  * <zh/> 销毁工具栏
63
63
  *
64
64
  * <en/> Destroy the toolbar
65
+ * @internal
65
66
  */
66
67
  destroy(): void;
67
68
  private getDOMContent;
@@ -3,6 +3,11 @@ import type { RuntimeContext } from '../runtime/types';
3
3
  import type { ElementDatum, ID, IElementEvent } from '../types';
4
4
  import type { BasePluginOptions } from './base-plugin';
5
5
  import { BasePlugin } from './base-plugin';
6
+ /**
7
+ * <zh/> 提示框插件配置项
8
+ *
9
+ * <en/> Tooltip plugin options
10
+ */
6
11
  export interface TooltipOptions extends BasePluginOptions, Pick<TooltipStyleProps, 'position' | 'offset' | 'enterable' | 'style' | 'container' | 'title'> {
7
12
  /**
8
13
  * <zh/> 触发行为,可选 hover | click
@@ -29,6 +34,11 @@ export interface TooltipOptions extends BasePluginOptions, Pick<TooltipStyleProp
29
34
  */
30
35
  enable?: boolean | ((event: IElementEvent) => boolean);
31
36
  }
37
+ /**
38
+ * <zh/> 提示框插件
39
+ *
40
+ * <en/> Tooltip plugin
41
+ */
32
42
  export declare class Tooltip extends BasePlugin<TooltipOptions> {
33
43
  static defaultOptions: Partial<TooltipOptions>;
34
44
  private currentTarget;
@@ -112,6 +122,7 @@ export declare class Tooltip extends BasePlugin<TooltipOptions> {
112
122
  * <zh/> 销毁tooltip
113
123
  *
114
124
  * <en/> Destroy tooltip
125
+ * @internal
115
126
  */
116
127
  destroy(): void;
117
128
  }
@@ -186,6 +186,7 @@ export declare class Watermark extends BasePlugin<WatermarkOptions> {
186
186
  * <zh/> 销毁水印
187
187
  *
188
188
  * <en/> Destroy the watermark
189
+ * @internal
189
190
  */
190
191
  destroy(): void;
191
192
  }
@@ -3,6 +3,11 @@ import type { DrawContext } from '../runtime/element';
3
3
  import type { CustomBehaviorOption } from '../spec/behavior';
4
4
  import type { DrawData } from './types';
5
5
  export type BaseTransformOptions = CustomBehaviorOption;
6
+ /**
7
+ * <zh/> 数据转换的基类
8
+ *
9
+ * <en/> Base class for data transforms
10
+ */
6
11
  export declare abstract class BaseTransform<T extends BaseTransformOptions = BaseTransformOptions> extends BaseExtension<T> {
7
12
  beforeDraw(data: DrawData, context: DrawContext): DrawData;
8
13
  afterLayout(): void;
@@ -7,16 +7,14 @@ import { BaseTransform } from './base-transform';
7
7
  import type { DrawData } from './types';
8
8
  export interface ProcessParallelEdgesOptions extends BaseTransformOptions {
9
9
  /**
10
- * <zh/> 处理模式,默认为捆绑
10
+ * <zh/> 处理模式
11
+ * - `'merge'`: 将平行边合并为一条边,适用于不需要区分平行边的情况
12
+ * - '`bundle`': 每条边都会与其他所有平行边捆绑在一起,并通过改变曲率与其他边分开。如果一组平行边的数量是奇数,那么中心的边将被绘制为直线,其他的边将被绘制为曲线
11
13
  *
12
- * <en/> Processing mode, default is bundle
13
- * @remarks
14
- * <zh/>
15
- * - merge: 将平行边合并为一条边,适用于不需要区分平行边的情况
16
- * - bundle: 每条边都会与其他所有平行边捆绑在一起,并通过改变曲率与其他边分开。如果一组平行边的数量是奇数,那么中心的边将被绘制为直线,其他的边将被绘制为曲线
17
- * <en/>
18
- * - merge: Merge parallel edges into one edge which is suitable for cases where parallel edges do not need to be distinguished
19
- * - bundle: Each edge will be bundled with all other parallel edges and separated from them by varying the curvature. If the number of parallel edges in a group is odd, the central edge will be drawn as a straight line, and the others will be drawn as curves
14
+ * <en/> Processing mode
15
+ * - '`merge`': Merge parallel edges into one edge which is suitable for cases where parallel edges do not need to be distinguished
16
+ * - '`bundle`': Each edge will be bundled with all other parallel edges and separated from them by varying the curvature. If the number of parallel edges in a group is odd, the central edge will be drawn as a straight line, and the others will be drawn as curves
17
+ * @defaultValue 'bundle'
20
18
  */
21
19
  mode: 'bundle' | 'merge';
22
20
  /**
@@ -4,10 +4,10 @@ import type { DrawData } from './types';
4
4
  * <zh/> 重新分配绘制任务
5
5
  *
6
6
  * <en/> Reassign drawing tasks
7
- * @param input - <zh>绘制数据 | <en>DrawData
8
- * @param type - <zh>类型 | <en>type
9
- * @param elementType - <zh>元素类型 | <en>element type
10
- * @param datum - <zh>数据 | <en>data
11
- * @param overwrite - <zh>是否覆盖现有数据 | <en>whether to overwrite existing data
7
+ * @param input - <zh/>绘制数据 | <en/>DrawData
8
+ * @param type - <zh/>类型 | <en/>type
9
+ * @param elementType - <zh/>元素类型 | <en/>element type
10
+ * @param datum - <zh/>数据 | <en/>data
11
+ * @param overwrite - <zh/>是否覆盖现有数据 | <en/>whether to overwrite existing data
12
12
  */
13
13
  export declare function reassignTo(input: DrawData, type: 'add' | 'update' | 'remove', elementType: ElementType, datum: ElementDatum, overwrite?: boolean): void;
@@ -84,6 +84,15 @@ export declare function isPointOnBBoxBoundary(point: Point, bbox: AABB, extended
84
84
  * @returns <zh/> 如果点在包围盒外返回 true,否则返回 false | <en/> Returns true if the point is outside the bounding box, false otherwise
85
85
  */
86
86
  export declare function isPointOutsideBBox(point: Point, bbox: AABB): boolean;
87
+ /**
88
+ * <zh/> 判断点是否位于包围盒中心
89
+ *
90
+ * <en/> When the point is at the center of the bounding box
91
+ * @param point - <zh/> 点 | <en/> Point
92
+ * @param bbox - <zh/> 包围盒 | <en/> Bounding box
93
+ * @returns <zh/> 如果点在包围盒中心返回 true,否则返回 false | <en/> Returns true if the point is at the center of the bounding box, false otherwise
94
+ */
95
+ export declare function isPointBBoxCenter(point: Point, bbox: AABB): boolean;
87
96
  /**
88
97
  * <zh/> 获取包围盒上离点 `p` 最近的边
89
98
  *
@@ -92,16 +101,16 @@ export declare function isPointOutsideBBox(point: Point, bbox: AABB): boolean;
92
101
  * @param p - <zh/> 点 | <en/> Point
93
102
  * @returns <zh/> 离点 `p` 最近的边 | <en/> The side nearest to the point `p`
94
103
  */
95
- export declare function getNearestSideToPoint(bbox: AABB, p: Point): 'left' | 'right' | 'top' | 'bottom';
104
+ export declare function getNearestBoundarySide(p: Point, bbox: AABB): 'left' | 'right' | 'top' | 'bottom';
96
105
  /**
97
- * <zh/> 获取包围盒上离点 `p` 最近的点
106
+ * <zh/> 获取包围盒上离点 `p` 最近的边界点
98
107
  *
99
108
  * <en/> Get a point on the boundary nearest to the point `p`
100
109
  * @param bbox - <zh/> 包围盒 | <en/> Bounding box
101
110
  * @param p - <zh/> 点 | <en/> Point
102
111
  * @returns <zh/> 离点 `p` 最近的点 | <en/> The point nearest to the point `p`
103
112
  */
104
- export declare function getNearestPointToPoint(bbox: AABB, p: Point): Point;
113
+ export declare function getNearestBoundaryPoint(p: Point, bbox: AABB): Point;
105
114
  /**
106
115
  * The triangle center point of the bounding box
107
116
  * @param bbox - bounding box
@@ -1,9 +1,9 @@
1
1
  import type { Padding, STDPadding } from '../types/padding';
2
2
  /**
3
- * <zh> 解析 padding
3
+ * <zh/> 解析 padding
4
4
  *
5
- * <en> parse padding
6
- * @param padding - <zh> padding | <en> padding
7
- * @returns <zh> 标准 padding | <en> standard padding
5
+ * <en/> parse padding
6
+ * @param padding - <zh/> padding | <en/> padding
7
+ * @returns <zh/> 标准 padding | <en/> standard padding
8
8
  */
9
9
  export declare function parsePadding(padding?: Padding): STDPadding;
@@ -55,7 +55,7 @@ export declare function subObject(obj: Record<string, any>, prefix: string): Rec
55
55
  */
56
56
  export declare function omitStyleProps<T extends Record<string, any>>(style: Record<string, any>, prefix: string | string[]): T;
57
57
  /**
58
- * <zh> 替换前缀
58
+ * <zh/> 替换前缀
59
59
  *
60
60
  * <en/> Replace prefix
61
61
  * @param style - <zh/> 样式 | <en/> style
@@ -17,7 +17,7 @@ type Route = {
17
17
  * @param options - <zh/> 配置项 | <en/> options
18
18
  * @returns <zh/> 路径点集 | <en/> vertices
19
19
  */
20
- export declare function orth(sourcePoint: Point, targetPoint: Point, sourceNode: Node, targetNode: Node, controlPoints: Point[], options: OrthRouterOptions): Point[];
20
+ export declare function orth(sourcePoint: Point, targetPoint: Point, sourceNode: Node, targetNode: Node, controlPoints: Point[], options: OrthRouterOptions): import("../../types").Vector2[];
21
21
  /**
22
22
  * <zh/> 获取两点之间的方向,从 `from` 到 `to` 的方向
23
23
  *
@@ -1,6 +1,8 @@
1
1
  import type { STDSize, Size } from '../types';
2
2
  /**
3
- * <zh/> 解析尺寸配置 | <en/> Parse size configuration
3
+ * <zh/> 解析尺寸配置
4
+ *
5
+ * <en/> Parse size configuration
4
6
  * @param size - <zh/> 尺寸配置 | <en/> size configuration
5
7
  * @returns <zh/> 标准尺寸格式 | <en/> standard size format
6
8
  */
@@ -15,10 +15,10 @@ export declare function replaceTranslateInTransform(x: number, y: number, z: num
15
15
  * <zh/> 重新分配绘制任务
16
16
  *
17
17
  * <en/> Reassign drawing tasks
18
- * @param input - <zh>绘制数据 | <en>DrawData
19
- * @param type - <zh>类型 | <en>type
20
- * @param elementType - <zh>元素类型 | <en>element type
21
- * @param datum - <zh>数据 | <en>data
22
- * @param merge - <zh>是否合并 | <en>whether to merge
18
+ * @param input - <zh/>绘制数据 | <en/>DrawData
19
+ * @param type - <zh/>类型 | <en/>type
20
+ * @param elementType - <zh/>元素类型 | <en/>element type
21
+ * @param datum - <zh/>数据 | <en/>data
22
+ * @param merge - <zh/>是否合并 | <en/>whether to merge
23
23
  */
24
24
  export declare const reassignTo: (input: DrawData, type: "add" | "update" | "remove", elementType: ElementType, datum: ElementDatum, merge?: boolean) => void;
@@ -1 +1 @@
1
- export declare const version = "5.0.20";
1
+ export declare const version = "5.0.21";
@@ -1,6 +1,16 @@
1
1
  import { BaseExtension } from '../registry/extension';
2
2
  import type { CustomBehaviorOption } from '../spec/behavior';
3
+ /**
4
+ * <zh/> 交互通用配置项
5
+ *
6
+ * <en/> Base options for behaviors
7
+ */
3
8
  export interface BaseBehaviorOptions extends CustomBehaviorOption {
4
9
  }
10
+ /**
11
+ * <zh/> 交互的基类
12
+ *
13
+ * <en/> Base class for behaviors
14
+ */
5
15
  export declare abstract class BaseBehavior<T extends BaseBehaviorOptions = BaseBehaviorOptions> extends BaseExtension<T> {
6
16
  }
@@ -1,4 +1,9 @@
1
1
  import { BaseExtension } from '../registry/extension';
2
+ /**
3
+ * <zh/> 交互的基类
4
+ *
5
+ * <en/> Base class for behaviors
6
+ */
2
7
  export class BaseBehavior extends BaseExtension {
3
8
  }
4
9
  //# sourceMappingURL=base-behavior.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-behavior.js","sourceRoot":"src/","sources":["behaviors/base-behavior.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAKtD,MAAM,OAAgB,YAAkE,SAAQ,aAAgB;CAAG"}
1
+ {"version":3,"file":"base-behavior.js","sourceRoot":"src/","sources":["behaviors/base-behavior.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAUtD;;;;GAIG;AACH,MAAM,OAAgB,YAAkE,SAAQ,aAAgB;CAAG"}
@@ -1,5 +1,5 @@
1
1
  import type { RuntimeContext } from '../runtime/types';
2
- import type { EdgeDirection, IPointerEvent, State } from '../types';
2
+ import type { EdgeDirection, Element, IPointerEvent, State } from '../types';
3
3
  import type { BaseBehaviorOptions } from './base-behavior';
4
4
  import { BaseBehavior } from './base-behavior';
5
5
  /**
@@ -32,7 +32,7 @@ export interface HoverActivateOptions extends BaseBehaviorOptions {
32
32
  * - `1` means the current node and its directly adjacent nodes and edges are activated, etc
33
33
  * @defaultValue 0
34
34
  */
35
- degree?: number;
35
+ degree?: number | ((event: IPointerEvent) => number);
36
36
  /**
37
37
  * <zh/> 指定边的方向
38
38
  * - `'both'`: 表示激活当前节点的所有关系
@@ -88,6 +88,7 @@ export declare class HoverActivate extends BaseBehavior<HoverActivateOptions> {
88
88
  private toggleFrozen;
89
89
  private bindEvents;
90
90
  private hoverElement;
91
+ protected getActiveIds(event: IPointerEvent<Element>): string[];
91
92
  private updateElementsState;
92
93
  private getElementsState;
93
94
  private validate;
@@ -52,15 +52,20 @@ export class HoverActivate extends BaseBehavior {
52
52
  else
53
53
  onHoverEnd?.(event);
54
54
  };
55
+ getActiveIds(event) {
56
+ const { graph } = this.context;
57
+ const { degree, direction } = this.options;
58
+ const { targetType, target } = event;
59
+ return degree
60
+ ? getElementNthDegreeIds(graph, targetType, target.id, typeof degree === 'function' ? degree(event) : degree, direction)
61
+ : [target.id];
62
+ }
55
63
  updateElementsState = (event, add) => {
56
64
  if (!this.options.state && !this.options.inactiveState)
57
65
  return;
58
66
  const { graph } = this.context;
59
- const { state, degree, direction, animation, inactiveState } = this.options;
60
- const { targetType, target } = event;
61
- const activeIds = degree
62
- ? getElementNthDegreeIds(graph, targetType, target.id, degree, direction)
63
- : [target.id];
67
+ const { state, animation, inactiveState } = this.options;
68
+ const activeIds = this.getActiveIds(event);
64
69
  const states = {};
65
70
  if (state) {
66
71
  Object.assign(states, this.getElementsState(activeIds, state, add));
@@ -76,8 +81,12 @@ export class HoverActivate extends BaseBehavior {
76
81
  const states = {};
77
82
  ids.forEach((id) => {
78
83
  const currentState = graph.getElementState(id);
79
- const updatedState = add ? [...currentState, state] : currentState.filter((s) => s !== state);
80
- states[id] = updatedState;
84
+ if (add) {
85
+ states[id] = currentState.includes(state) ? currentState : [...currentState, state];
86
+ }
87
+ else {
88
+ states[id] = currentState.filter((s) => s !== state);
89
+ }
81
90
  });
82
91
  return states;
83
92
  };