@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.
- package/dist/g6.min.js +2 -2
- package/dist/lib/behaviors/collapse-expand.d.ts +4 -5
- package/dist/lib/behaviors/create-edge.d.ts +55 -0
- package/dist/lib/behaviors/drag-canvas.d.ts +6 -6
- package/dist/lib/behaviors/drag-element.d.ts +5 -3
- package/dist/lib/behaviors/focus-element.d.ts +4 -3
- package/dist/lib/behaviors/hover-element.d.ts +4 -5
- package/dist/lib/behaviors/index.d.ts +2 -0
- package/dist/lib/behaviors/zoom-canvas.d.ts +7 -6
- package/dist/lib/constants/events/graph.d.ts +5 -13
- package/dist/lib/constants/index.d.ts +1 -0
- package/dist/lib/constants/registry.d.ts +20 -0
- package/dist/lib/elements/combos/base-combo.d.ts +21 -0
- package/dist/lib/elements/edges/base-edge.d.ts +21 -0
- package/dist/lib/elements/nodes/base-node.d.ts +22 -1
- package/dist/lib/exports.d.ts +16 -14
- package/dist/lib/plugins/camera-setting.d.ts +95 -0
- package/dist/lib/plugins/contextmenu.d.ts +8 -5
- package/dist/lib/plugins/index.d.ts +4 -0
- package/dist/lib/plugins/legend.d.ts +49 -0
- package/dist/lib/plugins/tooltip.d.ts +12 -10
- package/dist/lib/registry/extension/index.d.ts +2 -2
- package/dist/lib/registry/index.d.ts +6 -4
- package/dist/lib/registry/types.d.ts +0 -6
- package/dist/lib/runtime/canvas.d.ts +2 -1
- package/dist/lib/runtime/data.d.ts +1 -1
- package/dist/lib/runtime/element.d.ts +4 -5
- package/dist/lib/runtime/graph.d.ts +31 -4
- package/dist/lib/runtime/plugin.d.ts +1 -0
- package/dist/lib/types/event.d.ts +42 -7
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/utils/bbox.d.ts +1 -1
- package/dist/lib/utils/element.d.ts +19 -11
- package/dist/lib/utils/event/events.d.ts +8 -13
- package/dist/lib/utils/shortcut.d.ts +10 -0
- package/esm/behaviors/collapse-expand.d.ts +4 -5
- package/esm/behaviors/collapse-expand.js +8 -4
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/create-edge.d.ts +55 -0
- package/esm/behaviors/create-edge.js +141 -0
- package/esm/behaviors/create-edge.js.map +1 -0
- package/esm/behaviors/drag-canvas.d.ts +6 -6
- package/esm/behaviors/drag-canvas.js +15 -7
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element.d.ts +5 -3
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/focus-element.d.ts +4 -3
- package/esm/behaviors/focus-element.js.map +1 -1
- package/esm/behaviors/hover-element.d.ts +4 -5
- package/esm/behaviors/hover-element.js.map +1 -1
- package/esm/behaviors/index.d.ts +2 -0
- package/esm/behaviors/index.js +1 -0
- package/esm/behaviors/index.js.map +1 -1
- package/esm/behaviors/zoom-canvas.d.ts +7 -6
- package/esm/behaviors/zoom-canvas.js +6 -2
- package/esm/behaviors/zoom-canvas.js.map +1 -1
- package/esm/constants/events/graph.d.ts +5 -13
- package/esm/constants/events/graph.js +4 -12
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/constants/index.d.ts +1 -0
- package/esm/constants/index.js +1 -0
- package/esm/constants/index.js.map +1 -1
- package/esm/constants/registry.d.ts +20 -0
- package/esm/constants/registry.js +22 -0
- package/esm/constants/registry.js.map +1 -0
- package/esm/elements/combos/base-combo.d.ts +21 -0
- package/esm/elements/combos/base-combo.js +21 -0
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/edges/base-edge.d.ts +21 -0
- package/esm/elements/edges/base-edge.js +21 -0
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +22 -1
- package/esm/elements/nodes/base-node.js +21 -0
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/exports.d.ts +16 -14
- package/esm/exports.js +7 -6
- package/esm/exports.js.map +1 -1
- package/esm/plugins/camera-setting.d.ts +95 -0
- package/esm/plugins/camera-setting.js +65 -0
- package/esm/plugins/camera-setting.js.map +1 -0
- package/esm/plugins/contextmenu.d.ts +8 -5
- package/esm/plugins/contextmenu.js.map +1 -1
- package/esm/plugins/index.d.ts +4 -0
- package/esm/plugins/index.js +2 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/legend.d.ts +49 -0
- package/esm/plugins/legend.js +267 -0
- package/esm/plugins/legend.js.map +1 -0
- package/esm/plugins/tooltip.d.ts +12 -10
- package/esm/plugins/tooltip.js +0 -1
- package/esm/plugins/tooltip.js.map +1 -1
- package/esm/preset.js +2 -5
- package/esm/preset.js.map +1 -1
- package/esm/registry/build-in.js +4 -2
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/extension/index.d.ts +2 -2
- package/esm/registry/extension/index.js.map +1 -1
- package/esm/registry/index.d.ts +6 -4
- package/esm/registry/index.js.map +1 -1
- package/esm/registry/types.d.ts +0 -6
- package/esm/runtime/behavior.js +3 -2
- package/esm/runtime/behavior.js.map +1 -1
- package/esm/runtime/canvas.d.ts +2 -1
- package/esm/runtime/canvas.js +68 -30
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +1 -1
- package/esm/runtime/element.d.ts +4 -5
- package/esm/runtime/element.js +32 -13
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +31 -4
- package/esm/runtime/graph.js +48 -9
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/plugin.d.ts +1 -0
- package/esm/runtime/plugin.js +3 -0
- package/esm/runtime/plugin.js.map +1 -1
- package/esm/types/event.d.ts +42 -7
- package/esm/types/index.d.ts +0 -1
- package/esm/utils/bbox.d.ts +1 -1
- package/esm/utils/element.d.ts +19 -11
- package/esm/utils/element.js +19 -9
- package/esm/utils/element.js.map +1 -1
- package/esm/utils/event/events.d.ts +8 -13
- package/esm/utils/event/events.js +3 -8
- package/esm/utils/event/events.js.map +1 -1
- package/esm/utils/shortcut.d.ts +10 -0
- package/esm/utils/shortcut.js +24 -3
- package/esm/utils/shortcut.js.map +1 -1
- package/lib/behaviors/collapse-expand.d.ts +4 -5
- package/lib/behaviors/collapse-expand.js +8 -4
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/create-edge.d.ts +55 -0
- package/lib/behaviors/create-edge.js +145 -0
- package/lib/behaviors/create-edge.js.map +1 -0
- package/lib/behaviors/drag-canvas.d.ts +6 -6
- package/lib/behaviors/drag-canvas.js +15 -7
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element.d.ts +5 -3
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/focus-element.d.ts +4 -3
- package/lib/behaviors/focus-element.js.map +1 -1
- package/lib/behaviors/hover-element.d.ts +4 -5
- package/lib/behaviors/hover-element.js.map +1 -1
- package/lib/behaviors/index.d.ts +2 -0
- package/lib/behaviors/index.js +3 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/behaviors/zoom-canvas.d.ts +7 -6
- package/lib/behaviors/zoom-canvas.js +6 -2
- package/lib/behaviors/zoom-canvas.js.map +1 -1
- package/lib/constants/events/graph.d.ts +5 -13
- package/lib/constants/events/graph.js +4 -12
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +1 -0
- package/lib/constants/index.js.map +1 -1
- package/lib/constants/registry.d.ts +20 -0
- package/lib/constants/registry.js +25 -0
- package/lib/constants/registry.js.map +1 -0
- package/lib/elements/combos/base-combo.d.ts +21 -0
- package/lib/elements/combos/base-combo.js +21 -0
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/edges/base-edge.d.ts +21 -0
- package/lib/elements/edges/base-edge.js +21 -0
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +22 -1
- package/lib/elements/nodes/base-node.js +21 -0
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/exports.d.ts +16 -14
- package/lib/exports.js +23 -1
- package/lib/exports.js.map +1 -1
- package/lib/plugins/camera-setting.d.ts +95 -0
- package/lib/plugins/camera-setting.js +69 -0
- package/lib/plugins/camera-setting.js.map +1 -0
- package/lib/plugins/contextmenu.d.ts +8 -5
- package/lib/plugins/contextmenu.js.map +1 -1
- package/lib/plugins/index.d.ts +4 -0
- package/lib/plugins/index.js +5 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/legend.d.ts +49 -0
- package/lib/plugins/legend.js +271 -0
- package/lib/plugins/legend.js.map +1 -0
- package/lib/plugins/tooltip.d.ts +12 -10
- package/lib/plugins/tooltip.js +0 -1
- package/lib/plugins/tooltip.js.map +1 -1
- package/lib/preset.js +2 -5
- package/lib/preset.js.map +1 -1
- package/lib/registry/build-in.js +2 -0
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/extension/index.d.ts +2 -2
- package/lib/registry/extension/index.js.map +1 -1
- package/lib/registry/index.d.ts +6 -4
- package/lib/registry/index.js.map +1 -1
- package/lib/registry/types.d.ts +0 -6
- package/lib/runtime/behavior.js +3 -2
- package/lib/runtime/behavior.js.map +1 -1
- package/lib/runtime/canvas.d.ts +2 -1
- package/lib/runtime/canvas.js +68 -30
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +1 -1
- package/lib/runtime/element.d.ts +4 -5
- package/lib/runtime/element.js +31 -12
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +31 -4
- package/lib/runtime/graph.js +47 -8
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/plugin.d.ts +1 -0
- package/lib/runtime/plugin.js +3 -0
- package/lib/runtime/plugin.js.map +1 -1
- package/lib/types/event.d.ts +42 -7
- package/lib/types/index.d.ts +0 -1
- package/lib/utils/bbox.d.ts +1 -1
- package/lib/utils/element.d.ts +19 -11
- package/lib/utils/element.js +21 -10
- package/lib/utils/element.js.map +1 -1
- package/lib/utils/event/events.d.ts +8 -13
- package/lib/utils/event/events.js +4 -10
- package/lib/utils/event/events.js.map +1 -1
- package/lib/utils/shortcut.d.ts +10 -0
- package/lib/utils/shortcut.js +24 -3
- package/lib/utils/shortcut.js.map +1 -1
- package/package.json +2 -2
- package/src/behaviors/collapse-expand.ts +13 -11
- package/src/behaviors/create-edge.ts +206 -0
- package/src/behaviors/drag-canvas.ts +22 -14
- package/src/behaviors/drag-element.ts +8 -11
- package/src/behaviors/focus-element.ts +7 -6
- package/src/behaviors/hover-element.ts +14 -10
- package/src/behaviors/index.ts +2 -0
- package/src/behaviors/zoom-canvas.ts +14 -9
- package/src/constants/events/graph.ts +4 -12
- package/src/constants/index.ts +1 -0
- package/src/constants/registry.ts +20 -0
- package/src/elements/combos/base-combo.ts +24 -0
- package/src/elements/edges/base-edge.ts +25 -1
- package/src/elements/nodes/base-node.ts +25 -1
- package/src/exports.ts +55 -12
- package/src/plugins/camera-setting.ts +153 -0
- package/src/plugins/contextmenu.ts +10 -7
- package/src/plugins/index.ts +4 -0
- package/src/plugins/legend.ts +321 -0
- package/src/plugins/tooltip.ts +16 -15
- package/src/preset.ts +2 -6
- package/src/registry/build-in.ts +12 -2
- package/src/registry/extension/index.ts +4 -4
- package/src/registry/index.ts +10 -4
- package/src/registry/types.ts +0 -7
- package/src/runtime/behavior.ts +3 -2
- package/src/runtime/canvas.ts +80 -40
- package/src/runtime/element.ts +52 -20
- package/src/runtime/graph.ts +56 -12
- package/src/runtime/plugin.ts +4 -0
- package/src/types/event.ts +62 -7
- package/src/types/index.ts +0 -1
- package/src/utils/bbox.ts +1 -1
- package/src/utils/element.ts +22 -11
- package/src/utils/event/events.ts +15 -17
- package/src/utils/shortcut.ts +28 -3
- package/dist/lib/types/behavior.d.ts +0 -5
- package/esm/types/behavior.d.ts +0 -5
- package/esm/types/behavior.js +0 -2
- package/esm/types/behavior.js.map +0 -1
- package/lib/types/behavior.d.ts +0 -5
- package/lib/types/behavior.js +0 -3
- package/lib/types/behavior.js.map +0 -1
- package/src/types/behavior.ts +0 -6
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { CategoryOptions } from '@antv/component';
|
|
2
|
+
import { Selection } from '@antv/component';
|
|
3
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
4
|
+
import type { ElementDatum } from '../types';
|
|
5
|
+
import type { CardinalPlacement } from '../types/placement';
|
|
6
|
+
import type { BasePluginOptions } from './base-plugin';
|
|
7
|
+
import { BasePlugin } from './base-plugin';
|
|
8
|
+
type Field = string | ((item: ElementDatum) => string);
|
|
9
|
+
export interface LegendOptions extends BasePluginOptions, Omit<CategoryOptions, 'data'> {
|
|
10
|
+
/** <zh/> 触发方式 | <en/> Event type that triggers display of legend */
|
|
11
|
+
trigger?: 'hover' | 'click';
|
|
12
|
+
/** <zh/> 位置 | <en/> Legend position */
|
|
13
|
+
position?: CardinalPlacement;
|
|
14
|
+
/** <zh/> 节点分类标识 | <en/> Node Classification Identifier */
|
|
15
|
+
nodeField?: Field;
|
|
16
|
+
/** <zh/> 边分类标识 | <en/> Edge Classification Identifier */
|
|
17
|
+
edgeField?: Field;
|
|
18
|
+
/** <zh/> Combo分类标识 | <en/> Combo Classification Identifier */
|
|
19
|
+
comboField?: Field;
|
|
20
|
+
}
|
|
21
|
+
export declare class Legend extends BasePlugin<LegendOptions> {
|
|
22
|
+
static defaultOptions: Partial<LegendOptions>;
|
|
23
|
+
private typePrefix;
|
|
24
|
+
private element;
|
|
25
|
+
private draw;
|
|
26
|
+
private fieldMap;
|
|
27
|
+
private selectedItems;
|
|
28
|
+
constructor(context: RuntimeContext, options: LegendOptions);
|
|
29
|
+
update(options: Partial<LegendOptions>): void;
|
|
30
|
+
private clear;
|
|
31
|
+
private bindEvents;
|
|
32
|
+
private changeState;
|
|
33
|
+
click: (el: Selection) => void;
|
|
34
|
+
mouseleave: (el: Selection) => void;
|
|
35
|
+
mouseenter: (el: Selection) => void;
|
|
36
|
+
updateElement(): void;
|
|
37
|
+
private setFieldMap;
|
|
38
|
+
private getEvents;
|
|
39
|
+
private getMarkerData;
|
|
40
|
+
layout: (position: CardinalPlacement) => {
|
|
41
|
+
display: string;
|
|
42
|
+
flexDirection: string;
|
|
43
|
+
justifyContent: string;
|
|
44
|
+
alignItems: string;
|
|
45
|
+
};
|
|
46
|
+
private createElement;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { TooltipStyleProps } from '@antv/component';
|
|
2
2
|
import type { RuntimeContext } from '../runtime/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Element, ElementDatum, ElementType, IPointerEvent } from '../types';
|
|
4
4
|
import type { BasePluginOptions } from './base-plugin';
|
|
5
5
|
import { BasePlugin } from './base-plugin';
|
|
6
6
|
export interface TooltipOptions extends BasePluginOptions, Pick<TooltipStyleProps, 'position' | 'offset' | 'enterable' | 'style' | 'container'> {
|
|
7
7
|
/** <zh/> 触发方式 | <en/> Event type that triggers display of tooltip */
|
|
8
8
|
trigger?: 'hover' | 'click';
|
|
9
9
|
/** <zh/> 自定义内容 | <en/> Function for getting tooltip content */
|
|
10
|
-
getContent?: (evt:
|
|
10
|
+
getContent?: (evt: IElementEvent, items: ElementDatum[]) => HTMLElement | string;
|
|
11
11
|
/** <zh/> 是否启用 | <en/> Is enable */
|
|
12
|
-
enable?: boolean | ((evt:
|
|
12
|
+
enable?: boolean | ((evt: IElementEvent) => boolean);
|
|
13
13
|
}
|
|
14
14
|
export declare class Tooltip extends BasePlugin<TooltipOptions> {
|
|
15
15
|
static defaultOptions: Partial<TooltipOptions>;
|
|
@@ -18,22 +18,24 @@ export declare class Tooltip extends BasePlugin<TooltipOptions> {
|
|
|
18
18
|
private container;
|
|
19
19
|
constructor(context: RuntimeContext, options: TooltipOptions);
|
|
20
20
|
getEvents(): {
|
|
21
|
-
[key: string]:
|
|
21
|
+
[key: string]: (event: IElementEvent) => void;
|
|
22
22
|
};
|
|
23
23
|
update(options: Partial<TooltipOptions>): void;
|
|
24
24
|
private render;
|
|
25
25
|
private unbindEvents;
|
|
26
26
|
private bindEvents;
|
|
27
27
|
private isEnable;
|
|
28
|
-
onClick: (e:
|
|
29
|
-
onPointerMove: (e:
|
|
30
|
-
onPointerLeave: (e:
|
|
31
|
-
onCanvasMove: (e:
|
|
28
|
+
onClick: (e: IElementEvent) => void;
|
|
29
|
+
onPointerMove: (e: IElementEvent) => void;
|
|
30
|
+
onPointerLeave: (e: IElementEvent) => void;
|
|
31
|
+
onCanvasMove: (e: IElementEvent) => void;
|
|
32
32
|
private onPointerEnter;
|
|
33
33
|
showTooltipById: (id: string, elementType?: ElementType) => void;
|
|
34
34
|
private getItems;
|
|
35
|
-
showTooltip: (e:
|
|
36
|
-
hideTooltip: (e?:
|
|
35
|
+
showTooltip: (e: IElementEvent) => void;
|
|
36
|
+
hideTooltip: (e?: IElementEvent) => void;
|
|
37
37
|
private initTooltip;
|
|
38
38
|
destroy(): void;
|
|
39
39
|
}
|
|
40
|
+
type IElementEvent = IPointerEvent<Element>;
|
|
41
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type EventEmitter from '@antv/event-emitter';
|
|
2
2
|
import type { RuntimeContext } from '../../runtime/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { IEvent } from '../../types';
|
|
4
4
|
import type { ExtensionOptions, LooselyExtensionOption, STDExtensionOption } from './types';
|
|
5
5
|
export declare abstract class ExtensionController<Extension extends BaseExtension<LooselyExtensionOption>> {
|
|
6
6
|
protected context: RuntimeContext;
|
|
@@ -25,7 +25,7 @@ export declare abstract class ExtensionController<Extension extends BaseExtensio
|
|
|
25
25
|
export declare class BaseExtension<T extends LooselyExtensionOption> {
|
|
26
26
|
protected context: RuntimeContext;
|
|
27
27
|
protected options: Required<T>;
|
|
28
|
-
protected events: [EventEmitter | HTMLElement, string,
|
|
28
|
+
protected events: [EventEmitter | HTMLElement, string, (event: IEvent) => void][];
|
|
29
29
|
destroyed: boolean;
|
|
30
30
|
constructor(context: RuntimeContext, options: T);
|
|
31
31
|
update(options: Partial<T>): void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExtensionCategory } from '../constants';
|
|
2
|
+
import type { Loosen } from '../types';
|
|
3
|
+
import type { ExtensionRegistry } from './types';
|
|
2
4
|
/**
|
|
3
5
|
* <zh/> 注册一个新的扩展。
|
|
4
6
|
*
|
|
@@ -29,7 +31,7 @@ import type { ExtensionCategory, ExtensionRegistry } from './types';
|
|
|
29
31
|
* ```
|
|
30
32
|
* @public
|
|
31
33
|
*/
|
|
32
|
-
export declare function register<T extends ExtensionCategory>(category: T
|
|
34
|
+
export declare function register<T extends ExtensionCategory>(category: Loosen<T>, type: string, Ctor: ExtensionRegistry[T][string]): void;
|
|
33
35
|
/**
|
|
34
36
|
* <zh/> 根据类别和类型获取扩展
|
|
35
37
|
*
|
|
@@ -39,7 +41,7 @@ export declare function register<T extends ExtensionCategory>(category: T, type:
|
|
|
39
41
|
* @returns <zh/> 注册的扩展 | <en/> Registered extension
|
|
40
42
|
* @internal
|
|
41
43
|
*/
|
|
42
|
-
export declare function getExtension<T extends ExtensionCategory>(category: T
|
|
44
|
+
export declare function getExtension<T extends ExtensionCategory>(category: Loosen<T>, type: string): ExtensionRegistry[T][string] | undefined;
|
|
43
45
|
/**
|
|
44
46
|
* <zh/> 根据类别获取扩展
|
|
45
47
|
*
|
|
@@ -48,7 +50,7 @@ export declare function getExtension<T extends ExtensionCategory>(category: T, t
|
|
|
48
50
|
* @returns <zh/> 注册的扩展 | <en/> Registered extension
|
|
49
51
|
* @internal
|
|
50
52
|
*/
|
|
51
|
-
export declare function getExtensions<T extends ExtensionCategory
|
|
53
|
+
export declare function getExtensions<T extends Loosen<ExtensionCategory>>(category: T): ExtensionRegistry[T];
|
|
52
54
|
/**
|
|
53
55
|
* <zh/> 注册内置扩展
|
|
54
56
|
*
|
|
@@ -25,8 +25,9 @@ export declare class Canvas {
|
|
|
25
25
|
};
|
|
26
26
|
get document(): import("@antv/g").Document;
|
|
27
27
|
renderers: Record<CanvasLayer, IRenderer>;
|
|
28
|
+
private initialized;
|
|
28
29
|
constructor(config: CanvasConfig);
|
|
29
|
-
init(): Promise<
|
|
30
|
+
init(): Promise<void>;
|
|
30
31
|
getRendererType(layer?: CanvasLayer): "canvas" | "svg" | "gpu" | "unknown";
|
|
31
32
|
get context(): import("@antv/g").CanvasContext;
|
|
32
33
|
getDevice(): any;
|
|
@@ -96,7 +96,7 @@ export declare class DataController {
|
|
|
96
96
|
* @returns <zh/> 节点和 combo 的数据 | <en/> node and combo data
|
|
97
97
|
*/
|
|
98
98
|
getNodeLikeData(ids?: ID[]): NodeLikeData[];
|
|
99
|
-
getElementDataByState(elementType: ElementType, state: string): (NodeData |
|
|
99
|
+
getElementDataByState(elementType: ElementType, state: string): (NodeData | EdgeData | ComboData)[];
|
|
100
100
|
getElementState(id: ID): State[];
|
|
101
101
|
hasNode(id: ID): boolean;
|
|
102
102
|
hasEdge(id: ID): boolean;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { DisplayObject, IAnimation } from '@antv/g';
|
|
2
2
|
import type { ID } from '@antv/graphlib';
|
|
3
|
-
import type { BaseShape } from '../elements/shapes';
|
|
4
3
|
import type { AnimationStage } from '../spec/element/animation';
|
|
5
|
-
import type { Combo, ElementDatum, ElementType, Node, State } from '../types';
|
|
4
|
+
import type { Combo, Element, ElementDatum, ElementType, Node, State } from '../types';
|
|
6
5
|
import type { RuntimeContext } from './types';
|
|
7
6
|
export declare class ElementController {
|
|
8
7
|
private context;
|
|
@@ -14,7 +13,7 @@ export declare class ElementController {
|
|
|
14
13
|
private emit;
|
|
15
14
|
private forEachElementData;
|
|
16
15
|
private getTheme;
|
|
17
|
-
getThemeStyle(elementType: ElementType): import("
|
|
16
|
+
getThemeStyle(elementType: ElementType): import("../spec/element/node").NodeStyle | import("../spec/element/edge").EdgeStyle | import("../spec/element/combo").ComboStyle;
|
|
18
17
|
getThemeStateStyle(elementType: ElementType, states: State[]): any;
|
|
19
18
|
private paletteStyle;
|
|
20
19
|
private computePaletteStyle;
|
|
@@ -55,9 +54,9 @@ export declare class ElementController {
|
|
|
55
54
|
private computeElementsStatesStyle;
|
|
56
55
|
getStateStyle(id: ID): Record<string, unknown>;
|
|
57
56
|
private computeStyle;
|
|
58
|
-
getElement<T extends
|
|
57
|
+
getElement<T extends Element>(id: ID): T | undefined;
|
|
59
58
|
getNodes(): Node[];
|
|
60
|
-
getEdges(): import("
|
|
59
|
+
getEdges(): import("..").BaseEdge[];
|
|
61
60
|
getCombos(): Combo[];
|
|
62
61
|
private getAnimation;
|
|
63
62
|
private getAnimationExecutor;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import EventEmitter from '@antv/event-emitter';
|
|
2
2
|
import type { AABB, BaseStyleProps, DataURLOptions } from '@antv/g';
|
|
3
3
|
import type { ID } from '@antv/graphlib';
|
|
4
|
+
import type { Plugin } from '../plugins/types';
|
|
4
5
|
import type { BehaviorOptions, ComboData, ComboOptions, EdgeData, EdgeOptions, G6Spec, GraphData, LayoutOptions, NodeData, NodeOptions, PluginOptions, ThemeOptions } from '../spec';
|
|
5
|
-
import { UpdateBehaviorOption } from '../spec/behavior';
|
|
6
|
-
import { UpdatePluginOption } from '../spec/plugin';
|
|
7
|
-
import type { CallableValue, DataID, EdgeDirection, ElementType, FitViewOptions, NodeLikeData, PartialEdgeData, PartialGraphData, PartialNodeLikeData, Point, Position, State, ViewportAnimationEffectTiming } from '../types';
|
|
6
|
+
import type { UpdateBehaviorOption } from '../spec/behavior';
|
|
7
|
+
import type { UpdatePluginOption } from '../spec/plugin';
|
|
8
|
+
import type { CallableValue, DataID, EdgeDirection, ElementType, FitViewOptions, IEvent, NodeLikeData, PartialEdgeData, PartialGraphData, PartialNodeLikeData, Point, Position, State, ViewportAnimationEffectTiming } from '../types';
|
|
8
9
|
import { Canvas } from './canvas';
|
|
9
10
|
import type { HierarchyKey } from './data';
|
|
10
11
|
export declare class Graph extends EventEmitter {
|
|
@@ -86,6 +87,14 @@ export declare class Graph extends EventEmitter {
|
|
|
86
87
|
* @returns <zh/> 插件配置 | <en/> plugin configuration
|
|
87
88
|
*/
|
|
88
89
|
getPlugins(): PluginOptions;
|
|
90
|
+
/**
|
|
91
|
+
* <zh/> 获取插件实例
|
|
92
|
+
*
|
|
93
|
+
* <en/> Get plugin instance
|
|
94
|
+
* @param key - <zh/> 插件 key | <en/> plugin key
|
|
95
|
+
* @returns <zh/> 插件实例 | <en/> plugin instance
|
|
96
|
+
*/
|
|
97
|
+
getPluginInstance<T extends Plugin>(key: string): T;
|
|
89
98
|
getData(): GraphData;
|
|
90
99
|
getNodeData(): NodeData[];
|
|
91
100
|
getNodeData(id: ID): NodeData;
|
|
@@ -145,7 +154,7 @@ export declare class Graph extends EventEmitter {
|
|
|
145
154
|
getElementDataByState(elementType: 'node', state: State): NodeData[];
|
|
146
155
|
getElementDataByState(elementType: 'edge', state: State): EdgeData[];
|
|
147
156
|
getElementDataByState(elementType: 'combo', state: State): ComboData[];
|
|
148
|
-
private
|
|
157
|
+
private initCanvas;
|
|
149
158
|
private createRuntime;
|
|
150
159
|
private prepare;
|
|
151
160
|
/**
|
|
@@ -438,4 +447,22 @@ export declare class Graph extends EventEmitter {
|
|
|
438
447
|
getViewportCenter(): Point;
|
|
439
448
|
getCanvasCenter(): Point;
|
|
440
449
|
private onResize;
|
|
450
|
+
/**
|
|
451
|
+
* <zh/> 监听事件
|
|
452
|
+
*
|
|
453
|
+
* <en/> Listen to events
|
|
454
|
+
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
455
|
+
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
456
|
+
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
457
|
+
*/
|
|
458
|
+
on<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void): this;
|
|
459
|
+
/**
|
|
460
|
+
* <zh/> 一次性监听事件
|
|
461
|
+
*
|
|
462
|
+
* <en/> Listen to events once
|
|
463
|
+
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
464
|
+
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
465
|
+
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
466
|
+
*/
|
|
467
|
+
once<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void): this;
|
|
441
468
|
}
|
|
@@ -1,8 +1,43 @@
|
|
|
1
|
-
import type { Document,
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
1
|
+
import type { DisplayObject, Document, FederatedEvent, FederatedPointerEvent, FederatedWheelEvent, IAnimation } from '@antv/g';
|
|
2
|
+
import type { AnimationType } from '../constants';
|
|
3
|
+
import type { ElementDatum } from './data';
|
|
4
|
+
import type { Element, ElementType } from './element';
|
|
5
|
+
import type { TransformOptions } from './viewport';
|
|
6
|
+
export type IEvent = IGraphLifeCycleEvent | IAnimateEvent | IElementLifeCycleEvent | IViewportEvent | IPointerEvent | IWheelEvent | IKeyboardEvent | IDragEvent;
|
|
7
|
+
export interface IPointerEvent<T extends Target = Target> extends TargetedEvent<FederatedPointerEvent, T> {
|
|
8
8
|
}
|
|
9
|
+
export interface IWheelEvent<T extends Target = Target> extends TargetedEvent<FederatedWheelEvent, T> {
|
|
10
|
+
}
|
|
11
|
+
export interface IKeyboardEvent extends KeyboardEvent {
|
|
12
|
+
}
|
|
13
|
+
export interface IDragEvent<T extends Target = Target> extends TargetedEvent<FederatedPointerEvent, T> {
|
|
14
|
+
dx: number;
|
|
15
|
+
dy: number;
|
|
16
|
+
}
|
|
17
|
+
export interface IGraphLifeCycleEvent extends NativeEvent {
|
|
18
|
+
data?: any;
|
|
19
|
+
}
|
|
20
|
+
export interface IElementLifeCycleEvent extends NativeEvent {
|
|
21
|
+
elementType: ElementType;
|
|
22
|
+
data: ElementDatum;
|
|
23
|
+
}
|
|
24
|
+
export interface IViewportEvent extends NativeEvent {
|
|
25
|
+
data: TransformOptions;
|
|
26
|
+
}
|
|
27
|
+
export interface IAnimateEvent extends NativeEvent {
|
|
28
|
+
animationType: AnimationType;
|
|
29
|
+
animation: IAnimation | null;
|
|
30
|
+
data?: any;
|
|
31
|
+
}
|
|
32
|
+
/** <zh/> G6 原生事件 | <en/> G6 native event */
|
|
33
|
+
interface NativeEvent {
|
|
34
|
+
type: string;
|
|
35
|
+
}
|
|
36
|
+
/** <zh/> 具有目标的事件 | <en/> Event with target */
|
|
37
|
+
type TargetedEvent<E extends FederatedEvent, T extends Target = Target> = Omit<E, 'target'> & {
|
|
38
|
+
originalTarget: DisplayObject;
|
|
39
|
+
target: T;
|
|
40
|
+
targetType: 'canvas' | 'node' | 'edge' | 'combo';
|
|
41
|
+
};
|
|
42
|
+
export type Target = Document | Element;
|
|
43
|
+
export {};
|
package/dist/lib/utils/bbox.d.ts
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
import type { AABB, DisplayObject, TextStyleProps } from '@antv/g';
|
|
2
|
-
import { NodePortStyleProps } from '../elements/nodes/base-node';
|
|
2
|
+
import type { NodePortStyleProps } from '../elements/nodes/base-node';
|
|
3
3
|
import type { TriangleDirection } from '../elements/nodes/triangle';
|
|
4
|
-
import type { Combo, Edge, Node, Placement, Point, Position } from '../types';
|
|
4
|
+
import type { Combo, Edge, Element, Node, Placement, Point, Position } from '../types';
|
|
5
5
|
import type { LabelPlacement, Port } from '../types/node';
|
|
6
6
|
/**
|
|
7
|
-
* <zh/> 判断是否是
|
|
7
|
+
* <zh/> 判断是否是 Node 的实例
|
|
8
8
|
*
|
|
9
|
-
* <en/> Judge whether the instance is
|
|
9
|
+
* <en/> Judge whether the instance is Node
|
|
10
10
|
* @param shape - <zh/> 实例 | <en/> instance
|
|
11
|
-
* @returns <zh/> 是否是
|
|
11
|
+
* @returns <zh/> 是否是 Node 的实例 | <en/> whether the instance is Node
|
|
12
12
|
*/
|
|
13
13
|
export declare function isNode(shape: DisplayObject | Port): shape is Node;
|
|
14
14
|
/**
|
|
15
|
-
* <zh/> 判断是否是
|
|
15
|
+
* <zh/> 判断是否是 Edge 的实例
|
|
16
16
|
*
|
|
17
|
-
* <en/> Judge whether the instance is
|
|
17
|
+
* <en/> Judge whether the instance is Edge
|
|
18
18
|
* @param shape - <zh/> 实例 | <en/> instance
|
|
19
|
-
* @returns <zh/> 是否是
|
|
19
|
+
* @returns <zh/> 是否是 Edge 的实例 | <en/> whether the instance is Edge
|
|
20
20
|
*/
|
|
21
21
|
export declare function isEdge(shape: DisplayObject): shape is Edge;
|
|
22
22
|
/**
|
|
23
|
-
* <zh/> 判断是否是
|
|
23
|
+
* <zh/> 判断是否是 Combo 的实例
|
|
24
24
|
*
|
|
25
|
-
* <en/> Judge whether the instance is
|
|
25
|
+
* <en/> Judge whether the instance is Combo
|
|
26
26
|
* @param shape - <zh/> 实例 | <en/> instance
|
|
27
|
-
* @returns <zh/> 是否是
|
|
27
|
+
* @returns <zh/> 是否是 Combo 的实例 | <en/> whether the instance is Combo
|
|
28
28
|
*/
|
|
29
29
|
export declare function isCombo(shape: DisplayObject): shape is Combo;
|
|
30
|
+
/**
|
|
31
|
+
* <zh/> 判断是否是 Element 的实例
|
|
32
|
+
*
|
|
33
|
+
* <en/> Judge whether the instance is Element
|
|
34
|
+
* @param shape - <zh/> 实例 | <en/> instance
|
|
35
|
+
* @returns <zh/> 是否是 Element 的实例 | <en/> whether the instance is Element
|
|
36
|
+
*/
|
|
37
|
+
export declare function isElement(shape: any): shape is Element;
|
|
30
38
|
/**
|
|
31
39
|
* <zh/> 判断两个节点是否相同
|
|
32
40
|
*
|
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
import type { IAnimation } from '@antv/g';
|
|
2
|
-
import type { ID } from '@antv/graphlib';
|
|
3
2
|
import type { AnimationType, GraphEvent } from '../../constants';
|
|
4
|
-
import type {
|
|
5
|
-
import type { State, TransformOptions } from '../../types';
|
|
3
|
+
import type { ElementDatum, ElementType, IAnimateEvent, IElementLifeCycleEvent, IGraphLifeCycleEvent, IViewportEvent, TransformOptions } from '../../types';
|
|
6
4
|
export declare class BaseEvent {
|
|
7
5
|
type: string;
|
|
8
6
|
constructor(type: string);
|
|
9
7
|
}
|
|
10
|
-
export declare class GraphLifeCycleEvent extends BaseEvent {
|
|
8
|
+
export declare class GraphLifeCycleEvent extends BaseEvent implements IGraphLifeCycleEvent {
|
|
11
9
|
data?: any;
|
|
12
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, data?: any);
|
|
13
11
|
}
|
|
14
|
-
export declare class AnimateEvent extends BaseEvent {
|
|
12
|
+
export declare class AnimateEvent extends BaseEvent implements IAnimateEvent {
|
|
15
13
|
animationType: AnimationType;
|
|
16
14
|
animation: IAnimation | null;
|
|
17
15
|
data?: any;
|
|
18
16
|
constructor(type: GraphEvent.BEFORE_ANIMATE | GraphEvent.AFTER_ANIMATE, animationType: AnimationType, animation: IAnimation | null, data?: any);
|
|
19
17
|
}
|
|
20
|
-
export declare class ElementLifeCycleEvent extends BaseEvent {
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
export declare class ElementLifeCycleEvent extends BaseEvent implements IElementLifeCycleEvent {
|
|
19
|
+
elementType: ElementType;
|
|
20
|
+
data: ElementDatum;
|
|
21
|
+
constructor(type: GraphEvent.BEFORE_ELEMENT_CREATE | GraphEvent.AFTER_ELEMENT_CREATE | GraphEvent.BEFORE_ELEMENT_UPDATE | GraphEvent.AFTER_ELEMENT_UPDATE | GraphEvent.BEFORE_ELEMENT_DESTROY | GraphEvent.AFTER_ELEMENT_DESTROY, elementType: ElementType, data: ElementDatum);
|
|
23
22
|
}
|
|
24
|
-
export declare class ViewportEvent extends BaseEvent {
|
|
23
|
+
export declare class ViewportEvent extends BaseEvent implements IViewportEvent {
|
|
25
24
|
data: TransformOptions;
|
|
26
25
|
constructor(type: GraphEvent.BEFORE_TRANSFORM | GraphEvent.AFTER_TRANSFORM, data: TransformOptions);
|
|
27
26
|
}
|
|
28
|
-
export declare class ElementStateChangeEvent extends BaseEvent {
|
|
29
|
-
states: Record<ID, State | State[]>;
|
|
30
|
-
constructor(type: GraphEvent.BEFORE_ELEMENT_STATE_CHANGE | GraphEvent.AFTER_ELEMENT_STATE_CHANGE, states: Record<ID, State | State[]>);
|
|
31
|
-
}
|
|
@@ -15,6 +15,16 @@ export declare class Shortcut {
|
|
|
15
15
|
private onKeyDown;
|
|
16
16
|
private onKeyUp;
|
|
17
17
|
private trigger;
|
|
18
|
+
/**
|
|
19
|
+
* <zh/> 扩展 wheel, drag 操作
|
|
20
|
+
*
|
|
21
|
+
* <en/> Extend wheel, drag operations
|
|
22
|
+
* @param eventType - event name
|
|
23
|
+
* @param event - event
|
|
24
|
+
*/
|
|
25
|
+
private triggerExtendKey;
|
|
18
26
|
private onWheel;
|
|
27
|
+
private onDrag;
|
|
28
|
+
destroy(): void;
|
|
19
29
|
}
|
|
20
30
|
export {};
|
|
@@ -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 {
|
|
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:
|
|
18
|
+
enable?: boolean | ((event: IPointerEvent) => boolean);
|
|
20
19
|
/**
|
|
21
20
|
* <zh/> 完成收起时的回调
|
|
22
21
|
*
|
|
23
22
|
* <en/> Callback when collapse is completed
|
|
24
23
|
*/
|
|
25
|
-
|
|
24
|
+
onCollapse?: (id: ID) => void;
|
|
26
25
|
/**
|
|
27
26
|
* <zh/> 完成展开时的回调
|
|
28
27
|
*
|
|
29
28
|
* <en/> Callback when expand is completed
|
|
30
29
|
*/
|
|
31
|
-
|
|
30
|
+
onExpand?: (id: ID) => void;
|
|
32
31
|
}
|
|
33
32
|
export declare class CollapseExpand extends BaseBehavior<CollapseExpandOptions> {
|
|
34
33
|
static defaultOptions: Partial<CollapseExpandOptions>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isFunction } from '@antv/util';
|
|
2
2
|
import { CommonEvent } from '../constants';
|
|
3
|
+
import { isElement } from '../utils/element';
|
|
3
4
|
import { BaseBehavior } from './base-behavior';
|
|
4
5
|
export class CollapseExpand extends BaseBehavior {
|
|
5
6
|
static defaultOptions = {
|
|
@@ -22,20 +23,23 @@ export class CollapseExpand extends BaseBehavior {
|
|
|
22
23
|
onCollapseExpand = async (event) => {
|
|
23
24
|
if (!this.validate(event))
|
|
24
25
|
return;
|
|
25
|
-
const
|
|
26
|
+
const { target } = event;
|
|
27
|
+
if (!isElement(target))
|
|
28
|
+
return;
|
|
29
|
+
const id = target.id;
|
|
26
30
|
const { model, graph } = this.context;
|
|
27
31
|
const data = model.getComboData([id])[0];
|
|
28
32
|
if (!data)
|
|
29
33
|
return false;
|
|
30
|
-
const {
|
|
34
|
+
const { onCollapse, onExpand, animation } = this.options;
|
|
31
35
|
const isCollapse = data.style?.collapsed;
|
|
32
36
|
if (isCollapse) {
|
|
33
37
|
await graph.expand(id, animation);
|
|
34
|
-
|
|
38
|
+
onExpand?.(id);
|
|
35
39
|
}
|
|
36
40
|
else {
|
|
37
41
|
await graph.collapse(id, animation);
|
|
38
|
-
|
|
42
|
+
onCollapse?.(id);
|
|
39
43
|
}
|
|
40
44
|
};
|
|
41
45
|
validate(event) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapse-expand.js","sourceRoot":"src/","sources":["behaviors/collapse-expand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"collapse-expand.js","sourceRoot":"src/","sources":["behaviors/collapse-expand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA6B/C,MAAM,OAAO,cAAe,SAAQ,YAAmC;IACrE,MAAM,CAAC,cAAc,GAAmC;QACtD,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,IAAI;KAChB,CAAC;IAEF,YAAY,OAAuB,EAAE,OAA8B;QACjE,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAEO,UAAU;QAChB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,YAAY,EAAE,CAAC;QAEpB,KAAK,CAAC,EAAE,CAAC,SAAS,WAAW,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACnE,CAAC;IAEO,YAAY;QAClB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC/B,KAAK,CAAC,GAAG,CAAC,SAAS,WAAW,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACpE,CAAC;IAEO,gBAAgB,GAAG,KAAK,EAAE,KAAoB,EAAE,EAAE;QACxD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO;QAClC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAAE,OAAO;QAE/B,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;QACrB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QAExB,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACzD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC;QACzC,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YAClC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YACpC,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC;IAEM,QAAQ,CAAC,KAAoB;QACnC,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,KAAK,CAAC;QACjC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAChC,IAAI,UAAU,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC"}
|
|
@@ -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
|
+
}
|