ngx-vflow 0.8.0 → 0.9.1

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 (30) hide show
  1. package/esm2022/lib/vflow/components/vflow/vflow.component.mjs +22 -16
  2. package/esm2022/lib/vflow/directives/flow-size-controller.directive.mjs +36 -0
  3. package/esm2022/lib/vflow/directives/map-context.directive.mjs +16 -12
  4. package/esm2022/lib/vflow/interfaces/box.mjs +2 -0
  5. package/esm2022/lib/vflow/interfaces/fit-view-options.interface.mjs +2 -0
  6. package/esm2022/lib/vflow/interfaces/rect.mjs +2 -0
  7. package/esm2022/lib/vflow/interfaces/viewport.interface.mjs +1 -1
  8. package/esm2022/lib/vflow/services/flow-settings.service.mjs +12 -4
  9. package/esm2022/lib/vflow/services/node-changes.service.mjs +6 -3
  10. package/esm2022/lib/vflow/services/viewport.service.mjs +26 -3
  11. package/esm2022/lib/vflow/utils/nodes.mjs +36 -0
  12. package/esm2022/lib/vflow/utils/viewport.mjs +15 -0
  13. package/esm2022/lib/vflow/vflow.module.mjs +6 -3
  14. package/esm2022/public-api.mjs +2 -1
  15. package/fesm2022/ngx-vflow.mjs +217 -96
  16. package/fesm2022/ngx-vflow.mjs.map +1 -1
  17. package/lib/vflow/components/vflow/vflow.component.d.ts +4 -4
  18. package/lib/vflow/directives/flow-size-controller.directive.d.ts +10 -0
  19. package/lib/vflow/directives/map-context.directive.d.ts +9 -3
  20. package/lib/vflow/interfaces/box.d.ts +6 -0
  21. package/lib/vflow/interfaces/fit-view-options.interface.d.ts +15 -0
  22. package/lib/vflow/interfaces/rect.d.ts +6 -0
  23. package/lib/vflow/interfaces/viewport.interface.d.ts +1 -0
  24. package/lib/vflow/services/flow-settings.service.d.ts +10 -2
  25. package/lib/vflow/services/viewport.service.d.ts +5 -0
  26. package/lib/vflow/utils/nodes.d.ts +3 -0
  27. package/lib/vflow/utils/viewport.d.ts +4 -0
  28. package/lib/vflow/vflow.module.d.ts +4 -3
  29. package/package.json +1 -1
  30. package/public-api.d.ts +1 -0
@@ -13,6 +13,7 @@ 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
15
  import { SpacePointContextDirective } from '../../directives/space-point-context.directive';
16
+ import { FitViewOptions } from '../../interfaces/fit-view-options.interface';
16
17
  import * as i0 from "@angular/core";
17
18
  import * as i1 from "../../directives/connection-controller.directive";
18
19
  import * as i2 from "../../directives/changes-controller.directive";
