@metadev/daga 1.4.2 → 1.5.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.
Files changed (27) hide show
  1. package/Changelog.md +16 -1
  2. package/assets/icon/property/add.svg +23 -3
  3. package/assets/icon/property/gear.svg +3 -0
  4. package/assets/icon/property/move.svg +35 -0
  5. package/assets/styles/_property-editor.scss +161 -101
  6. package/assets/styles/daga.scss +1 -1
  7. package/fesm2022/metadev-daga.mjs +1276 -651
  8. package/fesm2022/metadev-daga.mjs.map +1 -1
  9. package/index.d.ts +4 -4
  10. package/lib/diagram-editor/diagram/collab/collab-action.d.ts +144 -22
  11. package/lib/diagram-editor/diagram/collab/primitives.d.ts +9 -2
  12. package/lib/diagram-editor/diagram/converters/daga-exporter.d.ts +1 -1
  13. package/lib/diagram-editor/diagram/converters/daga-model.d.ts +57 -3
  14. package/lib/diagram-editor/diagram/diagram-action.d.ts +23 -51
  15. package/lib/diagram-editor/diagram/diagram-connection.d.ts +20 -3
  16. package/lib/diagram-editor/diagram/diagram-element.d.ts +24 -2
  17. package/lib/diagram-editor/diagram/diagram-field.d.ts +9 -2
  18. package/lib/diagram-editor/diagram/diagram-node.d.ts +25 -6
  19. package/lib/diagram-editor/diagram/diagram-port.d.ts +3 -2
  20. package/lib/diagram-editor/diagram/diagram-property.d.ts +60 -8
  21. package/lib/diagram-editor/diagram/diagram-section.d.ts +18 -2
  22. package/lib/property-editor/object-editor/object-editor.component.d.ts +2 -3
  23. package/lib/property-editor/option-list-editor/option-list-editor.component.d.ts +5 -1
  24. package/lib/property-editor/property-editor.component.d.ts +2 -0
  25. package/lib/property-editor/property-settings/property-settings.component.d.ts +35 -0
  26. package/lib/property-editor/text-list-editor/text-list-editor.component.d.ts +3 -1
  27. package/package.json +5 -5
@@ -8,7 +8,7 @@ import { DiagramField } from './diagram-field';
8
8
  import { DiagramModel } from './diagram-model';
9
9
  import { DiagramPort } from './diagram-port';
10
10
  import { PropertySet, ValueSet } from './diagram-property';
11
- import { DiagramSection } from './diagram-section';
11
+ import { DiagramSection, DiagramSectionGeometry } from './diagram-section';
12
12
  /**
13
13
  * Default values of the look of a diagram node.
14
14
  * @see DIAGRAM_NODE_TYPE_DEFAULTS
@@ -36,6 +36,14 @@ export declare const DIAGRAM_NODE_TYPE_DEFAULTS: {
36
36
  priority: number;
37
37
  properties: never[];
38
38
  };
39
+ export type DiagramNodeGeometry = {
40
+ readonly coords: Point;
41
+ readonly width: number;
42
+ readonly height: number;
43
+ readonly sections: {
44
+ [sectionId: string]: DiagramSectionGeometry;
45
+ };
46
+ };
39
47
  /**
40
48
  * A node type, which holds properties that nodes of this type share in common.
41
49
  * @see NodeTypeConfig
@@ -99,10 +107,10 @@ export declare class DiagramNode extends DiagramElement {
99
107
  */
100
108
  coords: Point;
101
109
  /**
102
- * Collaborative timestamp for coords.
110
+ * Collaborative timestamp for SetGeometryCollabActions.
103
111
  * @public
104
112
  */
105
- coordsTimestamp?: CollabTimestamp;
113
+ geometryTimestamp: CollabTimestamp | null;
106
114
  /**
107
115
  * Dimension of this node along the x axis.
108
116
  * @public
@@ -119,7 +127,8 @@ export declare class DiagramNode extends DiagramElement {
119
127
  */
