@metadev/daga 1.3.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/Changelog.md +31 -0
  2. package/assets/styles/_diagram-buttons.scss +71 -37
  3. package/assets/styles/_palette.scss +12 -4
  4. package/assets/styles/_property-editor.scss +0 -3
  5. package/assets/styles/daga.scss +9 -5
  6. package/fesm2022/metadev-daga.mjs +3069 -2588
  7. package/fesm2022/metadev-daga.mjs.map +1 -1
  8. package/index.d.ts +1 -1
  9. package/lib/diagram/diagram.component.d.ts +28 -3
  10. package/lib/diagram-buttons/diagram-buttons.component.d.ts +14 -3
  11. package/lib/diagram-editor/diagram/converters/daga-model.d.ts +5 -0
  12. package/lib/diagram-editor/diagram/diagram-action.d.ts +61 -10
  13. package/lib/diagram-editor/diagram/diagram-canvas.d.ts +26 -7
  14. package/lib/diagram-editor/diagram/diagram-config.d.ts +199 -41
  15. package/lib/diagram-editor/diagram/diagram-connection.d.ts +1 -0
  16. package/lib/diagram-editor/diagram/diagram-element.d.ts +10 -0
  17. package/lib/diagram-editor/diagram/diagram-field.d.ts +11 -4
  18. package/lib/diagram-editor/diagram/diagram-model.d.ts +0 -16
  19. package/lib/diagram-editor/diagram/diagram-node.d.ts +5 -4
  20. package/lib/diagram-editor/diagram/diagram-port.d.ts +1 -0
  21. package/lib/diagram-editor/diagram/diagram-section.d.ts +40 -8
  22. package/lib/diagram-editor/diagram-editor.component.d.ts +2 -1
  23. package/lib/interfaces/canvas.d.ts +48 -17
  24. package/lib/palette/palette.component.d.ts +8 -6
  25. package/lib/property-editor/property-editor.component.d.ts +9 -4
  26. package/lib/services/canvas-provider.service.d.ts +1 -1
  27. package/lib/services/daga-configuration.service.d.ts +1 -1
  28. package/lib/util/events.d.ts +5 -1
  29. package/lib/util/style.d.ts +13 -0
  30. package/lib/util/text-util.d.ts +2 -0
  31. package/package.json +1 -1
  32. package/assets/config/generic-diagram.json +0 -94
  33. package/assets/icon/connection/arrow.svg +0 -23
  34. package/assets/icon/connection/empty-arrow.svg +0 -19
  35. package/assets/icon/connection/empty-diamond.svg +0 -20
  36. package/assets/icon/connection/filled-arrow.svg +0 -19
  37. package/assets/icon/connection/filled-diamond.svg +0 -20
  38. package/assets/icon/connection/line.svg +0 -9
@@ -1,12 +1,13 @@
1
1
  import { Subject } from 'rxjs';
2
- import { ActionQueue } from '../diagram-editor/diagram/diagram-action';
2
+ import { ActionQueue, DiagramActions } from '../diagram-editor/diagram/diagram-action';
3
+ import { UserActionConfig } from '../diagram-editor/diagram/diagram-config';
3
4
  import { DiagramConnectionType } from '../diagram-editor/diagram/diagram-connection';
4
5
  import { DiagramElement } from '../diagram-editor/diagram/diagram-element';
5
6
  import { DiagramModel } from '../diagram-editor/diagram/diagram-model';
6
7
  import { DiagramValidator } from '../errors/diagram-validator';
7
8
  import { Point } from '../util/canvas-util';
8
9
  import { DiagramEditor } from './diagram-editor';
9
- import { UserActionConfig } from '../diagram-editor/diagram/diagram-config';
10
+ import { ValueSet } from '../diagram-editor/diagram/diagram-property';
10
11
  /**
11
12
  * Provides the functionality for the visual representation of the elements of a model.
12
13
  * @public
@@ -26,7 +27,7 @@ export interface Canvas {
26
27
  * Background color of the diagram.
27
28
  * @public
28
29
  */
29
- color: string;
30
+ backgroundColor: string;
30
31
  /**
31
32
  * Distance between the grid points of the diagram.
32
33
  * @public
@@ -47,16 +48,6 @@ export interface Canvas {
47
48
  * @public
48
49
  */
49
50
  connectionType?: DiagramConnectionType;
