@metadev/daga 4.0.1 → 4.0.2

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.
@@ -2,7 +2,7 @@ import { Canvas } from '../../interfaces/canvas';
2
2
  import { Point } from '../../util/canvas-util';
3
3
  import { DiagramElement, DiagramElementSet } from '../model/diagram-element';
4
4
  import { DiagramModel } from '../model/diagram-model';
5
- import { ValueSet } from '../model/diagram-property';
5
+ import { ValueSet } from '../property/value';
6
6
  /**
7
7
  * Text to display as the title of the property editor when editing the properties of a diagram's value set.
8
8
  * @private
@@ -2,7 +2,7 @@ import { Canvas } from '../../interfaces/canvas';
2
2
  import { Point } from '../../util/canvas-util';
3
3
  import { DagaConnection, DagaNode } from '../converters/daga-model';
4
4
  import { DiagramNodeGeometry } from '../model/diagram-node';
5
- import { ValueSet } from '../model/diagram-property';
5
+ import { ValueSet } from '../property/value';
6
6
  import { CollabTimestamp } from './primitives';
7
7
  /**
8
8
  * An action taken by a local or remote user.
@@ -37,6 +37,7 @@ export interface CanvasConfig {
37
37
  */
38
38
  priorityThresholds?: number[];
39
39
  }
40
+ export type GridStyle = 'dots' | 'lines';
40
41
  /**
41
42
  * Configuration of the guide grid in the background of the diagram.
42
43
  */