120
128
  get name(): string;
121
129
  set name(name: string);
122
- constructor(model: DiagramModel, type: DiagramNodeType, coords?: Point, id?: string);
130
+ constructor(model: DiagramModel, type: DiagramNodeType, coords: Point | undefined, id: string);
131
+ get removed(): boolean;
123
132
  updateInView(): void;
124
133
  getPriority(): number;
125
134
  /**
@@ -174,6 +183,16 @@ export declare class DiagramNode extends DiagramElement {
174
183
  * @param indexY A section index.
175
184
  */
176
185
  stretchSections(direction: Side, distance: number, indexX: number, indexY: number): void;
186
+ /**
187
+ * Returns the current values of all geometric properties (coordinates and dimensions) of this node and its sections.
188
+ * @public
189
+ */
190
+ getGeometry(): DiagramNodeGeometry;
191
+ /**
192
+ * Sets all geometric properties (coordinates and dimensions) of this node and its sections.
193
+ * @public
194
+ */
195
+ setGeometry(geometry: DiagramNodeGeometry): void;
177
196
  }
178
197
  export declare class DiagramNodeSet extends DiagramEntitySet<DiagramNode> {
179
198
  private model;
@@ -192,9 +211,9 @@ export declare class DiagramNodeSet extends DiagramEntitySet<DiagramNode> {
192
211
  * @public
193
212
  * @param type The type of the node given as either the type itself or the id of the type.
194
213
  * @param coords The coordinates of the top left corner of the node in the diagram.
195
- * @param id The id of the node. Should be left undefined unless a specific id is required.
214
+ * @param id The id of the node.
196
215
  * @returns The instanced node.
197
216
  */
198
- new(type: DiagramNodeType | string, coords: Point, id?: string | undefined): DiagramNode;
217
+ new(type: DiagramNodeType | string, coords: Point, id: string): DiagramNode;
199
218
  remove(id: string): void;
200
219
  }
@@ -54,7 +54,8 @@ export declare class DiagramPort extends DiagramElement {
54
54
  * @public
55
55
  */
56
56
  incomingConnections: DiagramConnection[];
57
- constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, direction: Side, id?: string);
57
+ constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, direction: Side, id: string);
58
+ get removed(): boolean;
58
59
  updateInView(): void;
59
60
  /**
60
61
  * Add a connection to this port's list of outgoing connections.
@@ -94,6 +95,6 @@ export declare class DiagramPortSet extends DiagramEntitySet<DiagramPort> {
94
95
  * 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.
95
96
  * @private
96
97
  */
97
- new(rootElement: DiagramNode | DiagramSection | undefined, coords: Point, direction: Side, id?: string | undefined): DiagramPort;
98
+ new(rootElement: DiagramNode | DiagramSection | undefined, coords: Point, direction: Side, id: string): DiagramPort;
98
99
  remove(id: string): void;
99
100
  }
@@ -1,3 +1,4 @@
1
+ import { CollabTimestamp, CollabTimestampSet } from './collab/primitives';
1
2
  /**
2
3
  * A property which is part of a property set and defines what values a value in a value set can take.
3
4
  * @see PropertySet
@@ -92,6 +93,11 @@ export declare enum Type {
92
93
  * @see Type.Option
93
94
  */
94
95
  OptionList = "option-list",
96
+ /**
97
+ * A type whose value must be a list of values picked from a set of options without repeated values.
98
+ * @see Type.Option
99
+ */
100
+ OptionSet = "option-set",
95
101
  /**
96
102
  * A type whose value must be a string without newline characters.
97
103
  */