50
- /**
51
- * Elements below the priority threshold shouldn't be displayed.
52
- * @public
53
- */
54
- priorityThreshold?: number;
55
- /**
56
- * Possible values that the priority threshold can take.
57
- * @public
58
- */
59
- priorityThresholds: number[];
60
51
  /**
61
52
  * Identifier of the current layout format used by the diagram.
62
53
  * @public
@@ -83,19 +74,20 @@ export interface Canvas {
83
74
  */
84
75
  viewInitialized$: Subject<void>;
85
76
  /**
86
- * Subject for tracking when validators are added to the canvas.
77
+ * Subject for tracking when validators are added to or removed from the canvas.
87
78
  * @public
88
79
  */
89
80
  validatorChanges$: Subject<void>;
90
81
  /**
91
82
  * Subject for tracking changes in the diagram.
92
83
  * Used to detect if there have been changes over a period of time.
84
+ * Values are sent when the user performs changes on the diagram, but not when the changes are performed programmatically.
93
85
  * @public
94
86
  */
95
- diagramChanges$: Subject<number>;
87
+ diagramChanges$: Subject<void>;
96
88
  /**
97
89
  * Subject for tracking the presence of important changes in the diagram.
98
- * Used to detect if there are any changes that require an immediate reaction.
90
+ * Used to detect if there are any changes that require immediate handling.
99
91
  * @public
100
92
  */
101
93
  diagramImportantChanges$: Subject<void>;
@@ -153,6 +145,12 @@ export interface Canvas {
153
145
  * @param event A MouseEvent.
154
146
  */
155
147
  getPointerLocationRelativeToBody(event: MouseEvent): Point;
148
+ /**
149
+ * Get the location of the pointer in the given event relative to the screen.
150
+ * @private
151
+ * @param event A MouseEvent.
152
+ */
153
+ getPointerLocationRelativeToScreen(event: MouseEvent): Point;
156
154
  /**
157
155
  * Adds a validator to the list of validators of the diagram.
158
156
  * @public
@@ -163,6 +161,22 @@ export interface Canvas {
163
161
  * @public
164
162
  */
165
163
  removeValidator(validator: DiagramValidator): void;
164
+ /**
165
+ * Get the possible priority thresholds of the diagram.
166
+ * @public
167
+ */
168
+ getPriorityThresholdOptions(): number[] | undefined;
169
+ /**
170
+ * Get the current priority threshold of the diagram.
171
+ * @public
172
+ */
173
+ getPriorityThreshold(): number | undefined;
174
+ /**
175
+ * Changes the current priority threshold of the diagram.
176
+ * @public
177
+ * @param priority A priority threshold.
178
+ */
179
+ setPriorityThreshold(priority: number): void;
166
180
  /**
167
181
  * Update the view of the canvas to show the current state of the model.
168
182
  * @public
@@ -193,6 +207,16 @@ export interface Canvas {
193
207
  * @public
194
208
  */
195
209
  updateFieldsInView(...ids: string[]): void;
210
+ /**
211
+ * Fit the root of a diagram field to encompass the totality of the field.
212
+ * @param id The id of a diagram field
213
+ */
214
+ fitFieldRootInView(id: string): void;
215
+ /**
216
+ * Fit a node to encompass the totality of its sections.
217
+ * @param id The id of a node
218
+ */
219
+ fitNodeInView(id: string): void;
196
220
  /**
197
221
  * Get the d3 Selection containing the view of all the elements in the canvas.
198
222
  * @private
@@ -245,9 +269,16 @@ export interface Canvas {
245
269
  * @public
246
270
  */
247
271
  cancelAllUserActions(): void;
272
+ /**
273
+ * Checks whether the user can perform the given action.
274
+ * @public
275
+ */
276
+ canUserPerformAction(action: DiagramActions): boolean;
248
277
  /**
249
278
  * Sets the diagram element whose ValueSet is being displayed in the value set editor.
250
279
  * @private
251
280
  */
252
- setPropertyEditorSelection(selection?: DiagramElement): void;
281
+ setPropertyEditorSelection(selection?: {
282
+ valueSet: ValueSet;
283
+ } & (DiagramElement | DiagramModel)): void;
253
284
  }
@@ -1,10 +1,10 @@
1
1
  import { AfterContentInit, AfterViewInit, ElementRef } from '@angular/core';
2
2
  import * as d3 from 'd3';
3
- import { PaletteConfig } from '../diagram-editor/diagram/diagram-config';
3
+ import { PaletteSectionConfig } from '../diagram-editor/diagram/diagram-config';
4
4
  import { Canvas } from '../interfaces/canvas';
