@visuallyjs/browser-ui-angular 1.1.3 → 1.2.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 (54) hide show
  1. package/esm2022/index.mjs +3 -0
  2. package/esm2022/lib/charts/area.chart.component.mjs +8 -36
  3. package/esm2022/lib/charts/bar.chart.component.mjs +8 -36
  4. package/esm2022/lib/charts/bubble.chart.component.mjs +8 -36
  5. package/esm2022/lib/charts/column.chart.component.mjs +8 -36
  6. package/esm2022/lib/charts/line.chart.component.mjs +8 -36
  7. package/esm2022/lib/charts/pie.chart.component.mjs +8 -36
  8. package/esm2022/lib/charts/sankey.chart.component.mjs +12 -8
  9. package/esm2022/lib/charts/scatter.chart.component.mjs +8 -36
  10. package/esm2022/lib/charts/series.based.chart.component.mjs +54 -0
  11. package/esm2022/lib/charts/xy.chart.component.mjs +10 -22
  12. package/esm2022/lib/color.tag.component.mjs +33 -27
  13. package/esm2022/lib/controls-component.mjs +48 -44
  14. package/esm2022/lib/diagram-palette-component.mjs +37 -32
  15. package/esm2022/lib/edge.type.picker.component.mjs +23 -18
  16. package/esm2022/lib/export-controls-component.mjs +7 -9
  17. package/esm2022/lib/hooks/use-visuallyjs-update.mjs +21 -0
  18. package/esm2022/lib/hooks/use-zoom.mjs +24 -0
  19. package/esm2022/lib/inspector.component.mjs +29 -27
  20. package/esm2022/lib/miniview-component.mjs +33 -25
  21. package/esm2022/lib/palette.component.mjs +42 -37
  22. package/esm2022/lib/shape.component.mjs +20 -18
  23. package/esm2022/lib/shape.palette.component.mjs +25 -21
  24. package/esm2022/lib/surface-component.mjs +7 -5
  25. package/esm2022/lib/vjs-service.mjs +35 -1
  26. package/fesm2022/visuallyjs-browser-ui-angular.mjs +466 -503
  27. package/fesm2022/visuallyjs-browser-ui-angular.mjs.map +1 -1
  28. package/index.d.ts +3 -0
  29. package/lib/charts/area.chart.component.d.ts +10 -15
  30. package/lib/charts/bar.chart.component.d.ts +9 -15
  31. package/lib/charts/bubble.chart.component.d.ts +12 -15
  32. package/lib/charts/column.chart.component.d.ts +12 -15
  33. package/lib/charts/line.chart.component.d.ts +16 -17
  34. package/lib/charts/pie.chart.component.d.ts +9 -15
  35. package/lib/charts/sankey.chart.component.d.ts +5 -0
  36. package/lib/charts/scatter.chart.component.d.ts +9 -15
  37. package/lib/charts/series.based.chart.component.d.ts +44 -0
  38. package/lib/charts/xy.chart.component.d.ts +13 -11
  39. package/lib/color.tag.component.d.ts +5 -5
  40. package/lib/controls-component.d.ts +6 -4
  41. package/lib/diagram-palette-component.d.ts +8 -2
  42. package/lib/edge.type.picker.component.d.ts +5 -5
  43. package/lib/export-controls-component.d.ts +6 -6
  44. package/lib/hooks/use-visuallyjs-update.d.ts +21 -0
  45. package/lib/hooks/use-zoom.d.ts +6 -0
  46. package/lib/inspector.component.d.ts +6 -7
  47. package/lib/miniview-component.d.ts +17 -9
  48. package/lib/palette.component.d.ts +5 -6
  49. package/lib/shape.component.d.ts +5 -5
  50. package/lib/shape.palette.component.d.ts +5 -3
  51. package/lib/surface-component.d.ts +5 -1
  52. package/lib/vjs-service.d.ts +41 -0
  53. package/package.json +2 -2
  54. package/visuallyjs-browser-ui-angular.tgz +0 -0
