@metadev/daga 3.1.4 → 4.0.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.
@@ -1,21 +1,67 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
+ import { FieldConfig, PortTypeConfig } from '../config/diagram-config';
4
+ import { ImageLook, ImageLookConfig, ShapedLook, ShapedLookConfig } from '../config/diagram-look';
3
5
  import { DiagramConnection } from './diagram-connection';
4
6
  import { DiagramElement, DiagramElementSet } from './diagram-element';
7
+ import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
5
8
  import { DiagramField, LabeledElement } from './diagram-field';
6
9
  import { DiagramModel } from './diagram-model';
7
10
  import { DiagramNode } from './diagram-node';
8
11
  import { DiagramSection } from './diagram-section';
12
+ /**
13
+ * Default values of the look of a diagram port.
14
+ * @private
15
+ * @see DIAGRAM_NODE_TYPE_DEFAULTS
16
+ */
17
+ export declare const DIAGRAM_PORT_LOOK_DEFAULTS: ShapedLookConfig;
9
18
  /**
10
19
  * Default values of the parameters of a diagram port.
11
20
  * @private
12
21
  * @see DiagramPort
13
22
  */
14
- export declare const DIAGRAM_PORT_DEFAULTS: {
15
- radius: number;
16
- highlightedColor: string;
17
- selectedColor: string;
23
+ export declare const DIAGRAM_PORT_TYPE_DEFAULTS: {
24
+ name: string;
25
+ label: null;
26
+ allowsOutgoing: boolean;
27
+ allowsIncoming: boolean;
28
+ width: number;
29
+ look: ShapedLookConfig;
18
30
  };
31
+ /**
32
+ * The types allowed for the look of a port.
33
+ * @public
34
+ * @see Look
35
+ * @see DiagramPort
36
+ */
37
+ export type PortLook = ShapedLook | ImageLook;
38
+ /**
39
+ * A port type, which holds properties that ports of this type share in common.
40
+ * @public
41
+ * @see PortTypeConfig
42
+ */
43
+ export declare class DiagramPortType implements DiagramEntity {
44
+ readonly id: string;
45
+ name: string;
46
+ label: FieldConfig | null;
47
+ /**
48
+ * Whether ports of this type can be used as a connection start point.
49
+ */
50
+ allowsOutgoing: boolean;
51
+ /**
52
+ * Whether ports of this type can be used as a connection end point.
53
+ */
54
+ allowsIncoming: boolean;
55
+ /**
56
+ * Width of ports of this type in diagram units.
57
+ */
58
+ width: number;
59
+ defaultLook: PortLook;
60
+ selectedLook: PortLook;
61
+ highlightedLook: PortLook;
62
+ selectedAndHighlightedLook: PortLook;
63
+ constructor(options: PortTypeConfig);
64
+ }
19
65
  /**
20
66
  * A port which is part of a node or section and at which connections can start or end.
21
67
  * @public
@@ -24,6 +70,11 @@ export declare const DIAGRAM_PORT_DEFAULTS: {
24
70
  * @see DiagramSection
25
71
  */
26
72
  export declare class DiagramPort extends DiagramElement implements LabeledElement {
73
+ private _type;
74
+ get type(): DiagramPortType | undefined;
75
+ set type(type: DiagramPortType | undefined);
76
+ get typeString(): string | undefined;
77
+ set typeString(typeString: string | undefined);
27
78
  /**
28
79
  * Element that this port belongs to.
29
80
  * @public
@@ -34,16 +85,29 @@ export declare class DiagramPort extends DiagramElement implements LabeledElemen
34
85
  * @public
35
86
  */
36
87
  label?: DiagramField;
88
+ /**
89
+ * Coordinates of this port.
90
+ * @public
91
+ */
92
+ coords: Point;
93
+ /**
94
+ * Coordinates of the point where connections end and start from this port.
95
+ * @public
96
+ */
97
+ connectionPoint: Point;
37
98
  /**
38
99
  * Direction of the connections of this port at the coordinates of this port.
39
100
  * @public
40
101
  */
41
102
  direction: Side;
42
103
  /**
43
- * Coordinates of this port.
44
- * @public
104
+ * Whether this port can be used as a connection start point.
45
105
  */
46
- coords: Point;
106
+ get allowsOutgoing(): boolean;
107
+ /**
108
+ * Whether this port can be used as a connection end point.
109
+ */
110
+ get allowsIncoming(): boolean;
47
111
  /**
48
112
  * Connections that start at this port.
49
113
  * @public
@@ -54,7 +118,38 @@ export declare class DiagramPort extends DiagramElement implements LabeledElemen
54
118
  * @public
55
119
  */
56
120
  incomingConnections: DiagramConnection[];
57
- constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, direction: Side, id: string);
121
+ /**
122
+ * Name of this port. Alias for this port's label's text.
123
+ * @public
124
+ */
125
+ get name(): string;
126
+ set name(name: string);
127
+ private _defaultLook?;
128
+ private _selectedLook?;
129
+ private _highlightedLook?;
130
+ private _selectedAndHighlightedLook?;
131
+ /**
132
+ * Current look of this port.
133
+ * @private
134
+ */
135
+ get look(): PortLook;
136
+ /**
137
+ * Sets the look configuration of the look to override the one determined by the type.
138
+ * `undefined` resets it to the one determined by the type.
139
+ * @private
140
+ */
141
+ set look(look: ShapedLookConfig | ImageLookConfig | undefined);
142
+ /**
143
+ * Current width of this port.
144
+ * @private
145
+ */
146
+ get width(): number;
147
+ /**
148
+ * Current height of this port. Same as the width.
149
+ * @private
150
+ */
151
+ get height(): number;
152
+ constructor(model: DiagramModel, type: DiagramPortType | undefined, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, connectionPoint: Point | undefined, direction: Side, id: string);
58
153
  get removed(): boolean;
59
154
  updateInView(): void;
60
155
  raise(): void;
@@ -87,6 +182,11 @@ export declare class DiagramPort extends DiagramElement implements LabeledElemen
87
182
  }
