@metadev/daga 1.5.2 → 1.5.3

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.
package/Changelog.md CHANGED
@@ -6,6 +6,12 @@ List of releases and changes.
6
6
 
7
7
  ## Next release Lobera
8
8
 
9
+ ## v. 1.5.3
10
+
11
+ Date: _2024-09-09_
12
+
13
+ - Create interface for listening to user events on the diagram [#160](https://github.com/metadevpro/daga/issues/160) [#161](https://github.com/metadevpro/daga/pull/161)
14
+
9
15
  ## v. 1.5.2
10
16
 
11
17
  Date: _2024-08-30_
@@ -5425,6 +5425,23 @@ class DiagramModel {
5425
5425
  }
5426
5426
  }
5427
5427
 
5428
+ /**
5429
+ * Represents an action taken by the user on the diagram.
5430
+ * @public
5431
+ */
5432
+ class DiagramEvent {
5433
+ constructor(cause, type, target, coords) {
5434
+ this.cause = cause;
5435
+ this.type = type;
5436
+ this.target = target;
5437
+ this.coords = coords;
5438
+ this.defaultPrevented = false;
5439
+ }
5440
+ preventDefault() {
5441
+ this.defaultPrevented = true;
5442
+ }
5443
+ }
5444
+
5428
5445
  /**
5429
5446
  * Thickness of the invisible path around a connection used to make it easier to click on, in pixels.
5430
5447
  * @private
@@ -5555,10 +5572,17 @@ class DiagramCanvas {
5555
5572
  d3.select(this.diagramRoot).node()?.focus();
5556
5573
  })
5557
5574
  .on(Events.ContextMenu, (event) => {
5558
- if (this.canUserPerformAction(DiagramActions.ContextMenu)) {
5575
+ const diagramEvent = new DiagramEvent(event, Events.ContextMenu, undefined);
5576
+ this.parentComponent.modelEvent.emit(diagramEvent);
5577
+ if (!diagramEvent.defaultPrevented &&
5578
+ this.canUserPerformAction(DiagramActions.ContextMenu)) {
5559
5579
  event.preventDefault();
5560
5580
  this.openContextMenu(event);
5561
5581
  }
5582
+ })
5583
+ .on(Events.DoubleClick, (event) => {
5584
+ const diagramEvent = new DiagramEvent(event, Events.DoubleClick, undefined);
5585
+ this.parentComponent.modelEvent.emit(diagramEvent);
5562
5586
  })
5563
5587
  .on(Events.KeyDown, (event) => {
5564
5588
  if (!event.ctrlKey &&
@@ -5866,12 +5890,19 @@ class DiagramCanvas {
5866
5890
  this.toggleUserSelection(d);
5867
5891
  })
5868
5892
  .on(Events.ContextMenu, (event, d) => {
5869
- if (this.canUserPerformAction(DiagramActions.ContextMenu)) {
5893
+ const diagramEvent = new DiagramEvent(event, Events.ContextMenu, d);
5894
+ this.parentComponent.modelEvent.emit(diagramEvent);
5895
+ if (!diagramEvent.defaultPrevented &&
5896
+ this.canUserPerformAction(DiagramActions.ContextMenu)) {
5870
5897
  event.preventDefault();
5871
5898
  this.highlight(d);
5872
5899
  this.addToUserSelection(d);
5873
5900
  this.openContextMenu(event);
5874
5901
  }
5902
+ })
5903
+ .on(Events.DoubleClick, (event, d) => {
5904
+ const diagramEvent = new DiagramEvent(event, Events.DoubleClick, d);
5905
+ this.parentComponent.modelEvent.emit(diagramEvent);
5875
5906
  })
5876
5907
  .call(d3
5877
5908
  .drag()
@@ -6398,13 +6429,20 @@ class DiagramCanvas {
6398
6429
  this.toggleUserSelection(getRelatedNodeOrItself(d));
6399
6430
  })
6400
6431
  .on(Events.ContextMenu, (event, d) => {
6401
- if (this.canUserPerformAction(DiagramActions.ContextMenu)) {
6432
+ const diagramEvent = new DiagramEvent(event, Events.ContextMenu, d);
6433
+ this.parentComponent.modelEvent.emit(diagramEvent);
6434
+ if (!diagramEvent.defaultPrevented &&
6435
+ this.canUserPerformAction(DiagramActions.ContextMenu)) {
6402
6436
  event.preventDefault();
6403
6437
  const elementToSelect = getRelatedNodeOrItself(d);
6404
6438
  this.highlight(elementToSelect);
6405
6439
  this.addToUserSelection(elementToSelect);
6406
6440
  this.openContextMenu(event);
6407
6441
  }
6442
+ })
6443
+ .on(Events.DoubleClick, (event, d) => {
6444
+ const diagramEvent = new DiagramEvent(event, Events.DoubleClick, d);
6445
+ this.parentComponent.modelEvent.emit(diagramEvent);
6408
6446
  })
6409
6447
  .call(d3
6410
6448
  .drag()
@@ -6966,13 +7004,20 @@ class DiagramCanvas {
6966
7004
  this.toggleUserSelection(getRelatedNodeOrItself(d));
6967
7005
  })
6968
7006
  .on(Events.ContextMenu, (event, d) => {
6969
- if (this.canUserPerformAction(DiagramActions.ContextMenu)) {
7007
+ const diagramEvent = new DiagramEvent(event, Events.ContextMenu, d);
7008
+ this.parentComponent.modelEvent.emit(diagramEvent);
7009
+ if (!diagramEvent.defaultPrevented &&
7010
+ this.canUserPerformAction(DiagramActions.ContextMenu)) {
6970
7011
  event.preventDefault();
6971
7012
  const elementToSelect = getRelatedNodeOrItself(d);
6972
7013
  this.highlight(elementToSelect);
6973
7014
  this.addToUserSelection(elementToSelect);
6974
7015
  this.openContextMenu(event);
6975
7016
  }
7017
+ })
7018
+ .on(Events.DoubleClick, (event, d) => {
7019
+ const diagramEvent = new DiagramEvent(event, Events.DoubleClick, d);
7020
+ this.parentComponent.modelEvent.emit(diagramEvent);
6976
7021
  })
6977
7022
  .call(d3
6978
7023
  .drag()
@@ -7128,12 +7173,19 @@ class DiagramCanvas {
7128
7173
  this.toggleUserSelection(d);
7129
7174
  })
7130
7175
  .on(Events.ContextMenu, (event, d) => {
7131
- if (this.canUserPerformAction(DiagramActions.ContextMenu)) {
7176
+ const diagramEvent = new DiagramEvent(event, Events.ContextMenu, d);
7177
+ this.parentComponent.modelEvent.emit(diagramEvent);
7178
+ if (!diagramEvent.defaultPrevented &&
7179
+ this.canUserPerformAction(DiagramActions.ContextMenu)) {
7132
7180
  event.preventDefault();
7133
7181
  this.highlight(d);
7134
7182
  this.addToUserSelection(d);
7135
7183
  this.openContextMenu(event);
7136
7184
  }
7185
+ })
7186
+ .on(Events.DoubleClick, (event, d) => {
7187
+ const diagramEvent = new DiagramEvent(event, Events.DoubleClick, d);
7188
+ this.parentComponent.modelEvent.emit(diagramEvent);
7137
7189
  });
7138
7190
  enterSelection.append('path').attr('class', 'diagram-connection-path');
7139
7191
  enterSelection.append('path').attr('class', 'diagram-connection-path-box');
@@ -7221,7 +7273,10 @@ class DiagramCanvas {
7221
7273
  this.toggleUserSelection(getRelatedNodeOrItself(d));
7222
7274
  })
7223
7275
  .on(Events.ContextMenu, (event, d) => {
7224
- if (this.canUserPerformAction(DiagramActions.ContextMenu)) {
7276
+ const diagramEvent = new DiagramEvent(event, Events.ContextMenu, d);
7277
+ this.parentComponent.modelEvent.emit(diagramEvent);
7278
+ if (!diagramEvent.defaultPrevented &&
7279
+ this.canUserPerformAction(DiagramActions.ContextMenu)) {
7225
7280
  event.preventDefault();
7226
7281
  const elementToSelect = getRelatedNodeOrItself(d);
7227
7282
  this.highlight(elementToSelect);
@@ -7229,8 +7284,11 @@ class DiagramCanvas {
7229
7284
  this.openContextMenu(event);
7230
7285
  }
7231
7286
  })
7232
- .on(Events.DoubleClick, (_event, d) => {
7233
- if (this.canUserPerformAction(DiagramActions.EditField) &&
7287
+ .on(Events.DoubleClick, (event, d) => {
7288
+ const diagramEvent = new DiagramEvent(event, Events.DoubleClick, d);
7289
+ this.parentComponent.modelEvent.emit(diagramEvent);
7290
+ if (!diagramEvent.defaultPrevented &&
7291
+ this.canUserPerformAction(DiagramActions.EditField) &&
7234
7292
  d.editable &&
7235
7293
  !d.removed) {
7236
7294
  this.currentAction = new EditFieldAction(this, d.id, d.text, '');
@@ -9829,6 +9887,11 @@ class DiagramEditorComponent {
9829
9887
  constructor(configurationService, canvasProvider) {
9830
9888
  this.configurationService = configurationService;
9831
9889
  this.canvasProvider = canvasProvider;
9890
+ /**
9891
+ * Output for user events on the diagram's model.
9892
+ * @public
9893
+ */
9894
+ this.modelEvent = new EventEmitter();
9832
9895
  this.Corner = Corner;
