@html-graph/html-graph 0.1.7 → 1.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/README.md +5 -5
- package/dist/main.d.ts +123 -114
- package/dist/main.js +137 -144
- package/dist/main.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ npm i @html-graph/html-graph
|
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
```javascript
|
|
23
|
-
import {
|
|
23
|
+
import { CanvasBuilder } from "@html-graph/html-graph";
|
|
24
24
|
|
|
25
25
|
function createNode({ name, x, y, frontPortId, backPortId }) {
|
|
26
26
|
const node = document.createElement("div");
|
|
@@ -33,9 +33,9 @@ function createNode({ name, x, y, frontPortId, backPortId }) {
|
|
|
33
33
|
backPort.classList.add("port");
|
|
34
34
|
text.innerText = name;
|
|
35
35
|
|
|
36
|
-
node.appendChild(backPort);
|
|
37
|
-
node.appendChild(text);
|
|
38
36
|
node.appendChild(frontPort);
|
|
37
|
+
node.appendChild(text);
|
|
38
|
+
node.appendChild(backPort);
|
|
39
39
|
|
|
40
40
|
return {
|
|
41
41
|
element: node,
|
|
@@ -48,7 +48,7 @@ function createNode({ name, x, y, frontPortId, backPortId }) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const canvas = new
|
|
51
|
+
const canvas = new CanvasBuilder()
|
|
52
52
|
.setOptions({
|
|
53
53
|
edges: {
|
|
54
54
|
shape: {
|
|
@@ -57,7 +57,7 @@ const canvas = new HtmlGraphBuilder()
|
|
|
57
57
|
},
|
|
58
58
|
})
|
|
59
59
|
.setUserDraggableNodes()
|
|
60
|
-
.
|
|
60
|
+
.setUserTransformableViewport()
|
|
61
61
|
.setResizeReactiveNodes()
|
|
62
62
|
.build();
|
|
63
63
|
|
package/dist/main.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare interface AddEdgeRequest {
|
|
2
|
-
readonly id?: unknown;
|
|
2
|
+
readonly id?: unknown | undefined;
|
|
3
3
|
readonly from: string;
|
|
4
4
|
readonly to: string;
|
|
5
|
-
readonly shape?: EdgeShape;
|
|
6
|
-
readonly priority?: number;
|
|
5
|
+
readonly shape?: EdgeShape | undefined;
|
|
6
|
+
readonly priority?: number | undefined;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
declare interface AddEdgeRequest_2 {
|
|
@@ -17,13 +17,13 @@ declare interface AddEdgeRequest_2 {
|
|
|
17
17
|
export declare type AddNodePorts = Iterable<MarkNodePortRequest>;
|
|
18
18
|
|
|
19
19
|
export declare interface AddNodeRequest {
|
|
20
|
-
readonly id?: unknown;
|
|
20
|
+
readonly id?: unknown | undefined;
|
|
21
21
|
readonly element: HTMLElement;
|
|
22
22
|
readonly x: number;
|
|
23
23
|
readonly y: number;
|
|
24
|
-
readonly ports?: AddNodePorts;
|
|
25
|
-
readonly centerFn?: CenterFn;
|
|
26
|
-
readonly priority?: number;
|
|
24
|
+
readonly ports?: AddNodePorts | undefined;
|
|
25
|
+
readonly centerFn?: CenterFn | undefined;
|
|
26
|
+
readonly priority?: number | undefined;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
declare interface AddNodeRequest_2 {
|
|
@@ -76,18 +76,18 @@ export declare class BezierEdgeShape implements EdgeShape {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
declare interface BezierEdgeShape_2 {
|
|
79
|
-
readonly type?: "bezier";
|
|
80
|
-
readonly color?: string;
|
|
81
|
-
readonly width?: number;
|
|
82
|
-
readonly curvature?: number;
|
|
83
|
-
readonly arrowLength?: number;
|
|
84
|
-
readonly arrowWidth?: number;
|
|
85
|
-
readonly hasSourceArrow?: boolean;
|
|
86
|
-
readonly hasTargetArrow?: boolean;
|
|
87
|
-
readonly cycleRadius?: number;
|
|
88
|
-
readonly smallCycleRadius?: number;
|
|
89
|
-
readonly detourDistance?: number;
|
|
90
|
-
readonly detourDirection?: number;
|
|
79
|
+
readonly type?: "bezier" | undefined;
|
|
80
|
+
readonly color?: string | undefined;
|
|
81
|
+
readonly width?: number | undefined;
|
|
82
|
+
readonly curvature?: number | undefined;
|
|
83
|
+
readonly arrowLength?: number | undefined;
|
|
84
|
+
readonly arrowWidth?: number | undefined;
|
|
85
|
+
readonly hasSourceArrow?: boolean | undefined;
|
|
86
|
+
readonly hasTargetArrow?: boolean | undefined;
|
|
87
|
+
readonly cycleRadius?: number | undefined;
|
|
88
|
+
readonly smallCycleRadius?: number | undefined;
|
|
89
|
+
readonly detourDistance?: number | undefined;
|
|
90
|
+
readonly detourDirection?: number | undefined;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export declare interface Canvas {
|
|
@@ -168,6 +168,27 @@ export declare interface Canvas {
|
|
|
168
168
|
destroy(): void;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
declare class CanvasBuilder {
|
|
172
|
+
private coreOptions;
|
|
173
|
+
private dragOptions;
|
|
174
|
+
private transformOptions;
|
|
175
|
+
private isDraggable;
|
|
176
|
+
private isTransformable;
|
|
177
|
+
private hasResizeReactiveNodes;
|
|
178
|
+
setOptions(options: CoreOptions): CanvasBuilder;
|
|
179
|
+
setUserDraggableNodes(options?: DragOptions): CanvasBuilder;
|
|
180
|
+
/**
|
|
181
|
+
* @deprecated
|
|
182
|
+
* use setUserTransformableViewport instead
|
|
183
|
+
*/
|
|
184
|
+
setUserTransformableCanvas(options?: TransformOptions): CanvasBuilder;
|
|
185
|
+
setUserTransformableViewport(options?: TransformOptions): CanvasBuilder;
|
|
186
|
+
setResizeReactiveNodes(): CanvasBuilder;
|
|
187
|
+
build(): Canvas;
|
|
188
|
+
}
|
|
189
|
+
export { CanvasBuilder }
|
|
190
|
+
export { CanvasBuilder as HtmlGraphBuilder }
|
|
191
|
+
|
|
171
192
|
/**
|
|
172
193
|
* Provides low level API for acting on graph
|
|
173
194
|
*/
|
|
@@ -262,8 +283,8 @@ declare interface EdgePayload {
|
|
|
262
283
|
}
|
|
263
284
|
|
|
264
285
|
export declare interface EdgeRenderParams {
|
|
265
|
-
readonly
|
|
266
|
-
readonly
|
|
286
|
+
readonly from: EdgeRenderPort;
|
|
287
|
+
readonly to: EdgeRenderPort;
|
|
267
288
|
}
|
|
268
289
|
|
|
269
290
|
export declare interface EdgeRenderPort {
|
|
@@ -375,31 +396,17 @@ export declare class HorizontalEdgeShape implements EdgeShape {
|
|
|
375
396
|
|
|
376
397
|
declare interface HorizontalEdgeShape_2 {
|
|
377
398
|
readonly type: "horizontal";
|
|
378
|
-
readonly color?: string;
|
|
379
|
-
readonly width?: number;
|
|
380
|
-
readonly arrowLength?: number;
|
|
381
|
-
readonly arrowWidth?: number;
|
|
382
|
-
readonly arrowOffset?: number;
|
|
383
|
-
readonly hasSourceArrow?: boolean;
|
|
384
|
-
readonly hasTargetArrow?: boolean;
|
|
385
|
-
readonly cycleSquareSide?: number;
|
|
386
|
-
readonly roundness?: number;
|
|
387
|
-
readonly detourDistance?: number;
|
|
388
|
-
readonly detourDirection?: number;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
export declare class HtmlGraphBuilder {
|
|
392
|
-
private coreOptions;
|
|
393
|
-
private dragOptions;
|
|
394
|
-
private transformOptions;
|
|
395
|
-
private isDraggable;
|
|
396
|
-
private isTransformable;
|
|
397
|
-
private hasResizeReactiveNodes;
|
|
398
|
-
setOptions(options: CoreOptions): HtmlGraphBuilder;
|
|
399
|
-
setUserDraggableNodes(options?: DragOptions): HtmlGraphBuilder;
|
|
400
|
-
setUserTransformableCanvas(options?: TransformOptions): HtmlGraphBuilder;
|
|
401
|
-
setResizeReactiveNodes(): HtmlGraphBuilder;
|
|
402
|
-
build(): Canvas;
|
|
399
|
+
readonly color?: string | undefined;
|
|
400
|
+
readonly width?: number | undefined;
|
|
401
|
+
readonly arrowLength?: number | undefined;
|
|
402
|
+
readonly arrowWidth?: number | undefined;
|
|
403
|
+
readonly arrowOffset?: number | undefined;
|
|
404
|
+
readonly hasSourceArrow?: boolean | undefined;
|
|
405
|
+
readonly hasTargetArrow?: boolean | undefined;
|
|
406
|
+
readonly cycleSquareSide?: number | undefined;
|
|
407
|
+
readonly roundness?: number | undefined;
|
|
408
|
+
readonly detourDistance?: number | undefined;
|
|
409
|
+
readonly detourDirection?: number | undefined;
|
|
403
410
|
}
|
|
404
411
|
|
|
405
412
|
export declare class HtmlGraphError extends Error {
|
|
@@ -409,16 +416,16 @@ export declare class HtmlGraphError extends Error {
|
|
|
409
416
|
declare type IncrementalPriority = "incremental";
|
|
410
417
|
|
|
411
418
|
export declare type MarkNodePortRequest = {
|
|
412
|
-
readonly id?: unknown;
|
|
419
|
+
readonly id?: unknown | undefined;
|
|
413
420
|
readonly element: HTMLElement;
|
|
414
|
-
readonly direction?: number;
|
|
421
|
+
readonly direction?: number | undefined;
|
|
415
422
|
};
|
|
416
423
|
|
|
417
424
|
export declare interface MarkPortRequest {
|
|
418
|
-
readonly id?: unknown;
|
|
425
|
+
readonly id?: unknown | undefined;
|
|
419
426
|
readonly element: HTMLElement;
|
|
420
427
|
readonly nodeId: unknown;
|
|
421
|
-
readonly direction?: number;
|
|
428
|
+
readonly direction?: number | undefined;
|
|
422
429
|
}
|
|
423
430
|
|
|
424
431
|
export declare interface NodeDragPayload {
|
|
@@ -437,15 +444,15 @@ declare interface NodePayload {
|
|
|
437
444
|
}
|
|
438
445
|
|
|
439
446
|
export declare interface PatchMatrixRequest {
|
|
440
|
-
readonly scale?: number;
|
|
441
|
-
readonly
|
|
442
|
-
readonly
|
|
447
|
+
readonly scale?: number | undefined;
|
|
448
|
+
readonly x?: number | undefined;
|
|
449
|
+
readonly y?: number | undefined;
|
|
443
450
|
}
|
|
444
451
|
|
|
445
452
|
declare interface PatchTransformRequest {
|
|
446
453
|
readonly scale?: number;
|
|
447
|
-
readonly
|
|
448
|
-
readonly
|
|
454
|
+
readonly x?: number;
|
|
455
|
+
readonly y?: number;
|
|
449
456
|
}
|
|
450
457
|
|
|
451
458
|
export declare interface Point {
|
|
@@ -469,18 +476,18 @@ export declare class PublicGraphStore {
|
|
|
469
476
|
getAllNodeIds(): readonly unknown[];
|
|
470
477
|
getPort(portId: unknown): GraphPort | null;
|
|
471
478
|
getAllPortIds(): readonly unknown[];
|
|
472
|
-
getNodePortIds(nodeId: unknown): readonly unknown[] |
|
|
479
|
+
getNodePortIds(nodeId: unknown): readonly unknown[] | null;
|
|
473
480
|
getPortNodeId(portId: unknown): unknown | null;
|
|
474
481
|
getAllEdgeIds(): readonly unknown[];
|
|
475
482
|
getEdge(edgeId: unknown): GraphEdge | null;
|
|
476
|
-
getPortIncomingEdgeIds(portId: unknown): readonly unknown[];
|
|
477
|
-
getPortOutcomingEdgeIds(portId: unknown): readonly unknown[];
|
|
478
|
-
getPortCycleEdgeIds(portId: unknown): readonly unknown[];
|
|
479
|
-
getPortAdjacentEdgeIds(portId: unknown): readonly unknown[];
|
|
480
|
-
getNodeIncomingEdgeIds(nodeId: unknown): readonly unknown[];
|
|
481
|
-
getNodeOutcomingEdgeIds(nodeId: unknown): readonly unknown[];
|
|
482
|
-
getNodeCycleEdgeIds(nodeId: unknown): readonly unknown[];
|
|
483
|
-
getNodeAdjacentEdgeIds(nodeId: unknown): readonly unknown[];
|
|
483
|
+
getPortIncomingEdgeIds(portId: unknown): readonly unknown[] | null;
|
|
484
|
+
getPortOutcomingEdgeIds(portId: unknown): readonly unknown[] | null;
|
|
485
|
+
getPortCycleEdgeIds(portId: unknown): readonly unknown[] | null;
|
|
486
|
+
getPortAdjacentEdgeIds(portId: unknown): readonly unknown[] | null;
|
|
487
|
+
getNodeIncomingEdgeIds(nodeId: unknown): readonly unknown[] | null;
|
|
488
|
+
getNodeOutcomingEdgeIds(nodeId: unknown): readonly unknown[] | null;
|
|
489
|
+
getNodeCycleEdgeIds(nodeId: unknown): readonly unknown[] | null;
|
|
490
|
+
getNodeAdjacentEdgeIds(nodeId: unknown): readonly unknown[] | null;
|
|
484
491
|
}
|
|
485
492
|
|
|
486
493
|
export declare class PublicViewportTransformer {
|
|
@@ -565,17 +572,17 @@ export declare class StraightEdgeShape implements EdgeShape {
|
|
|
565
572
|
|
|
566
573
|
declare interface StraightEdgeShape_2 {
|
|
567
574
|
readonly type: "straight";
|
|
568
|
-
readonly color?: string;
|
|
569
|
-
readonly width?: number;
|
|
570
|
-
readonly arrowLength?: number;
|
|
571
|
-
readonly arrowWidth?: number;
|
|
572
|
-
readonly arrowOffset?: number;
|
|
573
|
-
readonly hasSourceArrow?: boolean;
|
|
574
|
-
readonly hasTargetArrow?: boolean;
|
|
575
|
-
readonly cycleSquareSide?: number;
|
|
576
|
-
readonly roundness?: number;
|
|
577
|
-
readonly detourDistance?: number;
|
|
578
|
-
readonly detourDirection?: number;
|
|
575
|
+
readonly color?: string | undefined;
|
|
576
|
+
readonly width?: number | undefined;
|
|
577
|
+
readonly arrowLength?: number | undefined;
|
|
578
|
+
readonly arrowWidth?: number | undefined;
|
|
579
|
+
readonly arrowOffset?: number | undefined;
|
|
580
|
+
readonly hasSourceArrow?: boolean | undefined;
|
|
581
|
+
readonly hasTargetArrow?: boolean | undefined;
|
|
582
|
+
readonly cycleSquareSide?: number | undefined;
|
|
583
|
+
readonly roundness?: number | undefined;
|
|
584
|
+
readonly detourDistance?: number | undefined;
|
|
585
|
+
readonly detourDirection?: number | undefined;
|
|
579
586
|
}
|
|
580
587
|
|
|
581
588
|
export declare interface TransformOptions {
|
|
@@ -599,8 +606,8 @@ export declare interface TransformOptions {
|
|
|
599
606
|
|
|
600
607
|
export declare interface TransformPayload {
|
|
601
608
|
readonly scale: number;
|
|
602
|
-
readonly
|
|
603
|
-
readonly
|
|
609
|
+
readonly x: number;
|
|
610
|
+
readonly y: number;
|
|
604
611
|
}
|
|
605
612
|
|
|
606
613
|
export declare type TransformPreprocessorFn = (params: TransformPreprocessorParams) => TransformPayload;
|
|
@@ -626,26 +633,26 @@ export declare interface TransformPreprocessorParams {
|
|
|
626
633
|
|
|
627
634
|
declare interface TransformState {
|
|
628
635
|
readonly scale: number;
|
|
629
|
-
readonly
|
|
630
|
-
readonly
|
|
636
|
+
readonly x: number;
|
|
637
|
+
readonly y: number;
|
|
631
638
|
}
|
|
632
639
|
|
|
633
640
|
export declare interface UpdateEdgeRequest {
|
|
634
|
-
readonly from?: unknown;
|
|
635
|
-
readonly to?: unknown;
|
|
636
|
-
readonly shape?: EdgeShape;
|
|
637
|
-
readonly priority?: number;
|
|
641
|
+
readonly from?: unknown | undefined;
|
|
642
|
+
readonly to?: unknown | undefined;
|
|
643
|
+
readonly shape?: EdgeShape | undefined;
|
|
644
|
+
readonly priority?: number | undefined;
|
|
638
645
|
}
|
|
639
646
|
|
|
640
647
|
export declare interface UpdateNodeRequest {
|
|
641
|
-
readonly x?: number;
|
|
642
|
-
readonly y?: number;
|
|
643
|
-
readonly priority?: number;
|
|
644
|
-
readonly centerFn?: CenterFn;
|
|
648
|
+
readonly x?: number | undefined;
|
|
649
|
+
readonly y?: number | undefined;
|
|
650
|
+
readonly priority?: number | undefined;
|
|
651
|
+
readonly centerFn?: CenterFn | undefined;
|
|
645
652
|
}
|
|
646
653
|
|
|
647
654
|
export declare interface UpdatePortRequest {
|
|
648
|
-
readonly direction?: number;
|
|
655
|
+
readonly direction?: number | undefined;
|
|
649
656
|
}
|
|
650
657
|
|
|
651
658
|
export declare class UserDraggableNodesCanvas implements Canvas {
|
|
@@ -689,7 +696,7 @@ export declare class UserDraggableNodesCanvas implements Canvas {
|
|
|
689
696
|
private removeTouchDragListeners;
|
|
690
697
|
}
|
|
691
698
|
|
|
692
|
-
|
|
699
|
+
declare class UserTransformableViewportCanvas implements Canvas {
|
|
693
700
|
private readonly canvas;
|
|
694
701
|
readonly model: PublicGraphStore;
|
|
695
702
|
readonly transformation: PublicViewportTransformer;
|
|
@@ -706,20 +713,20 @@ export declare class UserTransformableCanvas implements Canvas {
|
|
|
706
713
|
private readonly observer;
|
|
707
714
|
private readonly options;
|
|
708
715
|
constructor(canvas: Canvas, transformOptions?: TransformOptions);
|
|
709
|
-
attach(element: HTMLElement):
|
|
710
|
-
detach():
|
|
711
|
-
addNode(node: AddNodeRequest):
|
|
712
|
-
updateNode(nodeId: unknown, request?: UpdateNodeRequest):
|
|
713
|
-
removeNode(nodeId: unknown):
|
|
714
|
-
markPort(port: MarkPortRequest):
|
|
715
|
-
updatePort(portId: string, request?: UpdatePortRequest):
|
|
716
|
-
unmarkPort(portId: string):
|
|
717
|
-
addEdge(edge: AddEdgeRequest):
|
|
718
|
-
updateEdge(edgeId: unknown, request?: UpdateEdgeRequest):
|
|
719
|
-
removeEdge(edgeId: unknown):
|
|
720
|
-
patchViewportMatrix(request: PatchMatrixRequest):
|
|
721
|
-
patchContentMatrix(request: PatchMatrixRequest):
|
|
722
|
-
clear():
|
|
716
|
+
attach(element: HTMLElement): UserTransformableViewportCanvas;
|
|
717
|
+
detach(): UserTransformableViewportCanvas;
|
|
718
|
+
addNode(node: AddNodeRequest): UserTransformableViewportCanvas;
|
|
719
|
+
updateNode(nodeId: unknown, request?: UpdateNodeRequest): UserTransformableViewportCanvas;
|
|
720
|
+
removeNode(nodeId: unknown): UserTransformableViewportCanvas;
|
|
721
|
+
markPort(port: MarkPortRequest): UserTransformableViewportCanvas;
|
|
722
|
+
updatePort(portId: string, request?: UpdatePortRequest): UserTransformableViewportCanvas;
|
|
723
|
+
unmarkPort(portId: string): UserTransformableViewportCanvas;
|
|
724
|
+
addEdge(edge: AddEdgeRequest): UserTransformableViewportCanvas;
|
|
725
|
+
updateEdge(edgeId: unknown, request?: UpdateEdgeRequest): UserTransformableViewportCanvas;
|
|
726
|
+
removeEdge(edgeId: unknown): UserTransformableViewportCanvas;
|
|
727
|
+
patchViewportMatrix(request: PatchMatrixRequest): UserTransformableViewportCanvas;
|
|
728
|
+
patchContentMatrix(request: PatchMatrixRequest): UserTransformableViewportCanvas;
|
|
729
|
+
clear(): UserTransformableViewportCanvas;
|
|
723
730
|
destroy(): void;
|
|
724
731
|
private moveViewport;
|
|
725
732
|
private scaleViewport;
|
|
@@ -728,6 +735,8 @@ export declare class UserTransformableCanvas implements Canvas {
|
|
|
728
735
|
private stopTouchDrag;
|
|
729
736
|
private removeTouchDragListeners;
|
|
730
737
|
}
|
|
738
|
+
export { UserTransformableViewportCanvas as UserTransformableCanvas }
|
|
739
|
+
export { UserTransformableViewportCanvas }
|
|
731
740
|
|
|
732
741
|
export declare interface VerticalEdgeParams {
|
|
733
742
|
readonly color?: string | undefined;
|
|
@@ -764,17 +773,17 @@ export declare class VerticalEdgeShape implements EdgeShape {
|
|
|
764
773
|
|
|
765
774
|
declare interface VerticalEdgeShape_2 {
|
|
766
775
|
readonly type: "vertical";
|
|
767
|
-
readonly color?: string;
|
|
768
|
-
readonly width?: number;
|
|
769
|
-
readonly arrowLength?: number;
|
|
770
|
-
readonly arrowWidth?: number;
|
|
771
|
-
readonly arrowOffset?: number;
|
|
772
|
-
readonly hasSourceArrow?: boolean;
|
|
773
|
-
readonly hasTargetArrow?: boolean;
|
|
774
|
-
readonly cycleSquareSide?: number;
|
|
775
|
-
readonly roundness?: number;
|
|
776
|
-
readonly detourDistance?: number;
|
|
777
|
-
readonly detourDirection?: number;
|
|
776
|
+
readonly color?: string | undefined;
|
|
777
|
+
readonly width?: number | undefined;
|
|
778
|
+
readonly arrowLength?: number | undefined;
|
|
779
|
+
readonly arrowWidth?: number | undefined;
|
|
780
|
+
readonly arrowOffset?: number | undefined;
|
|
781
|
+
readonly hasSourceArrow?: boolean | undefined;
|
|
782
|
+
readonly hasTargetArrow?: boolean | undefined;
|
|
783
|
+
readonly cycleSquareSide?: number | undefined;
|
|
784
|
+
readonly roundness?: number | undefined;
|
|
785
|
+
readonly detourDistance?: number | undefined;
|
|
786
|
+
readonly detourDirection?: number | undefined;
|
|
778
787
|
}
|
|
779
788
|
|
|
780
789
|
declare class ViewportTransformer {
|