@metadev/daga 3.0.0 → 3.1.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.
@@ -30,11 +30,14 @@ export declare const DIAGRAM_NODE_TYPE_DEFAULTS: {
30
30
  minHeight: number;
31
31
  resizableX: boolean;
32
32
  resizableY: boolean;
33
+ padding: number;
33
34
  label: null;
34
35
  ports: never[];
35
36
  sectionGrid: null;
36
37
  look: NodeShapedLook;
37
38
  isUnique: boolean;
39
+ canBeParentless: boolean;
40
+ childrenTypes: never[];
38
41
  priority: number;
39
42
  properties: never[];
40
43
  };
@@ -45,6 +48,9 @@ export type DiagramNodeGeometry = {
45
48
  readonly sections: {
46
49
  [sectionId: string]: DiagramSectionGeometry;
47
50
  };
51
+ readonly children: {
52
+ [childId: string]: DiagramNodeGeometry;
53
+ };
48
54
  };
49
55
  /**
50
56
  * A node type, which holds properties that nodes of this type share in common.
@@ -60,11 +66,17 @@ export declare class DiagramNodeType implements DiagramEntity {
60
66
  minHeight: number;
61
67
  resizableX: boolean;
62
68
  resizableY: boolean;
69
+ bottomPadding: number;
70
+ leftPadding: number;
71
+ rightPadding: number;
72
+ topPadding: number;
63
73
  label: FieldConfig | null;
64
74
  ports: PortConfig[];
65
75
  sectionGrid: SectionGridConfig | null;
66
76
  look: NodeShapedLook | NodeImageLook | NodeStretchableImageLook;
67
77
  isUnique: boolean;
78
+ canBeParentless: boolean;
79
+ childrenTypes: string[];
68
80
  priority: number;
69
81
  propertySet: PropertySet;
70
82
  constructor(options: NodeTypeConfig);
@@ -93,6 +105,16 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
93
105
  * @public
94
106
  */
95
107
  label?: DiagramField;
108
+ /**
109
+ * Parent of this node.
110
+ * @public
111
+ */
112
+ parent?: DiagramNode;
113
+ /**
114
+ * Nodes contained within this node.
115
+ * @public
116
+ */
117
+ children: DiagramNode[];
96
118
  /**
97
119
  * Sections of this node.
98
120
  * @public
@@ -114,7 +136,7 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
114
136
  */
115
137
  coords: Point;
116
138
  /**
117
- * Collaborative timestamp for SetGeometryCollabActions.
139
+ * Collaborative timestamp for MoveCollabAction, SetGeometryCollabAction and SetParentCollabAction.
118
140
  * @public
119
141
  */
120
142
  geometryTimestamp: CollabTimestamp | null;
@@ -137,6 +159,7 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
137
159
  constructor(model: DiagramModel, type: DiagramNodeType, coords: Point | undefined, id: string);
138
160
  get removed(): boolean;
139
161
  updateInView(): void;
162
+ raise(): void;
140
163
  getPriority(): number;
141
164
  /**
142
165
  * Get the port of this node which is closest to the given coordinates.
@@ -168,6 +191,26 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
168
191
  * @returns A list of nodes.
169
192
  */
170
193
  getAdjacentNodes(includeRemoved?: boolean): DiagramNode[];
194
+ /**
195
+ * Return the ancestor of this node which has no ancestors. If this node has no ancestors, returns itself.
196
+ * @returns The ancestor of this node which has no ancestors.
197
+ */
198
+ getLastAncestor(): DiagramNode;
199
+ /**
200
+ * Return true if this node is among the ancestors of the given node.
201
+ * @param child A node.
202
+ * @returns `true` if this node is among the ancestors of the given node, `false` otherwise.
203
+ */
204
+ isAncestorOf(child: DiagramNode): boolean;
205
+ /**
206
+ * Return true if the given node is among the ancestors of this node.
207
+ * @param child A node.
208
+ * @returns `true` if the given node is among the ancestors of this node, `false` otherwise.
209
+ */
210
+ isDescendantOf(child: DiagramNode): boolean;
211
+ addChild(child: DiagramNode): void;
212
+ removeChild(child: DiagramNode): void;
213
+ fitToChild(child: DiagramNode): void;
171
214
  /**
172
215
  * Change the coordinates of this node to the given coordinates and move its sections, ports and labels correspondingly.
173
216
  * @public
@@ -194,7 +237,7 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
194
237
  * Returns the current values of all geometric properties (coordinates and dimensions) of this node and its sections.
195
238
  * @public
196
239
  */