9833
9896
  this.Side = Side;
9834
9897
  }
@@ -9839,7 +9902,7 @@ class DiagramEditorComponent {
9839
9902
  this.canvasProvider.initCanvasView(this.appendTo.nativeElement);
9840
9903
  }
9841
9904
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DiagramEditorComponent, deps: [{ token: DagaConfigurationService }, { token: CanvasProviderService }], target: i0.ɵɵFactoryTarget.Component }); }
9842
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.2", type: DiagramEditorComponent, isStandalone: true, selector: "daga-diagram-editor", viewQueries: [{ propertyName: "appendTo", first: true, predicate: ["appendTo"], descendants: true }, { propertyName: "diagramButtons", first: true, predicate: ["diagramButtons"], descendants: true }, { propertyName: "palette", first: true, predicate: ["palette"], descendants: true }, { propertyName: "propertyEditor", first: true, predicate: ["propertyEditor"], descendants: true }], ngImport: i0, template: "<div class=\"append-to\" #appendTo></div>\n<daga-diagram-buttons\n *ngIf=\"config.components?.buttons?.exists !== false\"\n #diagramButtons\n [location]=\"config.components?.buttons?.location || Corner.BottomRight\"\n [direction]=\"config.components?.buttons?.direction || Side.Top\"\n [enableFilter]=\"config.components?.buttons?.enableFilter !== false\"\n [enableLayout]=\"config.components?.buttons?.enableLayout !== false\"\n [enableUndoRedo]=\"config.components?.buttons?.enableUndoRedo !== false\"\n [enableZoom]=\"config.components?.buttons?.enableZoom !== false\"\n [zoomRate]=\"config.components?.buttons?.zoomRate || 2\"\n/>\n<daga-palette\n *ngIf=\"\n config.components?.palette?.exists !== false &&\n config.components?.palette?.sections &&\n (config.components?.palette?.sections?.length || 0) > 0\n \"\n #palette\n [location]=\"config.components?.palette?.location || Corner.TopLeft\"\n [direction]=\"config.components?.palette?.direction || Side.Bottom\"\n [width]=\"config.components?.palette?.width || '12rem'\"\n [palettes]=\"config.components?.palette?.sections || []\"\n/>\n<daga-property-editor\n *ngIf=\"config.components?.propertyEditor?.exists !== false\"\n #propertyEditor\n [location]=\"config.components?.propertyEditor?.location || Corner.TopRight\"\n [direction]=\"config.components?.propertyEditor?.direction || Side.Bottom\"\n [width]=\"config.components?.propertyEditor?.width || '24rem'\"\n/>\n<daga-errors *ngIf=\"config.components?.errors?.exists !== false\" />\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: DiagramButtonsComponent, selector: "daga-diagram-buttons", inputs: ["location", "direction", "enableFilter", "enableLayout", "enableUndoRedo", "enableZoom", "zoomRate"] }, { kind: "component", type: PaletteComponent, selector: "daga-palette", inputs: ["palettes", "currentPalette", "currentCategory", "location", "direction", "width"] }, { kind: "component", type: PropertyEditorComponent, selector: "daga-property-editor", inputs: ["location", "direction", "width", "valueSet"] }, { kind: "component", type: ErrorsComponent, selector: "daga-errors" }] }); }
9905
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.2", type: DiagramEditorComponent, isStandalone: true, selector: "daga-diagram-editor", outputs: { modelEvent: "modelEvent" }, viewQueries: [{ propertyName: "appendTo", first: true, predicate: ["appendTo"], descendants: true }, { propertyName: "diagramButtons", first: true, predicate: ["diagramButtons"], descendants: true }, { propertyName: "palette", first: true, predicate: ["palette"], descendants: true }, { propertyName: "propertyEditor", first: true, predicate: ["propertyEditor"], descendants: true }], ngImport: i0, template: "<div class=\"append-to\" #appendTo></div>\n<daga-diagram-buttons\n *ngIf=\"config.components?.buttons?.exists !== false\"\n #diagramButtons\n [location]=\"config.components?.buttons?.location || Corner.BottomRight\"\n [direction]=\"config.components?.buttons?.direction || Side.Top\"\n [enableFilter]=\"config.components?.buttons?.enableFilter !== false\"\n [enableLayout]=\"config.components?.buttons?.enableLayout !== false\"\n [enableUndoRedo]=\"config.components?.buttons?.enableUndoRedo !== false\"\n [enableZoom]=\"config.components?.buttons?.enableZoom !== false\"\n [zoomRate]=\"config.components?.buttons?.zoomRate || 2\"\n/>\n<daga-palette\n *ngIf=\"\n config.components?.palette?.exists !== false &&\n config.components?.palette?.sections &&\n (config.components?.palette?.sections?.length || 0) > 0\n \"\n #palette\n [location]=\"config.components?.palette?.location || Corner.TopLeft\"\n [direction]=\"config.components?.palette?.direction || Side.Bottom\"\n [width]=\"config.components?.palette?.width || '12rem'\"\n [palettes]=\"config.components?.palette?.sections || []\"\n/>\n<daga-property-editor\n *ngIf=\"config.components?.propertyEditor?.exists !== false\"\n #propertyEditor\n [location]=\"config.components?.propertyEditor?.location || Corner.TopRight\"\n [direction]=\"config.components?.propertyEditor?.direction || Side.Bottom\"\n [width]=\"config.components?.propertyEditor?.width || '24rem'\"\n/>\n<daga-errors *ngIf=\"config.components?.errors?.exists !== false\" />\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: DiagramButtonsComponent, selector: "daga-diagram-buttons", inputs: ["location", "direction", "enableFilter", "enableLayout", "enableUndoRedo", "enableZoom", "zoomRate"] }, { kind: "component", type: PaletteComponent, selector: "daga-palette", inputs: ["palettes", "currentPalette", "currentCategory", "location", "direction", "width"] }, { kind: "component", type: PropertyEditorComponent, selector: "daga-property-editor", inputs: ["location", "direction", "width", "valueSet"] }, { kind: "component", type: ErrorsComponent, selector: "daga-errors" }] }); }
9843
9906
  }
