@metadev/daga 2.0.2 → 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.
- package/Changelog.md +25 -1
- package/README.md +11 -1
- package/index.cjs.js +1929 -1211
- package/index.esm.js +1917 -1208
- package/package.json +1 -1
- package/src/index.d.ts +27 -21
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +9 -12
- package/src/lib/diagram/collab/collab-action.d.ts +58 -2
- package/src/lib/diagram/converters/daga-model.d.ts +1 -0
- package/src/lib/diagram/diagram-action.d.ts +67 -4
- package/src/lib/diagram/diagram-config.d.ts +32 -4
- package/src/lib/diagram/diagram-event.d.ts +74 -8
- package/src/lib/diagram/layout/diagram-layout.d.ts +4 -0
- package/src/lib/diagram/model/diagram-connection.d.ts +3 -2
- package/src/lib/diagram/model/diagram-decorator.d.ts +1 -0
- package/src/lib/diagram/model/diagram-element.d.ts +5 -0
- package/src/lib/diagram/model/diagram-field.d.ts +7 -6
- package/src/lib/diagram/model/diagram-node.d.ts +71 -4
- package/src/lib/diagram/model/diagram-object.d.ts +1 -0
- package/src/lib/diagram/model/diagram-port.d.ts +3 -2
- package/src/lib/diagram/model/diagram-property.d.ts +3 -1
- package/src/lib/diagram/model/diagram-section.d.ts +3 -2
- package/src/lib/interfaces/canvas.d.ts +8 -11
- package/src/lib/util/events.d.ts +2 -0
- package/src/lib/util/line.d.ts +6 -1
- package/src/lib/util/shape.d.ts +6 -1
|
@@ -6,7 +6,7 @@ import { DiagramConnection } from './diagram-connection';
|
|
|
6
6
|
import { DiagramDecorator } from './diagram-decorator';
|
|
7
7
|
import { DiagramElement, DiagramElementSet } from './diagram-element';
|
|
8
8
|
import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
|
|
9
|
-
import { DiagramField } from './diagram-field';
|
|
9
|
+
import { DiagramField, LabeledElement } from './diagram-field';
|
|
10
10
|
import { DiagramModel } from './diagram-model';
|
|
11
11
|
import { DiagramPort } from './diagram-port';
|
|
12
12
|
import { PropertySet, ValueSet } from './diagram-property';
|
|
@@ -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);
|
|
@@ -76,7 +88,7 @@ export declare class DiagramNodeType implements DiagramEntity {
|
|
|
76
88
|
* @see DiagramPort
|
|
77
89
|
* @see DiagramSection
|
|
78
90
|
*/
|
|
79
|
-
export declare class DiagramNode extends DiagramElement {
|
|
91
|
+
export declare class DiagramNode extends DiagramElement implements LabeledElement {
|
|
80
92
|
type: DiagramNodeType;
|
|
81
93
|
/**
|
|
82
94
|
* Additional properties of this node.
|
|
@@ -93,6 +105,16 @@ export declare class DiagramNode extends DiagramElement {
|
|
|
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 {
|
|
|
114
136
|
*/
|
|
115
137
|
coords: Point;
|
|
116
138
|
/**
|
|
117
|
-
* Collaborative timestamp for
|
|
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 {
|
|
|
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 {
|
|
|
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 {
|
|
|
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
|
|
@@ -2,7 +2,7 @@ import { Point } from '../../util/canvas-util';
|
|
|
2
2
|
import { Side } from '../../util/svg-util';
|
|
3
3
|
import { DiagramConnection } from './diagram-connection';
|
|
4
4
|
import { DiagramElement, DiagramElementSet } from './diagram-element';
|
|
5
|
-
import { DiagramField } from './diagram-field';
|
|
5
|
+
import { DiagramField, LabeledElement } from './diagram-field';
|
|
6
6
|
import { DiagramModel } from './diagram-model';
|
|
7
7
|
import { DiagramNode } from './diagram-node';
|
|
8
8
|
import { DiagramSection } from './diagram-section';
|
|
@@ -23,7 +23,7 @@ export declare const DIAGRAM_PORT_DEFAULTS: {
|
|
|
23
23
|
* @see DiagramNode
|
|
24
24
|
* @see DiagramSection
|
|
25
25
|
*/
|
|
26
|
-
export declare class DiagramPort extends DiagramElement {
|
|
26
|
+
export declare class DiagramPort extends DiagramElement implements LabeledElement {
|
|
27
27
|
/**
|
|
28
28
|
* Element that this port belongs to.
|
|
29
29
|
* @public
|
|
@@ -57,6 +57,7 @@ export declare class DiagramPort extends DiagramElement {
|
|
|
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
|
-
|
|
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,
|
|
@@ -4,7 +4,7 @@ import { NodeShapedLook, SectionConfig } from '../diagram-config';
|
|
|
4
4
|
import { DiagramConnection } from './diagram-connection';
|
|
5
5
|
import { DiagramDecorator } from './diagram-decorator';
|
|
6
6
|
import { DiagramElement, DiagramElementSet } from './diagram-element';
|
|
7
|
-
import { DiagramField } from './diagram-field';
|
|
7
|
+
import { DiagramField, LabeledElement } from './diagram-field';
|
|
8
8
|
import { DiagramModel } from './diagram-model';
|
|
9
9
|
import { DiagramNode } from './diagram-node';
|
|
10
10
|
import { DiagramPort } from './diagram-port';
|
|
@@ -61,7 +61,7 @@ export type DiagramSectionGeometry = {
|
|
|
61
61
|
* @see DiagramNode
|
|
62
62
|
* @see DiagramPort
|
|
63
63
|
*/
|
|
64
|
-
export declare class DiagramSection extends DiagramElement {
|
|
64
|
+
export declare class DiagramSection extends DiagramElement implements LabeledElement {
|
|
65
65
|
/**
|
|
66
66
|
* Node that this section belongs to.
|
|
67
67
|
* @public
|
|
@@ -114,6 +114,7 @@ export declare class DiagramSection extends DiagramElement {
|
|
|
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<
|
|
135
|
+
readonly diagramChange$: Subject<{
|
|
136
|
+
action: DiagramAction;
|
|
137
|
+
method: DiagramActionMethod;
|
|
138
|
+
}>;
|
|
136
139
|
/**
|
|
137
|
-
* Subject for tracking the
|
|
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
|
|
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
|
package/src/lib/util/events.d.ts
CHANGED
package/src/lib/util/line.d.ts
CHANGED
|
@@ -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
|
package/src/lib/util/shape.d.ts
CHANGED
|
@@ -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
|