@metadev/daga 4.2.0 → 4.2.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.
- package/Changelog.md +11 -1
- package/index.cjs.js +299 -166
- package/index.esm.js +299 -166
- package/package.json +1 -1
- package/src/lib/diagram/canvas/diagram-canvas.d.ts +1 -1
- package/src/lib/diagram/canvas/diagram-user-selection.d.ts +3 -1
- package/src/lib/diagram/config/diagram-config.d.ts +54 -1
- package/src/lib/diagram/model/diagram-decorator.d.ts +13 -3
- package/src/lib/diagram/model/diagram-field.d.ts +9 -3
- package/src/lib/diagram/model/diagram-port.d.ts +13 -3
- package/src/lib/diagram/model/diagram-section.d.ts +16 -0
- package/src/lib/interfaces/canvas.d.ts +2 -1
- package/src/lib/util/canvas-util.d.ts +18 -0
- package/src/lib/util/trig.d.ts +20 -0
package/package.json
CHANGED
|
@@ -118,7 +118,7 @@ export declare class DiagramCanvas implements Canvas {
|
|
|
118
118
|
private updateConnectionMarkersInView;
|
|
119
119
|
fieldRootFitsInView(id: string): boolean;
|
|
120
120
|
fitFieldRootInView(id: string, shrink?: boolean): void;
|
|
121
|
-
fitNodeInView(id: string): void;
|
|
121
|
+
fitNodeInView(id: string, shrink?: boolean): void;
|
|
122
122
|
selectRoot(): d3.Selection<HTMLDivElement, unknown, null, unknown>;
|
|
123
123
|
selectSVGElement(): d3.Selection<SVGElement, unknown, null, unknown>;
|
|
124
124
|
selectCanvasView(): d3.Selection<SVGGElement, unknown, null, unknown>;
|
|
@@ -65,10 +65,12 @@ export declare class DiagramUserSelection extends DiagramElementSet<DiagramEleme
|
|
|
65
65
|
* Opens the value set of a diagram model or a diagram element in the property editor.
|
|
66
66
|
* @public
|
|
67
67
|
* @param selection A diagram model or a diagram element with a value set.
|
|
68
|
+
* @param makeUpdateValuesAction Whether the method should create an UpdateValuesAction.
|
|
68
69
|
* @see PropertyEditor
|
|
70
|
+
* @see UpdateValuesAction
|
|
69
71
|
*/
|
|
70
72
|
openInPropertyEditor(selection?: {
|
|
71
73
|
valueSet: ValueSet;
|
|
72
|
-
} & (DiagramElement | DiagramModel)): void;
|
|
74
|
+
} & (DiagramElement | DiagramModel), makeUpdateValuesAction?: boolean): void;
|
|
73
75
|
private makeUpdateValuesAction;
|
|
74
76
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Point } from '../../util/canvas-util';
|
|
1
|
+
import { AnchorPoint, Point } from '../../util/canvas-util';
|
|
2
2
|
import { HorizontalAlign, Side, VerticalAlign } from '../../util/svg-util';
|
|
3
3
|
import { DiagramActions } from '../diagram-action';
|
|
4
4
|
import { Property } from '../property/property';
|
|
@@ -258,6 +258,24 @@ export interface PortConfig {
|
|
|
258
258
|
* Direction that the connections passing by this port follow at the point of the port.
|
|
259
259
|
*/
|
|
260
260
|
direction: Side;
|
|
261
|
+
/**
|
|
262
|
+
* Horizontal anchor point for this port. Determines how the port behaves when its root element is resized.
|
|
263
|
+
* - 'start': Always maintains the same distance from the left edge
|
|
264
|
+
* - 'middle': Always maintains the same relative position from the center
|
|
265
|
+
* - 'end': Always maintains the same distance from the right edge
|
|
266
|
+
* - 'floating': Scales proportionally with the element (default behavior)
|
|
267
|
+
* @default 'floating'
|
|
268
|
+
*/
|
|
269
|
+
anchorPointX?: AnchorPoint;
|
|
270
|
+
/**
|
|
271
|
+
* Vertical anchor point for this port. Determines how the port behaves when its root element is resized.
|
|
272
|
+
* - 'start': Always maintains the same distance from the top edge
|
|
273
|
+
* - 'middle': Always maintains the same relative position from the center
|
|
274
|
+
* - 'end': Always maintains the same distance from the bottom edge
|
|
275
|
+
* - 'floating': Scales proportionally with the element (default behavior)
|
|
276
|
+
* @default 'floating'
|
|
277
|
+
*/
|
|
278
|
+
anchorPointY?: AnchorPoint;
|
|
261
279
|
}
|
|
262
280
|
/**
|
|
263
281
|
* Configuration for a field that is part of another element.
|
|
@@ -322,6 +340,11 @@ export interface FieldConfig {
|
|
|
322
340
|
* @default false
|
|
323
341
|
*/
|
|
324
342
|
fit?: boolean;
|
|
343
|
+
/**
|
|
344
|
+
* Whether when `fit` is enabled should the root element of the field also shrink if there is excess space.
|
|
345
|
+
* @default true
|
|
346
|
+
*/
|
|
347
|
+
shrink?: boolean;
|
|
325
348
|
}
|
|
326
349
|
/**
|
|
327
350
|
* Configuration for a decorator that is part of another element.
|
|
@@ -347,6 +370,24 @@ export interface DecoratorConfig {
|
|
|
347
370
|
* Inner HTML of this decorator.
|
|
348
371
|
*/
|
|
349
372
|
html: string;
|
|
373
|
+
/**
|
|
374
|
+
* Horizontal anchor point for this decorator. Determines how the decorator behaves when its root element is resized.
|
|
375
|
+
* - 'start': Always maintains the same distance from the left edge
|
|
376
|
+
* - 'middle': Always maintains the same relative position from the center
|
|
377
|
+
* - 'end': Always maintains the same distance from the right edge
|
|
378
|
+
* - 'floating': Scales proportionally with the element (default behavior)
|
|
379
|
+
* @default 'floating'
|
|
380
|
+
*/
|
|
381
|
+
anchorPointX?: AnchorPoint;
|
|
382
|
+
/**
|
|
383
|
+
* Vertical anchor point for this decorator. Determines how the decorator behaves when its root element is resized.
|
|
384
|
+
* - 'start': Always maintains the same distance from the top edge
|
|
385
|
+
* - 'middle': Always maintains the same relative position from the center
|
|
386
|
+
* - 'end': Always maintains the same distance from the bottom edge
|
|
387
|
+
* - 'floating': Scales proportionally with the element (default behavior)
|
|
388
|
+
* @default 'floating'
|
|
389
|
+
*/
|
|
390
|
+
anchorPointY?: AnchorPoint;
|
|
350
391
|
}
|
|
351
392
|
/**
|
|
352
393
|
* Configuration for the grid of sections of a node.
|
|
@@ -406,6 +447,18 @@ export interface SectionConfig {
|
|
|
406
447
|
* @default 0
|
|
407
448
|
*/
|
|
408
449
|
priority?: number;
|
|
450
|
+
/**
|
|
451
|
+
* Whether this section can be resized horizontally.
|
|
452
|
+
* If undefined, inherits from the parent node's resizableX setting.
|
|
453
|
+
* @default undefined
|
|
454
|
+
*/
|
|
455
|
+
resizableX?: boolean;
|
|
456
|
+
/**
|
|
457
|
+
* Whether this section can be resized vertically.
|
|
458
|
+
* If undefined, inherits from the parent node's resizableY setting.
|
|
459
|
+
* @default undefined
|
|
460
|
+
*/
|
|
461
|
+
resizableY?: boolean;
|
|
409
462
|
}
|
|
410
463
|
/**
|
|
411
464
|
* Configuration for a type of connection.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Point } from '../../util/canvas-util';
|
|
1
|
+
import { AnchorPoint, Point } from '../../util/canvas-util';
|
|
2
2
|
import { DiagramElement, DiagramElementSet } from './diagram-element';
|
|
3
3
|
import { DiagramModel } from './diagram-model';
|
|
4
4
|
import { DiagramNode } from './diagram-node';
|
|
@@ -35,7 +35,17 @@ export declare class DiagramDecorator extends DiagramElement {
|
|
|
35
35
|
height: number;
|
|
36
36
|
priority: number;
|
|
37
37
|
html: string;
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Horizontal anchor point for this decorator. Determines how the decorator behaves when its root element is resized.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
anchorPointX: AnchorPoint;
|
|
43
|
+
/**
|
|
44
|
+
* Vertical anchor point for this decorator. Determines how the decorator behaves when its root element is resized.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
anchorPointY: AnchorPoint;
|
|
48
|
+
constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, width: number, height: number, priority: number, html: string, id: string, anchorPointX?: AnchorPoint, anchorPointY?: AnchorPoint);
|
|
39
49
|
get removed(): boolean;
|
|
40
50
|
updateInView(): void;
|
|
41
51
|
raise(): void;
|
|
@@ -65,6 +75,6 @@ export declare class DiagramDecoratorSet extends DiagramElementSet<DiagramDecora
|
|
|
65
75
|
* @param id The id of the decorator. Cannot be an empty string.
|
|
66
76
|
* @returns The instanced decorator.
|
|
67
77
|
*/
|
|
68
|
-
new(rootElement: DiagramNode | DiagramSection | undefined, coords: Point, width: number, height: number, priority: number, html: string, id: string): DiagramDecorator;
|
|
78
|
+
new(rootElement: DiagramNode | DiagramSection | undefined, coords: Point, width: number, height: number, priority: number, html: string, id: string, anchorPointX?: AnchorPoint, anchorPointY?: AnchorPoint): DiagramDecorator;
|
|
69
79
|
remove(id: string): void;
|
|
70
80
|
}
|
|
@@ -21,6 +21,7 @@ export declare const DIAGRAM_FIELD_DEFAULTS: {
|
|
|
21
21
|
verticalAlign: VerticalAlign;
|
|
22
22
|
orientation: Side;
|
|
23
23
|
fit: boolean;
|
|
24
|
+
shrink: boolean;
|
|
24
25
|
};
|
|
25
26
|
export interface LabeledElement {
|
|
26
27
|
label?: DiagramField;
|
|
@@ -87,7 +88,7 @@ export declare class DiagramField extends DiagramElement {
|
|
|
87
88
|
* Orientation of the text of this field.
|
|
88
89
|
* @public
|
|
89
90
|
*/
|
|
90
|
-
orientation:
|
|
91
|
+
orientation: number;
|
|
91
92
|
private _text;
|
|
92
93
|
/**
|
|
93
94
|
* Default text that this field's text resets to when empty.
|
|
@@ -115,7 +116,12 @@ export declare class DiagramField extends DiagramElement {
|
|
|
115
116
|
* @public
|
|
116
117
|
*/
|
|
117
118
|
fit: boolean;
|
|
118
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Whether when `fit` is enabled should the root element of the field also shrink if there is excess space.
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
shrink: boolean;
|
|
124
|
+
constructor(model: DiagramModel, rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, width: number, height: number, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, text: string, editable: boolean, fit: boolean, shrink: boolean);
|
|
119
125
|
get removed(): boolean;
|
|
120
126
|
updateInView(): void;
|
|
121
127
|
raise(): void;
|
|
@@ -138,7 +144,7 @@ export declare class DiagramFieldSet extends DiagramElementSet<DiagramField> {
|
|
|
138
144
|
* Instance a new field and add it to this set. This method is normally called when instancing an element with a field and it is rarely called by itself.
|
|
139
145
|
* @private
|
|
140
146
|
*/
|
|
141
|
-
new(rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, text: string, editable: boolean, fit: boolean): DiagramField;
|
|
147
|
+
new(rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, text: string, editable: boolean, fit: boolean, shrink: boolean): DiagramField;
|
|
142
148
|
remove(id: string): void;
|
|
143
149
|
}
|
|
144
150
|
export declare const getBottomMargin: (config?: FieldConfig | null) => number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Point } from '../../util/canvas-util';
|
|
1
|
+
import { AnchorPoint, Point } from '../../util/canvas-util';
|
|
2
2
|
import { Side } from '../../util/svg-util';
|
|
3
3
|
import { FieldConfig, PortTypeConfig } from '../config/diagram-config';
|
|
4
4
|
import { ImageLook, ImageLookConfig, ShapedLook, ShapedLookConfig } from '../config/diagram-look-config';
|
|
@@ -100,6 +100,16 @@ export declare class DiagramPort extends DiagramElement implements LabeledElemen
|
|
|
100
100
|
* @public
|
|
101
101
|
*/
|
|
102
102
|
direction: Side;
|
|
103
|
+
/**
|
|
104
|
+
* Horizontal anchor point for this port. Determines how the port behaves when its root element is resized.
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
anchorPointX: AnchorPoint;
|
|
108
|
+
/**
|
|
109
|
+
* Vertical anchor point for this port. Determines how the port behaves when its root element is resized.
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
anchorPointY: AnchorPoint;
|
|
103
113
|
/**
|
|
104
114
|
* Whether this port can be used as a connection start point.
|
|
105
115
|
*/
|
|
@@ -149,7 +159,7 @@ export declare class DiagramPort extends DiagramElement implements LabeledElemen
|
|
|
149
159
|
* @private
|
|
150
160
|
*/
|
|
151
161
|
get height(): number;
|
|
152
|
-
constructor(model: DiagramModel, type: DiagramPortType | undefined, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, connectionPoint: Point | undefined, direction: Side, id: string);
|
|
162
|
+
constructor(model: DiagramModel, type: DiagramPortType | undefined, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, connectionPoint: Point | undefined, direction: Side, id: string, anchorPointX?: AnchorPoint, anchorPointY?: AnchorPoint);
|
|
153
163
|
get removed(): boolean;
|
|
154
164
|
updateInView(): void;
|
|
155
165
|
raise(): void;
|
|
@@ -196,6 +206,6 @@ export declare class DiagramPortSet extends DiagramElementSet<DiagramPort> {
|
|
|
196
206
|
* Instance a new port and add it to this set. This method is normally called when instancing an element with a port and it is rarely called by itself.
|
|
197
207
|
* @private
|
|
198
208
|
*/
|
|
199
|
-
new(type: DiagramPortType | undefined, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, connectionPoint: Point | undefined, direction: Side, id: string): DiagramPort;
|
|
209
|
+
new(type: DiagramPortType | undefined, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, connectionPoint: Point | undefined, direction: Side, id: string, anchorPointX?: AnchorPoint, anchorPointY?: AnchorPoint): DiagramPort;
|
|
200
210
|
remove(id: string): void;
|
|
201
211
|
}
|
|
@@ -61,6 +61,8 @@ export declare class DiagramSectionType {
|
|
|
61
61
|
highlightedLook: NodeLook;
|
|
62
62
|
selectedAndHighlightedLook: NodeLook;
|
|
63
63
|
priority: number;
|
|
64
|
+
resizableX: boolean | undefined;
|
|
65
|
+
resizableY: boolean | undefined;
|
|
64
66
|
constructor(options: SectionConfig);
|
|
65
67
|
}
|
|
66
68
|
/**
|
|
@@ -143,6 +145,20 @@ export declare class DiagramSection extends DiagramElement implements LabeledEle
|
|
|
143
145
|
getMinWidth(): number;
|
|
144
146
|
getMinHeight(): number;
|
|
145
147
|
getPriority(): number;
|
|
148
|
+
/**
|
|
149
|
+
* Returns whether this section can be resized horizontally.
|
|
150
|
+
* If the section has a specific resizableX setting, it uses that.
|
|
151
|
+
* Otherwise, it inherits from the parent node's resizableX setting.
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
getResizableX(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Returns whether this section can be resized vertically.
|
|
157
|
+
* If the section has a specific resizableY setting, it uses that.
|
|
158
|
+
* Otherwise, it inherits from the parent node's resizableY setting.
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
getResizableY(): boolean;
|
|
146
162
|
/**
|
|
147
163
|
* Get the port of this section which is closest to the given coordinates.
|
|
148
164
|
* @param coords A point in the diagram.
|
|
@@ -299,8 +299,9 @@ export interface Canvas {
|
|
|
299
299
|
/**
|
|
300
300
|
* Fit a node to encompass the totality of its sections.
|
|
301
301
|
* @param id The id of a node
|
|
302
|
+
* @param shrink Whether the node should shrink if there is excess space; `true` by default
|
|
302
303
|
*/
|
|
303
|
-
fitNodeInView(id: string): void;
|
|
304
|
+
fitNodeInView(id: string, shrink?: boolean): void;
|
|
304
305
|
/**
|
|
305
306
|
* Get the d3 Selection containing the root html div element of the canvas.
|
|
306
307
|
* @private
|
|
@@ -53,6 +53,24 @@ export declare const translateCoordinate: (oldCoordinate: number, oldCoordinates
|
|
|
53
53
|
* @returns A new point.
|
|
54
54
|
*/
|
|
55
55
|
export declare const translatePoint: (oldPoint: Point, oldCoordsX: [number, number], oldCoordsY: [number, number], newCoordsX: [number, number], newCoordsY: [number, number]) => Point;
|
|
56
|
+
/**
|
|
57
|
+
* Types of anchor points for ports and decorators.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export type AnchorPoint = 'start' | 'middle' | 'end' | 'floating';
|
|
61
|
+
/**
|
|
62
|
+
* Moves the coordinates of the given point according to the given changes in coordinates and anchor points.
|
|
63
|
+
* @public
|
|
64
|
+
* @param oldPoint A point.
|
|
65
|
+
* @param oldCoordsX A range of coordinates along the x axis.
|
|
66
|
+
* @param oldCoordsY A range of coordinates along the y axis.
|
|
67
|
+
* @param newCoordsX A range of coordinates along the x axis.
|
|
68
|
+
* @param newCoordsY A range of coordinates along the y axis.
|
|
69
|
+
* @param anchorPointX The horizontal anchor point behavior.
|
|
70
|
+
* @param anchorPointY The vertical anchor point behavior.
|
|
71
|
+
* @returns A new point.
|
|
72
|
+
*/
|
|
73
|
+
export declare const translatePointWithAnchors: (oldPoint: Point, oldCoordsX: [number, number], oldCoordsY: [number, number], newCoordsX: [number, number], newCoordsY: [number, number], anchorPointX: AnchorPoint, anchorPointY: AnchorPoint) => Point;
|
|
56
74
|
/**
|
|
57
75
|
* Calculates the result of moving the given point by the given distance in the given direction.
|
|
58
76
|
* @public
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const degreesToRadians: (theta: number) => number;
|
|
2
|
+
export declare const radiansToDegrees: (theta: number) => number;
|
|
3
|
+
/**
|
|
4
|
+
* Calculates the size of the bounding box of a rectangle that has been rotated by the given number of degrees.
|
|
5
|
+
*
|
|
6
|
+
* @param width The width of a rectangle.
|
|
7
|
+
* @param height The height of a rectangle.
|
|
8
|
+
* @param orientation A rotation in degrees.
|
|
9
|
+
* @returns The size of the bounding box.
|
|
10
|
+
*/
|
|
11
|
+
export declare const rotate: (width: number, height: number, orientation: number) => [number, number];
|
|
12
|
+
/**
|
|
13
|
+
* Calculates the original size of the a rectangle that has been rotated by the given number of degrees resulting in a bounding box of the given size.
|
|
14
|
+
*
|
|
15
|
+
* @param width The width of a bounding box.
|
|
16
|
+
* @param height The height of a bounding box.
|
|
17
|
+
* @param orientation A rotation in degrees.
|
|
18
|
+
* @returns The size of the original rectangle.
|
|
19
|
+
*/
|
|
20
|
+
export declare const unrotate: (width: number, height: number, orientation: number) => [number, number];
|