9844
9907
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImport: i0, type: DiagramEditorComponent, decorators: [{
9845
9908
  type: Component,
@@ -9862,6 +9925,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.2", ngImpor
9862
9925
  }], propertyEditor: [{
9863
9926
  type: ViewChild,
9864
9927
  args: ['propertyEditor']
9928
+ }], modelEvent: [{
9929
+ type: Output
9865
9930
  }] } });
9866
9931
 
9867
9932
  /**
@@ -10201,5 +10266,5 @@ function now() {
10201
10266
  * Generated bundle index. Do not edit.
10202
10267
  */
10203
10268
 
10204
- export { ACTION_QUEUE_SIZE, ActionQueue, AddConnectionAction, AddNodeAction, AdjacencyLayout, BreadthAdjacencyLayout, BreadthLayout, CanvasProviderService, ClosedShape, CollabClient, CollapseButtonComponent, Corner, DagaConfigurationService, DagaExporter, DagaImporter, DagaModule, DiagramActions, DiagramButtonsComponent, DiagramCanvas, DiagramComponent, DiagramConnection, DiagramConnectionSet, DiagramConnectionType, DiagramEditorComponent, DiagramElement, DiagramEntitySet, DiagramField, DiagramFieldSet, DiagramModel, DiagramNode, DiagramNodeSet, DiagramNodeType, DiagramPort, DiagramPortSet, DiagramSection, DiagramSectionSet, EditFieldAction, ErrorsComponent, ForceLayout, HorizontalAlign, HorizontalLayout, LineShape, LineStyle, ObjectEditorComponent, PaletteComponent, PriorityLayout, Property, PropertyEditorComponent, PropertySet, RemoveAction, SetGeometryAction, Side, TextListEditorComponent, TextMapEditorComponent, Type, UpdateValuesAction, ValueSet, VerticalAlign, VerticalLayout, layouts };
10269
+ export { ACTION_QUEUE_SIZE, ActionQueue, AddConnectionAction, AddNodeAction, AdjacencyLayout, BreadthAdjacencyLayout, BreadthLayout, CanvasProviderService, ClosedShape, CollabClient, CollapseButtonComponent, Corner, DagaConfigurationService, DagaExporter, DagaImporter, DagaModule, DiagramActions, DiagramButtonsComponent, DiagramCanvas, DiagramComponent, DiagramConnection, DiagramConnectionSet, DiagramConnectionType, DiagramEditorComponent, DiagramElement, DiagramEntitySet, DiagramEvent, DiagramField, DiagramFieldSet, DiagramModel, DiagramNode, DiagramNodeSet, DiagramNodeType, DiagramPort, DiagramPortSet, DiagramSection, DiagramSectionSet, EditFieldAction, ErrorsComponent, ForceLayout, HorizontalAlign, HorizontalLayout, LineShape, LineStyle, ObjectEditorComponent, PaletteComponent, PriorityLayout, Property, PropertyEditorComponent, PropertySet, RemoveAction, SetGeometryAction, Side, TextListEditorComponent, TextMapEditorComponent, Type, UpdateValuesAction, ValueSet, VerticalAlign, VerticalLayout, layouts };
10205
10270
  //# sourceMappingURL=metadev-daga.mjs.map