@visuallyjs/browser-ui-angular 1.1.4 → 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 +24 -26
  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 +457 -504
  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 +6 -8
  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,12 +1,18 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, inject, ElementRef, Component, Input, ChangeDetectorRef, signal, computed, Directive, EventEmitter, ViewContainerRef, NgZone, reflectComponentType, Output, NgModule } from '@angular/core';
2
+ import { signal, Injectable, inject, ElementRef, effect, Component, Input, ChangeDetectorRef, computed, Directive, EventEmitter, ViewContainerRef, NgZone, reflectComponentType, Output, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
- import { log, Surface, Paper, MiniviewPlugin, EVENT_ZOOM, EVENT_PORT_UPDATED, BrowserUIModel, OVERLAY_TYPE_CUSTOM, ELEMENT_DIV, isGroup, extend, renderSurface, EVENT_NODE_UPDATED, EVENT_PORT_ADDED, EVENT_GROUP_UPDATED, EVENT_DATA_LOAD_END, EVENT_EDGE_UPDATED, EVENT_INTERNAL_CONNECTION, ShapeLibraryDefaults, ShapePalette, DEFAULT_LABEL_FILL_RATIO, convertToMultilineText, LassoPlugin, EVENT_SURFACE_MODE_CHANGED, EVENT_UNDOREDO_UPDATE, TRUE, FALSE, EVENT_SELECT, EVENT_DESELECT, EVENT_SELECTION_CLEARED, SURFACE_MODE_PAN, SURFACE_MODE_SELECT, supportsPathEditing, PAN_VIEW_BOX, PAN_PATH, LASSO_VIEW_BOX, LASSO_PATH, ZOOM_TO_FIT_VIEW_BOX, ZOOM_TO_FIT_PATH, ZOOM_IN_OUT_VIEW_BOX, ZOOM_IN_PATH, ZOOM_OUT_PATH, CLASS_CONTROLS_RESET_SELECTION, RESET_SELECTION_VIEW_BOX, RESET_SELECTION_PATH, CLEAR_VIEW_BOX, CLEAR_PATH, INSPECTOR_CONTEXT_EDGE_PROPERTY_MAPPINGS, EdgeTypePicker, Palette, SvgExportUI, ImageExportUI, CLASS_CONTROLS, CLASS_EXPORT_CONTROLS, INSPECTOR_CONTEXT_RECENT_COLORS, EVENT_CONTEXT_UPDATE, CLASS_COLOR_PICKER, CLASS_COLOR_PICKER_SWATCHES, CLASS_COLOR_PICKER_SWATCH, createDiagram, ColumnChart, BarChart, DiagramPalette, CategoryValueChart, LineChart, AreaChart, PieChart, ScatterChart, BubbleChart, SankeyChart, Edge, Node, Group, Port, Inspector } from '@visuallyjs/browser-ui';
5
+ import { log, Surface, Paper, MiniviewPlugin, EVENT_ZOOM, EVENT_PORT_UPDATED, BrowserUIModel, OVERLAY_TYPE_CUSTOM, ELEMENT_DIV, isGroup, extend, renderSurface, EVENT_NODE_UPDATED, EVENT_PORT_ADDED, EVENT_GROUP_UPDATED, EVENT_DATA_LOAD_END, EVENT_EDGE_UPDATED, EVENT_INTERNAL_CONNECTION, ShapeLibraryDefaults, ShapePalette, convertToMultilineText, DEFAULT_LABEL_FILL_RATIO, LassoPlugin, EVENT_SURFACE_MODE_CHANGED, EVENT_UNDOREDO_UPDATE, TRUE, FALSE, EVENT_SELECT, EVENT_DESELECT, EVENT_SELECTION_CLEARED, SURFACE_MODE_PAN, SURFACE_MODE_SELECT, supportsPathEditing, PAN_VIEW_BOX, PAN_PATH, LASSO_VIEW_BOX, LASSO_PATH, ZOOM_TO_FIT_VIEW_BOX, ZOOM_TO_FIT_PATH, ZOOM_IN_OUT_VIEW_BOX, ZOOM_IN_PATH, ZOOM_OUT_PATH, CLASS_CONTROLS_RESET_SELECTION, RESET_SELECTION_VIEW_BOX, RESET_SELECTION_PATH, CLEAR_VIEW_BOX, CLEAR_PATH, INSPECTOR_CONTEXT_EDGE_PROPERTY_MAPPINGS, EdgeTypePicker, Palette, SvgExportUI, ImageExportUI, CLASS_CONTROLS, CLASS_EXPORT_CONTROLS, INSPECTOR_CONTEXT_RECENT_COLORS, EVENT_CONTEXT_UPDATE, CLASS_COLOR_PICKER, CLASS_COLOR_PICKER_SWATCHES, CLASS_COLOR_PICKER_SWATCH, createDiagram, ColumnChart, BarChart, DiagramPalette, CategoryValueChart, LineChart, AreaChart, PieChart, ScatterChart, BubbleChart, SankeyChart, Edge, Node, Group, Port, Inspector, EVENT_DATA_UPDATED, EVENT_GRAPH_CLEARED } from '@visuallyjs/browser-ui';
6
6
 
7
7
 
8
8
  class VisuallyJsService {
9
9
  constructor() {
10
+ this.model = signal(null);
11
+ this.surface = signal(null);
12
+ this.paper = signal(null);
13
+ this.diagram = signal(null);
14
+ this.inspector = signal(null);
15
+ this.ui = signal(null);
10
16
  this.inspectorListeners = [];
11
17
  this.surfaceListeners = [];
12
18
  this.paperListeners = [];
@@ -14,7 +20,10 @@ class VisuallyJsService {
14
20
  this.diagramListeners = [];
15
21
  this.uiListeners = [];
16
22
  }
23
+
17
24
  $setInspector(i) {
25
+ this.inspector.set(i);
26
+ // deprecated from here
18
27
  this.$inspector = i;
19
28
  this.$notifyInspector();
20
29
  }
@@ -30,11 +39,16 @@ class VisuallyJsService {
30
39
  this.inspectorListeners.length = 0;
31
40
  }
32
41
  $setSurface(s) {
42
+ this.model.set(s.model);
43
+ this.surface.set(s);
44
+ this.ui.set(s);
45
+ // deprecated from here
33
46
  // @ts-ignore
34
47
  this.$setModel(s.model);
35
48
  this.$surface = s;
36
49
  this.$notifySurface();
37
50
  }
51
+
38
52
  $notifySurface() {
39
53
  this.surfaceListeners.forEach(sl => {
40
54
  try {
@@ -66,11 +80,16 @@ class VisuallyJsService {
66
80
  }
67
81
  }
68
82
  $setPaper(p) {
83
+ this.model.set(p.model);
84
+ this.paper.set(p);
85
+ this.ui.set(p);
86
+ // deprecated below
69
87
  // @ts-ignore
70
88
  this.$setModel(p.model);
71
89
  this.$paper = p;
72
90
  this.$notifyPaper();
73
91
  }
92
+
74
93
  $notifyPaper() {
75
94
  this.paperListeners.forEach(sl => {
76
95
  try {
@@ -92,7 +111,17 @@ class VisuallyJsService {
92
111
  this.paperListeners.push(cb);
93
112
  }
94
113
  }
114
+
95
115
  $setDiagram(d) {
116
+ this.model.set(d.model);
117
+ this.diagram.set(d);
118
+ if (d.$ui instanceof Surface) {
119
+ this.surface.set(d.$ui);
120
+ }
121
+ if (d.$ui instanceof Paper) {
122
+ this.paper.set(d.$ui);
123
+ }
124
+ // deprecated below
96
125
  this.$diagram = d;
97
126
  if (d.$ui instanceof Surface) {
98
127
  this.$setSurface(d.$ui);
@@ -102,6 +131,7 @@ class VisuallyJsService {
102
131
  }
103
132
  this.$notifyDiagram();
104
133
  }
134
+
105
135
  $notifyDiagram() {
106
136
  this.diagramListeners.forEach(sl => {
107
137
  try {
@@ -133,9 +163,12 @@ class VisuallyJsService {
133
163
  }
134
164
 
135
165
  $setModel(m) {
166
+ this.model.set(m);
167
+ // deprecated below
136
168
  this.$model = m;
137
169
  this.$notifyModel();
138
170
  }
171
+
139
172
  $notifyModel() {
140
173
  this.modelListeners.forEach(sl => {
141
174
  try {
@@ -147,6 +180,7 @@ class VisuallyJsService {
147
180
  });
148
181
  this.modelListeners.length = 0;
149
182
  }
183
+
150
184
  $notifyUI(ui) {
151
185
  this.uiListeners.forEach(sl => {
152
186
  try {
@@ -192,31 +226,29 @@ class MiniviewComponent {
192
226
  this.trackSelection = true;
193
227
  this.$el = inject(ElementRef);
194
228
  this.$vjs = inject(VisuallyJsService);
195
- }
196
-
197
- ngAfterViewInit() {
198
- this.ngZone.runOutsideAngular(() => {
199
- // this.$service.addMiniview(this.surfaceId, {
200
- // container: this.el.nativeElement.childNodes[0],
201
- // elementFilter: this.elementFilter,
202
- // typeFunction: this.typeFunction,
203
- // activeTracking: this.activeTracking,
204
- // clickToCenter: this.clickToCenter !== false
205
- // })
206
- this.$vjs.getUI((b) => {
207
- this.$miniview = b.addPlugin({
208
- type: MiniviewPlugin.type,
209
- options: {
210
- container: this.$el.nativeElement.childNodes[0],
211
- elementFilter: this.elementFilter,
212
- typeFunction: this.typeFunction,
213
- activeTracking: this.activeTracking,
214
- clickToCenter: this.clickToCenter !== false,
215
- showLasso: this.showLasso !== false,
216
- trackSelection: this.trackSelection !== false
217
- },
218
- });
219
- });
229
+ this.$ui = this.$vjs.ui;
230
+ this.initialized = false;
231
+ effect(() => {
232
+ if (!this.initialized) {
233
+ const ui = this.$ui();
234
+ if (ui != null) {
235
+ this.initialized = true;
236
+ this.ngZone.runOutsideAngular(() => {
237
+ this.$miniview = ui.addPlugin({
238
+ type: MiniviewPlugin.type,
239
+ options: {
240
+ container: this.$el.nativeElement.childNodes[0],
241
+ elementFilter: this.elementFilter,
242
+ typeFunction: this.typeFunction,
243
+ activeTracking: this.activeTracking,
244
+ clickToCenter: this.clickToCenter,
245
+ showLasso: this.showLasso,
246
+ trackSelection: this.trackSelection
247
+ },
248
+ });
249
+ });
250
+ }
251
+ }
220
252
  });
221
253
  }
222
254
 
@@ -547,6 +579,7 @@ class SurfaceComponent {
547
579
  this.$ngZone = inject(NgZone);
548
580
  this.$vjs = inject(VisuallyJsService);
549
581
  }
582
+ // $vjsSignals = inject(VisuallyJsSignalService)
550
583
 
551
584
  getNativeElement(component) {
552
585
  return component.location.nativeElement.childNodes[0];
@@ -756,11 +789,9 @@ class SurfaceComponent {
756
789
  const renderParams = extend(this.renderOptions || {}, {
757
790
  view: view,
758
791
  });
759
- let model = new BrowserUIAngularModel(this.modelOptions);
792
+ let model = this.inputModel || new BrowserUIAngularModel(this.modelOptions);
760
793
  this.model = model;
761
794
  this.surface = renderSurface(model, self.$el.nativeElement, templateRenderer, renderParams);
762
- //this.$service.addSurface(this.surfaceId, this.surface);
763
- // new
764
795
  this.$vjs.$setSurface(this.surface);
765
796
  // ----------------
766
797
  this.nodeUpdateFn = this.nodeOrGroupUpdated.bind(this);
@@ -793,7 +824,7 @@ class SurfaceComponent {
793
824
  this.surface.unbind(EVENT_INTERNAL_CONNECTION, this.edgeAddFn);
794
825
  }
795
826
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SurfaceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
796
- 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 }); }
827
+ 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 }); }
797
828
  }
798
829
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SurfaceComponent, decorators: [{
799
830
  type: Component,
@@ -801,7 +832,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
801
832
  selector: "vjs-surface",
802
833
  template: `<ng-content></ng-content>`
803
834
  }]
804
- }], propDecorators: { viewOptions: [{
835
+ }], propDecorators: { inputModel: [{
836
+ type: Input,
837
+ args: [{ alias: "model" }]
838
+ }], viewOptions: [{
805
839
  type: Input
806
840
  }], renderOptions: [{
807
841
  type: Input
@@ -836,25 +870,29 @@ class ShapePaletteComponent {
836
870
  this.dataGenerator = undefined;
837
871
  this.$el = inject(ElementRef);
838
872
  this.$vjs = inject(VisuallyJsService);
839
- }
840
- ngAfterViewInit() {
841
- this.$vjs.getUI((ui) => {
842
-
843
- new ShapePalette(ui, {
844
- container: this.$el.nativeElement,
845
- initialSet: this.initialSet,
846
- dragSize: this.dragSize,
847
- iconSize: this.iconSize,
848
- fill: this.fill,
849
- outline: this.outline,
850
- shapeLibrary: ui.getShapeLibrary(),
851
- showAllMessage: this.showAllMessage,
852
- selectAfterDrop: this.selectAfterDrop,
853
- paletteStrokeWidth: this.paletteStrokeWidth,
854
- dataGenerator: this.dataGenerator,
855
- onVertexAdded: this.onVertexAdded,
856
- preparedShapes: this.preparedShapes
857
- });
873
+ this.ui = this.$vjs.ui;
874
+ this.initialized = false;
875
+ effect(() => {
876
+ const ui = this.ui();
877
+ if (ui != null && !this.initialized) {
878
+ this.initialized = true;
879
+ // tslint:disable-next-line:no-unused-expression
880
+ new ShapePalette(ui, {
881
+ container: this.$el.nativeElement,
882
+ initialSet: this.initialSet,
883
+ dragSize: this.dragSize,
884
+ iconSize: this.iconSize,
885
+ fill: this.fill,
886
+ outline: this.outline,
887
+ shapeLibrary: ui.getShapeLibrary(),
888
+ showAllMessage: this.showAllMessage,
889
+ selectAfterDrop: this.selectAfterDrop,
890
+ paletteStrokeWidth: this.paletteStrokeWidth,
891
+ dataGenerator: this.dataGenerator,
892
+ onVertexAdded: this.onVertexAdded,
893
+ preparedShapes: this.preparedShapes
894
+ });
895
+ }
858
896
  });
859
897
  }
860
898
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ShapePaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
@@ -866,7 +904,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
866
904
  template: `<div></div>`,
867
905
  selector: `vjs-shape-palette`
868
906
  }]
869
- }], propDecorators: { initialSet: [{
907
+ }], ctorParameters: function () { return []; }, propDecorators: { initialSet: [{
870
908
  type: Input
871
909
  }], dragSize: [{
872
910
  type: Input
@@ -892,18 +930,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
892
930
 
893
931
 
894
932
  class ShapeComponent {
895
- constructor() {
896
-
897
- this.showLabels = false;
898
-
899
- this.labelProperty = "label";
900
-
901
- this.multilineLabels = true;
902
-
903
- this.labelFillRatio = DEFAULT_LABEL_FILL_RATIO;
904
- this.$el = inject(ElementRef);
905
- this.$vjs = inject(VisuallyJsService);
906
- }
907
933
  _render() {
908
934
  if (this.shapeLibrary != null) {
909
935
  const svg = this.$el.nativeElement.childNodes[0];
@@ -918,10 +944,24 @@ class ShapeComponent {
918
944
  }
919
945
  }
920
946
  }
921
- ngAfterViewInit() {
922
- this.$vjs.getUI((b) => {
923
- this.shapeLibrary = b.getShapeLibrary();
924
- this._render();
947
+ constructor() {
948
+
949
+ this.showLabels = false;
950
+
951
+ this.labelProperty = "label";
952
+
953
+ this.multilineLabels = true;
954
+
955
+ this.labelFillRatio = DEFAULT_LABEL_FILL_RATIO;
956
+ this.$el = inject(ElementRef);
957
+ this.$vjs = inject(VisuallyJsService);
958
+ this.ui = this.$vjs.ui;
959
+ effect(() => {
960
+ const ui = this.ui();
961
+ if (ui != null && this.shapeLibrary == null) {
962
+ this.shapeLibrary = ui.getShapeLibrary();
963
+ this._render();
964
+ }
925
965
  });
926
966
  }
927
967
  ngOnChanges(changes) {
@@ -950,7 +990,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
950
990
  ></svg:svg>`,
951
991
  selector: `vjs-shape`,
952
992
  }]
953
- }], propDecorators: { obj: [{
993
+ }], ctorParameters: function () { return []; }, propDecorators: { obj: [{
954
994
  type: Input
955
995
  }], width: [{
956
996
  type: Input
@@ -978,6 +1018,15 @@ const CLASS_SELECTED_MODE = "vjs-selected-mode";
978
1018
  const ATTRIBUTE_HAS_SELECTION = "vjs-controls-has-selection";
979
1019
 
980
1020
  class ControlsComponent {
1021
+ updateSelectionState() {
1022
+ const controls = this.getNativeElement(this.$el);
1023
+ if (this.ui().model.getSelection().isEmpty()) {
1024
+ controls.removeAttribute(ATTRIBUTE_HAS_SELECTION);
1025
+ }
1026
+ else {
1027
+ controls.setAttribute(ATTRIBUTE_HAS_SELECTION, "true");
1028
+ }
1029
+ }
981
1030
  constructor() {
982
1031
 
983
1032
  this.undoRedo = true;
@@ -993,43 +1042,37 @@ class ControlsComponent {
993
1042
  this.buttons = [];
994
1043
 
995
1044
  this.orientation = "row";
1045
+ this.initialized = false;
996
1046
  this.showPanButton = true;
997
1047
  this.showLassoButton = true;
998
1048
  this.$vjs = inject(VisuallyJsService);
999
1049
  this.$el = inject(ElementRef);
1000
1050
  this.$cdr = inject(ChangeDetectorRef);
1001
- }
1002
- updateSelectionState() {
1003
- const controls = this.getNativeElement(this.$el);
1004
- if (this.ui.model.getSelection().isEmpty()) {
1005
- controls.removeAttribute(ATTRIBUTE_HAS_SELECTION);
1006
- }
1007
- else {
1008
- controls.setAttribute(ATTRIBUTE_HAS_SELECTION, "true");
1009
- }
1010
- }
1011
- ngOnInit() {
1051
+ this.ui = this.$vjs.ui;
1052
+ this.model = computed(() => this.ui()?.model);
1012
1053
  this.modeButtons = this.buttons.filter((b) => b.mode != null);
1013
1054
  this.otherButtons = this.buttons.filter((b) => b.mode == null);
1014
- this.$vjs.getUI((ui) => {
1015
- this.ui = ui;
1016
- this.showLassoButton = ui.getPlugin(LassoPlugin.type) != null;
1017
- this.showPanButton = this.showLassoButton === true;
1018
- this.ui.bind(EVENT_SURFACE_MODE_CHANGED, (mode) => {
1019
- const controls = this.getNativeElement(this.$el);
1020
- const modeButtons = this.ui.$getSelector(controls, "[data-mode]");
1021
- this.ui.removeClass(modeButtons, CLASS_SELECTED_MODE);
1022
- this.ui.addClass(this.ui.$getSelector(controls, `[data-mode='${mode}']`), CLASS_SELECTED_MODE);
1023
- });
1024
- this.ui.model.bind(EVENT_UNDOREDO_UPDATE, (state) => {
1025
- const controls = this.getNativeElement(this.$el);
1026
- controls.setAttribute(ATTRIBUTE_CAN_UNDO, state.undoCount > 0 ? TRUE : FALSE);
1027
- controls.setAttribute(ATTRIBUTE_CAN_REDO, state.redoCount > 0 ? TRUE : FALSE);
1028
- });
1029
- this.ui.model.bind(EVENT_SELECT, () => this.updateSelectionState());
1030
- this.ui.model.bind(EVENT_DESELECT, () => this.updateSelectionState());
1031
- this.ui.model.bind(EVENT_SELECTION_CLEARED, () => this.updateSelectionState());
1032
- this.$cdr.detectChanges();
1055
+ effect(() => {
1056
+ const ui = this.ui();
1057
+ if (!this.initialized && ui) {
1058
+ this.showLassoButton = ui.getPlugin(LassoPlugin.type) != null;
1059
+ this.showPanButton = this.showLassoButton === true;
1060
+ this.ui.bind(EVENT_SURFACE_MODE_CHANGED, (mode) => {
1061
+ const controls = this.getNativeElement(this.$el);
1062
+ const modeButtons = ui.$getSelector(controls, "[data-mode]");
1063
+ ui.removeClass(modeButtons, CLASS_SELECTED_MODE);
1064
+ ui.addClass(ui.$getSelector(controls, `[data-mode='${mode}']`), CLASS_SELECTED_MODE);
1065
+ });
1066
+ ui.model.bind(EVENT_UNDOREDO_UPDATE, (state) => {
1067
+ const controls = this.getNativeElement(this.$el);
1068
+ controls.setAttribute(ATTRIBUTE_CAN_UNDO, state.undoCount > 0 ? TRUE : FALSE);
1069
+ controls.setAttribute(ATTRIBUTE_CAN_REDO, state.redoCount > 0 ? TRUE : FALSE);
1070
+ });
1071
+ ui.model.bind(EVENT_SELECT, () => this.updateSelectionState());
1072
+ ui.model.bind(EVENT_DESELECT, () => this.updateSelectionState());
1073
+ ui.model.bind(EVENT_SELECTION_CLEARED, () => this.updateSelectionState());
1074
+ this.$cdr.detectChanges();
1075
+ }
1033
1076
  });
1034
1077
  }
1035
1078
  getNativeElement(component) {
@@ -1038,35 +1081,36 @@ class ControlsComponent {
1038
1081
  component.location.nativeElement).childNodes[0];
1039
1082
  }
1040
1083
  panMode() {
1041
- this.ui.setMode(SURFACE_MODE_PAN);
1084
+ this.ui().setMode(SURFACE_MODE_PAN);
1042
1085
  }
1043
1086
  selectMode() {
1044
- this.ui.setMode(SURFACE_MODE_SELECT);
1087
+ this.ui().setMode(SURFACE_MODE_SELECT);
1045
1088
  }
1046
1089
  zoomToFit() {
1047
- this.ui.model.clearSelection();
1048
- this.ui.zoomToFit();
1090
+ this.model().clearSelection();
1091
+ this.ui().zoomToFit();
1049
1092
  }
1050
1093
  zoomIn() {
1051
- this.ui.zoomIn();
1094
+ this.ui().zoomIn();
1052
1095
  }
1053
1096
  zoomOut() {
1054
- this.ui.zoomOut();
1097
+ this.ui().zoomOut();
1055
1098
  }
1056
1099
  resetSelection() {
1057
- this.ui.model.clearSelection();
1058
- if (supportsPathEditing(this.ui)) {
1059
- this.ui.stopEditingPath();
1100
+ const ui = this.ui();
1101
+ this.model().clearSelection();
1102
+ if (supportsPathEditing(ui)) {
1103
+ ui.stopEditingPath();
1060
1104
  }
1061
1105
  }
1062
1106
  undo() {
1063
- this.ui.model.undo();
1107
+ this.model()?.undo();
1064
1108
  }
1065
1109
  redo() {
1066
- this.ui.model.redo();
1110
+ this.model()?.redo();
1067
1111
  }
1068
1112
  doClear() {
1069
- const t = this.ui.model;
1113
+ const t = this.model();
1070
1114
  if ((t.getNodeCount() === 0 && t.getGroupCount() === 0) ||
1071
1115
  confirm(this.clearMessage)) {
1072
1116
  t.clear();
@@ -1116,7 +1160,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1116
1160
  <i *ngFor="let button of otherButtons" class="{{ button.class }}" title="{{ button.title }}"></i>
1117
1161
  </div>`,
1118
1162
  }]
1119
- }], propDecorators: { undoRedo: [{
1163
+ }], ctorParameters: function () { return []; }, propDecorators: { undoRedo: [{
1120
1164
  type: Input
1121
1165
  }], zoomToExtents: [{
1122
1166
  type: Input
@@ -1134,28 +1178,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1134
1178
 
1135
1179
 
1136
1180
  class EdgeTypePickerComponent {
1181
+ resolveMappings() {
1182
+ const mappings = this.edgeMappings || this._inspector().getFromContext(INSPECTOR_CONTEXT_EDGE_PROPERTY_MAPPINGS);
1183
+ return mappings || this._inspector().$ui.$getEdgePropertyMappings();
1184
+ }
1137
1185
  constructor(el) {
1138
1186
  this.el = el;
1139
1187
 
1140
1188
  this.changeEvent = new EventEmitter();
1141
1189
  this.$vjs = inject(VisuallyJsService);
1142
- }
1143
- resolveMappings() {
1144
- const mappings = this.edgeMappings || this.inspector.getFromContext(INSPECTOR_CONTEXT_EDGE_PROPERTY_MAPPINGS);
1145
- return mappings || this.inspector.$ui.$getEdgePropertyMappings();
1146
- }
1147
- ngAfterViewInit() {
1148
- this.$vjs.getInspector(inspector => {
1149
- this.inspector = inspector;
1150
- this.inspector.onChange(() => {
1151
- this.edgeTypePicker.select(this.propertyName, this.inspector.getValue(this.propertyName));
1152
- });
1153
- const current = this.inspector.getValue(this.propertyName) || '';
1154
- this.edgeTypePicker = new EdgeTypePicker(this.inspector.$ui, this.el.nativeElement, this.resolveMappings(), current, (p, v) => {
1155
- this.inspector.setValue(this.propertyName, v);
1156
- this.changeEvent.emit(v);
1157
- });
1158
- this.edgeTypePicker.render(this.propertyName, this.inspector._currentCommonData);
1190
+ this._inspector = this.$vjs.inspector;
1191
+ this.initialised = false;
1192
+ effect(() => {
1193
+ if (!this.initialised) {
1194
+ const inspector = this._inspector();
1195
+ if (inspector != null) {
1196
+ this.initialised = true;
1197
+ inspector.onChange(() => {
1198
+ this.edgeTypePicker.select(this.propertyName, inspector.getValue(this.propertyName));
1199
+ });
1200
+ const current = inspector.getValue(this.propertyName) || '';
1201
+ this.edgeTypePicker = new EdgeTypePicker(inspector.$ui, this.el.nativeElement, this.resolveMappings(), current, (p, v) => {
1202
+ inspector.setValue(this.propertyName, v);
1203
+ this.changeEvent.emit(v);
1204
+ });
1205
+ this.edgeTypePicker.render(this.propertyName, inspector._currentCommonData);
1206
+ }
1207
+ }
1159
1208
  });
1160
1209
  }
1161
1210
  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 }); }
@@ -1180,42 +1229,47 @@ class PaletteComponent {
1180
1229
  constructor() {
1181
1230
  this.$vjs = inject(VisuallyJsService);
1182
1231
  this.$el = inject(ElementRef);
1183
- }
1184
-
1185
- ngAfterViewInit() {
1186
- this.$vjs.getSurface((surface) => {
1187
- let self = this;
1188
- let params = {
1189
- source: self.$el.nativeElement,
1190
- selector: self.selector,
1191
- allowDropOnEdge: this.allowDropOnEdge,
1192
- allowDropOnCanvas: this.allowDropOnCanvas,
1193
- allowDropOnGroup: this.allowDropOnGroup,
1194
- allowDropOnNode: this.allowDropOnNode,
1195
- mode: this.mode,
1196
- selectAfterAdd: this.selectAfterAdd,
1197
- allowClickToAdd: this.allowClickToAdd,
1198
- clickToAddOnly: this.clickToAddOnly
1199
- };
1200
- if (this.dataGenerator != null) {
1201
- params.dataGenerator = this.dataGenerator;
1202
- }
1203
- if (this.typeGenerator != null) {
1204
- params.typeGenerator = this.typeGenerator;
1205
- }
1206
- if (this.groupIdentifier != null) {
1207
- params.groupIdentifier = this.groupIdentifier;
1208
- }
1209
- if (this.onVertexAdded != null) {
1210
- params.onVertexAdded = this.onVertexAdded;
1211
- }
1212
- if (this.dragSize != null) {
1213
- params.dragSize = this.dragSize;
1214
- }
1215
- if (this.canvasDropFilter != null) {
1216
- params.canvasDropFilter = this.canvasDropFilter;
1232
+ this.$surface = this.$vjs.surface;
1233
+ this.initialized = false;
1234
+ effect(() => {
1235
+ if (!this.initialized) {
1236
+ const surface = this.$surface();
1237
+ if (surface != null) {
1238
+ this.initialized = true;
1239
+ let self = this;
1240
+ let params = {
1241
+ source: self.$el.nativeElement,
1242
+ selector: self.selector,
1243
+ allowDropOnEdge: this.allowDropOnEdge,
1244
+ allowDropOnCanvas: this.allowDropOnCanvas,
1245
+ allowDropOnGroup: this.allowDropOnGroup,
1246
+ allowDropOnNode: this.allowDropOnNode,
1247
+ mode: this.mode,
1248
+ selectAfterAdd: this.selectAfterAdd,
1249
+ allowClickToAdd: this.allowClickToAdd,
1250
+ clickToAddOnly: this.clickToAddOnly
1251
+ };
1252
+ if (this.dataGenerator != null) {
1253
+ params.dataGenerator = this.dataGenerator;
1254
+ }
1255
+ if (this.typeGenerator != null) {
1256
+ params.typeGenerator = this.typeGenerator;
1257
+ }
1258
+ if (this.groupIdentifier != null) {
1259
+ params.groupIdentifier = this.groupIdentifier;
1260
+ }
1261
+ if (this.onVertexAdded != null) {
1262
+ params.onVertexAdded = this.onVertexAdded;
1263
+ }
1264
+ if (this.dragSize != null) {
1265
+ params.dragSize = this.dragSize;
1266
+ }
1267
+ if (this.canvasDropFilter != null) {
1268
+ params.canvasDropFilter = this.canvasDropFilter;
1269
+ }
1270
+ this.palette = new Palette(surface, params);
1271
+ }
1217
1272
  }
1218
- this.palette = new Palette(surface, params);
1219
1273
  });
1220
1274
  }
1221
1275
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
@@ -1226,7 +1280,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1226
1280
  args: [{
1227
1281
  selector: "[vjs-palette]",
1228
1282
  }]
1229
- }], propDecorators: { selector: [{
1283
+ }], ctorParameters: function () { return []; }, propDecorators: { selector: [{
1230
1284
  type: Input
1231
1285
  }], dataGenerator: [{
1232
1286
  type: Input
@@ -1274,20 +1328,18 @@ class ExportControlsComponent {
1274
1328
  // new
1275
1329
  this.$vjs = inject(VisuallyJsService);
1276
1330
  this.$el = inject(ElementRef);
1277
- }
1278
- ngOnInit() {
1279
- this.$vjs.getUI((b) => {
1280
- this.ui = b;
1281
- });
1331
+
1332
+ this.ui = this.$vjs.ui;
1333
+ this.model = computed(() => this.ui()?.model);
1282
1334
  }
1283
1335
  exportSVG() {
1284
- new SvgExportUI(this.ui).export(this.svgOptions);
1336
+ new SvgExportUI(this.ui()).export(this.svgOptions);
1285
1337
  }
1286
1338
  exportPNG() {
1287
- new ImageExportUI(this.ui).export(this.imageOptions);
1339
+ new ImageExportUI(this.ui()).export(this.imageOptions);
1288
1340
  }
1289
1341
  exportJPG() {
1290
- new ImageExportUI(this.ui).export(Object.assign(this.imageOptions || {}, {
1342
+ new ImageExportUI(this.ui()).export(Object.assign(this.imageOptions || {}, {
1291
1343
  type: "image/jpeg",
1292
1344
  }));
1293
1345
  }
@@ -1340,9 +1392,39 @@ class ColorPickerComponent {
1340
1392
  this.$vjs = inject(VisuallyJsService);
1341
1393
  this.$el = inject(ElementRef);
1342
1394
  this.$cdr = inject(ChangeDetectorRef);
1395
+ this.initialized = false;
1396
+ effect(() => {
1397
+ const i = this.$vjs.inspector();
1398
+ if (!this.initialized) {
1399
+ this.initialized = true;
1400
+ this.swatches.set(i.ensureContext(INSPECTOR_CONTEXT_RECENT_COLORS, () => []));
1401
+ i.bind(EVENT_CONTEXT_UPDATE, (p) => {
1402
+ if (p.key === INSPECTOR_CONTEXT_RECENT_COLORS) {
1403
+ this.swatches.set(p.value);
1404
+ this.$cdr.detectChanges();
1405
+ }
1406
+ });
1407
+ const colorInput = this.$el.nativeElement.querySelector("[type='color']");
1408
+ colorInput.onchange = () => {
1409
+ const color = colorInput.value;
1410
+ this.pushColor(color);
1411
+ i.setValue(this.propertyName, color, true);
1412
+ };
1413
+ setTimeout(() => {
1414
+ // if there is a color, maybe push to context
1415
+ const v = i.getValue(this.propertyName);
1416
+ if (v != null) {
1417
+ this.pushColor(v);
1418
+ }
1419
+ });
1420
+ }
1421
+ });
1343
1422
  }
1344
1423
  $getInspector(cb) {
1345
- this.$vjs.getInspector(cb);
1424
+ const i = this.$vjs.inspector();
1425
+ if (i != null) {
1426
+ cb(i);
1427
+ }
1346
1428
  }
1347
1429
  selectColor(color) {
1348
1430
  this.$getInspector(inspector => {
@@ -1365,30 +1447,6 @@ class ColorPickerComponent {
1365
1447
  }
1366
1448
  });
1367
1449
  }
1368
- ngAfterViewInit() {
1369
- this.$getInspector(inspector => {
1370
- this.swatches.set(inspector.ensureContext(INSPECTOR_CONTEXT_RECENT_COLORS, () => []));
1371
- inspector.bind(EVENT_CONTEXT_UPDATE, (p) => {
1372
- if (p.key === INSPECTOR_CONTEXT_RECENT_COLORS) {
1373
- this.swatches.set(p.value);
1374
- this.$cdr.detectChanges();
1375
- }
1376
- });
1377
- const colorInput = this.$el.nativeElement.querySelector("[type='color']");
1378
- colorInput.onchange = () => {
1379
- const color = colorInput.value;
1380
- this.pushColor(color);
1381
- inspector.setValue(this.propertyName, color, true);
1382
- };
1383
- setTimeout(() => {
1384
- // if there is a color, maybe push to context
1385
- const v = inspector.getValue(this.propertyName);
1386
- if (v != null) {
1387
- this.pushColor(v);
1388
- }
1389
- });
1390
- });
1391
- }
1392
1450
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColorPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1393
1451
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColorPickerComponent, selector: "vjs-color", inputs: { propertyName: "propertyName", maxColors: "maxColors" }, outputs: { changeEvent: "changeEvent" }, ngImport: i0, template: "<div class=\"vjs-color-picker\">\n <input type=\"color\" [attr.vjs-att]=\"propertyName\"/>\n <div class=\"vjs-color-picker-swatches\">\n <div *ngFor=\"let swatch of swatches()\" class=\"vjs-color-picker-swatch\" attr.data-color=\"{{swatch}}\" style=\"background-color:{{swatch}}\" (click)=\"selectColor(swatch)\"></div>\n </div>\n </div>", isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
1394
1452
  }
@@ -1403,7 +1461,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1403
1461
  </div>
1404
1462
  </div>`
1405
1463
  }]
1406
- }], propDecorators: { propertyName: [{
1464
+ }], ctorParameters: function () { return []; }, propDecorators: { propertyName: [{
1407
1465
  type: Input
1408
1466
  }], maxColors: [{
1409
1467
  type: Input
@@ -1460,17 +1518,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1460
1518
  type: Input
1461
1519
  }] } });
1462
1520
 
1463
- class ColumnChartComponent {
1464
- constructor() {
1465
- this.$el = inject(ElementRef);
1466
- this.$ngZone = inject(NgZone);
1467
- this.$vjs = inject(VisuallyJsService);
1468
- }
1521
+
1522
+ class SeriesBasedChartComponent {
1469
1523
  _init(dataSource, data, url) {
1470
1524
  this.$ngZone.runOutsideAngular(() => {
1471
1525
  const o = Object.assign({}, this.options);
1472
1526
  Object.assign(o, { dataSource });
1473
- this.chart = new ColumnChart(this.$el.nativeElement, o);
1527
+ this.chart = this.createChart(this.$el.nativeElement, o);
1474
1528
  if (data) {
1475
1529
  this.chart.load({ data });
1476
1530
  }
@@ -1479,22 +1533,50 @@ class ColumnChartComponent {
1479
1533
  }
1480
1534
  });
1481
1535
  }
1536
+ constructor() {
1537
+ this.$el = inject(ElementRef);
1538
+ this.$ngZone = inject(NgZone);
1539
+ this.$vjs = inject(VisuallyJsService);
1540
+ effect(() => {
1541
+ if (this.useModel && this.chart == null) {
1542
+ const m = this.$vjs.model();
1543
+ if (m != null) {
1544
+ this._init(m, null, null);
1545
+ }
1546
+ }
1547
+ });
1548
+ }
1482
1549
 
1483
1550
  ngAfterViewInit() {
1484
- if (this.useModel) {
1485
- this.$vjs.getModel((p) => {
1486
- this._init(p, null, null);
1487
- });
1488
- }
1489
- else {
1551
+ if (!this.useModel) {
1490
1552
  this._init(null, this.data, this.url);
1491
1553
  }
1492
1554
  }
1493
1555
  ngOnDestroy() {
1494
1556
  this.chart?.destroy();
1495
1557
  }
1496
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1497
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColumnChartComponent, selector: "vjs-column-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
1558
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SeriesBasedChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1559
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SeriesBasedChartComponent }); }
1560
+ }
1561
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SeriesBasedChartComponent, decorators: [{
1562
+ type: Injectable
1563
+ }], ctorParameters: function () { return []; }, propDecorators: { data: [{
1564
+ type: Input
1565
+ }], url: [{
1566
+ type: Input
1567
+ }], options: [{
1568
+ type: Input
1569
+ }], useModel: [{
1570
+ type: Input
1571
+ }] } });
1572
+
1573
+
1574
+ class ColumnChartComponent extends SeriesBasedChartComponent {
1575
+ createChart(el, options) {
1576
+ return new ColumnChart(el, options);
1577
+ }
1578
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1579
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColumnChartComponent, selector: "vjs-column-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
1498
1580
  }
1499
1581
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnChartComponent, decorators: [{
1500
1582
  type: Component,
@@ -1512,41 +1594,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1512
1594
  type: Input
1513
1595
  }] } });
1514
1596
 
1515
- class BarChartComponent {
1516
- constructor() {
1517
- this.$vjs = inject(VisuallyJsService);
1518
- this.$el = inject(ElementRef);
1519
- this.$ngZone = inject(NgZone);
1520
- }
1521
- _init(dataSource, data, url) {
1522
- this.$ngZone.runOutsideAngular(() => {
1523
- const o = Object.assign({}, this.options);
1524
- Object.assign(o, { dataSource });
1525
- this.chart = new BarChart(this.$el.nativeElement, o);
1526
- if (data) {
1527
- this.chart.load({ data });
1528
- }
1529
- else if (url) {
1530
- this.chart.load({ url });
1531
- }
1532
- });
1533
- }
1534
-
1535
- ngAfterViewInit() {
1536
- if (this.useModel) {
1537
- this.$vjs.getModel((p) => {
1538
- this._init(p, null, null);
1539
- });
1540
- }
1541
- else {
1542
- this._init(null, this.data, this.url);
1543
- }
1544
- }
1545
- ngOnDestroy() {
1546
- this.chart?.destroy();
1597
+
1598
+ class BarChartComponent extends SeriesBasedChartComponent {
1599
+ createChart(el, options) {
1600
+ return new BarChart(el, options);
1547
1601
  }
1548
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1549
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: BarChartComponent, selector: "vjs-bar-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
1602
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1603
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: BarChartComponent, selector: "vjs-bar-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
1550
1604
  }
1551
1605
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarChartComponent, decorators: [{
1552
1606
  type: Component,
@@ -1564,44 +1618,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1564
1618
  type: Input
1565
1619
  }] } });
1566
1620
 
1621
+
1567
1622
  class DiagramPaletteComponent {
1623
+ $init(diagram) {
1624
+ if (!this.initialized) {
1625
+
1626
+ new DiagramPalette(this.$el.nativeElement, diagram, {
1627
+ fill: this.fill,
1628
+ outline: this.outline,
1629
+ dragSize: this.dragSize,
1630
+ inspector: this.inspector,
1631
+ iconSize: this.iconSize,
1632
+ showLabels: this.showLabels,
1633
+ paletteStrokeWidth: this.paletteStrokeWidth,
1634
+ showAllMessage: this.showAllMessage,
1635
+ onCellAdded: this.onCellAdded,
1636
+ mode: this.mode,
1637
+ allowClickToAdd: this.allowClickToAdd,
1638
+ autoExitDrawMode: this.autoExitDrawMode,
1639
+ selectAfterAdd: this.selectAfterAdd,
1640
+ onVertexAdded: this.onVertexAdded,
1641
+ preparedShapes: this.preparedShapes
1642
+ });
1643
+ }
1644
+ }
1568
1645
  constructor() {
1569
1646
  this.$el = inject(ElementRef);
1570
1647
  this.$vjs = inject(VisuallyJsService);
1571
- }
1572
- $init() {
1573
-
1574
- new DiagramPalette(this.$el.nativeElement, this.diagram, {
1575
- fill: this.fill,
1576
- outline: this.outline,
1577
- dragSize: this.dragSize,
1578
- inspector: this.inspector,
1579
- iconSize: this.iconSize,
1580
- showLabels: this.showLabels,
1581
- paletteStrokeWidth: this.paletteStrokeWidth,
1582
- showAllMessage: this.showAllMessage,
1583
- onCellAdded: this.onCellAdded,
1584
- mode: this.mode,
1585
- allowClickToAdd: this.allowClickToAdd,
1586
- autoExitDrawMode: this.autoExitDrawMode,
1587
- selectAfterAdd: this.selectAfterAdd,
1588
- onVertexAdded: this.onVertexAdded,
1589
- preparedShapes: this.preparedShapes
1648
+ this.initialized = false;
1649
+ effect(() => {
1650
+ const d = this.$vjs.diagram();
1651
+ if (d != null) {
1652
+ this.$init(d);
1653
+ }
1590
1654
  });
1591
1655
  }
1592
1656
  ngAfterViewInit() {
1593
- if (this.diagram != null) {
1594
- this.$init();
1595
- }
1596
- else {
1597
- this.$vjs.getDiagram((d) => {
1598
- this.diagram = d;
1599
- this.$init();
1600
- });
1657
+ if (this.inputDiagram != null) {
1658
+ this.$init(this.inputDiagram);
1601
1659
  }
1602
1660
  }
1603
1661
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DiagramPaletteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1604
- 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", diagram: "diagram", onVertexAdded: "onVertexAdded", preparedShapes: "preparedShapes" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
1662
+ 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 }); }
1605
1663
  }
1606
1664
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DiagramPaletteComponent, decorators: [{
1607
1665
  type: Component,
@@ -1609,7 +1667,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1609
1667
  selector: "vjs-diagram-palette",
1610
1668
  template: `<div></div>`,
1611
1669
  }]
1612
- }], propDecorators: { fill: [{
1670
+ }], ctorParameters: function () { return []; }, propDecorators: { fill: [{
1613
1671
  type: Input
1614
1672
  }], outline: [{
1615
1673
  type: Input
@@ -1635,36 +1693,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1635
1693
  type: Input
1636
1694
  }], selectAfterAdd: [{
1637
1695
  type: Input
1638
- }], diagram: [{
1639
- type: Input
1696
+ }], inputDiagram: [{
1697
+ type: Input,
1698
+ args: [{ alias: "diagram" }]
1640
1699
  }], onVertexAdded: [{
1641
1700
  type: Input
1642
1701
  }], preparedShapes: [{
1643
1702
  type: Input
1644
1703
  }] } });
1645
1704
 
1646
- class XYChartComponent {
1647
- constructor() {
1648
- this.$el = inject(ElementRef);
1649
- this.$ngZone = inject(NgZone);
1650
- }
1651
-
1652
- ngAfterViewInit() {
1653
- this.$ngZone.runOutsideAngular(() => {
1654
- this.chart = new CategoryValueChart(this.$el.nativeElement, this.options);
1655
- if (this.data) {
1656
- this.chart.load({ data: this.data });
1657
- }
1658
- else if (this.url) {
1659
- this.chart.load({ url: this.url });
1660
- }
1661
- });
1662
- }
1663
- ngOnDestroy() {
1664
- this.chart?.destroy();
1705
+
1706
+ class XYChartComponent extends SeriesBasedChartComponent {
1707
+ createChart(el, options) {
1708
+ return new CategoryValueChart(el, options);
1665
1709
  }
1666
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: XYChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1667
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: XYChartComponent, selector: "vjs-xy-chart", inputs: { data: "data", url: "url", options: "options" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
1710
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: XYChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1711
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: XYChartComponent, selector: "vjs-xy-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
1668
1712
  }
1669
1713
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: XYChartComponent, decorators: [{
1670
1714
  type: Component,
@@ -1678,43 +1722,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1678
1722
  type: Input
1679
1723
  }], options: [{
1680
1724
  type: Input
1725
+ }], useModel: [{
1726
+ type: Input
1681
1727
  }] } });
1682
1728
 
1683
- class LineChartComponent {
1684
- constructor() {
1685
- this.$el = inject(ElementRef);
1686
- this.$ngZone = inject(NgZone);
1687
- this.$vjs = inject(VisuallyJsService);
1688
- }
1689
- _init(dataSource, data, url) {
1690
- this.$ngZone.runOutsideAngular(() => {
1691
- const o = Object.assign({}, this.options);
1692
- Object.assign(o, { dataSource });
1693
- this.chart = new LineChart(this.$el.nativeElement, o);
1694
- if (data) {
1695
- this.chart.load({ data });
1696
- }
1697
- else if (url) {
1698
- this.chart.load({ url });
1699
- }
1700
- });
1701
- }
1702
-
1703
- ngAfterViewInit() {
1704
- if (this.useModel) {
1705
- this.$vjs.getModel((p) => {
1706
- this._init(p, null, null);
1707
- });
1708
- }
1709
- else {
1710
- this._init(null, this.data, this.url);
1711
- }
1712
- }
1713
- ngOnDestroy() {
1714
- this.chart?.destroy();
1729
+
1730
+ class LineChartComponent extends SeriesBasedChartComponent {
1731
+ createChart(el, options) {
1732
+ return new LineChart(el, options);
1715
1733
  }
1716
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LineChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1717
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: LineChartComponent, selector: "vjs-line-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
1734
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LineChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1735
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: LineChartComponent, selector: "vjs-line-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
1718
1736
  }
1719
1737
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LineChartComponent, decorators: [{
1720
1738
  type: Component,
@@ -1732,41 +1750,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1732
1750
  type: Input
1733
1751
  }] } });
1734
1752
 
1735
- class AreaChartComponent {
1736
- constructor() {
1737
- this.$vjs = inject(VisuallyJsService);
1738
- this.$el = inject(ElementRef);
1739
- this.$ngZone = inject(NgZone);
1740
- }
1741
- _init(dataSource, data, url) {
1742
- this.$ngZone.runOutsideAngular(() => {
1743
- const o = Object.assign({}, this.options);
1744
- Object.assign(o, { dataSource });
1745
- this.chart = new AreaChart(this.$el.nativeElement, o);
1746
- if (data) {
1747
- this.chart.load({ data });
1748
- }
1749
- else if (url) {
1750
- this.chart.load({ url });
1751
- }
1752
- });
1753
- }
1754
-
1755
- ngAfterViewInit() {
1756
- if (this.useModel) {
1757
- this.$vjs.getModel((p) => {
1758
- this._init(p, null, null);
1759
- });
1760
- }
1761
- else {
1762
- this._init(null, this.data, this.url);
1763
- }
1764
- }
1765
- ngOnDestroy() {
1766
- this.chart?.destroy();
1753
+
1754
+ class AreaChartComponent extends SeriesBasedChartComponent {
1755
+ createChart(el, options) {
1756
+ return new AreaChart(el, options);
1767
1757
  }
1768
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AreaChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1769
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: AreaChartComponent, selector: "vjs-area-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
1758
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AreaChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1759
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: AreaChartComponent, selector: "vjs-area-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
1770
1760
  }
1771
1761
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AreaChartComponent, decorators: [{
1772
1762
  type: Component,
@@ -1784,41 +1774,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1784
1774
  type: Input
1785
1775
  }] } });
1786
1776
 
1787
- class PieChartComponent {
1788
- constructor() {
1789
- this.$el = inject(ElementRef);
1790
- this.$ngZone = inject(NgZone);
1791
- this.$vjs = inject(VisuallyJsService);
1792
- }
1793
- _init(dataSource, data, url) {
1794
- this.$ngZone.runOutsideAngular(() => {
1795
- const o = Object.assign({}, this.options);
1796
- Object.assign(o, { dataSource });
1797
- this.chart = new PieChart(this.$el.nativeElement, o);
1798
- if (data) {
1799
- this.chart.load({ data });
1800
- }
1801
- else if (url) {
1802
- this.chart.load({ url });
1803
- }
1804
- });
1805
- }
1806
-
1807
- ngAfterViewInit() {
1808
- if (this.useModel) {
1809
- this.$vjs.getModel((p) => {
1810
- this._init(p, null, null);
1811
- });
1812
- }
1813
- else {
1814
- this._init(null, this.data, this.url);
1815
- }
1816
- }
1817
- ngOnDestroy() {
1818
- this.chart?.destroy();
1777
+
1778
+ class PieChartComponent extends SeriesBasedChartComponent {
1779
+ createChart(el, options) {
1780
+ return new PieChart(el, options);
1819
1781
  }
1820
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PieChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1821
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: PieChartComponent, selector: "vjs-pie-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
1782
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PieChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1783
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: PieChartComponent, selector: "vjs-pie-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
1822
1784
  }
1823
1785
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PieChartComponent, decorators: [{
1824
1786
  type: Component,
@@ -1836,41 +1798,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1836
1798
  type: Input
1837
1799
  }] } });
1838
1800
 
1839
- class ScatterChartComponent {
1840
- constructor() {
1841
- this.$el = inject(ElementRef);
1842
- this.$ngZone = inject(NgZone);
1843
- this.$vjs = inject(VisuallyJsService);
1844
- }
1845
- _init(dataSource, data, url) {
1846
- this.$ngZone.runOutsideAngular(() => {
1847
- const o = Object.assign({}, this.options);
1848
- Object.assign(o, { dataSource });
1849
- this.chart = new ScatterChart(this.$el.nativeElement, o);
1850
- if (data) {
1851
- this.chart.load({ data });
1852
- }
1853
- else if (url) {
1854
- this.chart.load({ url });
1855
- }
1856
- });
1857
- }
1858
-
1859
- ngAfterViewInit() {
1860
- if (this.useModel) {
1861
- this.$vjs.getModel((p) => {
1862
- this._init(p, null, null);
1863
- });
1864
- }
1865
- else {
1866
- this._init(null, this.data, this.url);
1867
- }
1868
- }
1869
- ngOnDestroy() {
1870
- this.chart?.destroy();
1801
+
1802
+ class ScatterChartComponent extends SeriesBasedChartComponent {
1803
+ createChart(el, options) {
1804
+ return new ScatterChart(el, options);
1871
1805
  }
1872
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScatterChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1873
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ScatterChartComponent, selector: "vjs-scatter-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
1806
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScatterChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1807
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ScatterChartComponent, selector: "vjs-scatter-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
1874
1808
  }
1875
1809
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScatterChartComponent, decorators: [{
1876
1810
  type: Component,
@@ -1888,41 +1822,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1888
1822
  type: Input
1889
1823
  }] } });
1890
1824
 
1891
- class BubbleChartComponent {
1892
- constructor() {
1893
- this.$el = inject(ElementRef);
1894
- this.$ngZone = inject(NgZone);
1895
- this.$vjs = inject(VisuallyJsService);
1896
- }
1897
- _init(dataSource, data, url) {
1898
- this.$ngZone.runOutsideAngular(() => {
1899
- const o = Object.assign({}, this.options);
1900
- Object.assign(o, { dataSource });
1901
- this.chart = new BubbleChart(this.$el.nativeElement, o);
1902
- if (data) {
1903
- this.chart.load({ data });
1904
- }
1905
- else if (url) {
1906
- this.chart.load({ url });
1907
- }
1908
- });
1909
- }
1910
-
1911
- ngAfterViewInit() {
1912
- if (this.useModel) {
1913
- this.$vjs.getModel((p) => {
1914
- this._init(p, null, null);
1915
- });
1916
- }
1917
- else {
1918
- this._init(null, this.data, this.url);
1919
- }
1920
- }
1921
- ngOnDestroy() {
1922
- this.chart?.destroy();
1825
+
1826
+ class BubbleChartComponent extends SeriesBasedChartComponent {
1827
+ createChart(el, options) {
1828
+ return new BubbleChart(el, options);
1923
1829
  }
1924
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BubbleChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1925
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: BubbleChartComponent, selector: "vjs-bubble-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
1830
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BubbleChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1831
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: BubbleChartComponent, selector: "vjs-bubble-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
1926
1832
  }
1927
1833
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BubbleChartComponent, decorators: [{
1928
1834
  type: Component,
@@ -1940,11 +1846,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1940
1846
  type: Input
1941
1847
  }] } });
1942
1848
 
1849
+
1943
1850
  class SankeyChartComponent {
1944
1851
  constructor() {
1945
1852
  this.$el = inject(ElementRef);
1946
1853
  this.$ngZone = inject(NgZone);
1947
1854
  this.$vjs = inject(VisuallyJsService);
1855
+ effect(() => {
1856
+ if (this.useModel && this.chart == null) {
1857
+ const m = this.$vjs.model();
1858
+ if (m != null) {
1859
+ this._init(m, null, null, null);
1860
+ }
1861
+ }
1862
+ });
1948
1863
  }
1949
1864
 
1950
1865
  _init(dataSource, csvData, jsonData, url) {
@@ -1967,12 +1882,7 @@ class SankeyChartComponent {
1967
1882
  }
1968
1883
 
1969
1884
  ngAfterViewInit() {
1970
- if (this.useModel) {
1971
- this.$vjs.getModel((p) => {
1972
- this._init(p, null, null, null);
1973
- });
1974
- }
1975
- else {
1885
+ if (!this.useModel) {
1976
1886
  this._init(null, this.csvData, this.jsonData, this.url);
1977
1887
  }
1978
1888
  }
@@ -1995,7 +1905,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1995
1905
  selector: "vjs-sankey-chart",
1996
1906
  template: `<div></div>`
1997
1907
  }]
1998
- }], propDecorators: { csvData: [{
1908
+ }], ctorParameters: function () { return []; }, propDecorators: { csvData: [{
1999
1909
  type: Input
2000
1910
  }], jsonData: [{
2001
1911
  type: Input
@@ -2191,32 +2101,34 @@ class InspectorComponent {
2191
2101
  this.changeDetector = inject(ChangeDetectorRef);
2192
2102
 
2193
2103
  this.el = inject(ElementRef);
2194
- // new
2195
2104
  this.$vjs = inject(VisuallyJsService);
2196
- }
2197
-
2198
- ngAfterViewInit() {
2199
- this.$vjs.getUI((ui) => {
2200
- this.ui = ui;
2201
- this.inspector = new Inspector({
2202
- context: this.context,
2203
- container: this.el.nativeElement,
2204
- cssClass: this.cssClass,
2205
- showCloseButton: this.showCloseButton,
2206
- ui,
2207
- renderEmptyContainer: () => {
2208
- this.reset();
2209
- this.changeDetector.detectChanges();
2210
- },
2211
- refresh: (obj, cb) => {
2212
- this.currentObj = obj;
2213
- this.refresh(obj);
2214
- setTimeout(cb, 0);
2215
- this.changeDetector.detectChanges();
2216
- },
2217
- afterUpdate: () => this.afterUpdate(ui),
2218
- });
2219
- this.$vjs.$setInspector(this.inspector);
2105
+ this.ui = this.$vjs.ui;
2106
+ this.model = computed(() => this.ui()?.model);
2107
+ this.initialized = false;
2108
+ effect(() => {
2109
+ const ui = this.ui();
2110
+ if (!this.initialized && ui != null) {
2111
+ this.initialized = true;
2112
+ this.inspector = new Inspector({
2113
+ context: this.context,
2114
+ container: this.el.nativeElement,
2115
+ cssClass: this.cssClass,
2116
+ showCloseButton: this.showCloseButton,
2117
+ ui,
2118
+ renderEmptyContainer: () => {
2119
+ this.reset();
2120
+ this.changeDetector.detectChanges();
2121
+ },
2122
+ refresh: (obj, cb) => {
2123
+ this.currentObj = obj;
2124
+ this.refresh(obj);
2125
+ setTimeout(cb, 0);
2126
+ this.changeDetector.detectChanges();
2127
+ },
2128
+ afterUpdate: () => this.afterUpdate(ui),
2129
+ });
2130
+ this.$vjs.$setInspector(this.inspector);
2131
+ }
2220
2132
  });
2221
2133
  }
2222
2134
 
@@ -2236,7 +2148,7 @@ class InspectorComponent {
2236
2148
  }
2237
2149
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: InspectorComponent, decorators: [{
2238
2150
  type: Directive
2239
- }], propDecorators: { cssClass: [{
2151
+ }], ctorParameters: function () { return []; }, propDecorators: { cssClass: [{
2240
2152
  type: Input
2241
2153
  }], showCloseButton: [{
2242
2154
  type: Input
@@ -2245,8 +2157,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
2245
2157
  }] } });
2246
2158
 
2247
2159
 
2160
+ function useZoom() {
2161
+ const $vjs = inject(VisuallyJsService);
2162
+ const surface = $vjs.surface;
2163
+ const zoom = signal(1);
2164
+ effect(() => {
2165
+ const s = surface();
2166
+ if (s != null) {
2167
+ const zoomListener = (p) => {
2168
+ zoom.set(p.zoom);
2169
+ };
2170
+ s.bind(EVENT_ZOOM, zoomListener);
2171
+ zoom.set(s.getZoom());
2172
+ return () => {
2173
+ s.unbind(EVENT_ZOOM, zoomListener);
2174
+ };
2175
+ }
2176
+ return;
2177
+ });
2178
+ return zoom;
2179
+ }
2180
+
2181
+
2182
+ function useVisuallyJsUpdate(callback) {
2183
+ const $vjs = inject(VisuallyJsService);
2184
+ effect(() => {
2185
+ const m = $vjs.model();
2186
+ if (m != null) {
2187
+ const fn = () => callback(m);
2188
+ m.bind(EVENT_DATA_UPDATED, fn);
2189
+ m.bind(EVENT_GRAPH_CLEARED, fn);
2190
+ fn();
2191
+ return (() => {
2192
+ m.unbind(EVENT_DATA_UPDATED, fn);
2193
+ m.unbind(EVENT_GRAPH_CLEARED, fn);
2194
+ });
2195
+ }
2196
+ return;
2197
+ });
2198
+ }
2199
+
2200
+
2248
2201
 
2249
2202
 
2250
2203
 
2251
- export { AngularComponentOverlayType, AreaChartComponent, BarChartComponent, BaseAngularOverlayComponent, BaseGroupComponent, BaseNodeComponent, BasePortComponent, BaseVertexComponent, BrowserUIAngularModel, BubbleChartComponent, ColorPickerComponent, ColumnChartComponent, ControlsComponent, DecoratorComponent, DefaultGroupComponent, DefaultNodeComponent, DiagramComponent, DiagramPaletteComponent, EdgeTypePickerComponent, ExportControlsComponent, InspectorComponent, LineChartComponent, MiniviewComponent, PaletteComponent, PieChartComponent, SankeyChartComponent, ScatterChartComponent, ShapeComponent, ShapePaletteComponent, SurfaceComponent, VisuallyJsModule, VisuallyJsService, XYChartComponent };
2204
+ export { AngularComponentOverlayType, AreaChartComponent, BarChartComponent, BaseAngularOverlayComponent, BaseGroupComponent, BaseNodeComponent, BasePortComponent, BaseVertexComponent, BrowserUIAngularModel, BubbleChartComponent, ColorPickerComponent, ColumnChartComponent, ControlsComponent, DecoratorComponent, DefaultGroupComponent, DefaultNodeComponent, DiagramComponent, DiagramPaletteComponent, EdgeTypePickerComponent, ExportControlsComponent, InspectorComponent, LineChartComponent, MiniviewComponent, PaletteComponent, PieChartComponent, SankeyChartComponent, ScatterChartComponent, SeriesBasedChartComponent, ShapeComponent, ShapePaletteComponent, SurfaceComponent, VisuallyJsModule, VisuallyJsService, XYChartComponent, useVisuallyJsUpdate, useZoom };
2252
2205
  //# sourceMappingURL=visuallyjs-browser-ui-angular.mjs.map