197
- getGeometry(): DiagramNodeGeometry;
240
+ getGeometry(excludeId?: string): DiagramNodeGeometry;
198
241
  /**
199
242
  * Sets all geometric properties (coordinates and dimensions) of this node and its sections.
200
243
  * @public
@@ -223,4 +266,28 @@ export declare class DiagramNodeSet extends DiagramElementSet<DiagramNode> {
223
266
  */
224
267
  new(type: DiagramNodeType | string, coords: Point, id: string): DiagramNode;
225
268
  remove(id: string): void;
269
+ /**
270
+ * Gets all the nodes that overlap with the given coordinates.
271
+ * @public
272
+ * @param x A coordinate along the x axis.
273
+ * @param y A coordinate along the y axis.
274
+ * @returns All the nodes that overlap with the given coordinates.
275
+ */
276
+ getAtCoordinates(x: number, y: number): DiagramNode[];
226
277
  }
278
+ /**
279
+ * Removes any nodes from the given list which are a descendant of another node in the list.
280
+ * @param nodes A list of nodes.
281
+ * @returns The given list of nodes minus any node that is a descendant of another node in the list.
282
+ */
283
+ export declare const filterByOnlyAncestors: (nodes: DiagramNode[]) => DiagramNode[];
284
+ /**
285
+ * Removes any nodes from the given list which are an ancestor of another node in the list.
286
+ * @param nodes A list of nodes.
287
+ * @returns The given list of nodes minus any node that is an ancestor of another node in the list.
288
+ */
289
+ export declare const filterByOnlyDescendants: (nodes: DiagramNode[]) => DiagramNode[];
290
+ export declare const getBottomPadding: (config?: NodeTypeConfig | null) => number;
291
+ export declare const getLeftPadding: (config?: NodeTypeConfig | null) => number;
292
+ export declare const getRightPadding: (config?: NodeTypeConfig | null) => number;
293
+ export declare const getTopPadding: (config?: NodeTypeConfig | null) => number;
@@ -28,6 +28,7 @@ export declare class DiagramObject extends DiagramElement {
28
28
  select(): d3.Selection<SVGGElement, unknown, null, unknown> | undefined;
29
29
  get removed(): boolean;
30
30
  updateInView(): void;
31
+ raise(): void;
31
32
  /**
32
33
  * Change the coordinates of this object to the given coordinates.
33
34
  * @public
@@ -57,6 +57,7 @@ export declare class DiagramPort extends DiagramElement implements LabeledElemen
57
57
  constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, direction: Side, id: string);
58
58
  get removed(): boolean;
59
59
  updateInView(): void;
60
+ raise(): void;
60
61
  /**
61
62
  * Add a connection to this port's list of outgoing connections.
62
63
  * @public
@@ -157,7 +157,9 @@ export declare class ValueSet {
157
157
  propertySet: PropertySet;
158
158
  displayedProperties: Property[];
159
159
  hiddenProperties: Property[];
160
- private values;
160
+ values: {
161
+ [key: string]: unknown;
162
+ };
161
163
  private valueSets;
162
164
  /**
163
165
  * Collaborative timestamps for all keys in this.values that have ever been set,
@@ -114,6 +114,7 @@ export declare class DiagramSection extends DiagramElement implements LabeledEle
114
114
  constructor(model: DiagramModel, node: DiagramNode | undefined, indexXInNode: number, indexYInNode: number, coords: Point, width: number, height: number, id: string);
115
115
  get removed(): boolean;
116
116
  updateInView(): void;
117
+ raise(): void;
117
118
  getConfig(): SectionConfig | undefined;
118
119
  getMinWidth(): number;
119
120
  getMinHeight(): number;
@@ -3,7 +3,7 @@ import { DiagramContextMenu } from '../diagram/canvas/diagram-context-menu';
3
3
  import { DiagramUserHighlight } from '../diagram/canvas/diagram-user-highlight';
4
4
  import { DiagramUserSelection } from '../diagram/canvas/diagram-user-selection';
5
5
  import { CollabEngine } from '../diagram/collab/collab-engine';
6
- import { ActionStack, DiagramActions } from '../diagram/diagram-action';
6
+ import { ActionStack, DiagramAction, DiagramActionMethod, DiagramActions } from '../diagram/diagram-action';
7
7
  import { UserActionConfig } from '../diagram/diagram-config';
8
8
  import { DiagramEvent } from '../diagram/diagram-event';
9
9
  import { DiagramConnectionType } from '../diagram/model/diagram-connection';
@@ -127,28 +127,25 @@ export interface Canvas {
127
127
  */
128
128
  readonly validatorChange$: Subject<void>;
129
129
  /**
130
- * Subject for tracking changes in the diagram.
130
+ * Subject for tracking changes in the diagram which affect the diagram's model.
131
131
  * Used to detect if there have been changes over a period of time.
132
132
  * Values are sent when the user performs changes on the diagram, but not when the changes are performed programmatically.
133
133
  * @public
134
134
  */
135
- readonly diagramChange$: Subject<void>;
135
+ readonly diagramChange$: Subject<{
136
+ action: DiagramAction;
137
+ method: DiagramActionMethod;
138
+ }>;
136
139
  /**
137
- * Subject for tracking the presence of important changes in the diagram.
138
- * Used to detect if there are any changes that require immediate handling.
140
+ * Subject for tracking user events in the diagram which do not affect the diagram's model.
139
141
  * @public
140
142
  */
141
- readonly diagramImportantChange$: Subject<void>;
143
+ readonly diagramEvent$: Subject<DiagramEvent>;
142
144
  /**
143
145
  * Subject for tracking changes in the property editor.
144
146
  * @public
145
147
  */
146
148
  readonly propertyEditorChanges$: Subject<void>;
147
- /**
148
- * Subject for tracking user events in the diagram.
149
- * @public
150
- */
151
- readonly diagramEvent$: Subject<DiagramEvent>;
152
149
  /**
153
150
  * Initializes the view of the diagram.
154
151
  * @private
@@ -47,11 +47,16 @@ export declare enum LineStyle {
47
47
  */
48
48
  Dotted = "dotted"
49
49
  }
