@antv/g6 5.0.0-beta.5 → 5.0.0-beta.6
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/esm/index.d.ts +13 -1
- package/esm/index.js +1 -1
- package/esm/item/combo.d.ts +1 -1
- package/esm/item/combo.js +16 -9
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +1 -1
- package/esm/item/edge.js +15 -7
- package/esm/item/edge.js.map +1 -1
- package/esm/item/node.d.ts +1 -1
- package/esm/item/node.js +16 -9
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +1 -0
- package/esm/runtime/controller/item.js +19 -3
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/graph.d.ts +82 -4
- package/esm/runtime/graph.js +361 -47
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/brush-select.js +1 -2
- package/esm/stdlib/behavior/brush-select.js.map +1 -1
- package/esm/stdlib/behavior/create-edge.d.ts +57 -0
- package/esm/stdlib/behavior/create-edge.js +206 -0
- package/esm/stdlib/behavior/create-edge.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +7 -7
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
- package/esm/stdlib/behavior/drag-combo.js +35 -24
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +3 -3
- package/esm/stdlib/behavior/drag-node.js +70 -57
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/index.d.ts +2 -0
- package/esm/stdlib/behavior/index.js +2 -0
- package/esm/stdlib/behavior/index.js.map +1 -1
- package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
- package/esm/stdlib/behavior/lasso-select.js +1 -2
- package/esm/stdlib/behavior/lasso-select.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/esm/stdlib/behavior/scroll-canvas.js +266 -0
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -1
- package/esm/stdlib/behavior/zoom-canvas.js +7 -7
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/index.d.ts +4 -0
- package/esm/stdlib/index.js +5 -1
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
- package/esm/stdlib/plugin/minimap/index.js +109 -8
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/types/graph.d.ts +31 -5
- package/esm/types/hook.d.ts +16 -2
- package/esm/types/spec.d.ts +6 -3
- package/esm/util/item.d.ts +16 -1
- package/esm/util/item.js +31 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/warn.d.ts +14 -0
- package/esm/util/warn.js +4 -0
- package/esm/util/warn.js.map +1 -0
- package/lib/index.d.ts +13 -1
- package/lib/index.js +1 -1
- package/lib/item/combo.d.ts +1 -1
- package/lib/item/combo.js +16 -9
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +1 -1
- package/lib/item/edge.js +15 -7
- package/lib/item/edge.js.map +1 -1
- package/lib/item/node.d.ts +1 -1
- package/lib/item/node.js +16 -9
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +1 -0
- package/lib/runtime/controller/item.js +19 -3
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/graph.d.ts +82 -4
- package/lib/runtime/graph.js +361 -47
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/brush-select.js +1 -2
- package/lib/stdlib/behavior/brush-select.js.map +1 -1
- package/lib/stdlib/behavior/create-edge.d.ts +57 -0
- package/lib/stdlib/behavior/create-edge.js +210 -0
- package/lib/stdlib/behavior/create-edge.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +7 -7
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
- package/lib/stdlib/behavior/drag-combo.js +35 -24
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +3 -3
- package/lib/stdlib/behavior/drag-node.js +70 -57
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/index.d.ts +2 -0
- package/lib/stdlib/behavior/index.js +2 -0
- package/lib/stdlib/behavior/index.js.map +1 -1
- package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
- package/lib/stdlib/behavior/lasso-select.js +1 -2
- package/lib/stdlib/behavior/lasso-select.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/lib/stdlib/behavior/scroll-canvas.js +270 -0
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -1
- package/lib/stdlib/behavior/zoom-canvas.js +7 -7
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/index.d.ts +4 -0
- package/lib/stdlib/index.js +5 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
- package/lib/stdlib/plugin/minimap/index.js +109 -8
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/types/graph.d.ts +31 -5
- package/lib/types/hook.d.ts +16 -2
- package/lib/types/spec.d.ts +6 -3
- package/lib/util/item.d.ts +16 -1
- package/lib/util/item.js +33 -9
- package/lib/util/item.js.map +1 -1
- package/lib/util/warn.d.ts +14 -0
- package/lib/util/warn.js +8 -0
- package/lib/util/warn.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/item/combo.ts +14 -9
- package/src/item/edge.ts +13 -7
- package/src/item/node.ts +14 -9
- package/src/runtime/controller/item.ts +28 -6
- package/src/runtime/graph.ts +445 -51
- package/src/stdlib/behavior/brush-select.ts +4 -2
- package/src/stdlib/behavior/create-edge.ts +295 -0
- package/src/stdlib/behavior/drag-canvas.ts +8 -8
- package/src/stdlib/behavior/drag-combo.ts +2 -2
- package/src/stdlib/behavior/drag-node.ts +8 -8
- package/src/stdlib/behavior/index.ts +2 -0
- package/src/stdlib/behavior/lasso-select.ts +5 -3
- package/src/stdlib/behavior/scroll-canvas.ts +348 -0
- package/src/stdlib/behavior/zoom-canvas.ts +8 -8
- package/src/stdlib/index.ts +6 -0
- package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
- package/src/stdlib/plugin/minimap/index.ts +113 -9
- package/src/types/graph.ts +31 -5
- package/src/types/hook.ts +16 -2
- package/src/types/spec.ts +9 -3
- package/src/util/item.ts +65 -28
- package/src/util/warn.ts +20 -0
package/src/item/combo.ts
CHANGED
|
@@ -264,7 +264,7 @@ export default class Combo extends Node {
|
|
|
264
264
|
// @ts-ignore
|
|
265
265
|
public clone(
|
|
266
266
|
containerGroup: Group,
|
|
267
|
-
|
|
267
|
+
shapeIds?: string[],
|
|
268
268
|
disableAnimate?: boolean,
|
|
269
269
|
getCombinedBounds?: () =>
|
|
270
270
|
| {
|
|
@@ -276,14 +276,19 @@ export default class Combo extends Node {
|
|
|
276
276
|
| false,
|
|
277
277
|
getChildren?: () => (Node | Combo)[],
|
|
278
278
|
) {
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
279
|
+
if (shapeIds?.length) {
|
|
280
|
+
const group = new Group();
|
|
281
|
+
shapeIds.forEach((shapeId) => {
|
|
282
|
+
if (!this.shapeMap[shapeId] || this.shapeMap[shapeId].destroyed) return;
|
|
283
|
+
const clonedKeyShape = this.shapeMap[shapeId].cloneNode();
|
|
284
|
+
// TODO: other animating attributes?
|
|
285
|
+
clonedKeyShape.style.opacity =
|
|
286
|
+
this.renderExt.mergedStyles[shapeId]?.opacity || 1;
|
|
287
|
+
group.appendChild(clonedKeyShape);
|
|
288
|
+
});
|
|
289
|
+
group.setPosition(this.group.getPosition());
|
|
290
|
+
containerGroup.appendChild(group);
|
|
291
|
+
return group;
|
|
287
292
|
}
|
|
288
293
|
const clonedModel = clone(this.model);
|
|
289
294
|
clonedModel.data.disableAnimate = disableAnimate;
|
package/src/item/edge.ts
CHANGED
|
@@ -194,15 +194,21 @@ export default class Edge extends Item {
|
|
|
194
194
|
containerGroup: Group,
|
|
195
195
|
sourceItem: Node | Combo,
|
|
196
196
|
targetItem: Node | Combo,
|
|
197
|
-
|
|
197
|
+
shapeIds?: string[],
|
|
198
198
|
disableAnimate?: boolean,
|
|
199
199
|
) {
|
|
200
|
-
if (
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
if (shapeIds?.length) {
|
|
201
|
+
const group = new Group();
|
|
202
|
+
shapeIds.forEach((shapeId) => {
|
|
203
|
+
if (!this.shapeMap[shapeId] || this.shapeMap[shapeId].destroyed) return;
|
|
204
|
+
const clonedKeyShape = this.shapeMap[shapeId].cloneNode();
|
|
205
|
+
// TODO: other animating attributes?
|
|
206
|
+
clonedKeyShape.style.opacity =
|
|
207
|
+
this.renderExt.mergedStyles[shapeId]?.opacity || 1;
|
|
208
|
+
group.appendChild(clonedKeyShape);
|
|
209
|
+
});
|
|
210
|
+
containerGroup.appendChild(group);
|
|
211
|
+
return group;
|
|
206
212
|
}
|
|
207
213
|
const clonedModel = clone(this.model);
|
|
208
214
|
clonedModel.data.disableAnimate = disableAnimate;
|
package/src/item/node.ts
CHANGED
|
@@ -205,17 +205,22 @@ export default class Node extends Item {
|
|
|
205
205
|
|
|
206
206
|
public clone(
|
|
207
207
|
containerGroup: Group,
|
|
208
|
-
|
|
208
|
+
shapeIds?: string[],
|
|
209
209
|
disableAnimate?: boolean,
|
|
210
210
|
) {
|
|
211
|
-
if (
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
211
|
+
if (shapeIds?.length) {
|
|
212
|
+
const group = new Group();
|
|
213
|
+
shapeIds.forEach((shapeId) => {
|
|
214
|
+
if (!this.shapeMap[shapeId] || this.shapeMap[shapeId].destroyed) return;
|
|
215
|
+
const clonedKeyShape = this.shapeMap[shapeId].cloneNode();
|
|
216
|
+
// TODO: other animating attributes?
|
|
217
|
+
clonedKeyShape.style.opacity =
|
|
218
|
+
this.renderExt.mergedStyles[shapeId]?.opacity || 1;
|
|
219
|
+
group.appendChild(clonedKeyShape);
|
|
220
|
+
});
|
|
221
|
+
group.setPosition(this.group.getPosition());
|
|
222
|
+
containerGroup.appendChild(group);
|
|
223
|
+
return group;
|
|
219
224
|
}
|
|
220
225
|
const clonedModel = clone(this.model);
|
|
221
226
|
clonedModel.data.disableAnimate = disableAnimate;
|
|
@@ -177,6 +177,7 @@ export class ItemController {
|
|
|
177
177
|
this.graph.hooks.transientupdate.tap(this.onTransientUpdate.bind(this));
|
|
178
178
|
this.graph.hooks.viewportchange.tap(this.onViewportChange.bind(this));
|
|
179
179
|
this.graph.hooks.themechange.tap(this.onThemeChange.bind(this));
|
|
180
|
+
this.graph.hooks.mapperchange.tap(this.onMapperChange.bind(this));
|
|
180
181
|
this.graph.hooks.treecollapseexpand.tap(
|
|
181
182
|
this.onTreeCollapseExpand.bind(this),
|
|
182
183
|
);
|
|
@@ -850,6 +851,16 @@ export class ItemController {
|
|
|
850
851
|
});
|
|
851
852
|
};
|
|
852
853
|
|
|
854
|
+
private onMapperChange = ({ type, mapper }) => {
|
|
855
|
+
if (!mapper) return;
|
|
856
|
+
this.itemMap.forEach((item) => {
|
|
857
|
+
const itemTye = item.getType();
|
|
858
|
+
if (itemTye !== type) return;
|
|
859
|
+
item.mapper = mapper;
|
|
860
|
+
item.update(item.model, undefined, false);
|
|
861
|
+
});
|
|
862
|
+
};
|
|
863
|
+
|
|
853
864
|
private onDestroy = () => {
|
|
854
865
|
Object.values(this.itemMap).forEach((item) => item.destroy());
|
|
855
866
|
// Fix OOM problem, since this map will hold all the refs of items.
|
|
@@ -860,12 +871,17 @@ export class ItemController {
|
|
|
860
871
|
type: ITEM_TYPE | SHAPE_TYPE;
|
|
861
872
|
id: ID;
|
|
862
873
|
config: {
|
|
874
|
+
action: 'remove' | 'add' | 'update' | undefined;
|
|
863
875
|
style?: ShapeStyle;
|
|
864
|
-
|
|
876
|
+
/** Data to be merged into the transient item. */
|
|
865
877
|
data?: Record<string, any>;
|
|
866
|
-
|
|
867
|
-
|
|
878
|
+
shapeIds?: string[];
|
|
879
|
+
/** For type: 'edge' */
|
|
880
|
+
drawSource?: boolean;
|
|
881
|
+
/** For type: 'edge' */
|
|
882
|
+
drawTarget?: boolean;
|
|
868
883
|
upsertAncestors?: boolean;
|
|
884
|
+
visible?: boolean;
|
|
869
885
|
[shapeConfig: string]: unknown;
|
|
870
886
|
};
|
|
871
887
|
canvas: Canvas;
|
|
@@ -878,8 +894,11 @@ export class ItemController {
|
|
|
878
894
|
data = {},
|
|
879
895
|
capture,
|
|
880
896
|
action,
|
|
881
|
-
|
|
897
|
+
shapeIds,
|
|
898
|
+
drawSource,
|
|
899
|
+
drawTarget,
|
|
882
900
|
upsertAncestors,
|
|
901
|
+
visible = true,
|
|
883
902
|
} = config as any;
|
|
884
903
|
const isItemType = type === 'node' || type === 'edge' || type === 'combo';
|
|
885
904
|
// Removing
|
|
@@ -902,6 +921,9 @@ export class ItemController {
|
|
|
902
921
|
);
|
|
903
922
|
}
|
|
904
923
|
if (transientItem && !transientItem.destroyed) {
|
|
924
|
+
if (!(transientItem as Node | Edge | Combo).getType?.()) {
|
|
925
|
+
(transientItem as Group).remove();
|
|
926
|
+
}
|
|
905
927
|
transientItem.destroy();
|
|
906
928
|
}
|
|
907
929
|
this.transientItemMap.delete(id);
|
|
@@ -930,11 +952,11 @@ export class ItemController {
|
|
|
930
952
|
this.transientItemMap,
|
|
931
953
|
this.itemMap,
|
|
932
954
|
graphCore,
|
|
933
|
-
|
|
955
|
+
{ shapeIds, drawSource, drawTarget, visible },
|
|
934
956
|
upsertAncestors,
|
|
935
957
|
);
|
|
936
958
|
|
|
937
|
-
if (
|
|
959
|
+
if (shapeIds) {
|
|
938
960
|
// only update node positions to cloned node container(group)
|
|
939
961
|
if (
|
|
940
962
|
(type === 'node' || type === 'combo') &&
|