@visuallyjs/browser-ui-angular 1.2.0 → 1.2.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 (46) hide show
  1. package/esm2022/index.mjs +2 -0
  2. package/esm2022/lib/base.group.component.mjs +3 -3
  3. package/esm2022/lib/base.node.component.mjs +3 -3
  4. package/esm2022/lib/base.port.component.mjs +4 -4
  5. package/esm2022/lib/base.vertex.component.mjs +33 -12
  6. package/esm2022/lib/browser-ui-angular.module.mjs +18 -8
  7. package/esm2022/lib/charts/area.chart.component.mjs +3 -3
  8. package/esm2022/lib/charts/bar.chart.component.mjs +3 -3
  9. package/esm2022/lib/charts/bubble.chart.component.mjs +3 -3
  10. package/esm2022/lib/charts/column.chart.component.mjs +3 -3
  11. package/esm2022/lib/charts/line.chart.component.mjs +3 -3
  12. package/esm2022/lib/charts/pie.chart.component.mjs +3 -3
  13. package/esm2022/lib/charts/sankey.chart.component.mjs +4 -4
  14. package/esm2022/lib/charts/scatter.chart.component.mjs +3 -3
  15. package/esm2022/lib/charts/series.based.chart.component.mjs +4 -4
  16. package/esm2022/lib/charts/xy.chart.component.mjs +3 -3
  17. package/esm2022/lib/color.tag.component.mjs +6 -6
  18. package/esm2022/lib/controls-component.mjs +4 -4
  19. package/esm2022/lib/decorator-component.mjs +3 -3
  20. package/esm2022/lib/default-group-component.mjs +3 -3
  21. package/esm2022/lib/default-node-component.mjs +3 -3
  22. package/esm2022/lib/diagram-component.mjs +34 -12
  23. package/esm2022/lib/diagram-palette-component.mjs +4 -4
  24. package/esm2022/lib/edge.type.picker.component.mjs +5 -5
  25. package/esm2022/lib/export-controls-component.mjs +3 -3
  26. package/esm2022/lib/inspector.component.mjs +4 -4
  27. package/esm2022/lib/miniview-component.mjs +4 -4
  28. package/esm2022/lib/palette.component.mjs +4 -4
  29. package/esm2022/lib/paper-component.mjs +345 -0
  30. package/esm2022/lib/shape.component.mjs +4 -4
  31. package/esm2022/lib/shape.palette.component.mjs +4 -4
  32. package/esm2022/lib/surface-component.mjs +71 -14
  33. package/esm2022/lib/surface-popup-component.mjs +62 -0
  34. package/esm2022/lib/vjs-service.mjs +3 -3
  35. package/fesm2022/visuallyjs-browser-ui-angular.mjs +645 -142
  36. package/fesm2022/visuallyjs-browser-ui-angular.mjs.map +1 -1
  37. package/index.d.ts +2 -0
  38. package/lib/base.vertex.component.d.ts +29 -3
  39. package/lib/browser-ui-angular.module.d.ts +23 -21
  40. package/lib/diagram-component.d.ts +7 -5
  41. package/lib/overlay-component.d.ts +5 -5
  42. package/lib/paper-component.d.ts +156 -0
  43. package/lib/surface-component.d.ts +19 -11
  44. package/lib/surface-popup-component.d.ts +62 -0
  45. package/package.json +2 -2
  46. package/visuallyjs-browser-ui-angular.tgz +0 -0
@@ -1,23 +1,49 @@
1
- import { Component, ElementRef, inject, Input, NgZone } from "@angular/core";
1
+ import { Component, effect, ElementRef, inject, input, Input, NgZone } from "@angular/core";
2
2
  import { createDiagram } from "@visuallyjs/browser-ui";
3
3
  import { VisuallyJsService } from "./vjs-service";
4
4
  import * as i0 from "@angular/core";
5
5
 
