@html-graph/html-graph 5.1.0 → 6.0.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 CHANGED
@@ -2,7 +2,7 @@
2
2
  <img src="/media/logo-label.svg" alt="HTMLGraph" width="520" height="100"/>
3
3
  </p>
4
4
 
5
- <a target="_blank" href="https://html-graph.github.io/use-cases/advanced-demo/">
5
+ <a target="_blank" href="https://html-graph.github.io">
6
6
  <img width="100%" src="https://raw.githubusercontent.com/html-graph/html-graph/master/media/full-demo.gif"/>
7
7
  </a>
8
8
 
@@ -42,6 +42,14 @@ declare interface AddPortRequest {
42
42
  readonly direction: number;
43
43
  }
44
44
 
45
+ export declare interface AnimatedLayoutAlgorithm {
46
+ calculateNextCoordinates(graph: Graph, dt: number): ReadonlyMap<Identifier, Point>;
47
+ }
48
+
49
+ export declare interface AnimatedLayoutConfig {
50
+ readonly algorithm: AnimatedLayoutAlgorithm;
51
+ }
52
+
45
53
  export declare type ArrowRenderer = (params: ArrowRenderingParams) => string;
46
54
 
47
55
  export declare type ArrowRendererConfig = {
@@ -225,7 +233,9 @@ export declare class CanvasBuilder {
225
233
  private connectablePortsConfig;
226
234
  private draggableEdgesConfig;
227
235
  private virtualScrollConfig;
228
- private hasDraggableNode;
236
+ private layoutConfig;
237
+ private animatedLayoutConfig;
238
+ private hasDraggableNodes;
229
239
  private hasTransformableViewport;
230
240
  private hasNodeResizeReactiveEdges;
231
241
  private hasBackground;
@@ -237,6 +247,7 @@ export declare class CanvasBuilder {
237
247
  private readonly graph;
238
248
  private readonly viewport;
239
249
  private readonly window;
250
+ private readonly animationStaticNodes;
240
251
  constructor(element: HTMLElement);
241
252
  /**
242
253
  * specifies default values for graph entities
@@ -267,7 +278,18 @@ export declare class CanvasBuilder {
267
278
  * enables edge creation by dragging one port to another
268
279
  */
269
280
  enableUserConnectablePorts(config?: ConnectablePortsConfig): CanvasBuilder;
281
+ /**
282
+ * enables edges dragging by dragging one of the adjacent ports
283
+ */
270
284
  enableUserDraggableEdges(config?: DraggableEdgesConfig): CanvasBuilder;
285
+ /**
286
+ * enables nodes positioning with specified layout
287
+ */
288
+ enableLayout(config: LayoutConfig): CanvasBuilder;
289
+ /**
290
+ * enables animated nodes positioning with specified layout
291
+ */
292
+ enableAnimatedLayout(config: AnimatedLayoutConfig): CanvasBuilder;
271
293
  /**
272
294
  * builds final canvas
273
295
  */
@@ -465,11 +487,22 @@ declare type EdgeShapeConfig = BezierEdgeShapeConfig | StraightEdgeShapeConfig |
465
487
 
466
488
  declare type EdgeShapeFactory = (edgeId: Identifier) => EdgeShape;
467
489
 
490
+ declare interface EventEmitter<T> {
491
+ emit(payload: T): void;
492
+ }
493
+
468
494
  declare interface EventHandler<T> {
469
495
  subscribe(callback: (payload: T) => void): void;
470
496
  unsubscribe(callback: (payload: T) => void): void;
471
497
  }
472
498
 
499
+ export declare class EventSubject<T> implements EventEmitter<T>, EventHandler<T> {
500
+ private readonly callbacks;
501
+ subscribe(callback: (payload: T) => void): void;
502
+ unsubscribe(callback: (payload: T) => void): void;
503
+ emit(payload: T): void;
504
+ }
505
+
473
506
  export declare class Graph {
474
507
  private readonly graphStore;
475
508
  readonly onAfterNodeAdded: EventHandler<Identifier>;
@@ -531,9 +564,9 @@ declare class GraphStore {
531
564
  private readonly ports;
532
565
  private readonly edges;
533
566
  private readonly nodesElementsMap;
534
- private readonly incomingEdges;
535
- private readonly outcomingEdges;
536
- private readonly cycleEdges;
567
+ private readonly portIncomingEdges;
568
+ private readonly portOutcomingEdges;
569
+ private readonly portCycleEdges;
537
570
  private readonly elementPorts;
538
571
  private readonly afterNodeAddedEmitter;
539
572
  readonly onAfterNodeAdded: EventHandler<Identifier>;
@@ -674,6 +707,19 @@ export declare class InteractiveEdgeShape implements StructuredEdgeShape {
674
707
  render(params: EdgeRenderParams): void;
675
708
  }
676
709
 
710
+ export declare interface LayoutAlgorithm {
711
+ calculateCoordinates(graph: Graph): ReadonlyMap<Identifier, Point>;
712
+ }
713
+
714
+ export declare type LayoutApplyOn = {
715
+ type: "topologyChangeTimeout";
716
+ } | EventSubject<void>;
717
+
718
+ export declare interface LayoutConfig {
719
+ readonly algorithm: LayoutAlgorithm;
720
+ readonly applyOn: LayoutApplyOn;
721
+ }
722
+
677
723
  export declare type MarkNodePortRequest = {
678
724
  readonly id?: Identifier | undefined;
679
725
  readonly element: HTMLElement;