ngx-vflow 0.7.0 → 0.8.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.
Files changed (32) hide show
  1. package/esm2022/lib/vflow/components/background/background.component.mjs +4 -4
  2. package/esm2022/lib/vflow/components/connection/connection.component.mjs +2 -2
  3. package/esm2022/lib/vflow/components/handle/handle.component.mjs +5 -5
  4. package/esm2022/lib/vflow/components/node/node.component.mjs +31 -82
  5. package/esm2022/lib/vflow/components/vflow/vflow.component.mjs +12 -2
  6. package/esm2022/lib/vflow/directives/connection-controller.directive.mjs +91 -12
  7. package/esm2022/lib/vflow/directives/space-point-context.directive.mjs +11 -5
  8. package/esm2022/lib/vflow/interfaces/connection-settings.interface.mjs +1 -1
  9. package/esm2022/lib/vflow/interfaces/connection.internal.interface.mjs +2 -0
  10. package/esm2022/lib/vflow/models/connection.model.mjs +28 -6
  11. package/esm2022/lib/vflow/models/handle.model.mjs +1 -1
  12. package/esm2022/lib/vflow/services/flow-entities.service.mjs +2 -2
  13. package/esm2022/lib/vflow/services/flow-status.service.mjs +7 -7
  14. package/esm2022/lib/vflow/services/handle.service.mjs +1 -1
  15. package/esm2022/lib/vflow/types/connection-mode.type.mjs +2 -0
  16. package/esm2022/lib/vflow/utils/adjust-direction.mjs +30 -0
  17. package/esm2022/public-api.mjs +2 -1
  18. package/fesm2022/ngx-vflow.mjs +339 -246
  19. package/fesm2022/ngx-vflow.mjs.map +1 -1
  20. package/lib/vflow/components/node/node.component.d.ts +4 -12
  21. package/lib/vflow/components/vflow/vflow.component.d.ts +6 -0
  22. package/lib/vflow/directives/connection-controller.directive.d.ts +6 -0
  23. package/lib/vflow/directives/space-point-context.directive.d.ts +1 -0
  24. package/lib/vflow/interfaces/connection-settings.interface.d.ts +2 -0
  25. package/lib/vflow/interfaces/connection.internal.interface.d.ts +8 -0
  26. package/lib/vflow/models/connection.model.d.ts +5 -2
  27. package/lib/vflow/models/handle.model.d.ts +1 -1
  28. package/lib/vflow/services/flow-status.service.d.ts +7 -18
  29. package/lib/vflow/types/connection-mode.type.d.ts +1 -0
  30. package/lib/vflow/utils/adjust-direction.d.ts +11 -0
  31. package/package.json +1 -1
  32. package/public-api.d.ts +1 -0
@@ -9,11 +9,11 @@ export declare class NodeComponent implements OnInit, AfterViewInit, OnDestroy,
9
9
  private handleService;
10
10
  private draggableService;
11
11
  private flowStatusService;
12
- private flowEntitiesService;
13
12
  private nodeRenderingService;
14
13
  private flowSettingsService;
15
14
  private selectionService;
16
15
  private hostRef;
16
+ private connectionController;
17
17
  nodeModel: NodeModel;
18
18
  nodeHtmlTemplate?: TemplateRef<any>;
19
19
  nodeContentRef: ElementRef<SVGGraphicsElement>;
@@ -21,23 +21,15 @@ export declare class NodeComponent implements OnInit, AfterViewInit, OnDestroy,
21
21
  protected showMagnet: import("@angular/core").Signal<boolean>;
22
22
  protected styleWidth: import("@angular/core").Signal<string>;
23
23
  protected styleHeight: import("@angular/core").Signal<string>;
24
- private subscription;
25
24
  ngOnInit(): void;
26
25
  ngAfterViewInit(): void;
27
26
  ngOnDestroy(): void;
28
27
  protected startConnection(event: Event, handle: HandleModel): void;
29
- protected endConnection(): void;
30
- /**
31
- * TODO srp
32
- */
33
- protected validateTargetHandle(targetHandle: HandleModel): void;
34
- /**
35
- * TODO srp
36
- */
37
- protected resetValidateTargetHandle(targetHandle: HandleModel): void;
28
+ protected validateConnection(handle: HandleModel): void;
29
+ protected resetValidateConnection(targetHandle: HandleModel): void;
30
+ protected endConnection(handle: HandleModel): void;
38
31
  protected pullNode(): void;
39
32
  protected selectNode(): void;
40
- private setInitialHandles;
41
33
  static ɵfac: i0.ɵɵFactoryDeclaration<NodeComponent, never>;
42
34
  static ɵcmp: i0.ɵɵComponentDeclaration<NodeComponent, "g[node]", never, { "nodeModel": { "alias": "nodeModel"; "required": false; }; "nodeHtmlTemplate": { "alias": "nodeHtmlTemplate"; "required": false; }; }, {}, never, never, false, never>;
