@antv/g6 5.0.48 → 5.0.49
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 +22 -20
- package/dist/lib/behaviors/drag-canvas.d.ts +1 -0
- package/dist/lib/layouts/types.d.ts +21 -2
- package/dist/lib/plugins/hull/index.d.ts +1 -0
- package/dist/lib/plugins/tooltip.d.ts +1 -1
- package/dist/lib/registry/extension/index.d.ts +1 -0
- package/dist/lib/types/utility.d.ts +1 -0
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/drag-canvas.d.ts +1 -0
- package/esm/behaviors/drag-canvas.js +10 -0
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element.js +6 -1
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/hover-activate.js +1 -1
- package/esm/behaviors/hover-activate.js.map +1 -1
- package/esm/layouts/types.d.ts +21 -2
- package/esm/plugins/hull/index.d.ts +1 -0
- package/esm/plugins/hull/index.js +5 -1
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/minimap/index.js +29 -11
- package/esm/plugins/minimap/index.js.map +1 -1
- package/esm/plugins/tooltip.d.ts +1 -1
- package/esm/plugins/tooltip.js +4 -4
- package/esm/plugins/tooltip.js.map +1 -1
- package/esm/registry/extension/index.d.ts +1 -0
- package/esm/registry/extension/index.js +7 -3
- package/esm/registry/extension/index.js.map +1 -1
- package/esm/runtime/canvas.js +2 -0
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/element.js +6 -26
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.js +16 -2
- package/esm/runtime/graph.js.map +1 -1
- package/esm/transforms/collapse-expand-node.js +1 -1
- package/esm/transforms/collapse-expand-node.js.map +1 -1
- package/esm/types/utility.d.ts +1 -0
- package/esm/types/utility.js +2 -0
- package/esm/types/utility.js.map +1 -0
- package/esm/utils/layout.js +2 -2
- package/esm/utils/layout.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/drag-canvas.d.ts +1 -0
- package/lib/behaviors/drag-canvas.js +10 -0
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element.js +6 -1
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/hover-activate.js +1 -1
- package/lib/behaviors/hover-activate.js.map +1 -1
- package/lib/layouts/types.d.ts +21 -2
- package/lib/plugins/hull/index.d.ts +1 -0
- package/lib/plugins/hull/index.js +5 -1
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/minimap/index.js +29 -11
- package/lib/plugins/minimap/index.js.map +1 -1
- package/lib/plugins/tooltip.d.ts +1 -1
- package/lib/plugins/tooltip.js +4 -4
- package/lib/plugins/tooltip.js.map +1 -1
- package/lib/registry/extension/index.d.ts +1 -0
- package/lib/registry/extension/index.js +7 -3
- package/lib/registry/extension/index.js.map +1 -1
- package/lib/runtime/canvas.js +2 -0
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/element.js +6 -26
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.js +16 -2
- package/lib/runtime/graph.js.map +1 -1
- package/lib/transforms/collapse-expand-node.js +1 -1
- package/lib/transforms/collapse-expand-node.js.map +1 -1
- package/lib/types/utility.d.ts +1 -0
- package/lib/types/utility.js +3 -0
- package/lib/types/utility.js.map +1 -0
- package/lib/utils/layout.js +2 -2
- package/lib/utils/layout.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/behaviors/drag-canvas.ts +10 -0
- package/src/behaviors/drag-element.ts +9 -1
- package/src/behaviors/hover-activate.ts +1 -1
- package/src/layouts/types.ts +24 -3
- package/src/plugins/hull/index.ts +6 -1
- package/src/plugins/minimap/index.ts +27 -7
- package/src/plugins/tooltip.ts +4 -4
- package/src/registry/extension/index.ts +9 -3
- package/src/runtime/canvas.ts +2 -0
- package/src/runtime/element.ts +6 -32
- package/src/runtime/graph.ts +24 -2
- package/src/transforms/collapse-expand-node.ts +1 -1
- package/src/types/utility.ts +1 -0
- package/src/utils/layout.ts +2 -3
- package/src/version.ts +1 -1
|
@@ -4,6 +4,7 @@ import { GraphEvent } from '../../constants';
|
|
|
4
4
|
import type { RuntimeContext } from '../../runtime/types';
|
|
5
5
|
import { GraphData } from '../../spec';
|
|
6
6
|
import type { ElementDatum, ElementType, ID, IGraphLifeCycleEvent, Padding, Placement, Vector3 } from '../../types';
|
|
7
|
+
import { isVisible } from '../../utils/element';
|
|
7
8
|
import { idOf } from '../../utils/id';
|
|
8
9
|
import { parsePadding } from '../../utils/padding';
|
|
9
10
|
import { toPointObject } from '../../utils/point';
|
|
@@ -149,6 +150,7 @@ export class Minimap extends BasePlugin<MinimapOptions> {
|
|
|
149
150
|
const { graph } = this.context;
|
|
150
151
|
graph.on(GraphEvent.AFTER_DRAW, this.onDraw);
|
|
151
152
|
graph.on(GraphEvent.AFTER_RENDER, this.onRender);
|
|
153
|
+
graph.on(GraphEvent.AFTER_ANIMATE, this.onRender);
|
|
152
154
|
graph.on(GraphEvent.AFTER_TRANSFORM, this.onTransform);
|
|
153
155
|
}
|
|
154
156
|
|
|
@@ -156,6 +158,7 @@ export class Minimap extends BasePlugin<MinimapOptions> {
|
|
|
156
158
|
const { graph } = this.context;
|
|
157
159
|
graph.off(GraphEvent.AFTER_DRAW, this.onDraw);
|
|
158
160
|
graph.off(GraphEvent.AFTER_RENDER, this.onRender);
|
|
161
|
+
graph.off(GraphEvent.AFTER_ANIMATE, this.onRender);
|
|
159
162
|
graph.off(GraphEvent.AFTER_TRANSFORM, this.onTransform);
|
|
160
163
|
}
|
|
161
164
|
|
|
@@ -181,8 +184,18 @@ export class Minimap extends BasePlugin<MinimapOptions> {
|
|
|
181
184
|
|
|
182
185
|
private getElements(): Required<GraphData> {
|
|
183
186
|
const { filter } = this.options;
|
|
184
|
-
const { model } = this.context;
|
|
185
|
-
const
|
|
187
|
+
const { model, element } = this.context;
|
|
188
|
+
const originData = model.getData();
|
|
189
|
+
//过滤那些不存在于elementMap中的数据
|
|
190
|
+
const data = {
|
|
191
|
+
nodes: originData.nodes.filter((node) => element?.getElement(idOf(node))),
|
|
192
|
+
edges: originData.edges.filter((edge) => {
|
|
193
|
+
const edgeElement = element?.getElement(idOf(edge));
|
|
194
|
+
// 边数据存在且可见时才保留
|
|
195
|
+
return edgeElement && isVisible(edgeElement);
|
|
196
|
+
}),
|
|
197
|
+
combos: originData.combos.filter((combo) => element?.getElement(idOf(combo))),
|
|
198
|
+
};
|
|
186
199
|
|
|
187
200
|
if (!filter) return data;
|
|
188
201
|
|
|
@@ -373,8 +386,14 @@ export class Minimap extends BasePlugin<MinimapOptions> {
|
|
|
373
386
|
let [x, y, width, height] = this.maskBBox;
|
|
374
387
|
|
|
375
388
|
// clamp x, y, width, height
|
|
376
|
-
if (x < 0)
|
|
377
|
-
|
|
389
|
+
if (x < 0) {
|
|
390
|
+
width = upper(width + x, minimapWidth);
|
|
391
|
+
x = 0;
|
|
392
|
+
}
|
|
393
|
+
if (y < 0) {
|
|
394
|
+
height = upper(height + y, minimapHeight);
|
|
395
|
+
y = 0;
|
|
396
|
+
}
|
|
378
397
|
if (x + width > minimapWidth) width = lower(minimapWidth - x, 0);
|
|
379
398
|
if (y + height > minimapHeight) height = lower(minimapHeight - y, 0);
|
|
380
399
|
|
|
@@ -444,11 +463,11 @@ export class Minimap extends BasePlugin<MinimapOptions> {
|
|
|
444
463
|
// 当拖拽画布导致 mask 缩小时,拖拽 mask 时,能够恢复到实际大小
|
|
445
464
|
// When dragging the canvas causes the mask to shrink, dragging the mask will restore it to its actual size
|
|
446
465
|
if (width < fullWidth) {
|
|
447
|
-
if (movementX > 0) (x = lower(x - movementX, 0)), (width = upper(width + movementX, minimapWidth));
|
|
466
|
+
if (movementX > 0) ((x = lower(x - movementX, 0)), (width = upper(width + movementX, minimapWidth)));
|
|
448
467
|
else if (movementX < 0) width = upper(width - movementX, minimapWidth);
|
|
449
468
|
}
|
|
450
469
|
if (height < fullHeight) {
|
|
451
|
-
if (movementY > 0) (y = lower(y - movementY, 0)), (height = upper(height + movementY, minimapHeight));
|
|
470
|
+
if (movementY > 0) ((y = lower(y - movementY, 0)), (height = upper(height + movementY, minimapHeight)));
|
|
452
471
|
else if (movementY < 0) height = upper(height - movementY, minimapHeight);
|
|
453
472
|
}
|
|
454
473
|
|
|
@@ -505,8 +524,9 @@ export class Minimap extends BasePlugin<MinimapOptions> {
|
|
|
505
524
|
|
|
506
525
|
public destroy(): void {
|
|
507
526
|
this.unbindEvents();
|
|
508
|
-
this.canvas
|
|
527
|
+
this.canvas?.destroy();
|
|
509
528
|
this.mask?.remove();
|
|
529
|
+
this.container?.remove();
|
|
510
530
|
super.destroy();
|
|
511
531
|
}
|
|
512
532
|
}
|
package/src/plugins/tooltip.ts
CHANGED
|
@@ -94,12 +94,12 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
return {
|
|
97
|
-
'node:
|
|
97
|
+
'node:pointerover': this.onPointerOver,
|
|
98
98
|
'node:pointermove': this.onPointerMove,
|
|
99
99
|
'canvas:pointermove': this.onCanvasMove,
|
|
100
|
-
'edge:
|
|
100
|
+
'edge:pointerover': this.onPointerOver,
|
|
101
101
|
'edge:pointermove': this.onPointerMove,
|
|
102
|
-
'combo:
|
|
102
|
+
'combo:pointerover': this.onPointerOver,
|
|
103
103
|
'combo:pointermove': this.onPointerMove,
|
|
104
104
|
contextmenu: this.onPointerLeave,
|
|
105
105
|
'node:drag': this.onPointerLeave,
|
|
@@ -205,7 +205,7 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
|
|
|
205
205
|
this.hide(event);
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
private
|
|
208
|
+
private onPointerOver = (event: IElementEvent) => {
|
|
209
209
|
this.show(event);
|
|
210
210
|
};
|
|
211
211
|
|
|
@@ -46,6 +46,7 @@ export abstract class ExtensionController<E extends BaseExtension<any>> {
|
|
|
46
46
|
if (!Ctor) return print.warn(`The extension ${type} of ${category} is not registered.`);
|
|
47
47
|
|
|
48
48
|
const instance = new Ctor(this.context, extension);
|
|
49
|
+
instance.initialized = true;
|
|
49
50
|
this.extensionMap[key] = instance as E;
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -67,10 +68,13 @@ export abstract class ExtensionController<E extends BaseExtension<any>> {
|
|
|
67
68
|
|
|
68
69
|
protected destroyExtension(key: string) {
|
|
69
70
|
const instance = this.extensionMap[key];
|
|
70
|
-
|
|
71
|
+
|
|
72
|
+
if (!instance) return;
|
|
73
|
+
if (instance.initialized && !instance.destroyed) {
|
|
71
74
|
instance.destroy();
|
|
72
|
-
delete this.extensionMap[key];
|
|
73
75
|
}
|
|
76
|
+
|
|
77
|
+
delete this.extensionMap[key];
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
protected destroyExtensions(extensions: STDExtensionOption[]) {
|
|
@@ -78,7 +82,7 @@ export abstract class ExtensionController<E extends BaseExtension<any>> {
|
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
public destroy() {
|
|
81
|
-
|
|
85
|
+
this.destroyExtensions(this.extensions);
|
|
82
86
|
// @ts-expect-error force delete
|
|
83
87
|
this.context = {};
|
|
84
88
|
this.extensions = [];
|
|
@@ -98,6 +102,8 @@ export class BaseExtension<T extends { type: string; key?: string; [key: string]
|
|
|
98
102
|
|
|
99
103
|
protected events: [EventEmitter | HTMLElement, string, (event: IEvent) => void][] = [];
|
|
100
104
|
|
|
105
|
+
public initialized = false;
|
|
106
|
+
|
|
101
107
|
public destroyed = false;
|
|
102
108
|
|
|
103
109
|
constructor(context: RuntimeContext, options: Partial<T>) {
|
package/src/runtime/canvas.ts
CHANGED
|
@@ -404,6 +404,8 @@ function configCanvasDom(layers: Record<CanvasLayer, GCanvas>) {
|
|
|
404
404
|
|
|
405
405
|
if (domElement?.parentElement) {
|
|
406
406
|
domElement.parentElement.style.display = 'grid';
|
|
407
|
+
// 给父元素设置独立的层叠上下文,避免外部元素影响内部的层叠逻辑
|
|
408
|
+
domElement.parentElement.style.isolation = 'isolate';
|
|
407
409
|
}
|
|
408
410
|
});
|
|
409
411
|
}
|
package/src/runtime/element.ts
CHANGED
|
@@ -663,20 +663,8 @@ export class ElementController {
|
|
|
663
663
|
* @param options - <zh/> 选项 | <en/> options
|
|
664
664
|
*/
|
|
665
665
|
public async collapseNode(id: ID, options: CollapseExpandNodeOptions): Promise<void> {
|
|
666
|
-
const { animation
|
|
667
|
-
|
|
668
|
-
const { model, layout } = this.context;
|
|
669
|
-
|
|
670
|
-
const simulateLayoutData = this.computeChangesAndDrawData({ stage: 'collapse', animation });
|
|
671
|
-
if (!simulateLayoutData) return;
|
|
672
|
-
|
|
673
|
-
this.markDestroyElement(simulateLayoutData.drawData);
|
|
674
|
-
|
|
675
|
-
// 进行预布局,计算出所有元素的位置
|
|
676
|
-
// Perform pre-layout to calculate the position of all elements
|
|
677
|
-
const result = await layout!.simulate();
|
|
678
|
-
if (align) this.alignLayoutResultToElement(result, id);
|
|
679
|
-
model.updateData(result);
|
|
666
|
+
const { animation } = options;
|
|
667
|
+
const { model } = this.context;
|
|
680
668
|
|
|
681
669
|
// 重新计算数据 / Recalculate data
|
|
682
670
|
const data = this.computeChangesAndDrawData({ stage: 'collapse', animation });
|
|
@@ -718,31 +706,17 @@ export class ElementController {
|
|
|
718
706
|
public async expandNode(id: ID, options: CollapseExpandNodeOptions): Promise<void> {
|
|
719
707
|
const { model, layout } = this.context;
|
|
720
708
|
const { animation, align } = options;
|
|
721
|
-
|
|
722
709
|
const position = positionOf(model.getNodeData([id])[0]);
|
|
723
710
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
// 首先创建展开的元素,然后进行预布局
|
|
728
|
-
// First create the expanded element, then perform pre-layout
|
|
729
|
-
const {
|
|
730
|
-
drawData: { add },
|
|
731
|
-
} = preLayoutData;
|
|
732
|
-
this.createElements(add, { animation: false, stage: 'expand', target: id });
|
|
711
|
+
// 重新计算数据 / Recalculate data
|
|
712
|
+
const data = this.computeChangesAndDrawData({ stage: 'expand', animation });
|
|
713
|
+
this.createElements(data!.drawData.add, { animation: false, stage: 'expand', target: id });
|
|
733
714
|
// 重置动画 / Reset animation
|
|
734
715
|
this.context.animation!.clear();
|
|
735
|
-
|
|
736
|
-
const result = await layout!.simulate();
|
|
737
|
-
if (align) this.alignLayoutResultToElement(result, id);
|
|
738
|
-
model.updateData(result);
|
|
739
|
-
|
|
740
|
-
// 重新计算数据 / Recalculate data
|
|
741
716
|
this.computeStyle('expand');
|
|
742
|
-
const data = this.computeChangesAndDrawData({ stage: 'collapse', animation });
|
|
743
717
|
if (!data) return;
|
|
744
718
|
const { drawData } = data;
|
|
745
|
-
const { update } = drawData;
|
|
719
|
+
const { update, add } = drawData;
|
|
746
720
|
|
|
747
721
|
const context = { animation, stage: 'expand', data: drawData } as const;
|
|
748
722
|
|
package/src/runtime/graph.ts
CHANGED
|
@@ -1845,7 +1845,18 @@ export class Graph extends EventEmitter {
|
|
|
1845
1845
|
|
|
1846
1846
|
await this.frontElement(id);
|
|
1847
1847
|
this.isCollapsingExpanding = true;
|
|
1848
|
-
|
|
1848
|
+
|
|
1849
|
+
// 更新折叠状态 / Update collapse style
|
|
1850
|
+
model.updateData(
|
|
1851
|
+
elementType === 'node'
|
|
1852
|
+
? {
|
|
1853
|
+
nodes: [{ id, style: { collapsed: true } }],
|
|
1854
|
+
}
|
|
1855
|
+
: {
|
|
1856
|
+
combos: [{ id, style: { collapsed: true } }],
|
|
1857
|
+
},
|
|
1858
|
+
);
|
|
1859
|
+
|
|
1849
1860
|
if (elementType === 'node') await element!.collapseNode(id, options);
|
|
1850
1861
|
else if (elementType === 'combo') await element!.collapseCombo(id, !!options.animation);
|
|
1851
1862
|
|
|
@@ -1871,7 +1882,18 @@ export class Graph extends EventEmitter {
|
|
|
1871
1882
|
const elementType = model.getElementType(id);
|
|
1872
1883
|
|
|
1873
1884
|
this.isCollapsingExpanding = true;
|
|
1874
|
-
|
|
1885
|
+
|
|
1886
|
+
// 更新折叠状态 / Update collapse style
|
|
1887
|
+
model.updateData(
|
|
1888
|
+
elementType === 'node'
|
|
1889
|
+
? {
|
|
1890
|
+
nodes: [{ id, style: { collapsed: false } }],
|
|
1891
|
+
}
|
|
1892
|
+
: {
|
|
1893
|
+
combos: [{ id, style: { collapsed: false } }],
|
|
1894
|
+
},
|
|
1895
|
+
);
|
|
1896
|
+
|
|
1875
1897
|
if (elementType === 'node') await element!.expandNode(id, options);
|
|
1876
1898
|
else if (elementType === 'combo') await element!.expandCombo(id, !!options.animation);
|
|
1877
1899
|
|
|
@@ -34,7 +34,7 @@ export class CollapseExpandNode extends BaseTransform {
|
|
|
34
34
|
const id = idOf(node);
|
|
35
35
|
weakAssignTo(input, 'add', 'node', node);
|
|
36
36
|
|
|
37
|
-
const relatedEdges = this.context.model.getRelatedEdgesData(id
|
|
37
|
+
const relatedEdges = this.context.model.getRelatedEdgesData(id);
|
|
38
38
|
relatedEdges.forEach((edge) => {
|
|
39
39
|
reassignTo(input, 'add', 'edge', edge);
|
|
40
40
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type UnknownStruct = Record<string, unknown>;
|
package/src/utils/layout.ts
CHANGED
|
@@ -151,9 +151,8 @@ export function layoutAdapter(
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
private transformOptions(options: STDLayoutOptions) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (!onTick) return options;
|
|
154
|
+
if (!('onTick' in options)) return options;
|
|
155
|
+
const onTick = options.onTick as (data: GraphData) => void;
|
|
157
156
|
options.onTick = (data: LayoutMapping) => onTick(layoutMapping2GraphData(data));
|
|
158
157
|
return options;
|
|
159
158
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.0.
|
|
1
|
+
export const version = '5.0.49';
|