88
183
  export declare class DiagramPortSet extends DiagramElementSet<DiagramPort> {
89
184
  private model;
185
+ /**
186
+ * Set of the possible types of port that the ports of this set can have.
187
+ * @public
188
+ */
189
+ types: DiagramEntitySet<DiagramPortType>;
90
190
  /**
91
191
  * Instance a set of ports for the given model. This method is used internally.
92
192
  * @private
@@ -96,6 +196,6 @@ export declare class DiagramPortSet extends DiagramElementSet<DiagramPort> {
96
196
  * 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.
97
197
  * @private
98
198
  */
99
- new(rootElement: DiagramNode | DiagramSection | undefined, coords: Point, direction: Side, id: string): DiagramPort;
199
+ new(type: DiagramPortType | undefined, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, connectionPoint: Point | undefined, direction: Side, id: string): DiagramPort;
100
200
  remove(id: string): void;
101
201
  }
@@ -157,9 +157,7 @@ export declare class ValueSet {
157
157
  propertySet: PropertySet;
158
158
  displayedProperties: Property[];
159
159
  hiddenProperties: Property[];
160
- values: {
161
- [key: string]: unknown;
162
- };
160
+ private values;
163
161
  private valueSets;
164
162
  /**
165
163
  * Collaborative timestamps for all keys in this.values that have ever been set,
@@ -344,6 +342,23 @@ export declare const diff: (a: {
344
342
  }, {
345
343
  [key: string]: unknown;
346
344
  }];
345
+ /**
346
+ * Calculates the differences between the two given values of a valueset and returns two objects containing the differences in each relative to the other.
347
+ *
348
+ * @param a An object.
349
+ * @param b An object.
350
+ * @param valueSet A ValueSet to use as reference for the keys and types of each property.
351
+ * @returns A tuple of two objects with each containing the keys that have a different value in the corresponding argument compared to the other argument.
352
+ */
353
+ export declare const diffProperties: (a: {
354
+ [key: string]: unknown;
355
+ }, b: {
356
+ [key: string]: unknown;
357
+ }, valueSet: ValueSet) => [{
358
+ [key: string]: unknown;
359
+ }, {
360
+ [key: string]: unknown;
361
+ }];
347
362
  /**
348
363
  * Checks if the given value is an object.
349
364
  * @public
@@ -1,30 +1,14 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
- import { NodeShapedLook, SectionConfig } from '../diagram-config';
3
+ import { FieldConfig, PortConfig, SectionConfig, SectionGridConfig } from '../config/diagram-config';
4
+ import { ImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from '../config/diagram-look';
4
5
  import { DiagramConnection } from './diagram-connection';
5
6
  import { DiagramDecorator } from './diagram-decorator';
6
7
  import { DiagramElement, DiagramElementSet } from './diagram-element';
7
8
  import { DiagramField, LabeledElement } from './diagram-field';
8
9
  import { DiagramModel } from './diagram-model';
9
- import { DiagramNode } from './diagram-node';
10
+ import { DiagramNode, NodeLook } from './diagram-node';
10
11
  import { DiagramPort } from './diagram-port';
11
- /**
12
- * Default values of the look of a diagram section.
13
- * @private
14
- * @see DIAGRAM_SECTION_DEFAULTS
15
- */
16
- export declare const DIAGRAM_SECTION_LOOK_DEFAULTS: NodeShapedLook;
17
- /**
18
- * Default values of the parameters of a diagram section.
19
- * @private
20
- * @see DiagramSection
21
- */
22
- export declare const DIAGRAM_SECTION_DEFAULTS: {
23
- label: null;
24
- ports: never[];
25
- look: NodeShapedLook;
26
- priority: number;
27
- };
28
12
  /**
29
13
  * Default value of the default width of a diagram section.
30
14
  * @private
@@ -54,6 +38,31 @@ export type DiagramSectionGeometry = {
54
38
  readonly width: number;
55
39
  readonly height: number;
56
40
  };
41
+ /**
42
+ * A grid of sections which a node has.
43
+ * @public
44
+ * @see DiagramNode
45
+ * @see SectionGridConfig
46
+ */
47
+ export declare class DiagramSectionGrid {
48
+ defaultWidths: number[] | null;
49
+ defaultHeights: number[] | null;
50
+ minWidths: number[] | null;
51
+ minHeights: number[] | null;
52
+ margin: number;
53
+ sections: DiagramSectionType[][];
54
+ constructor(options: SectionGridConfig);
55
+ }
56
+ export declare class DiagramSectionType {
57
+ label: FieldConfig | null;
58
+ ports: PortConfig[];
59
+ defaultLook: NodeLook;
60
+ selectedLook: NodeLook;
61
+ highlightedLook: NodeLook;
62
+ selectedAndHighlightedLook: NodeLook;
63
+ priority: number;
64
+ constructor(options: SectionConfig);
65
+ }
57
66
  /**
58
67
  * A section of a node which can have connections and display a property of the node.
59
68
  * @public
@@ -111,11 +120,26 @@ export declare class DiagramSection extends DiagramElement implements LabeledEle
111
120
  */
112
121
  get name(): string;
113
122
  set name(name: string);
123
+ private _defaultLook?;
124
+ private _selectedLook?;
125
+ private _highlightedLook?;
126
+ private _selectedAndHighlightedLook?;
127
+ /**
128
+ * Current look of this port.
129
+ * @private
130
+ */
131
+ get look(): NodeLook;
132
+ /**
133
+ * Sets the look configuration of the look to override the one determined by the type.
134
+ * `undefined` resets it to the one determined by the type.
135
+ * @private
136
+ */
137
+ set look(look: ShapedLookConfig | ImageLookConfig | StretchableImageLookConfig | undefined);
114
138
  constructor(model: DiagramModel, node: DiagramNode | undefined, indexXInNode: number, indexYInNode: number, coords: Point, width: number, height: number, id: string);
115
139
  get removed(): boolean;
116
140
  updateInView(): void;
117
141
  raise(): void;
118
- getConfig(): SectionConfig | undefined;
142
+ get type(): DiagramSectionType | undefined;
119
143
  getMinWidth(): number;
120
144
  getMinHeight(): number;
121
145
  getPriority(): number;
@@ -4,7 +4,7 @@ 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
6
  import { ActionStack, DiagramAction, DiagramActionMethod, DiagramActions } from '../diagram/diagram-action';
7
- import { UserActionConfig } from '../diagram/diagram-config';
7
+ import { UserActionConfig } from '../diagram/config/diagram-config';
8
8
  import { DiagramEvent } from '../diagram/diagram-event';
9
9
  import { DiagramConnectionType } from '../diagram/model/diagram-connection';
10
10
  import { DiagramModel } from '../diagram/model/diagram-model';
@@ -1,4 +1,4 @@
1
- import { DiagramConfig } from '../diagram/diagram-config';
1
+ import { DiagramConfig } from '../diagram/config/diagram-config';
2
2
  /**
3
3
  * Creates the structuredClone function if it doesn't exist.
4
4
  * @private