6
6
  export class DiagramComponent {
7
7
  constructor() {
8
+
9
+ this.data = input();
10
+
11
+ this.url = input();
8
12
  this.$ngZone = inject(NgZone);
9
13
  this.$el = inject(ElementRef);
10
14
  this.$vjs = inject(VisuallyJsService);
15
+ this._dataEffect = effect(() => {
16
+ const currentData = this.data();
17
+ if (currentData) {
18
+ if (this.diagram) {
19
+ this.diagram.clear();
20
+ this.diagram.load({ data: currentData });
21
+ }
22
+ }
23
+ });
24
+ this._urlEffect = effect(() => {
25
+ const currentUrl = this.url();
26
+ if (currentUrl) {
27
+ // Respond to changes in the url here.
28
+ // For example, if you need to reload the model with new data:
29
+ if (this.diagram) {
30
+ this.diagram.clear();
31
+ this.diagram.load({ url: currentUrl });
32
+ }
33
+ }
34
+ });
11
35
  }
12
36
  ngAfterViewInit() {
13
37
  this.$ngZone.runOutsideAngular(() => {
14
38
  this.diagram = createDiagram(this.$el.nativeElement, this.options, this.modelOptions);
15
39
  this.$vjs.$setDiagram(this.diagram);
16
- if (this.data != null) {
17
- this.diagram.load({ data: this.data });
40
+ const initialData = this.data();
41
+ const initialUrl = this.url();
42
+ if (initialData) {
43
+ this.diagram.load({ data: initialData });
18
44
  }
19
- else if (this.url != null) {
20
- this.diagram.load({ url: this.url });
45
+ else if (initialUrl) {
46
+ this.diagram.load({ url: initialUrl });
21
47
  }
22
48
  });
23
49
  }
@@ -32,10 +58,10 @@ export class DiagramComponent {
32
58
  saveToUrl(options) {
33
59
  this.diagram.saveToUrl(options);
34
60
  }
35
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DiagramComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
36
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: DiagramComponent, selector: "vjs-diagram", inputs: { options: "options", data: "data", url: "url", modelOptions: "modelOptions" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true }); }
61
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DiagramComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
62
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "17.3.12", type: DiagramComponent, selector: "vjs-diagram", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: false, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: false, transformFunction: null }, modelOptions: { classPropertyName: "modelOptions", publicName: "modelOptions", isSignal: false, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true }); }
37
63
  }
38
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DiagramComponent, decorators: [{
64
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DiagramComponent, decorators: [{
39
65
  type: Component,
40
66
  args: [{
41
67
  selector: "vjs-diagram",
@@ -43,10 +69,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
43
69
  }]
44
70
  }], propDecorators: { options: [{
45
71
  type: Input
46
- }], data: [{
47
- type: Input
48
- }], url: [{
49
- type: Input
50
72
  }], modelOptions: [{
51
73
  type: Input
52
74
  }] } });
@@ -42,16 +42,16 @@ export class DiagramPaletteComponent {
42
42
  this.$init(this.inputDiagram);
43
43
  }
44
44
  }
45
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DiagramPaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
46
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: DiagramPaletteComponent, selector: "vjs-diagram-palette", inputs: { fill: "fill", outline: "outline", dragSize: "dragSize", inspector: "inspector", iconSize: "iconSize", showLabels: "showLabels", paletteStrokeWidth: "paletteStrokeWidth", showAllMessage: "showAllMessage", onCellAdded: "onCellAdded", mode: "mode", allowClickToAdd: "allowClickToAdd", autoExitDrawMode: "autoExitDrawMode", selectAfterAdd: "selectAfterAdd", inputDiagram: ["diagram", "inputDiagram"], onVertexAdded: "onVertexAdded", preparedShapes: "preparedShapes" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
45
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DiagramPaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
46
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: DiagramPaletteComponent, selector: "vjs-diagram-palette", inputs: { fill: "fill", outline: "outline", dragSize: "dragSize", inspector: "inspector", iconSize: "iconSize", showLabels: "showLabels", paletteStrokeWidth: "paletteStrokeWidth", showAllMessage: "showAllMessage", onCellAdded: "onCellAdded", mode: "mode", allowClickToAdd: "allowClickToAdd", autoExitDrawMode: "autoExitDrawMode", selectAfterAdd: "selectAfterAdd", inputDiagram: ["diagram", "inputDiagram"], onVertexAdded: "onVertexAdded", preparedShapes: "preparedShapes" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
47
47
  }
48
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DiagramPaletteComponent, decorators: [{
48
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DiagramPaletteComponent, decorators: [{
49
49
  type: Component,
50
50
  args: [{
51
51
  selector: "vjs-diagram-palette",
52
52
  template: `<div></div>`,
53
53
  }]
54
- }], ctorParameters: function () { return []; }, propDecorators: { fill: [{
54
+ }], ctorParameters: () => [], propDecorators: { fill: [{
55
55
  type: Input
56
56
  }], outline: [{
57
57
  type: Input
@@ -25,7 +25,7 @@ export class EdgeTypePickerComponent {
25
25
  });
26
26
  const current = inspector.getValue(this.propertyName) || '';
27
27
  this.edgeTypePicker = new EdgeTypePicker(inspector.$ui, this.el.nativeElement, this.resolveMappings(), current, (p, v) => {
28
- inspector.setValue(this.propertyName, v);
28
+ inspector.setValue(this.propertyName, v, null);
29
29
  this.changeEvent.emit(v);
30
30
  });
31
31
  this.edgeTypePicker.render(this.propertyName, inspector._currentCommonData);
@@ -33,16 +33,16 @@ export class EdgeTypePickerComponent {
33
33
  }
34
34
  });
35
35
  }
36
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EdgeTypePickerComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
37
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: EdgeTypePickerComponent, selector: "vjs-edge-type", inputs: { propertyName: "propertyName", edgeMappings: "edgeMappings" }, outputs: { changeEvent: "changeEvent" }, ngImport: i0, template: `<div [attr.vjs-att]="propertyName"></div>`, isInline: true }); }
36
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EdgeTypePickerComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
37
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: EdgeTypePickerComponent, selector: "vjs-edge-type", inputs: { propertyName: "propertyName", edgeMappings: "edgeMappings" }, outputs: { changeEvent: "changeEvent" }, ngImport: i0, template: `<div [attr.vjs-att]="propertyName"></div>`, isInline: true }); }
38
38
  }