5
5
  import { Palette } from '../interfaces/palette';
6
6
  import { CanvasProviderService } from '../services/canvas-provider.service';
7
- import { Corner } from '../util/svg-util';
7
+ import { Corner, Side } from '../util/svg-util';
8
8
  import * as i0 from "@angular/core";
9
9
  /**
10
10
  * Palette that the user can drag and drop nodes from.
@@ -16,16 +16,18 @@ export declare class PaletteComponent implements AfterContentInit, AfterViewInit
16
16
  private canvasProvider;
17
17
  get canvas(): Canvas;
18
18
  panel: ElementRef<HTMLDivElement>;
19
- palettes: PaletteConfig[];
20
- currentPalette: PaletteConfig;
19
+ palettes: PaletteSectionConfig[];
20
+ currentPalette: PaletteSectionConfig;
21
21
  currentCategory: string;
22
22
  location: Corner;
23
+ direction: Side;
24
+ width: string;
23
25
  private priorityThreshold?;
24
26
  constructor(canvasProvider: CanvasProviderService);
25
27
  ngAfterContentInit(): void;
26
28
  ngAfterViewInit(): void;
27
29
  refreshPalette(): void;
28
- switchPalette(palette: PaletteConfig): void;
30
+ switchPalette(palette: PaletteSectionConfig): void;
29
31
  selectPanel(): d3.Selection<HTMLDivElement, unknown, null, undefined>;
30
32
  selectPalette(): d3.Selection<HTMLDivElement, unknown, null, undefined>;
31
33
  private appendCategories;
@@ -33,5 +35,5 @@ export declare class PaletteComponent implements AfterContentInit, AfterViewInit
33
35
  private appendNodeTemplate;
34
36
  private appendConnectionTemplate;
35
37
  static ɵfac: i0.ɵɵFactoryDeclaration<PaletteComponent, never>;
36
- static ɵcmp: i0.ɵɵComponentDeclaration<PaletteComponent, "daga-palette", never, { "palettes": { "alias": "palettes"; "required": false; }; "currentPalette": { "alias": "currentPalette"; "required": false; }; "currentCategory": { "alias": "currentCategory"; "required": false; }; "location": { "alias": "location"; "required": false; }; }, {}, never, never, true, never>;
38
+ static ɵcmp: i0.ɵɵComponentDeclaration<PaletteComponent, "daga-palette", never, { "palettes": { "alias": "palettes"; "required": false; }; "currentPalette": { "alias": "currentPalette"; "required": false; }; "currentCategory": { "alias": "currentCategory"; "required": false; }; "location": { "alias": "location"; "required": false; }; "direction": { "alias": "direction"; "required": false; }; "width": { "alias": "width"; "required": false; }; }, {}, never, never, true, never>;
37
39
  }
@@ -1,23 +1,28 @@
1
- import { ChangeDetectorRef, ElementRef } from '@angular/core';
1
+ import { AfterViewInit, ChangeDetectorRef, ElementRef } from '@angular/core';
2
+ import * as d3 from 'd3';
2
3
  import { ValueSet } from '../diagram-editor/diagram/diagram-property';
3
4
  import { PropertyEditor } from '../interfaces/property-editor';
4
- import { Corner } from '../util/svg-util';
5
+ import { Corner, Side } from '../util/svg-util';
5
6
  import * as i0 from "@angular/core";
6
7
  /**
7
8
  * Editor of the values of a value set.
8
9
  * @see ValueSet
9
10
  * @private
10
11
  */