@@ -40,11 +41,11 @@ export declare class VflowComponent {
40
41
  /**
41
42
  * Minimum zoom value
42
43
  */
43
- minZoom: number;
44
+ set minZoom(value: number);
44
45
  /**
45
46
  * Maximum zoom value
46
47
  */
47
- maxZoom: number;
48
+ set maxZoom(value: number);
48
49
  /**
49
50
  * Object that controls flow direction.
50
51
  *
@@ -115,8 +116,6 @@ export declare class VflowComponent {
115
116
  * Observable with edges change
116
117
  */
117
118
  readonly edgesChange$: import("rxjs").Observable<EdgeChange[]>;
118
- protected flowWidth: Signal<string | number>;
119
- protected flowHeight: Signal<string | number>;
120
119
  protected markers: Signal<Map<number, import("ngx-vflow").Marker>>;
121
120
  /**
122
121
  * Change viewport to specified state
@@ -136,6 +135,7 @@ export declare class VflowComponent {
136
135
  * @param point point where to move
137
136
  */
138
137
  panTo(point: Point): void;
138
+ fitView(options?: FitViewOptions): void;
139
139
  /**
140
140
  * Get node by id
141
141
  *
@@ -0,0 +1,10 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class FlowSizeControllerDirective {
3
+ private host;
4
+ private flowSettingsService;
5
+ flowWidth: string | number;
6
+ flowHeight: string | number;
7
+ constructor();
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<FlowSizeControllerDirective, never>;
9
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FlowSizeControllerDirective, "svg[flowSizeController]", never, {}, {}, never, never, false, never>;
10
+ }
@@ -2,14 +2,14 @@ import { OnInit } from '@angular/core';
2
2
  import { ZoomBehavior } from 'd3-zoom';
3
3
  import { ViewportService } from '../services/viewport.service';
4
4
  import { SelectionService, ViewportForSelection } from '../services/selection.service';
5
+ import { FlowSettingsService } from '../services/flow-settings.service';
5
6
  import * as i0 from "@angular/core";
6
7
  export declare class MapContextDirective implements OnInit {
7
- minZoom: number;
8
- maxZoom: number;
9
8
  protected rootSvg: SVGSVGElement;
10
9
  protected host: SVGGElement;
11
10
  protected selectionService: SelectionService;
12
11
  protected viewportService: ViewportService;
12
+ protected flowSettingsService: FlowSettingsService;
13
13
  protected rootSvgSelection: import("d3-selection").Selection<SVGSVGElement, unknown, null, undefined>;
14
14
  protected zoomableSelection: import("d3-selection").Selection<SVGGElement, unknown, null, undefined>;
15
15
  protected viewportForSelection: Partial<ViewportForSelection>;
@@ -20,5 +20,11 @@ export declare class MapContextDirective implements OnInit {
20
20
  private onD3zoomStart;
21
21
  private onD3zoomEnd;
22
22
  static ɵfac: i0.ɵɵFactoryDeclaration<MapContextDirective, never>;
23
- static ɵdir: i0.ɵɵDirectiveDeclaration<MapContextDirective, "g[mapContext]", never, { "minZoom": { "alias": "minZoom"; "required": false; }; "maxZoom": { "alias": "maxZoom"; "required": false; }; }, {}, never, never, false, never>;
23
+ static ɵdir: i0.ɵɵDirectiveDeclaration<MapContextDirective, "g[mapContext]", never, {}, {}, never, never, false, never>;
24
+ }
25
+ declare module 'd3-selection' {
26
+ interface Selection<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> {
27
+ transition(): Selection<GElement, Datum, PElement, PDatum>;
28
+ duration(duration: number): Selection<GElement, Datum, PElement, PDatum>;
29
+ }
24
30
  }
@@ -0,0 +1,6 @@
1
+ export interface Box {
2
+ x: number;
3
+ y: number;
4
+ x2: number;
5
+ y2: number;
6
+ }
@@ -0,0 +1,15 @@
1
+ export interface FitViewOptions {
2
+ /**
3
+ * Padding for viewport
4
+ */
5
+ padding?: number;
6
+ /**
7
+ * Duration of animated transition to new viewport
8
+ */
9
+ duration?: number;
10
+ /**
11
+ * Nodes that should be visible after fitView.
12
+ * The whole flow will be visible if not passed or passed an empty array
13
+ */
14
+ nodes?: string[];
15
+ }
@@ -0,0 +1,6 @@
1
+ export interface Rect {
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ }
@@ -6,4 +6,5 @@ export interface ViewportState extends Point {
6
6
  export interface WritableViewport {
7
7
  changeType: ViewportChangeType;
8
8
  state: Partial<ViewportState>;
9
+ duration: number;
9
10
  }
@@ -13,8 +13,16 @@ export declare class FlowSettingsService {
13
13
  * @see {VflowComponent.view}
14
14
  */
15
15
  view: WritableSignal<[number, number] | 'auto'>;
16
- flowWidth: import("@angular/core").Signal<string | number>;
17
- flowHeight: import("@angular/core").Signal<string | number>;
16
+ /**
17
+ * Set based on view property. May change if view is 'auto'
18
+ */
19
+ computedFlowWidth: WritableSignal<number>;
20
+ /**
21
+ * Set based on view property. May change if view is 'auto'
22
+ */
23
+ computedFlowHeight: WritableSignal<number>;
24
+ minZoom: WritableSignal<number>;
25
+ maxZoom: WritableSignal<number>;
18
26
  static ɵfac: i0.ɵɵFactoryDeclaration<FlowSettingsService, never>;
19
27
  static ɵprov: i0.ɵɵInjectableDeclaration<FlowSettingsService>;
20
28
  }
@@ -1,7 +1,10 @@
1
1
  import { WritableSignal } from '@angular/core';
2
2
  import { ViewportState, WritableViewport } from '../interfaces/viewport.interface';
3
+ import { FitViewOptions } from '../interfaces/fit-view-options.interface';
3
4
  import * as i0 from "@angular/core";
4
5
  export declare class ViewportService {
6
+ private entitiesService;
7
+ private flowSettingsService;
5
8
  /**
6
9
  * The default value used by d3, just copy it here
7
10
  *
@@ -19,6 +22,8 @@ export declare class ViewportService {
19
22
  * - writableViewport signal
20
23
  */
21
24
  readonly readableViewport: WritableSignal<ViewportState>;
25
+ fitView(options?: FitViewOptions): void;
26
+ private getBoundsNodes;
22
27
  static ɵfac: i0.ɵɵFactoryDeclaration<ViewportService, never>;
23
28
  static ɵprov: i0.ɵɵInjectableDeclaration<ViewportService>;
24
29
  }
@@ -0,0 +1,3 @@
1
+ import { Rect } from "../interfaces/rect";
2
+ import { NodeModel } from "../models/node.model";
3
+ export declare function getNodesBounds(nodes: NodeModel[]): Rect;
@@ -0,0 +1,4 @@
1
+ import { Rect } from "../interfaces/rect";
2
+ import { ViewportState } from "../interfaces/viewport.interface";
3
+ export declare function getViewportForBounds(bounds: Rect, width: number, height: number, minZoom: number, maxZoom: number, padding: number): ViewportState;
4
+ export declare function clamp(value: number, min?: number, max?: number): number;
@@ -15,10 +15,11 @@ import * as i13 from "./directives/handle-size-controller.directive";
15
15
  import * as i14 from "./directives/selectable.directive";
16
16
  import * as i15 from "./directives/pointer.directive";
17
17
  import * as i16 from "./directives/root-pointer.directive";
18
- import * as i17 from "./directives/template.directive";
19
- import * as i18 from "@angular/common";
18
+ import * as i17 from "./directives/flow-size-controller.directive";
19
+ import * as i18 from "./directives/template.directive";
20
+ import * as i19 from "@angular/common";
20
21
  export declare class VflowModule {
21
22
  static ɵfac: i0.ɵɵFactoryDeclaration<VflowModule, never>;
22
- static ɵmod: i0.ɵɵNgModuleDeclaration<VflowModule, [typeof i1.VflowComponent, typeof i2.NodeComponent, typeof i3.EdgeComponent, typeof i4.EdgeLabelComponent, typeof i5.ConnectionComponent, typeof i6.HandleComponent, typeof i7.DefsComponent, typeof i8.BackgroundComponent, typeof i9.SpacePointContextDirective, typeof i10.MapContextDirective, typeof i11.RootSvgReferenceDirective, typeof i12.RootSvgContextDirective, typeof i13.HandleSizeControllerDirective, typeof i14.SelectableDirective, typeof i15.PointerDirective, typeof i16.RootPointerDirective, typeof i17.NodeHtmlTemplateDirective, typeof i17.EdgeLabelHtmlTemplateDirective, typeof i17.EdgeTemplateDirective, typeof i17.ConnectionTemplateDirective, typeof i17.HandleTemplateDirective], [typeof i18.CommonModule], [typeof i1.VflowComponent, typeof i6.HandleComponent, typeof i14.SelectableDirective, typeof i17.NodeHtmlTemplateDirective, typeof i17.EdgeLabelHtmlTemplateDirective, typeof i17.EdgeTemplateDirective, typeof i17.ConnectionTemplateDirective, typeof i17.HandleTemplateDirective]>;
23
+ static ɵmod: i0.ɵɵNgModuleDeclaration<VflowModule, [typeof i1.VflowComponent, typeof i2.NodeComponent, typeof i3.EdgeComponent, typeof i4.EdgeLabelComponent, typeof i5.ConnectionComponent, typeof i6.HandleComponent, typeof i7.DefsComponent, typeof i8.BackgroundComponent, typeof i9.SpacePointContextDirective, typeof i10.MapContextDirective, typeof i11.RootSvgReferenceDirective, typeof i12.RootSvgContextDirective, typeof i13.HandleSizeControllerDirective, typeof i14.SelectableDirective, typeof i15.PointerDirective, typeof i16.RootPointerDirective, typeof i17.FlowSizeControllerDirective, typeof i18.NodeHtmlTemplateDirective, typeof i18.EdgeLabelHtmlTemplateDirective, typeof i18.EdgeTemplateDirective, typeof i18.ConnectionTemplateDirective, typeof i18.HandleTemplateDirective], [typeof i19.CommonModule], [typeof i1.VflowComponent, typeof i6.HandleComponent, typeof i14.SelectableDirective, typeof i18.NodeHtmlTemplateDirective, typeof i18.EdgeLabelHtmlTemplateDirective, typeof i18.EdgeTemplateDirective, typeof i18.ConnectionTemplateDirective, typeof i18.HandleTemplateDirective]>;
23
24
  static ɵinj: i0.ɵɵInjectorDeclaration<VflowModule>;
24
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-vflow",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://www.ngx-vflow.org/",
6
6
  "author": "Artem Mangilev",
package/public-api.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from './lib/vflow/interfaces/handle-positions.interface';
10
10
  export * from './lib/vflow/interfaces/marker.interface';
11
11
  export { ViewportState } from './lib/vflow/interfaces/viewport.interface';
12
12
  export * from './lib/vflow/interfaces/component-node-event.interface';
13
+ export * from './lib/vflow/interfaces/fit-view-options.interface';
13
14
  export * from './lib/vflow/types/node-change.type';
14
15
  export * from './lib/vflow/types/edge-change.type';
15
16
  export * from './lib/vflow/types/position.type';