@@ -1,21 +1,9 @@
1
- import { Component, ElementRef, inject, Input, } from "@angular/core";
1
+ import { Component, effect, ElementRef, inject, Input, } from "@angular/core";
2
2
  import { DEFAULT_LABEL_FILL_RATIO, convertToMultilineText } 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 ShapeComponent {
7
- constructor() {
8
-
9
- this.showLabels = false;
10
-
11
- this.labelProperty = "label";
12
-
13
- this.multilineLabels = true;
14
-
15
- this.labelFillRatio = DEFAULT_LABEL_FILL_RATIO;
16
- this.$el = inject(ElementRef);
17
- this.$vjs = inject(VisuallyJsService);
18
- }
19
7
  _render() {
20
8
  if (this.shapeLibrary != null) {
21
9
  const svg = this.$el.nativeElement.childNodes[0];
@@ -30,10 +18,24 @@ export class ShapeComponent {
30
18
  }
31
19
  }
32
20
  }
33
- ngAfterViewInit() {
34
- this.$vjs.getUI((b) => {
35
- this.shapeLibrary = b.getShapeLibrary();
36
- this._render();
21
+ constructor() {
22
+
23
+ this.showLabels = false;
24
+
25
+ this.labelProperty = "label";
26
+
27
+ this.multilineLabels = true;
28
+
29
+ this.labelFillRatio = DEFAULT_LABEL_FILL_RATIO;
30
+ this.$el = inject(ElementRef);
31
+ this.$vjs = inject(VisuallyJsService);
32
+ this.ui = this.$vjs.ui;
33
+ effect(() => {
34
+ const ui = this.ui();
35
+ if (ui != null && this.shapeLibrary == null) {
36
+ this.shapeLibrary = ui.getShapeLibrary();
37
+ this._render();
38
+ }
37
39
  });
38
40
  }
39
41
  ngOnChanges(changes) {
@@ -62,7 +64,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
62
64
  ></svg:svg>`,
63
65
  selector: `vjs-shape`,
64
66
  }]
65
- }], propDecorators: { obj: [{
67
+ }], ctorParameters: function () { return []; }, propDecorators: { obj: [{
66
68
  type: Input
67
69
  }], width: [{
68
70
  type: Input
@@ -1,4 +1,4 @@
1
- import { Component, ElementRef, inject, Input } from "@angular/core";
1
+ import { Component, effect, ElementRef, inject, Input } from "@angular/core";
2
2
  import { ShapePalette, ShapeLibraryDefaults } from "@visuallyjs/browser-ui";
3
3
  import { VisuallyJsService } from "./vjs-service";
4
4
  import * as i0 from "@angular/core";
@@ -23,25 +23,29 @@ export class ShapePaletteComponent {
23
23
  this.dataGenerator = undefined;
24
24
  this.$el = inject(ElementRef);
25
25
  this.$vjs = inject(VisuallyJsService);
26
- }
27
- ngAfterViewInit() {
28
- this.$vjs.getUI((ui) => {
29
-
30
- new ShapePalette(ui, {
31
- container: this.$el.nativeElement,
32
- initialSet: this.initialSet,
33
- dragSize: this.dragSize,
34
- iconSize: this.iconSize,
35
- fill: this.fill,
36
- outline: this.outline,
37
- shapeLibrary: ui.getShapeLibrary(),
38
- showAllMessage: this.showAllMessage,
39
- selectAfterDrop: this.selectAfterDrop,
40
- paletteStrokeWidth: this.paletteStrokeWidth,
41
- dataGenerator: this.dataGenerator,
42
- onVertexAdded: this.onVertexAdded,
43
- preparedShapes: this.preparedShapes
44
- });
26
+ this.ui = this.$vjs.ui;
27
+ this.initialized = false;
28
+ effect(() => {
29
+ const ui = this.ui();
30
+ if (ui != null && !this.initialized) {
31
+ this.initialized = true;
32
+ // tslint:disable-next-line:no-unused-expression
33
+ new ShapePalette(ui, {
34
+ container: this.$el.nativeElement,
35
+ initialSet: this.initialSet,
36
+ dragSize: this.dragSize,
37
+ iconSize: this.iconSize,
38
+ fill: this.fill,
39
+ outline: this.outline,
40
+ shapeLibrary: ui.getShapeLibrary(),
41
+ showAllMessage: this.showAllMessage,
42
+ selectAfterDrop: this.selectAfterDrop,
43
+ paletteStrokeWidth: this.paletteStrokeWidth,
44
+ dataGenerator: this.dataGenerator,
45
+ onVertexAdded: this.onVertexAdded,
46
+ preparedShapes: this.preparedShapes
47
+ });
48
+ }
45
49
  });
46
50
  }
47
51
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ShapePaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
@@ -53,7 +57,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
53
57
  template: `<div></div>`,
54
58
  selector: `vjs-shape-palette`
55
59
  }]
56
- }], propDecorators: { initialSet: [{
60
+ }], ctorParameters: function () { return []; }, propDecorators: { initialSet: [{
57
61
  type: Input
58
62
  }], dragSize: [{
59
63
  type: Input
@@ -17,6 +17,7 @@ export class SurfaceComponent {
17
17
  this.$ngZone = inject(NgZone);
18
18
  this.$vjs = inject(VisuallyJsService);
19
19
  }
20
+ // $vjsSignals = inject(VisuallyJsSignalService)
20
21
 
21
22
  getNativeElement(component) {
22
23
  return component.location.nativeElement.childNodes[0];
@@ -226,11 +227,9 @@ export class SurfaceComponent {
226
227
  const renderParams = extend(this.renderOptions || {}, {
227
228
  view: view,
228
229
  });
229
- let model = new BrowserUIAngularModel(this.modelOptions);
230
+ let model = this.inputModel || new BrowserUIAngularModel(this.modelOptions);
230
231
  this.model = model;
231
232
  this.surface = renderSurface(model, self.$el.nativeElement, templateRenderer, renderParams);
232
- //this.$service.addSurface(this.surfaceId, this.surface);
233
- // new
234
233
  this.$vjs.$setSurface(this.surface);
235
234
  // ----------------
236
235
  this.nodeUpdateFn = this.nodeOrGroupUpdated.bind(this);
@@ -263,7 +262,7 @@ export class SurfaceComponent {
263
262
  this.surface.unbind(EVENT_INTERNAL_CONNECTION, this.edgeAddFn);
264
263
  }
265
264
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SurfaceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
266
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SurfaceComponent, selector: "vjs-surface", inputs: { viewOptions: "viewOptions", renderOptions: "renderOptions", modelOptions: "modelOptions", data: "data", url: "url" }, outputs: { vertexEvent: "vertexEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true }); }
265
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SurfaceComponent, selector: "vjs-surface", inputs: { inputModel: ["model", "inputModel"], viewOptions: "viewOptions", renderOptions: "renderOptions", modelOptions: "modelOptions", data: "data", url: "url" }, outputs: { vertexEvent: "vertexEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true }); }
267
266
  }
268
267
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SurfaceComponent, decorators: [{
269
268
  type: Component,
@@ -271,7 +270,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
271
270
  selector: "vjs-surface",
272
271
  template: `<ng-content></ng-content>`
273
272
  }]
274
- }], propDecorators: { viewOptions: [{
273
+ }], propDecorators: { inputModel: [{
274
+ type: Input,
275
+ args: [{ alias: "model" }]
276
+ }], viewOptions: [{
275
277
  type: Input
276
278
  }], renderOptions: [{
277
279
  type: Input
@@ -1,9 +1,15 @@
1
1
  import { log, Paper, Surface } from "@visuallyjs/browser-ui";
2
- import { Injectable } from "@angular/core";
2
+ import { Injectable, signal } from "@angular/core";
3
3
  import * as i0 from "@angular/core";
4
4
 
5
5
  export class VisuallyJsService {
6
6
  constructor() {
7
+ this.model = signal(null);
8
+ this.surface = signal(null);
9
+ this.paper = signal(null);
10
+ this.diagram = signal(null);
11
+ this.inspector = signal(null);
12
+ this.ui = signal(null);
7
13
  this.inspectorListeners = [];
8
14
  this.surfaceListeners = [];
9
15
  this.paperListeners = [];
@@ -11,7 +17,10 @@ export class VisuallyJsService {
11
17
  this.diagramListeners = [];
12
18
  this.uiListeners = [];
13
19
  }
20
+
14
21
  $setInspector(i) {
22
+ this.inspector.set(i);
23
+ // deprecated from here
15
24
  this.$inspector = i;
16
25
  this.$notifyInspector();
17
26
  }
@@ -27,11 +36,16 @@ export class VisuallyJsService {
27
36
  this.inspectorListeners.length = 0;
28
37
  }
29
38
  $setSurface(s) {
39
+ this.model.set(s.model);
40
+ this.surface.set(s);
41
+ this.ui.set(s);
42
+ // deprecated from here
30
43
  // @ts-ignore
31
44
  this.$setModel(s.model);
32
45
  this.$surface = s;
33
46
  this.$notifySurface();
34
47
  }
48
+
35
49
  $notifySurface() {
36
50
  this.surfaceListeners.forEach(sl => {
37
51
  try {
@@ -63,11 +77,16 @@ export class VisuallyJsService {
63
77
  }
64
78
  }
65
79
  $setPaper(p) {
80
+ this.model.set(p.model);
81
+ this.paper.set(p);
82
+ this.ui.set(p);
83
+ // deprecated below
66
84
  // @ts-ignore
67
85
  this.$setModel(p.model);
68
86
  this.$paper = p;
69
87
  this.$notifyPaper();
70
88
  }
89
+
71
90
  $notifyPaper() {
72
91
  this.paperListeners.forEach(sl => {
73
92
  try {
@@ -89,7 +108,17 @@ export class VisuallyJsService {
89
108
  this.paperListeners.push(cb);
90
109
  }
91
110
  }
111
+
92
112
  $setDiagram(d) {
113
+ this.model.set(d.model);
114
+ this.diagram.set(d);
115
+ if (d.$ui instanceof Surface) {
116
+ this.surface.set(d.$ui);
117
+ }
118
+ if (d.$ui instanceof Paper) {
119
+ this.paper.set(d.$ui);
120
+ }
121
+ // deprecated below
93
122
  this.$diagram = d;
94
123
  if (d.$ui instanceof Surface) {
95
124
  this.$setSurface(d.$ui);
@@ -99,6 +128,7 @@ export class VisuallyJsService {
99
128
  }
100
129
  this.$notifyDiagram();
101
130
  }
131
+
102
132
  $notifyDiagram() {
103
133
  this.diagramListeners.forEach(sl => {
104
134
  try {
@@ -130,9 +160,12 @@ export class VisuallyJsService {
130
160
  }
131
161
 
132
162
  $setModel(m) {
163
+ this.model.set(m);
164
+ // deprecated below
133
165
  this.$model = m;
134
166
  this.$notifyModel();
135
167
  }
168
+
136
169
  $notifyModel() {
137
170
  this.modelListeners.forEach(sl => {
138
171
  try {
@@ -144,6 +177,7 @@ export class VisuallyJsService {
144
177
  });
145
178
  this.modelListeners.length = 0;
146
179
  }
180
+
147
181
  $notifyUI(ui) {
148
182
  this.uiListeners.forEach(sl => {
149
183
  try {