50
+ /**
51
+ * A function that returns the `d` attribute for a SVG path that passes by the given points in order with the given direction at the start and end.
52
+ * @public
53
+ */
54
+ export type LineFunction = (points: Point[], startDirection?: Side | undefined, endDirection?: Side | undefined, minimumDistanceBeforeTurn?: number) => string;
50
55
  /**
51
56
  * Calculates the path of an SVG line with the given parameters.
52
57
  * @private
53
58
  */
54
- export declare const linePath: (shape: LineShape, points: Point[], startDirection?: Side | undefined, endDirection?: Side | undefined, minimumDistanceBeforeTurn?: number) => string;
59
+ export declare const linePath: (shape: LineShape | LineFunction, points: Point[], startDirection?: Side | undefined, endDirection?: Side | undefined, minimumDistanceBeforeTurn?: number) => string;
55
60
  /**
56
61
  * Calculates the dasharray property of an SVG line corresponding to the given line style and width.
57
62
  * @private
@@ -54,11 +54,16 @@ export declare enum ClosedShape {
54
54
  */
55
55
  StickyNote = "sticky-note"
56
56
  }
57
+ /**
58
+ * A function that returns the `d` attribute for a SVG path that starting at the given `x` and `y` coordinates describes a shape of the given `width` and `height`.
59
+ * @public
60
+ */
61
+ export type ShapeFunction = (x: number, y: number, width: number, height: number) => string;
57
62
  /**
58
63
  * Get the SVG path of the correspondign closed shape, starting at the given x and y coordinates, with the given width and height.
59
64
  * @private
60
65
  */
61
- export declare const generalClosedPath: (shape: ClosedShape, x: number, y: number, width: number, height: number) => string;
66
+ export declare const generalClosedPath: (shape: ClosedShape | ShapeFunction, x: number, y: number, width: number, height: number) => string;
62
67
  /**
63
68
  * Generates an ellipse SVG path.
64
69
  * @private