@@ -46,6 +47,11 @@ export interface GridConfig {
46
47
  * @default true
47
48
  */
48
49
  enabled?: boolean;
50
+ /**
51
+ * The style of the grid.
52
+ * @default "dots"
53
+ */
54
+ style?: GridStyle;
49
55
  /**
50
56
  * Color of grid elements such as the points or axes.
51
57
  * @default "rgba(0, 0, 0, 0.1)"
@@ -0,0 +1,249 @@
1
+ import { Corner, Side } from '../../util/svg-util';
2
+ import { FieldConfig } from './diagram-config';
3
+ import { ImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from './diagram-look-config';
4
+ /**
5
+ * Configuration for the components of the diagram.
6
+ * @public
7
+ */
8
+ export type ComponentsConfig = {
9
+ /**
10
+ * Configuration for the buttons component in the diagram.
11
+ * If left undefined, it is interpreted as disabling the buttons component,
12
+ * same as if the attribute `enabled` in its configuration was set to `false`.
13
+ */
14
+ buttons?: ButtonsComponentConfig;
15
+ /**
16
+ * Configuration for the errors component in the diagram.
17
+ * If left undefined, it is interpreted as disabling the errors component,
18
+ * same as if the attribute `enabled` in its configuration was set to `false`.
19
+ */
20
+ errors?: ErrorsComponentConfig;
21
+ /**
22
+ * Configuration for the palette component in the diagram.
23
+ * If left undefined, it is interpreted as disabling the palette component,
24
+ * same as if the attribute `enabled` in its configuration was set to `false`.
25
+ */
26
+ palette?: PaletteComponentConfig;
27
+ /**
28
+ * Configuration for the property editor component in the diagram.
29
+ * If left undefined, it is interpreted as disabling the property editor component,
30
+ * same as if the attribute `enabled` in its configuration was set to `false`.
31
+ */
32
+ propertyEditor?: PropertyEditorComponentConfig;
33
+ };
34
+ /**
35
+ * Configuration for the buttons component in a diagram.
36
+ * @public
37
+ * @see DiagramButtonsComponent
38
+ */
39
+ export interface ButtonsComponentConfig {
40
+ /**
41
+ * Whether this component is present in the diagram.
42
+ * @default true
43
+ */
44
+ enabled?: boolean;
45
+ /**
46
+ * Location of this component in the screen.
47
+ * @default 'bottom-right'
48
+ */
49
+ location?: Corner;
50
+ /**
51
+ * Direction that this component extends towards.
52
+ * @default 'top'
53
+ */
54
+ direction?: Side;
55
+ /**
56
+ * Whether to enable the user action (undo, redo) buttons in this component.
57
+ * @default true
58
+ */
59
+ enableAction?: boolean;
60
+ /**
61
+ * Whether to enable the filter button in this component.
62
+ * @default false
63
+ */
64
+ enableFilter?: boolean;
65
+ /**
66
+ * Whether to enable the layout button in this component.
67
+ * @default false
68
+ */
69
+ enableLayout?: boolean;
70
+ /**
71
+ * Whether to enable the user selection (copy, paste, cut, delete) buttons in this component.
72
+ * @default true
73
+ */
74
+ enableSelection?: boolean;
75
+ /**
76
+ * Whether to enable the zoom buttons in this component.
77
+ * @default true
78
+ */
79
+ enableZoom?: boolean;
80
+ }
81
+ /**
82
+ * Configuration for the errors component in a diagram.
83
+ * @public
84
+ * @see ErrorsComponent
85
+ */
86
+ export interface ErrorsComponentConfig {
87
+ /**
88
+ * Whether this component is present in the diagram.
89
+ * @default true
90
+ */
91
+ enabled?: boolean;
92
+ }
93
+ /**
94
+ * Configuration for the palette component in a diagram.
95
+ * @public
96
+ * @see PaletteComponent
97
+ */
98
+ export interface PaletteComponentConfig {
99
+ /**
100
+ * Whether this component is present in the diagram.
101
+ * @default true
102
+ */
103
+ enabled?: boolean;
104
+ /**
105
+ * Location of this component in the screen.
106
+ * @default 'top-left'
107
+ */
108
+ location?: Corner;
109
+ /**
110
+ * Direction that this component extends towards.
111
+ * @default 'bottom'
112
+ */
113
+ direction?: Side;
114
+ /**
115
+ * Dimension of this component in the direction perpendicular to the direction that it extends towards.
116
+ * @default '12rem'
117
+ */
118
+ width?: string;
119
+ /**
120
+ * Gap between the templates in this palette.
121
+ * @default '1rem'
122
+ */
123
+ gap?: string;
124
+ /**
125
+ * Configuration for the sections of this palette. By default, no sections are created.
126
+ * @default undefined
127
+ */
128
+ sections?: PaletteSectionConfig[];
129
+ }
130
+ /**
131
+ * Configuration for the property editor component in a diagram.
132
+ * @public
133
+ * @see PropertyEditorComponent
134
+ */
135
+ export interface PropertyEditorComponentConfig {
136
+ /**
137
+ * Whether this component is present in the diagram.
138
+ * @default true
139
+ */
140
+ enabled?: boolean;
141
+ /**
142
+ * Location of this component in the screen.
143
+ * @default 'top-right'
144
+ */
145
+ location?: Corner;
146
+ /**
147
+ * Direction that this component extends towards.
148
+ * @default 'bottom'
149
+ */
150
+ direction?: Side;
151
+ /**
152
+ * Dimension of this component in the direction perpendicular to the direction that it extends towards.
153
+ * @default '24rem'
154
+ */
155
+ width?: string;
156
+ }
157
+ /**
158
+ * Configuration for a palette.
159
+ * @public
160
+ * @see PaletteComponent
161
+ */
162
+ export interface PaletteSectionConfig {
163
+ /**
164
+ * Name of this palette. Displayed in the tab of this palette in the palette component. Can be left undefined if this is the only palette.
165
+ */
166
+ name?: string;
167
+ /**
168
+ * Categories of this palette. Used to enable displaying one of different categories of templates as defined here. Can be left undefined if there are no categories.
169
+ */
170
+ categories?: {
171
+ [key: string]: (NodeTemplateConfig | ConnectionTemplateConfig)[];
172
+ };
173
+ /**
174
+ * List of templates that are always displayed in this palette. Can be left undefined.
175
+ */
176
+ templates?: (NodeTemplateConfig | ConnectionTemplateConfig)[];
177
+ }
178
+ /**
179
+ * Configuration for a template of a node in a palette.
180
+ * @public
181
+ * @see PaletteComponent
182
+ */
183
+ export interface NodeTemplateConfig {
184
+ /**
185
+ * String used to indicate that this is a template of a node.
186
+ */
187
+ templateType: 'node';
188
+ /**
189
+ * Id of the type of node of this template. Must correspond to the id of a type of node defined in the nodeTypes list.
190
+ */
191
+ type: string;
192
+ /**
193
+ * Look of this template as it appears on the palette which can be used to override the default look of the nodes of this type.
194
+ */
195
+ look?: ShapedLookConfig | ImageLookConfig | StretchableImageLookConfig;
196
+ /**
197
+ * Label of this template as it appears on the palette and label that will be given to nodes created from this template.
198
+ */
199
+ label?: string;
200
+ /**
201
+ * Look of the label of this template as it appears on the palette. By default, the label of the type of node is used.
202
+ */
203
+ labelLook?: FieldConfig | null;
204
+ /**
205
+ * Default values of the properties of nodes created from this template.
206
+ */
207
+ values?: {
208
+ [key: string]: unknown;
209
+ };
210
+ }
211
+ /**
212
+ * Configuration for a template of a connection in a palette.
213
+ * @public
214
+ * @see PaletteComponent
215
+ */
216
+ export interface ConnectionTemplateConfig {
217
+ /**
218
+ * String used to indicate that this is a template of a connection.
219
+ */
220
+ templateType: 'connection';
221
+ /**
222
+ * Id of the type of connection of this template. Must correspond to the id of a type of connection defined in the connectionTypes list.
223
+ */
224
+ type: string;
225
+ /**
226
+ * Label of this template as it appears on the palette.
227
+ */
228
+ label: string;
229
+ /**
230
+ * Background color of this template as it appears on the palette.
231
+ */
232
+ backgroundColor: string;
233
+ /**
234
+ * File path of the background image of this template as it appears on the palette.
235
+ */
236
+ icon: string;
237
+ /**
238
+ * File path of the background image of this template as it appears on the palette when this connection type is selected.
239
+ */
240
+ selectedIcon: string;
241
+ /**
242
+ * Width of this template in diagram units as it appears on the palette.
243
+ */
244
+ width: number;
245
+ /**
246
+ * Height of this template in diagram units as it appears on the palette.
247
+ */
248
+ height: number;
249
+ }
@@ -1,9 +1,10 @@
1
1
  import { Point } from '../../util/canvas-util';
2
- import { Corner, HorizontalAlign, Side, VerticalAlign } from '../../util/svg-util';
2
+ import { HorizontalAlign, Side, VerticalAlign } from '../../util/svg-util';
3
3
  import { DiagramActions } from '../diagram-action';
4
- import { Property } from '../model/diagram-property';
4
+ import { Property } from '../property/property';
5
5
  import { CanvasConfig } from './diagram-canvas-config';
6
6
  import { ConnectionLookConfig, ImageLookConfig, MarkerImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from './diagram-look-config';
7
+ import { ComponentsConfig } from './diagram-components-config';
7
8
  /**
8
9
  * The configuration for a diagram.
9
10
  * @public
@@ -94,252 +95,6 @@ export interface DiagramConfig {
94
95
  export type UserActionConfig = {
95
96
  [key in DiagramActions]?: boolean;
96
97
  };
97
- /**
98
- * Configuration for the components of the diagram.
99
- * @public
100
- */
101
- export type ComponentsConfig = {
102
- /**
103
- * Configuration for the buttons component in the diagram.
104
- * If left undefined, it is interpreted as disabling the buttons component,
105
- * same as if the attribute `enabled` in its configuration was set to `false`.
106
- */
107
- buttons?: ButtonsComponentConfig;
108
- /**
109
- * Configuration for the errors component in the diagram.
110
- * If left undefined, it is interpreted as disabling the errors component,
111
- * same as if the attribute `enabled` in its configuration was set to `false`.
112
- */
113
- errors?: ErrorsComponentConfig;
114
- /**
115
- * Configuration for the palette component in the diagram.
116
- * If left undefined, it is interpreted as disabling the palette component,
117
- * same as if the attribute `enabled` in its configuration was set to `false`.
118
- */
119
- palette?: PaletteComponentConfig;
120
- /**
121
- * Configuration for the property editor component in the diagram.
122
- * If left undefined, it is interpreted as disabling the property editor component,
123
- * same as if the attribute `enabled` in its configuration was set to `false`.
124
- */
125
- propertyEditor?: PropertyEditorComponentConfig;
126
- };
127
- /**
128
- * Configuration for the buttons component in a diagram.
129
- * @public
130
- * @see DiagramButtonsComponent
131
- */
132
- export interface ButtonsComponentConfig {
133
- /**
134
- * Whether this component is present in the diagram.
135
- * @default true
136
- */
137
- enabled?: boolean;
138
- /**
139
- * Location of this component in the screen.
140
- * @default 'bottom-right'
141
- */
142
- location?: Corner;
143
- /**
144
- * Direction that this component extends towards.
145
- * @default 'top'
146
- */
147
- direction?: Side;
148
- /**
149
- * Whether to enable the user action (undo, redo) buttons in this component.
150
- * @default true
151
- */
152
- enableAction?: boolean;
153
- /**
154
- * Whether to enable the filter button in this component.
155
- * @default false
156
- */
157
- enableFilter?: boolean;
158
- /**
159
- * Whether to enable the layout button in this component.
160
- * @default false
161
- */
162
- enableLayout?: boolean;
163
- /**
164
- * Whether to enable the user selection (copy, paste, cut, delete) buttons in this component.
165
- * @default true
166
- */
167
- enableSelection?: boolean;
168
- /**
169
- * Whether to enable the zoom buttons in this component.
170
- * @default true
171
- */
172
- enableZoom?: boolean;
173
- }
174
- /**
175
- * Configuration for the errors component in a diagram.
176
- * @public
177
- * @see ErrorsComponent
178
- */
179
- export interface ErrorsComponentConfig {
180
- /**
181
- * Whether this component is present in the diagram.
182
- * @default true
183
- */
184
- enabled?: boolean;
185
- }
186
- /**
187
- * Configuration for the palette component in a diagram.
188
- * @public
189
- * @see PaletteComponent
190
- */
191
- export interface PaletteComponentConfig {
192
- /**
193
- * Whether this component is present in the diagram.
194
- * @default true
195
- */
196
- enabled?: boolean;
197
- /**
198
- * Location of this component in the screen.
199
- * @default 'top-left'
200
- */
201
- location?: Corner;
202
- /**
203
- * Direction that this component extends towards.
204
- * @default 'bottom'
205
- */
206
- direction?: Side;
207
- /**
208
- * Dimension of this component in the direction perpendicular to the direction that it extends towards.
209
- * @default '12rem'
210
- */
211
- width?: string;
212
- /**
213
- * Gap between the templates in this palette.
214
- * @default '1rem'
215
- */
216
- gap?: string;
217
- /**
218
- * Configuration for the sections of this palette. By default, no sections are created.
219
- * @default undefined
220
- */
221
- sections?: PaletteSectionConfig[];
222
- }
223
- /**
224
- * Configuration for the property editor component in a diagram.
225
- * @public
226
- * @see PropertyEditorComponent
227
- */
228
- export interface PropertyEditorComponentConfig {
229
- /**
230
- * Whether this component is present in the diagram.
231
- * @default true
232
- */
233
- enabled?: boolean;
234
- /**
235
- * Location of this component in the screen.
236
- * @default 'top-right'
237
- */
238
- location?: Corner;
239
- /**
240
- * Direction that this component extends towards.
241
- * @default 'bottom'
242
- */
243
- direction?: Side;
244
- /**
245
- * Dimension of this component in the direction perpendicular to the direction that it extends towards.
246
- * @default '24rem'
247
- */
248
- width?: string;
249
- }
250
- /**
251
- * Configuration for a palette.
252
- * @public
253
- * @see PaletteComponent
254
- */
255
- export interface PaletteSectionConfig {
256
- /**
257
- * Name of this palette. Displayed in the tab of this palette in the palette component. Can be left undefined if this is the only palette.
258
- */
259
- name?: string;
260
- /**
261
- * Categories of this palette. Used to enable displaying one of different categories of templates as defined here. Can be left undefined if there are no categories.
262
- */
263
- categories?: {
264
- [key: string]: (NodeTemplateConfig | ConnectionTemplateConfig)[];
265
- };
266
- /**
267
- * List of templates that are always displayed in this palette. Can be left undefined.
268
- */
269
- templates?: (NodeTemplateConfig | ConnectionTemplateConfig)[];
270
- }
271
- /**
272
- * Configuration for a template of a node in a palette.
273
- * @public
274
- * @see PaletteComponent
275
- */
276
- export interface NodeTemplateConfig {
277
- /**
278
- * String used to indicate that this is a template of a node.
279
- */
280
- templateType: 'node';
281
- /**
282
- * Id of the type of node of this template. Must correspond to the id of a type of node defined in the nodeTypes list.
283
- */
284
- type: string;
285
- /**
286
- * Look of this template as it appears on the palette which can be used to override the default look of the nodes of this type.
287
- */
288
- look?: ShapedLookConfig | ImageLookConfig | StretchableImageLookConfig;
289
- /**
290
- * Label of this template as it appears on the palette and label that will be given to nodes created from this template.
291
- */
292
- label?: string;
293
- /**
294
- * Look of the label of this template as it appears on the palette. By default, the label of the type of node is used.
295
- */
296
- labelLook?: FieldConfig | null;
297
- /**
298
- * Default values of the properties of nodes created from this template.
299
- */
300
- values?: {
301
- [key: string]: unknown;
302
- };
303
- }
304
- /**
305
- * Configuration for a template of a connection in a palette.
306
- * @public
307
- * @see PaletteComponent
308
- */
309
- export interface ConnectionTemplateConfig {
310
- /**
311
- * String used to indicate that this is a template of a connection.
312
- */
313
- templateType: 'connection';
314
- /**
315
- * Id of the type of connection of this template. Must correspond to the id of a type of connection defined in the connectionTypes list.
316
- */
317
- type: string;
318
- /**
319
- * Label of this template as it appears on the palette.
320
- */
321
- label: string;
322
- /**
323
- * Background color of this template as it appears on the palette.
324
- */
325
- backgroundColor: string;
326
- /**
327
- * File path of the background image of this template as it appears on the palette.
328
- */
329
- icon: string;
330
- /**
331
- * File path of the background image of this template as it appears on the palette when this connection type is selected.
332
- */
333
- selectedIcon: string;
334
- /**
335
- * Width of this template in diagram units as it appears on the palette.
336
- */
337
- width: number;
338
- /**
339
- * Height of this template in diagram units as it appears on the palette.
340
- */
341
- height: number;
342
- }
343
98
  /**
344
99
  * Configuration for a type of node.
345
100
  * @public
@@ -404,6 +159,11 @@ export interface NodeTypeConfig {
404
159
  * @default []
405
160
  */
406
161
  ports?: PortConfig[];
162
+ /**
163
+ * Configuration of the decorators of nodes of this type.
164
+ * @default []
165
+ */
166
+ decorators?: DecoratorConfig[];
407
167
  /**
408
168
  * Configuration of the look of nodes of this type as they should appear to the user.
409
169
  */
@@ -558,6 +318,31 @@ export interface FieldConfig {
558
318
  */
559
319
  fit?: boolean;
560
320
  }
321
+ /**
322
+ * Configuration for a decorator that is part of another element.
323
+ * @public
324
+ * @see DiagramDecorator
325
+ */
326
+ export interface DecoratorConfig {
327
+ /**
328
+ * Coordinates of this decorator relative to its root element's coordinates.
329
+ */
330
+ coords: Point;
331
+ /**
332
+ * Dimension of this decorator along the x axis.
333
+ * @public
334
+ */
335
+ width: number;
336
+ /**
337
+ * Dimension of this decorator along the y axis.
338
+ * @public
339
+ */
340
+ height: number;
341
+ /**
342
+ * Inner HTML of this decorator.
343
+ */
344
+ html: string;
345
+ }
561
346
  /**
562
347
  * Configuration for the grid of sections of a node.
563
348
  * @public
@@ -7,7 +7,8 @@ import { DiagramElement, DiagramElementSet } from './diagram-element';
7
7
  import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
8
8
  import { DiagramModel } from './diagram-model';
9
9
  import { DiagramPort } from './diagram-port';
10
- import { PropertySet, ValueSet } from './diagram-property';
10
+ import { PropertySet } from '../property/property';
11
+ import { ValueSet } from '../property/value';
11
12
  /**
12
13
  * Default values of the parameters of a diagram connection.
13
14
  * @private
@@ -1,11 +1,12 @@
1
1
  import { Canvas } from '../../interfaces/canvas';
2
+ import { Property } from '../property/property';
3
+ import { ValueSet } from '../property/value';
2
4
  import { DiagramConnectionSet } from './diagram-connection';
3
5
  import { DiagramDecoratorSet } from './diagram-decorator';
4
6
  import { DiagramFieldSet } from './diagram-field';
5
7
  import { DiagramNodeSet } from './diagram-node';
6
8
  import { DiagramObjectSet } from './diagram-object';
7
9
  import { DiagramPortSet } from './diagram-port';
8
- import { Property, ValueSet } from './diagram-property';
9
10
  import { DiagramSectionSet } from './diagram-section';
10
11
  /**
11
12
  * Stores the data of a diagram.
@@ -1,8 +1,10 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
3
  import { CollabTimestamp } from '../collab/primitives';
4
- import { FieldConfig, NodeTypeConfig, PortConfig } from '../config/diagram-config';
4
+ import { DecoratorConfig, FieldConfig, NodeTypeConfig, PortConfig } from '../config/diagram-config';
5
5
  import { ImageLook, ImageLookConfig, ShapedLook, ShapedLookConfig, StretchableImageLook, StretchableImageLookConfig } from '../config/diagram-look-config';
6
+ import { PropertySet } from '../property/property';
7
+ import { ValueSet } from '../property/value';
6
8
  import { DiagramConnection } from './diagram-connection';
7
9
  import { DiagramDecorator } from './diagram-decorator';
8
10
  import { DiagramElement, DiagramElementSet } from './diagram-element';
@@ -10,7 +12,6 @@ import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
10
12
  import { DiagramField, LabeledElement } from './diagram-field';
11
13
  import { DiagramModel } from './diagram-model';
12
14
  import { DiagramPort } from './diagram-port';
13
- import { PropertySet, ValueSet } from './diagram-property';
14
15
  import { DiagramSection, DiagramSectionGeometry, DiagramSectionGrid } from './diagram-section';
15
16
  /**
16
17
  * Default values of the look of a diagram node.
@@ -34,6 +35,7 @@ export declare const DIAGRAM_NODE_TYPE_DEFAULTS: {
34
35
  padding: number;
35
36
  label: null;
36
37
  ports: never[];
38
+ decorators: never[];
37
39
  sectionGrid: null;
38
40
  look: ShapedLookConfig;
39
41
  isUnique: boolean;
@@ -80,6 +82,7 @@ export declare class DiagramNodeType implements DiagramEntity {
80
82
  topPadding: number;
81
83
  label: FieldConfig | null;
82
84
  ports: PortConfig[];
85
+ decorators: DecoratorConfig[];
83
86
  sectionGrid: DiagramSectionGrid | null;
84
87
  defaultLook: NodeLook;
85
88
  selectedLook: NodeLook;