39
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EdgeTypePickerComponent, decorators: [{
39
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EdgeTypePickerComponent, decorators: [{
40
40
  type: Component,
41
41
  args: [{
42
42
  selector: "vjs-edge-type",
43
43
  template: `<div [attr.vjs-att]="propertyName"></div>`
44
44
  }]
45
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { propertyName: [{
45
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { propertyName: [{
46
46
  type: Input
47
47
  }], edgeMappings: [{
48
48
  type: Input
@@ -34,10 +34,10 @@ export class ExportControlsComponent {
34
34
  type: "image/jpeg",
35
35
  }));
36
36
  }
37
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExportControlsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
38
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ExportControlsComponent, selector: "vjs-export-controls", inputs: { showLabel: "showLabel", label: "label", margins: "margins", svgOptions: "svgOptions", imageOptions: "imageOptions", allowSvgExport: "allowSvgExport", allowPngExport: "allowPngExport", allowJpgExport: "allowJpgExport" }, ngImport: i0, template: "<div class=\"vjs-controls vjs-export-controls\">\n <span *ngIf=\"showLabel\">{{ label }}</span>\n <i *ngIf=\"allowSvgExport\"\n ><a href=\"#\" id=\"exportSvg\" (click)=\"exportSVG()\">SVG</a></i\n >\n <i *ngIf=\"allowPngExport\"\n ><a href=\"#\" id=\"exportPng\" (click)=\"exportPNG()\">PNG</a></i\n >\n <i *ngIf=\"allowJpgExport\"\n ><a href=\"#\" id=\"exportJpg\" (click)=\"exportJPG()\">JPG</a></i\n >\n </div>", isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
37
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ExportControlsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
38
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: ExportControlsComponent, selector: "vjs-export-controls", inputs: { showLabel: "showLabel", label: "label", margins: "margins", svgOptions: "svgOptions", imageOptions: "imageOptions", allowSvgExport: "allowSvgExport", allowPngExport: "allowPngExport", allowJpgExport: "allowJpgExport" }, ngImport: i0, template: "<div class=\"vjs-controls vjs-export-controls\">\n <span *ngIf=\"showLabel\">{{ label }}</span>\n <i *ngIf=\"allowSvgExport\"\n ><a href=\"#\" id=\"exportSvg\" (click)=\"exportSVG()\">SVG</a></i\n >\n <i *ngIf=\"allowPngExport\"\n ><a href=\"#\" id=\"exportPng\" (click)=\"exportPNG()\">PNG</a></i\n >\n <i *ngIf=\"allowJpgExport\"\n ><a href=\"#\" id=\"exportJpg\" (click)=\"exportJPG()\">JPG</a></i\n >\n </div>", isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
39
39
  }
40
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExportControlsComponent, decorators: [{
40
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ExportControlsComponent, decorators: [{
41
41
  type: Component,
42
42
  args: [{
43
43
  selector: "vjs-export-controls",
@@ -65,12 +65,12 @@ export class InspectorComponent {
65
65
  }
66
66
 
67
67
  afterUpdate(ui) { }
68
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: InspectorComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
69
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: InspectorComponent, inputs: { cssClass: "cssClass", showCloseButton: "showCloseButton", context: "context" }, ngImport: i0 }); }
68
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InspectorComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
69
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: InspectorComponent, inputs: { cssClass: "cssClass", showCloseButton: "showCloseButton", context: "context" }, ngImport: i0 }); }
70
70
  }
71
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: InspectorComponent, decorators: [{
71
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InspectorComponent, decorators: [{
72
72
  type: Directive
73
- }], ctorParameters: function () { return []; }, propDecorators: { cssClass: [{
73
+ }], ctorParameters: () => [], propDecorators: { cssClass: [{
74
74
  type: Input
75
75
  }], showCloseButton: [{
76
76
  type: Input
@@ -47,16 +47,16 @@ export class MiniviewComponent {
47
47
  this.$miniview.invalidate();
48
48
  }
49
49
  }
50
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MiniviewComponent, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
51
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: MiniviewComponent, selector: "vjs-miniview", inputs: { elementFilter: "elementFilter", typeFunction: "typeFunction", activeTracking: "activeTracking", clickToCenter: "clickToCenter", showLasso: "showLasso", trackSelection: "trackSelection" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
50
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MiniviewComponent, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
51
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: MiniviewComponent, selector: "vjs-miniview", inputs: { elementFilter: "elementFilter", typeFunction: "typeFunction", activeTracking: "activeTracking", clickToCenter: "clickToCenter", showLasso: "showLasso", trackSelection: "trackSelection" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
52
52
  }
53
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MiniviewComponent, decorators: [{
53
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MiniviewComponent, decorators: [{
54
54
  type: Component,
55
55
  args: [{
56
56
  selector: 'vjs-miniview',
57
57
  template: `<div></div>`
58
58
  }]
59
- }], ctorParameters: function () { return [{ type: i0.NgZone }]; }, propDecorators: { elementFilter: [{
59
+ }], ctorParameters: () => [{ type: i0.NgZone }], propDecorators: { elementFilter: [{
60
60
  type: Input
61
61
  }], typeFunction: [{
62
62
  type: Input
@@ -50,15 +50,15 @@ export class PaletteComponent {
50
50
  }
51
51
  });
52
52
  }
53
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
54
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: PaletteComponent, selector: "[vjs-palette]", inputs: { selector: "selector", dataGenerator: "dataGenerator", typeGenerator: "typeGenerator", groupIdentifier: "groupIdentifier", allowDropOnEdge: "allowDropOnEdge", allowDropOnGroup: "allowDropOnGroup", allowDropOnCanvas: "allowDropOnCanvas", allowDropOnNode: "allowDropOnNode", onVertexAdded: "onVertexAdded", dragSize: "dragSize", canvasDropFilter: "canvasDropFilter", mode: "mode", selectAfterAdd: "selectAfterAdd", allowClickToAdd: "allowClickToAdd", clickToAddOnly: "clickToAddOnly" }, ngImport: i0 }); }
53
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
54
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.12", type: PaletteComponent, selector: "[vjs-palette]", inputs: { selector: "selector", dataGenerator: "dataGenerator", typeGenerator: "typeGenerator", groupIdentifier: "groupIdentifier", allowDropOnEdge: "allowDropOnEdge", allowDropOnGroup: "allowDropOnGroup", allowDropOnCanvas: "allowDropOnCanvas", allowDropOnNode: "allowDropOnNode", onVertexAdded: "onVertexAdded", dragSize: "dragSize", canvasDropFilter: "canvasDropFilter", mode: "mode", selectAfterAdd: "selectAfterAdd", allowClickToAdd: "allowClickToAdd", clickToAddOnly: "clickToAddOnly" }, ngImport: i0 }); }
55
55
  }
56
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PaletteComponent, decorators: [{
56
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaletteComponent, decorators: [{
57
57
  type: Directive,
58
58
  args: [{
59
59
  selector: "[vjs-palette]",
60
60
  }]
61
- }], ctorParameters: function () { return []; }, propDecorators: { selector: [{
61
+ }], ctorParameters: () => [], propDecorators: { selector: [{
62
62
  type: Input
63
63
  }], dataGenerator: [{
64
64
  type: Input
@@ -0,0 +1,345 @@
1
+ import { Component, ElementRef, EventEmitter, Input, NgZone, Output, ViewContainerRef, inject, reflectComponentType, input, effect } from "@angular/core";
2
+ import { EVENT_EDGE_UPDATED, EVENT_GROUP_UPDATED, EVENT_NODE_UPDATED, EVENT_PORT_ADDED, EVENT_PORT_UPDATED, extend, renderPaper, OVERLAY_TYPE_CUSTOM, isGroup, EVENT_INTERNAL_CONNECTION, EVENT_DATA_LOAD_END, ELEMENT_DIV, EVENT_EDGE_REMOVED, EVENT_EDGE_ADDED } from "@visuallyjs/browser-ui";
3
+ import { AngularComponentOverlayType, } from "./overlay-component";
4
+ import { DefaultGroupComponent } from "./default-group-component";
5
+ import { DefaultNodeComponent } from "./default-node-component";
6
+ import { BasePortComponent } from "./base.port.component";
7
+ import { VisuallyJsService } from "./vjs-service";
8
+ import { BrowserUIAngularModel } from "./model";
9
+ import * as i0 from "@angular/core";
10
+
11
+ export class PaperComponent {
12
+ constructor() {
13
+
14
+ this.data = input();
15
+
16
+ this.url = input();
17
+
18
+ this.vertexEvent = new EventEmitter();
19
+ this.$el = inject(ElementRef);
20
+ this.$viewContainerRef = inject(ViewContainerRef);
21
+ this.$ngZone = inject(NgZone);
22
+ this.$vjs = inject(VisuallyJsService);
23
+ this._dataEffect = effect(() => {
24
+ const currentData = this.data();
25
+ if (currentData) {
26
+ if (this.model) {
27
+ this.model.clear();
28
+ this.model.load({ data: currentData });
29
+ }
30
+ }
31
+ });
32
+ this._urlEffect = effect(() => {
33
+ const currentUrl = this.url();
34
+ if (currentUrl) {
35
+ // Respond to changes in the url here.
36
+ // For example, if you need to reload the model with new data:
37
+ if (this.model) {
38
+ this.model.clear();
39
+ this.model.load({ url: currentUrl });
40
+ }
41
+ }
42
+ });
43
+ }
44
+
45
+ getNativeElement(component) {
46
+ return component.location.nativeElement.childNodes[0];
47
+ }
48
+ _getComponent(el, tryParent) {
49
+ if (el == null) {
50
+ return null;
51
+ }
52
+ else {
53
+ let vjc = el._visuallyJsNgComponent;
54
+ if (vjc == null && tryParent && el.parentNode != null) {
55
+ vjc = el.parentNode._visuallyJsNgComponent;
56
+ }
57
+ return vjc;
58
+ }
59
+ }
60
+ _getComponentThen(el, then, tryParent) {
61
+ const c = this._getComponent(el, tryParent);
62
+ if (c != null) {
63
+ then(c);
64
+ }
65
+ }
66
+
67
+ nodeOrGroupUpdated(params) {
68
+ const info = this.paper.getObjectInfo(params.vertex, false);
69
+ this._getComponentThen(info.el, (component) => {
70
+ component.data = params.vertex.data;
71
+ component.$data?.set(component.data);
72
+ if (component.changeDetectorRef) {
73
+ component.changeDetectorRef.detectChanges();
74
+ }
75
+ }, false);
76
+ }
77
+ portUpdated(params) {
78
+ const info = this.paper.getObjectInfo(params.port, false);
79
+ this._getComponentThen(info.el, (component) => {
80
+ if (component instanceof BasePortComponent) {
81
+ component.data = params.port.data;
82
+ if (component.changeDetectorRef) {
83
+ component.changeDetectorRef.detectChanges();
84
+ }
85
+ }
86
+ }, true);
87
+ }
88
+
89
+ edgeUpdated(params) {
90
+ const connection = this.paper.getRenderedConnection(params.edge.id);
91
+ if (connection) {
92
+ for (let id in connection.overlays) {
93
+ const canvas = connection.overlays[id].contentElement;
94
+ this._getComponentThen(canvas, (component) => {
95
+ if (component.changeDetectorRef != null) {
96
+ component.changeDetectorRef.detectChanges();
97
+ }
98
+ }, false);
99
+ }
100
+ }
101
+ }
102
+ edgeAddedRemoved(params) {
103
+ const info = this.paper.getObjectInfo(params.edge.source, false);
104
+ if (info.el) {
105
+ this._getComponentThen(info.el, (component) => {
106
+ try {
107
+ ;
108
+ component.$updateEdges();
109
+ if (component.changeDetectorRef) {
110
+ component.changeDetectorRef.detectChanges();
111
+ }
112
+ }
113
+ catch (e) { }
114
+ }, false);
115
+ }
116
+ const info2 = this.paper.getObjectInfo(params.edge.target, false);
117
+ if (info2.el && info.obj.getFullId() !== info2.obj.getFullId()) {
118
+ this._getComponentThen(info2.el, (component) => {
119
+ try {
120
+ ;
121
+ component.$updateEdges();
122
+ // tslint:disable-next-line:align
123
+ if (component.changeDetectorRef) {
124
+ component.changeDetectorRef.detectChanges();
125
+ }
126
+ }
127
+ catch (e) { }
128
+ }, false);
129
+ }
130
+ }
131
+
132
+ _processAngularOverlays(view) {
133
+ const self = this;
134
+ const edgeTypes = view.edges || {};
135
+ for (let edgeTypeId in edgeTypes) {
136
+ const edgeType = edgeTypes[edgeTypeId];
137
+ if (edgeType.overlays != null) {
138
+ edgeType.overlays = edgeType.overlays.map((o) => {
139
+ if (typeof o === "string") {
140
+ return o;
141
+ }
142
+ else {
143
+ const fo = o;
144
+ if (fo.type === AngularComponentOverlayType) {
145
+ const newSpec = Object.assign(fo, {
146
+ type: OVERLAY_TYPE_CUSTOM,
147
+ });
148
+ newSpec.options = (newSpec.options || {});
149
+ newSpec.options.create = (connection) => {
150
+ const el = document.createElement(ELEMENT_DIV);
151
+ let createdComponent = self.$viewContainerRef.createComponent(newSpec.options.component);
152
+ let angularOverlayComponent = createdComponent.instance;
153
+ let nativeEl = createdComponent.location.nativeElement.childNodes[0];
154
+ el.appendChild(nativeEl);
155
+ el._visuallyJsNgComponent = angularOverlayComponent;
156
+
157
+ if (connection != null) {
158
+ const edge = connection.edge;
159
+ angularOverlayComponent.edge = edge;
160
+ angularOverlayComponent.data = edge.data;
161
+ }
162
+ angularOverlayComponent.model = self.model;
163
+ angularOverlayComponent.ui = self.paper;
164
+ createdComponent.changeDetectorRef.detectChanges();
165
+ return el;
166
+ };
167
+ return newSpec;
168
+ }
169
+ else {
170
+ return fo;
171
+ }
172
+ }
173
+ });
174
+ }
175
+ }
176
+ return view;
177
+ }
178
+
179
+ save(options) {
180
+ this.paper.save(options);
181
+ }
182
+
183
+ exportData(options) {
184
+ return this.paper.model.exportData(options);
185
+ }
186
+
187
+ dataLoadEnd() {
188
+ setTimeout(() => {
189
+ if (this.paper != null) {
190
+ this.paper.repaintEverything();
191
+ }
192
+ }, 0);
193
+ }
194
+ $removeNgElement(el) {
195
+ if (el._ref != null) {
196
+ el._ref.destroy();
197
+ }
198
+ if (el.parentNode != null) {
199
+ el.parentNode.removeChild(el);
200
+ }
201
+ }
202
+
203
+ ngAfterViewInit() {
204
+ this.$ngZone.runOutsideAngular(() => {
205
+ const view = this._processAngularOverlays(this.viewOptions || {});
206
+ const self = this;
207
+ this.renderOptions = this.renderOptions || {};
208
+ const render = (directiveId, data, instance, objectType, paper, def, modelObject, eventInfo) => {
209
+ let component;
210
+ if (def.component == null) {
211
+ if (isGroup(modelObject)) {
212
+ component = DefaultGroupComponent;
213
+ }
214
+ else {
215
+ component = DefaultNodeComponent;
216
+ }
217
+ }
218
+ else {
219
+ component = def.component;
220
+ }
221
+ let createdComponent = self.$viewContainerRef.createComponent(component);
222
+ let _componentRef = createdComponent.instance;
223
+ _componentRef.data = data || {};
224
+ _componentRef.model = model;
225
+ _componentRef.paper = paper;
226
+ _componentRef.ui = paper;
227
+ _componentRef.modelObject = modelObject;
228
+ // get the reflection data for the component
229
+ const componentInfo = reflectComponentType(component);
230
+ // ..and populate any declared inputs from data
231
+ componentInfo.inputs.forEach((pt) => {
232
+ const pv = _componentRef.data[pt.propName];
233
+ if (pv != null) {
234
+ _componentRef[pt.propName] = pv;
235
+ }
236
+ });
237
+ // map to any outputs
238
+ componentInfo.outputs.forEach((pt) => {
239
+ _componentRef[pt.propName].subscribe((d) => self.vertexEvent.emit({
240
+ vertex: modelObject,
241
+ event: pt.propName,
242
+ payload: d,
243
+ component: createdComponent,
244
+ }));
245
+ });
246
+ // if angular def has 'inputs' set, set them on the component. this is different to the mechanism above, in which values are extracted from
247
+ // each node's backing data. here we inject values either as a string or from some arbitrary function.
248
+ if (def.inputs != null) {
249
+ for (let k in def.inputs) {
250
+ const v = def.inputs[k];
251
+ const value = typeof v === "string" ? v : v(modelObject);
252
+ _componentRef[k] = value;
253
+ }
254
+ }
255
+ createdComponent.changeDetectorRef.detectChanges();
256
+ // TODO this should not be necessary
257
+ const nativeElement = self.getNativeElement(createdComponent);
258
+ _componentRef._el = nativeElement;
259
+ _componentRef._el._visuallyJsNgComponent = _componentRef;
260
+ _componentRef._el._ref = createdComponent; // we store _ref so we can call `destroy` on it later if the node is removed.
261
+ paper.$vertexRendered(modelObject, nativeElement, def, eventInfo);
262
+ };
263
+ const templateRenderer = {
264
+ asynchronous: false,
265
+ reactive: true,
266
+ usesWrapperElement: false,
267
+ update: (el, data, v, renderer) => { },
268
+ render,
269
+ rerender: (directiveId, data, instance, objectType, paper, def, modelObject, eventInfo, originalElement) => {
270
+ this.$removeNgElement(originalElement);
271
+ render(directiveId, data, instance, objectType, paper, def, modelObject, eventInfo);
272
+ },
273
+ cleanupVertex: (objId, el) => {
274
+ this.$removeNgElement(el);
275
+ },
276
+ cleanupPort: (objId, el) => {
277
+ this.$removeNgElement(el);
278
+ },
279
+ };
280
+ const renderParams = extend(this.renderOptions || {}, {
281
+ view: view,
282
+ });
283
+ let model = this.inputModel || new BrowserUIAngularModel(this.modelOptions);
284
+ this.model = model;
285
+ this.paper = renderPaper(model, self.$el.nativeElement, templateRenderer, renderParams);
286
+ this.$vjs.$setPaper(this.paper);
287
+ // ----------------
288
+ this.nodeUpdateFn = this.nodeOrGroupUpdated.bind(this);
289
+ model.bind(EVENT_NODE_UPDATED, this.nodeUpdateFn);
290
+ model.bind(EVENT_PORT_ADDED, this.nodeUpdateFn);
291
+ model.bind(EVENT_GROUP_UPDATED, this.nodeUpdateFn);
292
+ this.dataLoadEndFn = this.dataLoadEnd.bind(this);
293
+ model.bind(EVENT_DATA_LOAD_END, this.dataLoadEndFn);
294
+ this.portUpdateFn = this.portUpdated.bind(this);
295
+ model.bind(EVENT_PORT_UPDATED, this.portUpdateFn);
296
+ this.edgeUpdateFn = this.edgeUpdated.bind(this);
297
+ model.bind(EVENT_EDGE_UPDATED, this.edgeUpdateFn);
298
+ this.edgeAddFn = this.edgeAddedRemoved.bind(this);
299
+ this.edgeRemoveFn = this.edgeAddedRemoved.bind(this);
300
+ model.bind(EVENT_EDGE_ADDED, this.edgeAddFn);
301
+ model.bind(EVENT_EDGE_REMOVED, this.edgeRemoveFn);
302
+ const initialData = this.data();
303
+ const initialUrl = this.url();
304
+ if (initialData) {
305
+ this.model.load({ data: initialData });
306
+ }
307
+ else if (initialUrl) {
308
+ this.model.load({ url: initialUrl });
309
+ }
310
+ });
311
+ }
312
+
313
+ ngOnDestroy() {
314
+ this.paper.destroy();
315
+ this.model.unbind(EVENT_NODE_UPDATED, this.nodeUpdateFn);
316
+ this.model.unbind(EVENT_GROUP_UPDATED, this.nodeUpdateFn);
317
+ this.model.unbind(EVENT_PORT_ADDED, this.nodeUpdateFn);
318
+ this.model.unbind(EVENT_PORT_UPDATED, this.portUpdateFn);
319
+ this.model.unbind(EVENT_EDGE_UPDATED, this.edgeUpdateFn);
320
+ this.model.unbind(EVENT_EDGE_ADDED, this.edgeAddFn);
321
+ this.model.unbind(EVENT_EDGE_REMOVED, this.edgeRemoveFn);
322
+ this.model.unbind(EVENT_DATA_LOAD_END, this.dataLoadEndFn);
323
+ this.paper.unbind(EVENT_INTERNAL_CONNECTION, this.edgeAddFn);
324
+ }
325
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
326
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "17.3.12", type: PaperComponent, selector: "vjs-paper", inputs: { inputModel: { classPropertyName: "inputModel", publicName: "model", isSignal: false, isRequired: false, transformFunction: null }, viewOptions: { classPropertyName: "viewOptions", publicName: "viewOptions", isSignal: false, isRequired: false, transformFunction: null }, renderOptions: { classPropertyName: "renderOptions", publicName: "renderOptions", isSignal: false, isRequired: false, transformFunction: null }, modelOptions: { classPropertyName: "modelOptions", publicName: "modelOptions", isSignal: false, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, url: { classPropertyName: "url", publicName: "url", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { vertexEvent: "vertexEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true }); }
327
+ }
328
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaperComponent, decorators: [{
329
+ type: Component,
330
+ args: [{
331
+ selector: "vjs-paper",
332
+ template: `<ng-content></ng-content>`
333
+ }]
334
+ }], propDecorators: { inputModel: [{
335
+ type: Input,
336
+ args: [{ alias: "model" }]
337
+ }], viewOptions: [{
338
+ type: Input
339
+ }], renderOptions: [{
340
+ type: Input
341
+ }], modelOptions: [{
342
+ type: Input
343
+ }], vertexEvent: [{
344
+ type: Output
345
+ }] } });
@@ -41,8 +41,8 @@ export class ShapeComponent {
41
41
  ngOnChanges(changes) {
42
42
  this._render();
43
43
  }
44
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ShapeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
45
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ShapeComponent, selector: "vjs-shape", inputs: { obj: "obj", width: "width", height: "height", showLabels: "showLabels", labelProperty: "labelProperty", labelStrokeWidth: "labelStrokeWidth", label: "label", multilineLabels: "multilineLabels", labelFillRatio: "labelFillRatio", font: "font" }, usesOnChanges: true, ngImport: i0, template: `<svg:svg
44
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ShapeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
45
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: ShapeComponent, selector: "vjs-shape", inputs: { obj: "obj", width: "width", height: "height", showLabels: "showLabels", labelProperty: "labelProperty", labelStrokeWidth: "labelStrokeWidth", label: "label", multilineLabels: "multilineLabels", labelFillRatio: "labelFillRatio", font: "font" }, usesOnChanges: true, ngImport: i0, template: `<svg:svg
46
46
  [attr.stroke-width]="obj.outlineWidth || 2"
47
47
  attr.fill="{{ obj.fill }}"
48
48
  attr.stroke="{{ obj.outline }}"
@@ -51,7 +51,7 @@ export class ShapeComponent {
51
51
  attr.viewBox="0 0 {{ width }} {{ height }}"
52
52
  ></svg:svg>`, isInline: true }); }
53
53
  }
54
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ShapeComponent, decorators: [{
54
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ShapeComponent, decorators: [{
55
55
  type: Component,
56
56
  args: [{
57
57
  template: `<svg:svg
@@ -64,7 +64,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
64
64
  ></svg:svg>`,
65
65
  selector: `vjs-shape`,
66
66
  }]
67
- }], ctorParameters: function () { return []; }, propDecorators: { obj: [{
67
+ }], ctorParameters: () => [], propDecorators: { obj: [{
68
68
  type: Input
69
69
  }], width: [{
70
70
  type: Input
@@ -48,16 +48,16 @@ export class ShapePaletteComponent {
48
48
  }
49
49
  });
50
50
  }
51
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ShapePaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
52
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ShapePaletteComponent, selector: "vjs-shape-palette", inputs: { initialSet: "initialSet", dragSize: "dragSize", iconSize: "iconSize", fill: "fill", outline: "outline", showAllMessage: "showAllMessage", selectAfterDrop: "selectAfterDrop", paletteStrokeWidth: "paletteStrokeWidth", onVertexAdded: "onVertexAdded", dataGenerator: "dataGenerator", preparedShapes: "preparedShapes" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
51
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ShapePaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
52
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: ShapePaletteComponent, selector: "vjs-shape-palette", inputs: { initialSet: "initialSet", dragSize: "dragSize", iconSize: "iconSize", fill: "fill", outline: "outline", showAllMessage: "showAllMessage", selectAfterDrop: "selectAfterDrop", paletteStrokeWidth: "paletteStrokeWidth", onVertexAdded: "onVertexAdded", dataGenerator: "dataGenerator", preparedShapes: "preparedShapes" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
53
53
  }
54
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ShapePaletteComponent, decorators: [{
54
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ShapePaletteComponent, decorators: [{
55
55
  type: Component,
56
56
  args: [{
57
57
  template: `<div></div>`,
58
58
  selector: `vjs-shape-palette`
59
59
  }]
60
- }], ctorParameters: function () { return []; }, propDecorators: { initialSet: [{
60
+ }], ctorParameters: () => [], propDecorators: { initialSet: [{
61
61
  type: Input
62
62
  }], dragSize: [{
63
63
  type: Input