43
35
  }
@@ -12,6 +12,7 @@ import { ConnectionModel } from '../../models/connection.model';
12
12
  import { NodeChange } from '../../types/node-change.type';
13
13
  import { EdgeChange } from '../../types/edge-change.type';
14
14
  import { Background } from '../../types/background.type';
15
+ import { SpacePointContextDirective } from '../../directives/space-point-context.directive';
15
16
  import * as i0 from "@angular/core";
16
17
  import * as i1 from "../../directives/connection-controller.directive";
17
18
  import * as i2 from "../../directives/changes-controller.directive";
@@ -89,6 +90,7 @@ export declare class VflowComponent {
89
90
  protected edgeLabelHtmlDirective?: EdgeLabelHtmlTemplateDirective;
90
91
  protected connectionTemplateDirective?: ConnectionTemplateDirective;
91
92
  protected mapContext: MapContextDirective;
93
+ protected spacePointContext: SpacePointContextDirective;
92
94
  /**
93
95
  * Signal for reading viewport change
94
96
  */
@@ -144,6 +146,10 @@ export declare class VflowComponent {
144
146
  * Sync method to get detached edges
145
147
  */
146
148
  getDetachedEdges(): Edge[];
149
+ /**
150
+ * Convert point received from document to point on the flow
151
+ */
152
+ documentPointToFlowPoint(point: Point): Point;
147
153
  protected trackNodes(idx: number, { node }: NodeModel): Node<unknown>;
148
154
  protected trackEdges(idx: number, { edge }: EdgeModel): Edge<unknown>;
149
155
  static ɵfac: i0.ɵɵFactoryDeclaration<VflowComponent, never>;
@@ -1,5 +1,6 @@
1
1
  import { EventEmitter } from '@angular/core';
2
2
  import { Connection } from '../interfaces/connection.interface';
3
+ import { HandleModel } from '../models/handle.model';
3
4
  import * as i0 from "@angular/core";
4
5
  export declare class ConnectionControllerDirective {
5
6
  /**
@@ -14,6 +15,11 @@ export declare class ConnectionControllerDirective {
14
15
  private statusService;
15
16
  private flowEntitiesService;
16
17
  protected connectEffect: import("@angular/core").EffectRef;
18
+ protected isStrictMode: import("@angular/core").Signal<boolean>;
19
+ startConnection(handle: HandleModel): void;
20
+ validateConnection(handle: HandleModel): void;
21
+ resetValidateConnection(targetHandle: HandleModel): void;
22
+ endConnection(handle: HandleModel): void;
17
23
  static ɵfac: i0.ɵɵFactoryDeclaration<ConnectionControllerDirective, never>;
18
24
  static ɵdir: i0.ɵɵDirectiveDeclaration<ConnectionControllerDirective, "[connectionController]", never, {}, { "onConnect": "onConnect"; }, never, never, true, never>;
19
25
  }
@@ -19,6 +19,7 @@ export declare class SpacePointContextDirective {
19
19
  target: Element | null;
20
20
  originalEvent: TouchEvent;
21
21
  } | undefined>;
22
+ documentPointToFlowPoint(documentPoint: Point): DOMPoint;
22
23
  static ɵfac: i0.ɵɵFactoryDeclaration<SpacePointContextDirective, never>;
23
24
  static ɵdir: i0.ɵɵDirectiveDeclaration<SpacePointContextDirective, "g[spacePointContext]", never, {}, {}, never, never, false, never>;
24
25
  }
@@ -1,3 +1,4 @@
1
+ import { ConnectionMode } from "../types/connection-mode.type";
1
2
  import { Connection } from "./connection.interface";
2
3
  import { Curve, EdgeType } from "./edge.interface";
3
4
  import { Marker } from "./marker.interface";
@@ -7,4 +8,5 @@ export interface ConnectionSettings {
7
8
  type?: EdgeType;
8
9
  validator?: ConnectionValidatorFn;
9
10
  marker?: Marker;
11
+ mode?: ConnectionMode;
10
12
  }
@@ -0,0 +1,8 @@
1
+ import { HandleModel } from "../models/handle.model";
2
+ import { NodeModel } from "../models/node.model";
3
+ export interface ConnectionInternal {
4
+ source: NodeModel;
5
+ target: NodeModel;
6
+ sourceHandle: HandleModel;
7
+ targetHandle: HandleModel;
8
+ }
@@ -1,9 +1,12 @@
1
1
  import { ConnectionSettings, ConnectionValidatorFn } from "../interfaces/connection-settings.interface";
2
2
  import { Curve, EdgeType } from "../interfaces/edge.interface";
3
+ import { ConnectionMode } from "../types/connection-mode.type";
3
4
  export declare class ConnectionModel {
4
- connection: ConnectionSettings;
5
+ settings: ConnectionSettings;
5
6
  curve: Curve;
6
7
  type: EdgeType;
7
8
  validator: ConnectionValidatorFn;
8
- constructor(connection: ConnectionSettings);
9
+ mode: ConnectionMode;
10
+ constructor(settings: ConnectionSettings);
11
+ private getValidators;
9
12
  }
@@ -3,7 +3,7 @@ import { NodeModel } from "./node.model";
3
3
  export type HandleState = 'valid' | 'invalid' | 'idle';
4
4
  export declare class HandleModel {
5
5
  rawHandle: NodeHandle;
6
- private parentNode;
6
+ parentNode: NodeModel;
7
7
  readonly strokeWidth = 2;
8
8
  /**
9
9
  * Pre-computed size for default handle, changed dynamically
@@ -1,5 +1,6 @@
1
1
  import { NodeModel } from '../models/node.model';
2
2
  import { HandleModel } from '../models/handle.model';
3
+ import { ConnectionInternal } from '../interfaces/connection.internal.interface';
3
4
  import * as i0 from "@angular/core";
4
5
  export interface FlowStatusIdle {
5
6
  state: 'idle';
@@ -7,37 +8,25 @@ export interface FlowStatusIdle {
7
8
  }
8
9
  export interface FlowStatusConnectionStart {
9
10
  state: 'connection-start';
10
- payload: {
11
- sourceNode: NodeModel;
12
- sourceHandle: HandleModel;
13
- };
11
+ payload: Omit<ConnectionInternal, 'target' | 'targetHandle'>;
14
12
  }
15
13
  export interface FlowStatusConnectionValidation {
16
14
  state: 'connection-validation';
17
- payload: {
18
- sourceNode: NodeModel;
19
- targetNode: NodeModel;
20
- sourceHandle: HandleModel;
21
- targetHandle: HandleModel;
15
+ payload: ConnectionInternal & {
22
16
  valid: boolean;
23
17
  };
24
18
  }
25
19
  export interface FlowStatusConnectionEnd {
26
20
  state: 'connection-end';
27
- payload: {
28
- sourceNode: NodeModel;
29
- targetNode: NodeModel;
30
- sourceHandle: HandleModel;
31
- targetHandle: HandleModel;
32
- };
21
+ payload: ConnectionInternal;
33
22
  }
34
23
  export type FlowStatus = FlowStatusIdle | FlowStatusConnectionStart | FlowStatusConnectionValidation | FlowStatusConnectionEnd;
35
24
  export declare class FlowStatusService {
36
25
  readonly status: import("@angular/core").WritableSignal<FlowStatus>;
37
26
  setIdleStatus(): void;
38
- setConnectionStartStatus(sourceNode: NodeModel, sourceHandle: HandleModel): void;
39
- setConnectionValidationStatus(valid: boolean, sourceNode: NodeModel, targetNode: NodeModel, sourceHandle: HandleModel, targetHandle: HandleModel): void;
40
- setConnectionEndStatus(sourceNode: NodeModel, targetNode: NodeModel, sourceHandle: HandleModel, targetHandle: HandleModel): void;
27
+ setConnectionStartStatus(source: NodeModel, sourceHandle: HandleModel): void;
28
+ setConnectionValidationStatus(valid: boolean, source: NodeModel, target: NodeModel, sourceHandle: HandleModel, targetHandle: HandleModel): void;
29
+ setConnectionEndStatus(source: NodeModel, target: NodeModel, sourceHandle: HandleModel, targetHandle: HandleModel): void;
41
30
  static ɵfac: i0.ɵɵFactoryDeclaration<FlowStatusService, never>;
42
31
  static ɵprov: i0.ɵɵInjectableDeclaration<FlowStatusService>;
43
32
  }
@@ -0,0 +1 @@
1
+ export type ConnectionMode = 'loose' | 'strict';
@@ -0,0 +1,11 @@
1
+ import { ConnectionInternal } from "../interfaces/connection.internal.interface";
2
+ /**
3
+ * This function contains a hack-y behavior.
4
+ * If the handles are of the same type (source-source or target-target),
5
+ * it returns nodes where source === target and
6
+ * handles where sourceHandle === targetHandle
7
+ *
8
+ * This leads to that notSelfValidator returns false for these cases,
9
+ * exactly what we need for strict connection type
10
+ */
11
+ export declare function adjustDirection(connection: ConnectionInternal): ConnectionInternal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-vflow",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://www.ngx-vflow.org/",
6
6
  "author": "Artem Mangilev",
package/public-api.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from './lib/vflow/types/node-change.type';
14
14
  export * from './lib/vflow/types/edge-change.type';
15
15
  export * from './lib/vflow/types/position.type';
16
16
  export * from './lib/vflow/types/background.type';
17
+ export * from './lib/vflow/types/connection-mode.type';
17
18
  export * from './lib/vflow/components/vflow/vflow.component';
18
19
  export * from './lib/vflow/components/handle/handle.component';
19
20
  export * from './lib/vflow/public-components/custom-node.component';