@@ -104,6 +110,10 @@ export declare enum Type {
104
110
  * A type whose value must be a list of strings.
105
111
  */
106
112
  TextList = "text-list",
113
+ /**
114
+ * A type whose value must be a list of strings without repeated values.
115
+ */
116
+ TextSet = "text-set",
107
117
  /**
108
118
  * A type whose value must be a map with string keys and values.
109
119
  */
@@ -146,6 +156,13 @@ export declare class ValueSet {
146
156
  hiddenProperties: Property[];
147
157
  private values;
148
158
  private valueSets;
159
+ /**
160
+ * Collaborative timestamps for all keys in this.values that have ever been set,
161
+ * even if since they've since been set to the default value.
162
+ *
163
+ * Object values (in this.valueSets) store their own timestamps separately.
164
+ */
165
+ private ownTimestamps;
149
166
  constructor(propertySet: PropertySet, rootElement: unknown);
150
167
  /**
151
168
  * Get the value of the root element attribute under the given keys.
@@ -180,6 +197,23 @@ export declare class ValueSet {
180
197
  getValues(): {
181
198
  [key: string]: unknown;
182
199
  };
200
+ /**
201
+ * Returns the values for all keys present in the given object, including keys in sub-objects.
202
+ *
203
+ * @private
204
+ * @param values An object containing all values for keys present in the given object.
205
+ */
206
+ getValuesForKeys(keys: {
207
+ [key: string]: unknown;
208
+ }): {
209
+ [key: string]: unknown;
210
+ };
211
+ /**
212
+ * Obtain all CollabTimestamps in the set, including those corresponding to nested keys.
213
+ * @private
214
+ * @returns An object containing all the CollabTimestamps in the set.
215
+ */
216
+ getTimestamps(): CollabTimestampSet;
183
217
  /**
184
218
  * Check if the value under the key is not empty.
185
219
  * @private
@@ -191,7 +225,7 @@ export declare class ValueSet {
191
225
  * Check if the value under the key is not empty or the default value.
192
226
  * @private
193
227
  * @param key A key.
194
- * @returns `true` if the value under the key is empty or the default value, `false` otherwise.
228
+ * @returns `true` if the value under the key is not empty or the default value, `false` otherwise.
195
229
  */
196
230
  hasSetValue(key: string): boolean;
197
231
  /**
@@ -215,6 +249,12 @@ export declare class ValueSet {
215
249
  setValues(values: {
216
250
  [key: string]: unknown;
217
251
  }): void;
252
+ /**
253
+ * Reset all timestamps and then set them to the given timestamps.
254
+ * @private
255
+ * @param values An object containing all the CollabTimestamps in the set.
256
+ */
257
+ setTimestamps(timestamps: CollabTimestampSet): void;
218
258
  /**
219
259
  * Writes the given values over the value set's existing values without resetting the existing values.
220
260
  * @private
@@ -223,6 +263,14 @@ export declare class ValueSet {
223
263
  overwriteValues(values: {
224
264
  [key: string]: unknown;
225
265
  }): void;
266
+ /**
267
+ * Variant of overwriteValues that applies last-writer-wins to each key, updating timestamps if appropriate.
268
+ * @private
269
+ * @param values An object containing all values to set the values to.
270
+ */
271
+ overwriteValuesLww(values: {
272
+ [key: string]: unknown;
273
+ }, timestamp: CollabTimestamp): void;
226
274
  /**
227
275
  * Set all the values of this set to the defaults.
228
276
  * If this set has a root element and any of its properties have root attributes, the root element's attributes are also set to the property's default value if one is provided.
@@ -270,17 +318,21 @@ export declare const empty: (a: unknown) => boolean;
270
318
  */
271
319
  export declare const equals: (a: unknown, b: unknown) => boolean;
272
320
  /**
273
- * Calculate the differences between the given values and return two objects, each containing the keys for which the values are different in each argument, containing the different values.
321
+ * Calculate the differences between the given objects and return two objects, each containing the keys for which the values are different in each argument, containing the different values.
274
322
  * @param a A dictionary.
275
323
  * @param b A dictionary.
276
- * @returns A tuple of two values with each containing the keys that have a different value in the corresponding argument compared to the other argument.
324
+ * @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.
277
325
  */
278
326
  export declare const diff: (a: {
279
327
  [key: string]: unknown;
280
328
  }, b: {
281
329
  [key: string]: unknown;
282
- }) => [{
283
- [key: string]: unknown;
284
- }, {
285
- [key: string]: unknown;
286
- }];
330
+ }) => [
331
+ {
332
+ [key: string]: unknown;
333
+ },
334
+ {
335
+ [key: string]: unknown;
336
+ }
337
+ ];
338
+ export declare const isObject: (x: unknown) => boolean;
@@ -48,6 +48,11 @@ export declare const DIAGRAM_SECTION_MIN_WIDTH = 1;
48
48
  * @private
