@html-graph/html-graph 9.0.0 → 9.1.0
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/html-graph.d.ts +20 -14
- package/dist/html-graph.js +26 -14
- package/dist/html-graph.min.js +499 -494
- package/dist/html-graph.min.umd.cjs +1 -1
- package/dist/html-graph.umd.cjs +26 -14
- package/package.json +1 -1
package/dist/html-graph.d.ts
CHANGED
|
@@ -259,13 +259,15 @@ export declare interface CenterConfig {
|
|
|
259
259
|
export declare type CenterFn = (width: number, height: number) => Point;
|
|
260
260
|
|
|
261
261
|
export declare interface ConnectablePortsConfig {
|
|
262
|
-
readonly edgeShape?: EdgeShapeConfig;
|
|
263
|
-
readonly connectionTypeResolver?: ConnectionTypeResolver;
|
|
264
|
-
readonly connectionAllowedVerifier?: ConnectionAllowedVerifier;
|
|
265
|
-
readonly connectionPreprocessor?: ConnectionPreprocessor;
|
|
266
|
-
readonly mouseDownEventVerifier?: MouseEventVerifier;
|
|
267
|
-
readonly mouseUpEventVerifier?: MouseEventVerifier;
|
|
268
|
-
readonly dragPortDirection?: DraggingPortDirectionConfig;
|
|
262
|
+
readonly edgeShape?: EdgeShapeConfig | undefined;
|
|
263
|
+
readonly connectionTypeResolver?: ConnectionTypeResolver | undefined;
|
|
264
|
+
readonly connectionAllowedVerifier?: ConnectionAllowedVerifier | undefined;
|
|
265
|
+
readonly connectionPreprocessor?: ConnectionPreprocessor | undefined;
|
|
266
|
+
readonly mouseDownEventVerifier?: MouseEventVerifier | undefined;
|
|
267
|
+
readonly mouseUpEventVerifier?: MouseEventVerifier | undefined;
|
|
268
|
+
readonly dragPortDirection?: DraggingPortDirectionConfig | undefined;
|
|
269
|
+
readonly grabbedPortIdResolver?: PortIdResolver | undefined;
|
|
270
|
+
readonly releasedPortIdResolver?: PortIdResolver | undefined;
|
|
269
271
|
readonly events?: {
|
|
270
272
|
readonly onAfterEdgeCreated?: (edgeId: Identifier) => void;
|
|
271
273
|
readonly onEdgeCreationInterrupted?: (params: EdgeCreationInProgressParams) => void;
|
|
@@ -343,13 +345,15 @@ declare interface DotsRenderer {
|
|
|
343
345
|
}
|
|
344
346
|
|
|
345
347
|
export declare interface DraggableEdgesConfig {
|
|
346
|
-
readonly connectionPreprocessor?: ConnectionPreprocessor;
|
|
347
|
-
readonly connectionAllowedVerifier?: ConnectionAllowedVerifier;
|
|
348
|
-
readonly mouseDownEventVerifier?: MouseEventVerifier;
|
|
349
|
-
readonly mouseUpEventVerifier?: MouseEventVerifier;
|
|
350
|
-
readonly draggingEdgeResolver?: DraggingEdgeResolver;
|
|
351
|
-
readonly draggingEdgeShape?: EdgeShapeConfig;
|
|
352
|
-
readonly dragPortDirection?: DraggingPortDirectionConfig;
|
|
348
|
+
readonly connectionPreprocessor?: ConnectionPreprocessor | undefined;
|
|
349
|
+
readonly connectionAllowedVerifier?: ConnectionAllowedVerifier | undefined;
|
|
350
|
+
readonly mouseDownEventVerifier?: MouseEventVerifier | undefined;
|
|
351
|
+
readonly mouseUpEventVerifier?: MouseEventVerifier | undefined;
|
|
352
|
+
readonly draggingEdgeResolver?: DraggingEdgeResolver | undefined;
|
|
353
|
+
readonly draggingEdgeShape?: EdgeShapeConfig | undefined;
|
|
354
|
+
readonly dragPortDirection?: DraggingPortDirectionConfig | undefined;
|
|
355
|
+
readonly grabbedPortIdResolver?: PortIdResolver | undefined;
|
|
356
|
+
readonly releasedPortIdResolver?: PortIdResolver | undefined;
|
|
353
357
|
readonly events?: {
|
|
354
358
|
readonly onAfterEdgeReattached?: (edgeId: Identifier) => void;
|
|
355
359
|
readonly onEdgeReattachInterrupted?: (edge: GraphEdge & {
|
|
@@ -802,6 +806,8 @@ export declare interface Point {
|
|
|
802
806
|
|
|
803
807
|
export declare type PortElement = HTMLElement | SVGElement;
|
|
804
808
|
|
|
809
|
+
export declare type PortIdResolver = (portIds: readonly Identifier[]) => Identifier | null;
|
|
810
|
+
|
|
805
811
|
export declare type PortOffset = number | PortOffsetFn | "box";
|
|
806
812
|
|
|
807
813
|
export declare type PortOffsetFn = (params: PortOffsetFnParams) => number;
|
package/dist/html-graph.js
CHANGED
|
@@ -1097,10 +1097,10 @@ var createAddNodeOverlayRequest = (payload) => {
|
|
|
1097
1097
|
};
|
|
1098
1098
|
//#endregion
|
|
1099
1099
|
//#region src/configurators/shared/find-port-at-point/find-port-for-element/find-port-for-element.ts
|
|
1100
|
-
var findPortForElement = (graph, element) => {
|
|
1100
|
+
var findPortForElement = (graph, element, portIdResolver) => {
|
|
1101
1101
|
let elementBuf = element;
|
|
1102
1102
|
while (elementBuf !== null) {
|
|
1103
|
-
const portId = graph.findPortIdsByElement(elementBuf)
|
|
1103
|
+
const portId = portIdResolver(graph.findPortIdsByElement(elementBuf));
|
|
1104
1104
|
if (portId !== null) return {
|
|
1105
1105
|
status: "portFound",
|
|
1106
1106
|
portId
|
|
@@ -1124,10 +1124,10 @@ function* getElementsAtPoint(root, point) {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
//#endregion
|
|
1126
1126
|
//#region src/configurators/shared/find-port-at-point/find-port-at-point.ts
|
|
1127
|
-
var findPortAtPoint = (graph, point) => {
|
|
1127
|
+
var findPortAtPoint = (graph, point, portIdResolver) => {
|
|
1128
1128
|
const elements = getElementsAtPoint(document, point);
|
|
1129
1129
|
for (const element of elements) {
|
|
1130
|
-
const result = findPortForElement(graph, element);
|
|
1130
|
+
const result = findPortForElement(graph, element, portIdResolver);
|
|
1131
1131
|
if (result.status === "portFound") return result.portId;
|
|
1132
1132
|
if (result.status === "nodeEncountered") return null;
|
|
1133
1133
|
}
|
|
@@ -3333,7 +3333,9 @@ var DraggablePortsConfigurator = class DraggablePortsConfigurator {
|
|
|
3333
3333
|
const mouseEvent = event;
|
|
3334
3334
|
if (!this.params.mouseDownEventVerifier(mouseEvent)) return;
|
|
3335
3335
|
const target = event.currentTarget;
|
|
3336
|
-
const
|
|
3336
|
+
const portIds = this.canvas.graph.findPortIdsByElement(target);
|
|
3337
|
+
const portId = this.params.grabbedPortIdResolver(portIds);
|
|
3338
|
+
if (portId === null) return;
|
|
3337
3339
|
if (!this.params.onPointerDownVerifier(portId, {
|
|
3338
3340
|
x: mouseEvent.clientX,
|
|
3339
3341
|
y: mouseEvent.clientY
|
|
@@ -3634,6 +3636,12 @@ var ConstantDraggingPortDirectionResolver = class {
|
|
|
3634
3636
|
}
|
|
3635
3637
|
};
|
|
3636
3638
|
//#endregion
|
|
3639
|
+
//#region src/configurators/shared/port-id-resolver/default-port-id-resolver/default-port-id-resolver.ts
|
|
3640
|
+
var defaultPortIdResolver = (portIds) => {
|
|
3641
|
+
if (portIds.length > 0) return portIds[0];
|
|
3642
|
+
return null;
|
|
3643
|
+
};
|
|
3644
|
+
//#endregion
|
|
3637
3645
|
//#region src/configurators/user-draggable-nodes-configurator/user-draggable-nodes-configurator.ts
|
|
3638
3646
|
var UserDraggableNodesConfigurator = class UserDraggableNodesConfigurator {
|
|
3639
3647
|
canvas;
|
|
@@ -4299,7 +4307,8 @@ var UserConnectablePortsConfigurator = class UserConnectablePortsConfigurator {
|
|
|
4299
4307
|
const params = this.edgeInProgress;
|
|
4300
4308
|
this.resetDragState();
|
|
4301
4309
|
this.params.onEdgeCreationInterrupted(params);
|
|
4302
|
-
}
|
|
4310
|
+
},
|
|
4311
|
+
grabbedPortIdResolver: this.params.grabbedPortIdResolver
|
|
4303
4312
|
};
|
|
4304
4313
|
DraggablePortsConfigurator.configure(this.canvas, this.window, this.pointInsideVerifier, this.eventTagger, draggablePortsParams);
|
|
4305
4314
|
}
|
|
@@ -4353,7 +4362,7 @@ var UserConnectablePortsConfigurator = class UserConnectablePortsConfigurator {
|
|
|
4353
4362
|
this.overlayCanvas.clear();
|
|
4354
4363
|
}
|
|
4355
4364
|
tryCreateConnection(cursor) {
|
|
4356
|
-
const targetPortId = findPortAtPoint(this.canvas.graph, cursor);
|
|
4365
|
+
const targetPortId = findPortAtPoint(this.canvas.graph, cursor, this.params.releasedPortIdResolver);
|
|
4357
4366
|
if (targetPortId === null) {
|
|
4358
4367
|
this.params.onEdgeCreationInterrupted(this.edgeInProgress);
|
|
4359
4368
|
return;
|
|
@@ -4434,7 +4443,8 @@ var UserDraggableEdgesConfigurator = class UserDraggableEdgesConfigurator {
|
|
|
4434
4443
|
shape: edge.shape,
|
|
4435
4444
|
priority: edge.priority
|
|
4436
4445
|
});
|
|
4437
|
-
}
|
|
4446
|
+
},
|
|
4447
|
+
grabbedPortIdResolver: this.params.grabbedPortIdResolver
|
|
4438
4448
|
};
|
|
4439
4449
|
DraggablePortsConfigurator.configure(this.canvas, this.window, this.pointInsideVerifier, this.eventTagger, draggablePortsParams);
|
|
4440
4450
|
}
|
|
@@ -4524,7 +4534,7 @@ var UserDraggableEdgesConfigurator = class UserDraggableEdgesConfigurator {
|
|
|
4524
4534
|
}).updatePort(OverlayId.DraggingNodeId, { direction });
|
|
4525
4535
|
}
|
|
4526
4536
|
tryCreateConnection(cursor) {
|
|
4527
|
-
const draggingPortId = findPortAtPoint(this.canvas.graph, cursor);
|
|
4537
|
+
const draggingPortId = findPortAtPoint(this.canvas.graph, cursor, this.params.releasedPortIdResolver);
|
|
4528
4538
|
this.overlayCanvas.removeEdge(OverlayId.EdgeId);
|
|
4529
4539
|
if (draggingPortId === null) {
|
|
4530
4540
|
const edge = this.draggingEdgePayload;
|
|
@@ -4711,19 +4721,17 @@ var AnimatedLayoutApplier = class {
|
|
|
4711
4721
|
//#endregion
|
|
4712
4722
|
//#region src/configurators/animated-layout-configurator/animated-layout-configurator.ts
|
|
4713
4723
|
var AnimatedLayoutConfigurator = class AnimatedLayoutConfigurator {
|
|
4714
|
-
win;
|
|
4715
4724
|
applier;
|
|
4716
4725
|
step = (dt) => {
|
|
4717
4726
|
this.applier.apply(dt);
|
|
4718
4727
|
};
|
|
4719
4728
|
constructor(canvas, params, win) {
|
|
4720
|
-
this.win = win;
|
|
4721
4729
|
this.applier = new AnimatedLayoutApplier(canvas, params.algorithm, {
|
|
4722
4730
|
staticNodeResolver: params.staticNodeResolver,
|
|
4723
4731
|
onBeforeApplied: params.onBeforeApplied,
|
|
4724
4732
|
onAfterApplied: params.onAfterApplied
|
|
4725
4733
|
});
|
|
4726
|
-
new AnimationSeries(
|
|
4734
|
+
new AnimationSeries(win, this.step);
|
|
4727
4735
|
}
|
|
4728
4736
|
static configure(canvas, params, win) {
|
|
4729
4737
|
new AnimatedLayoutConfigurator(canvas, params, win);
|
|
@@ -5192,7 +5200,9 @@ var createConnectablePortsParams = (config, defaultEdgeShapeFactory, graph) => {
|
|
|
5192
5200
|
mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaults$3.mouseEventVerifier,
|
|
5193
5201
|
onAfterEdgeCreated: config.events?.onAfterEdgeCreated ?? noopFn,
|
|
5194
5202
|
onEdgeCreationInterrupted: config.events?.onEdgeCreationInterrupted ?? noopFn,
|
|
5195
|
-
onEdgeCreationPrevented: config.events?.onEdgeCreationPrevented ?? noopFn
|
|
5203
|
+
onEdgeCreationPrevented: config.events?.onEdgeCreationPrevented ?? noopFn,
|
|
5204
|
+
grabbedPortIdResolver: config.grabbedPortIdResolver ?? defaultPortIdResolver,
|
|
5205
|
+
releasedPortIdResolver: config.releasedPortIdResolver ?? defaultPortIdResolver
|
|
5196
5206
|
};
|
|
5197
5207
|
};
|
|
5198
5208
|
//#endregion
|
|
@@ -5222,7 +5232,9 @@ var createDraggableEdgeParams = (config, graph) => {
|
|
|
5222
5232
|
onAfterEdgeReattached: config.events?.onAfterEdgeReattached ?? noopFn,
|
|
5223
5233
|
onEdgeReattachInterrupted: config.events?.onEdgeReattachInterrupted ?? noopFn,
|
|
5224
5234
|
onEdgeReattachPrevented: config.events?.onEdgeReattachPrevented ?? noopFn,
|
|
5225
|
-
draggingPortDirectionResolver: resolveDraggingPortDirectionResolver(config.dragPortDirection, graph, connectionAllowedVerifier)
|
|
5235
|
+
draggingPortDirectionResolver: resolveDraggingPortDirectionResolver(config.dragPortDirection, graph, connectionAllowedVerifier),
|
|
5236
|
+
grabbedPortIdResolver: config.grabbedPortIdResolver ?? defaultPortIdResolver,
|
|
5237
|
+
releasedPortIdResolver: config.releasedPortIdResolver ?? defaultPortIdResolver
|
|
5226
5238
|
};
|
|
5227
5239
|
};
|
|
5228
5240
|
//#endregion
|