11
- export declare class PropertyEditorComponent implements PropertyEditor {
12
+ export declare class PropertyEditorComponent implements AfterViewInit, PropertyEditor {
12
13
  private cdr;
13
14
  panel: ElementRef<HTMLDivElement>;
14
15
  location: Corner;
16
+ direction: Side;
17
+ width: string;
15
18
  title?: string;
16
19
  _valueSet: ValueSet | undefined;
17
20
  get valueSet(): ValueSet | undefined;
18
21
  set valueSet(valueSet: ValueSet | undefined);
19
22
  constructor(cdr: ChangeDetectorRef);
23
+ ngAfterViewInit(): void;
24
+ selectPanel(): d3.Selection<HTMLDivElement, unknown, null, undefined>;
20
25
  highlightProperty(...propertyNames: string[]): void;
21
26
  static ɵfac: i0.ɵɵFactoryDeclaration<PropertyEditorComponent, never>;
22
- static ɵcmp: i0.ɵɵComponentDeclaration<PropertyEditorComponent, "daga-property-editor", never, { "location": { "alias": "location"; "required": false; }; "valueSet": { "alias": "valueSet"; "required": false; }; }, {}, never, never, true, never>;
27
+ static ɵcmp: i0.ɵɵComponentDeclaration<PropertyEditorComponent, "daga-property-editor", never, { "location": { "alias": "location"; "required": false; }; "direction": { "alias": "direction"; "required": false; }; "width": { "alias": "width"; "required": false; }; "valueSet": { "alias": "valueSet"; "required": false; }; }, {}, never, never, true, never>;
23
28
  }
@@ -22,7 +22,7 @@ export declare class CanvasProviderService {
22
22
  */
23
23
  initCanvasView(appendTo: HTMLElement): void;
24
24
  /**
25
- * Get the diagram canvas of this context.
25
+ * Get the diagram canvas of this context. Should only be called after the view of the {@link DiagramComponent} context has been initialized.
26
26
  * @public
27
27
  * @returns A diagram canvas.
28
28
  */
@@ -13,7 +13,7 @@ export declare class DagaConfigurationService {
13
13
  */
14
14
  init(config: DiagramConfig): void;
15
15
  /**
16
- * Get the diagram configuration of this context.
16
+ * Get the diagram configuration of this context. Should only be called after the {@link DiagramComponent} context has been initialized.
17
17
  * @public
18
18
  * @returns A diagram configuration.
19
19
  */
@@ -7,11 +7,15 @@ export declare enum Events {
7
7
  Change = "change",
8
8
  Click = "click",
9
9
  DoubleClick = "dblclick",
10
+ Focus = "focus",
11
+ FocusIn = "focusin",
12
+ FocusOut = "focusout",
10
13
  Input = "input",
11
14
  KeyUp = "keyup",
12
15
  MouseMove = "mousemove",
13
16
  MouseOut = "mouseout",
14
- MouseOver = "mouseover"
17
+ MouseOver = "mouseover",
18
+ Wheel = "wheel"
15
19
  }
16
20
  /**
17
21
  * Keys in keyboard events.
@@ -0,0 +1,13 @@
1
+ export declare enum CursorStyle {
2
+ AllScroll = "all-scroll",
3
+ Auto = "auto",
4
+ EWResize = "ew-resize",
5
+ Grab = "grab",
6
+ Grabbing = "grabbing",
7
+ Move = "move",
8
+ NoDrop = "no-drop",
9
+ NSResize = "ns-resize",
10
+ NotAllowed = "not-allowed",
11
+ ZoomIn = "zoom-in",
12
+ ZoomOut = "zoom-out"
13
+ }
@@ -0,0 +1,2 @@
1
+ export declare const numberOfColumns: (s: string) => number;
2
+ export declare const numberOfRows: (s: string) => number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
3
  "description": "Diagramming engine for editing models on the Web. Made by Metadev.",
4
- "version": "1.3.1",
4
+ "version": "1.4.1",
5
5
  "author": "Metadev (https://metadev.pro)",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
7
7
  "repository": "git+https://github.com/metadevpro/daga-tutorial.git",
@@ -1,94 +0,0 @@
1
- {
2
- "type": "generic-diagram",
3
- "color": "#FFFFFF",
4
- "gridSize": 50,
5
- "snapToGrid": true,
6
- "guessConnectionType": false,
7
- "defaultConnection": "diagram-connection",
8
- "palettes": [
9
- {
10
- "name": "",
11
- "templates": [
12
- {
13
- "templateType": "node",
14
- "type": "diagram-node",
15
- "label": "Node"
16
- },
17
- {
18
- "templateType": "connection",
19
- "type": "diagram-connection",
20
- "label": "",
21
- "color": "white",
22
- "icon": "/assets/daga/icon/connection/filled-arrow.svg",
23
- "width": 150,
24
- "height": 50
25
- }
26
- ]
27
- }
28
- ],
29
- "nodeTypes": [
30
- {
31
- "id": "diagram-node",
32
- "name": "Node",
33
- "defaultWidth": 150,
34
- "defaultHeight": 50,
35
- "label": {
36
- "fontSize": 20,
37
- "margin": 10
38
- },
39
- "ports": [
40
- {
41
- "coords": [75, 0],
42
- "direction": "top"
43
- },
44
- {
45
- "coords": [0, 25],
46
- "direction": "left"
47
- },
48
- {
49
- "coords": [75, 50],
50
- "direction": "bottom"
51
- },
52
- {
53
- "coords": [150, 25],
54
- "direction": "right"
55
- }
56
- ],
57
- "look": {
58
- "lookType": "shaped-look",
59
- "shape": "rectangle",
60
- "color": "#FFFFFF",
61
- "borderColor": "#000000",
62
- "selectedColor": "#FFAAFF",
63
- "selectedBorderColor": "#AA00AA"
64
- }
65
- }
66
- ],
67
- "connectionTypes": [
68
- {
69
- "id": "diagram-connection",
70
- "name": "Connection",
71
- "color": "#000000",
72
- "selectedColor": "#AA00AA",
73
- "width": 3,
74
- "shape": "bezier",
75
- "defaultEndMarkerLook": {
76
- "image": "/assets/marker/arrow.svg",
77
- "selectedImage": "/assets/marker/arrow.svg",
78
- "markerWidth": 4,
79
- "markerHeight": 8,
80
- "markerRefX": 4,
81
- "markerRefY": 4
82
- },
83
- "label": {
84
- "color": "#FFFFFF",
85
- "selectedColor": "#FFFFFF",
86
- "fontSize": 12,
87
- "padding": 6,
88
- "margin": 20
89
- },
90
- "startTypes": ["diagram-node"],
91
- "endTypes": ["diagram-node"]
92
- }
93
- ]
94
- }
@@ -1,23 +0,0 @@
1
- <svg viewBox="0 0 150 50" xmlns="http://www.w3.org/2000/svg">
2
- <line
3
- x1="10"
4
- y1="25"
5
- x2="140"
6
- y2="25"
7
- stroke="black"
8
- />
9
- <line
10
- x1="120"
11
- y1="5"
12
- x2="140"
13
- y2="25"
14
- stroke="black"
15
- />
16
- <line
17
- x1="120"
18
- y1="45"
19
- x2="140"
20
- y2="25"
21
- stroke="black"
22
- />
23
- </svg>
@@ -1,19 +0,0 @@
1
- <svg viewBox="0 0 150 50" xmlns="http://www.w3.org/2000/svg">
2
- <line
3
- x1="10"
4
- y1="25"
5
- x2="120"
6
- y2="25"
7
- stroke="black"
8
- />
9
- <path
10
- d="
11
- M 140, 25
12
- L 120, 5
13
- L 120, 45
14
- z
15
- "
16
- stroke="black"
17
- fill="white"
18
- />
19
- </svg>
@@ -1,20 +0,0 @@
1
- <svg viewBox="0 0 150 50" xmlns="http://www.w3.org/2000/svg">
2
- <line
3
- x1="10"
4
- y1="25"
5
- x2="100"
6
- y2="25"
7
- stroke="black"
8
- />
9
- <path
10
- d="
11
- M 140, 25
12
- L 100, 5
13
- L 60, 25
14
- L 100, 45
15
- z
16
- "
17
- stroke="black"
18
- fill="white"
19
- />
20
- </svg>
@@ -1,19 +0,0 @@
1
- <svg viewBox="0 0 150 50" xmlns="http://www.w3.org/2000/svg">
2
- <line
3
- x1="10"
4
- y1="25"
5
- x2="120"
6
- y2="25"
7
- stroke="black"
8
- />
9
- <path
10
- d="
11
- M 140, 25
12
- L 120, 5
13
- L 120, 45
14
- z
15
- "
16
- stroke="none"
17
- fill="black"
18
- />
19
- </svg>
@@ -1,20 +0,0 @@
1
- <svg viewBox="0 0 150 50" xmlns="http://www.w3.org/2000/svg">
2
- <line
3
- x1="10"
4
- y1="25"
5
- x2="100"
6
- y2="25"
7
- stroke="black"
8
- />
9
- <path
10
- d="
11
- M 140, 25
12
- L 100, 5
13
- L 60, 25
14
- L 100, 45
15
- z
16
- "
17
- stroke="none"
18
- fill="black"
19
- />
20
- </svg>
@@ -1,9 +0,0 @@
1
- <svg viewBox="0 0 150 50" xmlns="http://www.w3.org/2000/svg">
2
- <line
3
- x1="10"
4
- y1="25"
5
- x2="140"
6
- y2="25"
7
- stroke="black"
8
- />
9
- </svg>