49
49
  */
50
50
  export declare const DIAGRAM_SECTION_MIN_HEIGHT = 1;
51
+ export type DiagramSectionGeometry = {
52
+ readonly coords: Point;
53
+ readonly width: number;
54
+ readonly height: number;
55
+ };
51
56
  /**
52
57
  * A section of a node which can have connections and display a property of the node.
53
58
  * @see DiagramConnection
@@ -100,7 +105,8 @@ export declare class DiagramSection extends DiagramElement {
100
105
  */
101
106
  get name(): string;
102
107
  set name(name: string);
103
- constructor(model: DiagramModel, node: DiagramNode | undefined, indexXInNode: number, indexYInNode: number, coords: Point, width: number, height: number, id?: string);
108
+ constructor(model: DiagramModel, node: DiagramNode | undefined, indexXInNode: number, indexYInNode: number, coords: Point, width: number, height: number, id: string);
109
+ get removed(): boolean;
104
110
  updateInView(): void;
105
111
  getConfig(): SectionConfig | undefined;
106
112
  getMinWidth(): number;
@@ -143,6 +149,16 @@ export declare class DiagramSection extends DiagramElement {
143
149
  * @param distance A distance.
144
150
  */
145
151
  stretch(direction: Side, distance: number): void;
152
+ /**
153
+ * Returns the current values of all geometric properties (coordinates and dimensions) of this section.
154
+ * @public
155
+ */
156
+ getGeometry(): DiagramSectionGeometry;
157
+ /**
158
+ * Sets all geometric properties (coordinates and dimensions) of this section.
159
+ * @public
160
+ */
161
+ setGeometry(geometry: DiagramSectionGeometry): void;
146
162
  }
147
163
  export declare class DiagramSectionSet extends DiagramEntitySet<DiagramSection> {
148
164
  private model;
@@ -155,6 +171,6 @@ export declare class DiagramSectionSet extends DiagramEntitySet<DiagramSection>
155
171
  * Instance a new section and add it to this set. This method is normally called when instancing an element with a section and it is rarely called by itself.
156
172
  * @private
157
173
  */
158
- new(node: DiagramNode, indexXInNode: number, indexYInNode: number, coords: Point, width: number, height: number, id?: string | undefined): DiagramSection;
174
+ new(node: DiagramNode, indexXInNode: number, indexYInNode: number, coords: Point, width: number, height: number, id: string): DiagramSection;
159
175
  remove(id: string): void;
160
176
  }
@@ -17,12 +17,11 @@ export declare class ObjectEditorComponent {
17
17
  _valueSet?: ValueSet;
18
18
  get valueSet(): ValueSet | undefined;
19
19
  set valueSet(valueSet: ValueSet | undefined);
20
- /** How many object-editors are parents of this object-editor. @private */
20
+ /** How many object-editor elements are parents of this object-editor element. @private */
21
21
  depth: number;
22
22
  Type: typeof Type;
23
+ getStyleClassName: (s: string) => string;
23
24
  constructor(cdr: ChangeDetectorRef, canvasProvider: CanvasProviderService);
24
- displayProperty(property: Property | Event | string | undefined): void;
25
- hideProperty(property: Property | Event | string | undefined): void;
26
25
  setValue(property: Property, value: unknown): void;
27
26
  dateToLocalDatetimeString(date: string | number | Date | null | undefined): string;
28
27
  localDatetimeStringToDate(string: string): Date;
@@ -16,14 +16,18 @@ export declare class OptionListEditorComponent {
16
16
  labelsOfValue: string[];
17
17
  options: Option<unknown>[];
18
18
  valueInput?: unknown;
19
+ allowRepeats: boolean;
20
+ optionsNotPresentInValue: Option<unknown>[];
19
21
  disabled: boolean;
20
22
  valueChange: EventEmitter<unknown[]>;
21
23
  constructor(cdr: ChangeDetectorRef);
22
24
  getLabelOfValue(value: unknown): string;
25
+ hasValue(value: unknown): boolean;
23
26
  removeFromValue(index: number): void;
24
27
  addToValue(): void;
25
28
  clearInput(): void;
29
+ updateOptionsNotPresentInValue(): void;
26
30
  onKeyUp(event: KeyboardEvent): void;
27
31
  static ɵfac: i0.ɵɵFactoryDeclaration<OptionListEditorComponent, never>;
28
- static ɵcmp: i0.ɵɵComponentDeclaration<OptionListEditorComponent, "daga-option-list-editor", never, { "value": { "alias": "value"; "required": false; }; "options": { "alias": "options"; "required": false; }; "valueInput": { "alias": "valueInput"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "valueChange": "valueChange"; }, never, never, true, never>;
32
+ static ɵcmp: i0.ɵɵComponentDeclaration<OptionListEditorComponent, "daga-option-list-editor", never, { "value": { "alias": "value"; "required": false; }; "options": { "alias": "options"; "required": false; }; "valueInput": { "alias": "valueInput"; "required": false; }; "allowRepeats": { "alias": "allowRepeats"; "required": false; }; "optionsNotPresentInValue": { "alias": "optionsNotPresentInValue"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "valueChange": "valueChange"; }, never, never, true, never>;
29
33
  }
@@ -19,6 +19,7 @@ export declare class PropertyEditorComponent implements AfterViewInit, PropertyE
19
19
  _valueSet: ValueSet | undefined;
20
20
  get valueSet(): ValueSet | undefined;
21
21
  set valueSet(valueSet: ValueSet | undefined);
22
+ settings?: boolean;
22
23
  constructor(cdr: ChangeDetectorRef);
23
24
  ngAfterViewInit(): void;
24
25
  selectPanel(): d3.Selection<HTMLDivElement, unknown, null, undefined>;
@@ -26,3 +27,4 @@ export declare class PropertyEditorComponent implements AfterViewInit, PropertyE
26
27
  static ɵfac: i0.ɵɵFactoryDeclaration<PropertyEditorComponent, never>;
27
28
  static ɵcmp: i0.ɵɵComponentDeclaration<PropertyEditorComponent, "daga-property-editor", never, { "location": { "alias": "location"; "required": false; }; "direction": { "alias": "direction"; "required": false; }; "width": { "alias": "width"; "required": false; }; "valueSet": { "alias": "valueSet"; "required": false; }; }, {}, never, never, true, never>;
28
29
  }
30
+ export declare const getStyleClassName: (s: string) => string;
@@ -0,0 +1,35 @@
1
+ import { AfterViewInit, ChangeDetectorRef, ElementRef } from '@angular/core';
2
+ import { Property, Type, ValueSet } from '../../diagram-editor/diagram/diagram-property';
3
+ import { Canvas } from '../../interfaces/canvas';
4
+ import { CanvasProviderService } from '../../services/canvas-provider.service';
5
+ import { Point } from '../../util/canvas-util';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Editor of the settings of a property editor, such as what properties are displayed and hidden and in what order.
9
+ * @see PropertyEditor
10
+ * @see ValueSet
11
+ * @private
12
+ */
13
+ export declare class PropertySettingsComponent implements AfterViewInit {
14
+ private element;
15
+ private cdr;
16
+ private canvasProvider;
17
+ get canvas(): Canvas;
18
+ _valueSet?: ValueSet;
19
+ get valueSet(): ValueSet | undefined;
20
+ set valueSet(valueSet: ValueSet | undefined);
21
+ /** How many property-settings elements are parents of this property-settings element. @private */
22
+ depth: number;
23
+ Type: typeof Type;
24
+ getStyleClassName: (s: string) => string;
25
+ asString: (value: unknown) => string;
26
+ constructor(element: ElementRef, cdr: ChangeDetectorRef, canvasProvider: CanvasProviderService);
27
+ ngAfterViewInit(): void;
28
+ private addListeners;
29
+ getClosestDropbarIndex(pointerCoords: Point): number;
30
+ displayProperty(property: Property | Event | string | undefined): void;
31
+ hideProperty(property: Property | Event | string | undefined): void;
32
+ static ɵfac: i0.ɵɵFactoryDeclaration<PropertySettingsComponent, never>;
33
+ static ɵcmp: i0.ɵɵComponentDeclaration<PropertySettingsComponent, "daga-property-settings", never, { "valueSet": { "alias": "valueSet"; "required": false; }; "depth": { "alias": "depth"; "required": false; }; }, {}, never, never, true, never>;
34
+ }
35
+ export declare const asString: (value: unknown) => string;
@@ -13,15 +13,17 @@ export declare class TextListEditorComponent {
13
13
  set value(value: string[]);
14
14
  get value(): string[];
15
15
  valueInput: string;
16
+ allowRepeats: boolean;
16
17
  disabled: boolean;
17
18
  valueChange: EventEmitter<string[]>;
18
19
  constructor(cdr: ChangeDetectorRef);
19
20
  getValueFromEvent(event: Event): string;
21
+ hasValue(value: string): boolean;
20
22
  removeFromValue(index: number): void;
21
23
  editFromValue(item: string, index: number): void;
22
24
  addToValue(): void;
23
25
  clearInput(): void;
24
26
  onKeyUp(event: KeyboardEvent): void;
25
27
  static ɵfac: i0.ɵɵFactoryDeclaration<TextListEditorComponent, never>;
26
- static ɵcmp: i0.ɵɵComponentDeclaration<TextListEditorComponent, "daga-text-list-editor", never, { "value": { "alias": "value"; "required": false; }; "valueInput": { "alias": "valueInput"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "valueChange": "valueChange"; }, never, never, true, never>;
28
+ static ɵcmp: i0.ɵɵComponentDeclaration<TextListEditorComponent, "daga-text-list-editor", never, { "value": { "alias": "value"; "required": false; }; "valueInput": { "alias": "valueInput"; "required": false; }; "allowRepeats": { "alias": "allowRepeats"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "valueChange": "valueChange"; }, never, never, true, never>;
27
29
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
3
  "description": "Diagramming engine for editing models on the Web. Made by Metadev.",
4
- "version": "1.4.2",
4
+ "version": "1.5.0",
5
5
  "author": "Metadev (https://metadev.pro)",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
7
7
  "repository": "git+https://github.com/metadevpro/daga-tutorial.git",
@@ -18,10 +18,10 @@
18
18
  "angular"
19
19
  ],
20
20
  "peerDependencies": {
21
- "@angular/common": "^17.0.0",
22
- "@angular/core": "^17.0.0",
23
- "@angular/forms": "^17.0.0",
24
- "d3": "^7.8.5",
21
+ "@angular/common": "^18.0.1",
22
+ "@angular/core": "^18.0.1",
23
+ "@angular/forms": "^18.0.1",
24
+ "d3": "^7.9.0",
25
25
  "rxjs": "~7.8.1",
26
26
  "uuid": "^9.0.0"
27
27
  },