@metadev/daga 1.0.0 → 1.2.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 (33) hide show
  1. package/Changelog.md +24 -1
  2. package/README.md +1 -1
  3. package/assets/fonts/DMMono-Medium.ttf +0 -0
  4. package/assets/fonts/DMMono-Medium.woff +0 -0
  5. package/assets/fonts/DMMono-Medium.woff2 +0 -0
  6. package/assets/fonts/WonderUnitSans-Medium.ttf +0 -0
  7. package/assets/fonts/WonderUnitSans-Medium.woff +0 -0
  8. package/assets/fonts/WonderUnitSans-Medium.woff2 +0 -0
  9. package/assets/styles/_collapse-button.scss +37 -0
  10. package/assets/styles/_diagram-buttons.scss +132 -0
  11. package/assets/styles/_diagram.scss +15 -0
  12. package/assets/styles/_errors.scss +83 -0
  13. package/assets/styles/_palette.scss +12 -0
  14. package/assets/styles/_property-editor.scss +160 -0
  15. package/assets/styles/daga.scss +152 -0
  16. package/fesm2022/metadev-daga.mjs +1257 -996
  17. package/fesm2022/metadev-daga.mjs.map +1 -1
  18. package/index.d.ts +16 -7
  19. package/lib/collapse-button/collapse-button.component.d.ts +1 -0
  20. package/lib/diagram-editor/diagram/diagram-action.d.ts +10 -1
  21. package/lib/diagram-editor/diagram/diagram-canvas.d.ts +8 -1
  22. package/lib/diagram-editor/diagram/diagram-config.d.ts +8 -0
  23. package/lib/diagram-editor/diagram/diagram-connection.d.ts +12 -3
  24. package/lib/diagram-editor/diagram/diagram-element.d.ts +74 -2
  25. package/lib/diagram-editor/diagram/diagram-field.d.ts +13 -3
  26. package/lib/diagram-editor/diagram/diagram-model.d.ts +10 -42
  27. package/lib/diagram-editor/diagram/diagram-node.d.ts +12 -3
  28. package/lib/diagram-editor/diagram/diagram-port.d.ts +12 -3
  29. package/lib/diagram-editor/diagram/diagram-section.d.ts +12 -2
  30. package/lib/interfaces/canvas.d.ts +7 -1
  31. package/lib/object-editor/object-editor.component.d.ts +1 -0
  32. package/package.json +1 -1
  33. package/assets/styles/styles.scss +0 -181
package/index.d.ts CHANGED
@@ -7,16 +7,17 @@ export { DagaImporter } from './lib/diagram-editor/diagram/converters/daga-impor
7
7
  export { DagaModel } from './lib/diagram-editor/diagram/converters/daga-model';
8
8
  export { DiagramModelExporter } from './lib/diagram-editor/diagram/converters/diagram-model-exporter';
9
9
  export { DiagramModelImporter } from './lib/diagram-editor/diagram/converters/diagram-model-importer';
10
- export { ActionQueue, AddConnectionAction, AddNodeAction, DiagramAction, EditFieldAction, MoveNodeAction, RemoveAction, StretchNodeAction, UpdateValuesAction } from './lib/diagram-editor/diagram/diagram-action';
10
+ export { ActionQueue, AddConnectionAction, AddNodeAction, DiagramAction, DiagramActions, EditFieldAction, MoveNodeAction, RemoveAction, StretchNodeAction, UpdateValuesAction } from './lib/diagram-editor/diagram/diagram-action';
11
11
  export { ACTION_QUEUE_SIZE, DiagramCanvas } from './lib/diagram-editor/diagram/diagram-canvas';
12
- export { DiagramConfig } from './lib/diagram-editor/diagram/diagram-config';
13
- export { DiagramConnection, DiagramConnectionType } from './lib/diagram-editor/diagram/diagram-connection';
14
- export { DiagramElement } from './lib/diagram-editor/diagram/diagram-element';
15
- export { DiagramField } from './lib/diagram-editor/diagram/diagram-field';
12
+ export { ConnectionMarkerLook, ConnectionTemplateConfig, ConnectionTypeConfig, DiagramConfig, FieldConfig, NodeImageLook, NodeShapedLook, NodeStretchableImageLook, NodeTemplateConfig, NodeTypeConfig, PaletteConfig, PortConfig, SectionConfig } from './lib/diagram-editor/diagram/diagram-config';
13
+ export { DiagramConnection, DiagramConnectionSet, DiagramConnectionType } from './lib/diagram-editor/diagram/diagram-connection';
14
+ export { DiagramElement, DiagramEntity, DiagramEntitySet } from './lib/diagram-editor/diagram/diagram-element';
15
+ export { DiagramField, DiagramFieldSet } from './lib/diagram-editor/diagram/diagram-field';
16
16
  export { DiagramModel } from './lib/diagram-editor/diagram/diagram-model';
17
- export { DiagramNode, DiagramNodeType } from './lib/diagram-editor/diagram/diagram-node';
18
- export { DiagramPort } from './lib/diagram-editor/diagram/diagram-port';
17
+ export { DiagramNode, DiagramNodeSet, DiagramNodeType } from './lib/diagram-editor/diagram/diagram-node';
18
+ export { DiagramPort, DiagramPortSet } from './lib/diagram-editor/diagram/diagram-port';
19
19
  export { Property, PropertySet, Type, ValueSet } from './lib/diagram-editor/diagram/diagram-property';
20
+ export { DiagramSection, DiagramSectionSet } from './lib/diagram-editor/diagram/diagram-section';
20
21
  export { AdjacencyLayout } from './lib/diagram-editor/diagram/layout/adjacency-layout';
21
22
  export { BreadthAdjacencyLayout } from './lib/diagram-editor/diagram/layout/breadth-adjacency-layout';
22
23
  export { BreadthLayout } from './lib/diagram-editor/diagram/layout/breadth-layout';
@@ -30,6 +31,10 @@ export { DiagramError } from './lib/errors/diagram-error';
30
31
  export { DiagramValidator } from './lib/errors/diagram-validator';
31
32
  export { ErrorsComponent } from './lib/errors/errors.component';
32
33
  export { Canvas } from './lib/interfaces/canvas';
34
+ export { DiagramButtons } from './lib/interfaces/diagram-buttons';
35
+ export { DiagramEditor } from './lib/interfaces/diagram-editor';
36
+ export { Palette } from './lib/interfaces/palette';
37
+ export { PropertyEditor } from './lib/interfaces/property-editor';
33
38
  export { ObjectEditorComponent } from './lib/object-editor/object-editor.component';
34
39
  export { PaletteComponent } from './lib/palette/palette.component';
35
40
  export { PropertyEditorComponent } from './lib/property-editor/property-editor.component';
@@ -37,3 +42,7 @@ export { CanvasProviderService } from './lib/services/canvas-provider.service';
37
42
  export { DagaConfigurationService } from './lib/services/daga-configuration.service';
38
43
  export { TextListEditorComponent } from './lib/text-list-editor/text-list-editor.component';
39
44
  export { TextMapEditorComponent } from './lib/text-map-editor/text-map-editor.component';
45
+ export { Line, Point, Rectangle } from './lib/util/canvas-util';
46
+ export { LineShape, LineStyle } from './lib/util/line';
47
+ export { ClosedShape } from './lib/util/shape';
48
+ export { Corner, HorizontalAlign, Side, VerticalAlign } from './lib/util/svg-util';
@@ -12,6 +12,7 @@ export declare class CollapseButtonComponent {
12
12
  visibleValue: string;
13
13
  Side: typeof Side;
14
14
  toggleCollapse(): void;
15
+ getClass(): string;
15
16
  static ɵfac: i0.ɵɵFactoryDeclaration<CollapseButtonComponent, never>;
16
17
  static ɵcmp: i0.ɵɵComponentDeclaration<CollapseButtonComponent, "daga-collapse-button", never, { "collapsableSelector": { "alias": "collapsableSelector"; "required": false; }; "collapsableAdditionalSelector": { "alias": "collapsableAdditionalSelector"; "required": false; }; "collapsed": { "alias": "collapsed"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "direction": { "alias": "direction"; "required": false; }; "rule": { "alias": "rule"; "required": false; }; "collapsedValue": { "alias": "collapsedValue"; "required": false; }; "visibleValue": { "alias": "visibleValue"; "required": false; }; }, {}, never, never, true, never>;
17
18
  }
@@ -31,6 +31,16 @@ export interface DiagramAction {
31
31
  undo(): void;
32
32
  redo(): void;
33
33
  }
34
+ export declare enum DiagramActions {
35
+ AddConnectionAction = "add-connection",
36
+ AddNodeAction = "add-node",
37
+ EditFieldAction = "edit-field",
38
+ MoveNodeAction = "move-node",
39
+ RemoveAction = "remove",
40
+ StretchNodeAction = "stretch-node",
41
+ StretchSectionAction = "stretch-section",
42
+ UpdateValuesAction = "update-values"
43
+ }
34
44
  export declare class AddNodeAction implements DiagramAction {
35
45
  canvas: Canvas;
36
46
  type: DiagramNodeType;
@@ -134,4 +144,3 @@ export declare class RemoveAction implements DiagramAction {
134
144
  undo(): void;
135
145
  redo(): void;
136
146
  }
137
- export declare const clone: <T extends object | null | undefined>(obj: T) => T;
@@ -4,7 +4,7 @@ import { DiagramValidator } from '../../errors/diagram-validator';
4
4
  import { Canvas } from '../../interfaces/canvas';
5
5
  import { DiagramEditor } from '../../interfaces/diagram-editor';
6
6
  import { Point } from '../../util/canvas-util';
7
- import { ActionQueue } from './diagram-action';
7
+ import { ActionQueue, DiagramActions } from './diagram-action';
8
8
  import { DiagramConfig } from './diagram-config';
9
9
  import { DiagramConnection, DiagramConnectionType } from './diagram-connection';
10
10
  import { DiagramElement } from './diagram-element';
@@ -15,6 +15,10 @@ import { ValueSet } from './diagram-property';
15
15
  * Thickness of the invisible path around a connection used to make it easier to click on, in pixels.
16
16
  */
17
17
  export declare const CONNECTION_PATH_BOX_THICKNESS = 12;
18
+ /**
19
+ * Thickness of the resizer line used to resize nodes and sections on drag, in pixels.
20
+ */
21
+ export declare const RESIZER_THICKNESS = 6;
18
22
  /**
19
23
  * Text to display as the title of the property editor when editing this diagram's properties.
20
24
  * @see PropertyEditorComponent
@@ -38,6 +42,9 @@ export declare class DiagramCanvas implements Canvas {
38
42
  priorityThresholds: number[];
39
43
  validators: DiagramValidator[];
40
44
  layoutFormat?: string;
45
+ userActions: {
46
+ [key in DiagramActions]?: boolean;
47
+ };
41
48
  actionQueue: ActionQueue;
42
49
  private static canvasCount;
43
50
  private backgroundPatternId;
@@ -2,6 +2,7 @@ import { Point } from '../../util/canvas-util';
2
2
  import { LineShape, LineStyle } from '../../util/line';
3
3
  import { ClosedShape } from '../../util/shape';
4
4
  import { HorizontalAlign, Side, VerticalAlign } from '../../util/svg-util';
5
+ import { DiagramActions } from './diagram-action';
5
6
  import { Property } from './diagram-property';
6
7
  /**
7
8
  * The configuration for a diagram.
@@ -58,6 +59,13 @@ export interface DiagramConfig {
58
59
  * @default undefined
59
60
  */
60
61
  layoutFormat?: string;
62
+ /**
63
+ * Mapping of user actions to a boolean indicating whether the user can perform those actions. Absent values are assumed to be `true`.
64
+ * @default {}
65
+ */
66
+ userActions?: {
67
+ [key in DiagramActions]?: boolean;
68
+ };
61
69
  /**
62
70
  * Configuration for the palettes of this diagram. Each configuration provided will configure one palette, which will be displayed as one of the tabs in the palette component.
63
71
  * @see PaletteComponent
@@ -1,11 +1,11 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { LineShape, LineStyle } from '../../util/line';
3
3
  import { Side } from '../../util/svg-util';
4
- import { DiagramElement } from './diagram-element';
4
+ import { ConnectionMarkerLook, ConnectionTypeConfig, FieldConfig } from './diagram-config';
5
+ import { DiagramElement, DiagramEntity, DiagramEntitySet } from './diagram-element';
5
6
  import { DiagramModel } from './diagram-model';
6
7
  import { DiagramPort } from './diagram-port';
7
8
  import { PropertySet, ValueSet } from './diagram-property';
8
- import { ConnectionMarkerLook, ConnectionTypeConfig, FieldConfig } from './diagram-config';
9
9
  export declare const DIAGRAM_CONNECTION_TYPE_DEFAULTS: {
10
10
  name: string;
11
11
  width: number;
@@ -20,7 +20,7 @@ export declare const DIAGRAM_CONNECTION_TYPE_DEFAULTS: {
20
20
  selectedColor: string;
21
21
  properties: never[];
22
22
  };
23
- export declare class DiagramConnectionType {
23
+ export declare class DiagramConnectionType implements DiagramEntity {
24
24
  id: string;
25
25
  name: string;
26
26
  width: number;
@@ -62,3 +62,12 @@ export declare class DiagramConnection extends DiagramElement {
62
62
  setEnd(end?: DiagramPort): void;
63
63
  tighten(): void;
64
64
  }
65
+ export declare class DiagramConnectionSet extends DiagramEntitySet<DiagramConnection> {
66
+ private model;
67
+ types: DiagramEntitySet<DiagramConnectionType>;
68
+ constructor(model: DiagramModel);
69
+ new(type: DiagramConnectionType, start?: DiagramPort, end?: DiagramPort, id?: string | undefined): DiagramConnection;
70
+ remove(id: string): void;
71
+ filter(type?: string, threshold?: number): DiagramConnection[];
72
+ find(type?: string, threshold?: number): DiagramConnection | undefined;
73
+ }
@@ -1,11 +1,19 @@
1
1
  import * as d3 from 'd3';
2
2
  import { DiagramModel } from './diagram-model';
3
3
  /**
4
- * Represents an object which exists as part of a particular diagram model and has a visual representation in a diagram canvas.
4
+ * Represents an object which exists as part of a diagram model.
5
+ * @see DiagramModel
6
+ */
7
+ export interface DiagramEntity {
8
+ get id(): string;
9
+ set id(value: string);
10
+ }
11
+ /**
12
+ * Represents an object which exists as part of a specific diagram model and has a visual representation in a diagram canvas.
5
13
  * @see DiagramModel
6
14
  * @see DiagramCanvas
7
15
  */
8
- export declare abstract class DiagramElement {
16
+ export declare abstract class DiagramElement implements DiagramEntity {
9
17
  model: DiagramModel;
10
18
  _id: string;
11
19
  get id(): string;
@@ -19,3 +27,67 @@ export declare abstract class DiagramElement {
19
27
  */
20
28
  select(): d3.Selection<SVGGElement, unknown, null, unknown> | undefined;
21
29
  }
30
+ /**
31
+ * Represents a collection of diagram entities of a type that exists as part of a diagram model.
32
+ * @see DiagramEntity
33
+ * @see DiagramModel
34
+ */
35
+ export declare class DiagramEntitySet<E extends DiagramEntity> implements Iterable<E> {
36
+ /**
37
+ * The list of entities contained in this set.
38
+ */
39
+ protected entities: E[];
40
+ /**
41
+ * A mapping of entity ids to their corresponding entity in this set for quickly fetching entities based on their id.
42
+ */
43
+ protected entityMap: {
44
+ [id: string]: E;
45
+ };
46
+ /**
47
+ * The number of entities of this set.
48
+ */
49
+ get length(): number;
50
+ /**
51
+ * Gets all of the entities of this set.
52
+ * @returns An array containing all of the entities of this set.
53
+ */
54
+ all(): E[];
55
+ /**
56
+ * Adds an entity to this set if there are no entities with the same id. Has no effect if there already exists an entity with the same id as the given entity.
57
+ * For creating entities with relationships with other entities, the new() method should be used instead. The add() method adds an entity but doesn't take care of setting that entity's relationships with other entities.
58
+ * @param entity An entity to be added to this set.
59
+ */
60
+ add(entity: E): void;
61
+ /**
62
+ * Removes all the entities in this set.
63
+ */
64
+ clear(): void;
65
+ /**
66
+ * Checks if this set contains an entity with the given id.
67
+ * @param id An id.
68
+ * @returns `true` if this set contains an entity with the given id, `false` otherwise.
69
+ */
70
+ contains(id: string): boolean;
71
+ /**
72
+ * Gets all of the entities of this set filtered following given criteria.
73
+ * @returns An array containing the entities of this set that meet the given criteria.
74
+ */
75
+ filter(): E[];
76
+ /**
77
+ * Gets an entity of this set matching specific criteria.
78
+ * @returns An entity of this set.
79
+ */
80
+ find(): E | undefined;
81
+ /**
82
+ * Gets an entity from this set.
83
+ * @param id An id.
84
+ * @returns An entity with the given id, or `undefined` if there are no entities with the given id.
85
+ */
86
+ get(id: string): E | undefined;
87
+ /**
88
+ * Attempts to find and remove an entity with the given id. Has no effect if there are no entities with the given id.
89
+ * @param id An id.
90
+ */
91
+ remove(id: string): void;
92
+ [Symbol.iterator](): Iterator<E>;
93
+ }
@@ -1,8 +1,10 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { HorizontalAlign, VerticalAlign } from '../../util/svg-util';
3
- import { DiagramElement } from './diagram-element';
3
+ import { DiagramElement, DiagramEntitySet } from './diagram-element';
4
4
  import { DiagramModel } from './diagram-model';
5
5
  import { DiagramNode } from './diagram-node';
6
+ import { DiagramPort } from './diagram-port';
7
+ import { DiagramSection } from './diagram-section';
6
8
  export declare const DIAGRAM_FIELD_DEFAULTS: {
7
9
  editable: boolean;
8
10
  fontSize: number;
@@ -15,7 +17,7 @@ export declare const DIAGRAM_FIELD_DEFAULTS: {
15
17
  verticalAlign: VerticalAlign;
16
18
  };
17
19
  export declare class DiagramField extends DiagramElement {
18
- rootElement?: DiagramElement;
20
+ rootElement?: DiagramNode | DiagramSection | DiagramPort;
19
21
  coords: Point;
20
22
  width: number;
21
23
  height: number;
@@ -30,8 +32,16 @@ export declare class DiagramField extends DiagramElement {
30
32
  get text(): string;
31
33
  set text(value: string);
32
34
  editable: boolean;
33
- constructor(model: DiagramModel, rootElement: DiagramElement | undefined, coords: Point, width: number, height: number, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, text: string, editable: boolean, id?: string);
35
+ constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | DiagramPort | undefined, coords: Point, width: number, height: number, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, text: string, editable: boolean, id?: string);
34
36
  updateInView(): void;
35
37
  move(coords: Point): void;
36
38
  getClosestNode(): DiagramNode | undefined;
37
39
  }
40
+ export declare class DiagramFieldSet extends DiagramEntitySet<DiagramField> {
41
+ private model;
42
+ constructor(model: DiagramModel);
43
+ new(rootElement: DiagramNode | DiagramSection | DiagramPort | undefined, coords: Point, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, text: string, editable: boolean, id?: string | undefined): DiagramField;
44
+ remove(id: string): void;
45
+ filter(threshold?: number): DiagramField[];
46
+ find(threshold?: number): DiagramField | undefined;
47
+ }
@@ -1,23 +1,18 @@
1
1
  import { Canvas } from '../../interfaces/canvas';
2
- import { Point } from '../../util/canvas-util';
3
- import { HorizontalAlign, Side, VerticalAlign } from '../../util/svg-util';
4
- import { DiagramConnection, DiagramConnectionType } from './diagram-connection';
5
- import { DiagramElement } from './diagram-element';
6
- import { DiagramField } from './diagram-field';
7
- import { DiagramNode, DiagramNodeType } from './diagram-node';
8
- import { DiagramPort } from './diagram-port';
2
+ import { DiagramConnectionSet } from './diagram-connection';
3
+ import { DiagramFieldSet } from './diagram-field';
4
+ import { DiagramNodeSet } from './diagram-node';
5
+ import { DiagramPortSet } from './diagram-port';
9
6
  import { Property, ValueSet } from './diagram-property';
10
- import { DiagramSection } from './diagram-section';
7
+ import { DiagramSectionSet } from './diagram-section';
11
8
  export declare class DiagramModel {
12
9
  canvas?: Canvas;
13
10
  renderToCanvas: boolean;
14
- nodeTypes: DiagramNodeType[];
15
- connectionTypes: DiagramConnectionType[];
16
- nodes: DiagramNode[];
17
- sections: DiagramSection[];
18
- ports: DiagramPort[];
19
- connections: DiagramConnection[];
20
- fields: DiagramField[];
11
+ nodes: DiagramNodeSet;
12
+ sections: DiagramSectionSet;
13
+ ports: DiagramPortSet;
14
+ connections: DiagramConnectionSet;
15
+ fields: DiagramFieldSet;
21
16
  id: string | undefined;
22
17
  name: string;
23
18
  description?: string;
@@ -34,31 +29,4 @@ export declare class DiagramModel {
34
29
  * Deletes everything in this diagram.
35
30
  */
36
31
  clear(): void;
37
- getElement(id: string): DiagramElement | undefined;
38
- deleteElement(element: DiagramElement): void;
39
- getNodeType(name: string): DiagramNodeType | undefined;
40
- getConnectionType(name: string): DiagramConnectionType | undefined;
41
- getNode(id: string): DiagramNode | undefined;
42
- getNodes(threshold?: number): DiagramNode[];
43
- getNodesOfType(type: string): DiagramNode[];
44
- addNode(type: DiagramNodeType, coords: Point, id?: string | undefined, sectionIds?: (string | undefined)[], sectionPortIds?: (string | undefined)[][], sectionPortLabelIds?: (string | undefined)[][], portIds?: (string | undefined)[], portLabelIds?: (string | undefined)[], labelId?: string | undefined): DiagramNode;
45
- deleteNode(node: DiagramNode): void;
46
- hasNodeOfType(type: string): boolean;
47
- getSection(id: string): DiagramSection | undefined;
48
- getSections(threshold?: number): DiagramSection[];
49
- addSection(node: DiagramNode, coords: Point, width: number, height: number, id?: string | undefined, portIds?: (string | undefined)[], portLabelIds?: (string | undefined)[]): DiagramSection;
50
- deleteSection(section: DiagramSection): void;
51
- getPort(id: string): DiagramPort | undefined;
52
- getPorts(threshold?: number): DiagramPort[];
53
- addPort(rootElement: DiagramElement | undefined, coords: Point, direction: Side, id?: string | undefined): DiagramPort;
54
- deletePort(port: DiagramPort): void;
55
- getConnection(id: string): DiagramConnection | undefined;
56
- getConnections(threshold?: number): DiagramConnection[];
57
- getConnectionsOfType(type: string): DiagramConnection[];
58
- addConnection(type: DiagramConnectionType, start?: DiagramPort, end?: DiagramPort, id?: string | undefined): DiagramConnection;
59
- deleteConnection(connection: DiagramConnection): void;
60
- getField(id: string): DiagramField | undefined;
61
- getFields(threshold?: number): DiagramField[];
62
- addField(rootElement: DiagramElement | undefined, coords: Point, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, text: string, editable: boolean, id?: string | undefined): DiagramField;
63
- deleteField(field: DiagramField): void;
64
32
  }
@@ -2,13 +2,13 @@ import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
3
  import { FieldConfig, NodeImageLook, NodeShapedLook, NodeStretchableImageLook, NodeTypeConfig, PortConfig, SectionConfig } from './diagram-config';
4
4
  import { DiagramConnection } from './diagram-connection';
5
- import { DiagramElement } from './diagram-element';
5
+ import { DiagramElement, DiagramEntity, DiagramEntitySet } from './diagram-element';
6
6
  import { DiagramField } from './diagram-field';
7
7
  import { DiagramModel } from './diagram-model';
8
8
  import { DiagramPort } from './diagram-port';
9
9
  import { PropertySet, ValueSet } from './diagram-property';
10
10
  import { DiagramSection } from './diagram-section';
11
- export declare const DIAGRAM_LOOK_DEFAULTS: NodeShapedLook;
11
+ export declare const DIAGRAM_NODE_LOOK_DEFAULTS: NodeShapedLook;
12
12
  export declare const DIAGRAM_NODE_TYPE_DEFAULTS: {
13
13
  name: string;
14
14
  defaultWidth: number;
@@ -25,7 +25,7 @@ export declare const DIAGRAM_NODE_TYPE_DEFAULTS: {
25
25
  priority: number;
26
26
  properties: never[];
27
27
  };
28
- export declare class DiagramNodeType {
28
+ export declare class DiagramNodeType implements DiagramEntity {
29
29
  id: string;
30
30
  name: string;
31
31
  defaultWidth: number;
@@ -66,3 +66,12 @@ export declare class DiagramNode extends DiagramElement {
66
66
  stretch(direction: Side, distance: number): void;
67
67
  stretchSections(direction: Side, distance: number, point: Point): void;
68
68
  }
69
+ export declare class DiagramNodeSet extends DiagramEntitySet<DiagramNode> {
70
+ private model;
71
+ types: DiagramEntitySet<DiagramNodeType>;
72
+ constructor(model: DiagramModel);
73
+ new(type: DiagramNodeType, coords: Point, id?: string | undefined, sectionIds?: (string | undefined)[], sectionPortIds?: (string | undefined)[][], sectionPortLabelIds?: (string | undefined)[][], portIds?: (string | undefined)[], portLabelIds?: (string | undefined)[], labelId?: string | undefined): DiagramNode;
74
+ remove(id: string): void;
75
+ filter(type?: string, threshold?: number): DiagramNode[];
76
+ find(type?: string, threshold?: number): DiagramNode | undefined;
77
+ }
@@ -1,23 +1,24 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
3
  import { DiagramConnection } from './diagram-connection';
4
- import { DiagramElement } from './diagram-element';
4
+ import { DiagramElement, DiagramEntitySet } from './diagram-element';
5
5
  import { DiagramField } from './diagram-field';
6
6
  import { DiagramModel } from './diagram-model';
7
7
  import { DiagramNode } from './diagram-node';
8
+ import { DiagramSection } from './diagram-section';
8
9
  export declare const DIAGRAM_PORT_DEFAULTS: {
9
10
  radius: number;
10
11
  highlightedColor: string;
11
12
  selectedColor: string;
12
13
  };
13
14
  export declare class DiagramPort extends DiagramElement {
14
- rootElement?: DiagramElement;
15
+ rootElement?: DiagramNode | DiagramSection;
15
16
  label?: DiagramField;
16
17
  direction: Side;
17
18
  coords: Point;
18
19
  outgoingConnections: DiagramConnection[];
19
20
  incomingConnections: DiagramConnection[];
20
- constructor(model: DiagramModel, rootElement: DiagramElement | undefined, coords: Point, direction: Side, id?: string);
21
+ constructor(model: DiagramModel, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, direction: Side, id?: string);
21
22
  updateInView(): void;
22
23
  startConnection(connection: DiagramConnection): void;
23
24
  finishConnection(connection: DiagramConnection): void;
@@ -25,3 +26,11 @@ export declare class DiagramPort extends DiagramElement {
25
26
  move(coords: Point): void;
26
27
  distanceTo(coords: Point): number;
27
28
  }
29
+ export declare class DiagramPortSet extends DiagramEntitySet<DiagramPort> {
30
+ private model;
31
+ constructor(model: DiagramModel);
32
+ new(rootElement: DiagramNode | DiagramSection | undefined, coords: Point, direction: Side, id?: string | undefined): DiagramPort;
33
+ remove(id: string): void;
34
+ filter(threshold?: number): DiagramPort[];
35
+ find(threshold?: number): DiagramPort | undefined;
36
+ }
@@ -1,11 +1,13 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
+ import { NodeShapedLook } from './diagram-config';
3
4
  import { DiagramConnection } from './diagram-connection';
4
- import { DiagramElement } from './diagram-element';
5
+ import { DiagramElement, DiagramEntitySet } from './diagram-element';
5
6
  import { DiagramField } from './diagram-field';
6
7
  import { DiagramModel } from './diagram-model';
7
8
  import { DiagramNode } from './diagram-node';
8
9
  import { DiagramPort } from './diagram-port';
10
+ export declare const DIAGRAM_SECTION_LOOK_DEFAULTS: NodeShapedLook;
9
11
  export declare const DIAGRAM_SECTION_DEFAULTS: {
10
12
  sectionsX: number;
11
13
  sectionsY: number;
@@ -14,7 +16,7 @@ export declare const DIAGRAM_SECTION_DEFAULTS: {
14
16
  margin: number;
15
17
  label: null;
16
18
  ports: never[];
17
- look: import("./diagram-config").NodeShapedLook;
19
+ look: NodeShapedLook;
18
20
  };
19
21
  export declare class DiagramSection extends DiagramElement {
20
22
  node?: DiagramNode;
@@ -34,3 +36,11 @@ export declare class DiagramSection extends DiagramElement {
34
36
  move(coords: Point): void;
35
37
  stretch(direction: Side, distance: number): void;
36
38
  }
39
+ export declare class DiagramSectionSet extends DiagramEntitySet<DiagramSection> {
40
+ private model;
41
+ constructor(model: DiagramModel);
42
+ new(node: DiagramNode, coords: Point, width: number, height: number, id?: string | undefined, portIds?: (string | undefined)[], portLabelIds?: (string | undefined)[]): DiagramSection;
43
+ remove(id: string): void;
44
+ filter(threshold?: number): DiagramSection[];
45
+ find(threshold?: number): DiagramSection | undefined;
46
+ }
@@ -1,5 +1,5 @@
1
1
  import { Subject } from 'rxjs';
2
- import { ActionQueue } from '../diagram-editor/diagram/diagram-action';
2
+ import { ActionQueue, DiagramActions } from '../diagram-editor/diagram/diagram-action';
3
3
  import { DiagramConnectionType } from '../diagram-editor/diagram/diagram-connection';
4
4
  import { DiagramElement } from '../diagram-editor/diagram/diagram-element';
5
5
  import { DiagramModel } from '../diagram-editor/diagram/diagram-model';
@@ -50,6 +50,12 @@ export interface Canvas {
50
50
  * Identifier of the current layout format used by the diagram.
51
51
  */
52
52
  layoutFormat?: string;
53
+ /**
54
+ * Mapping of what actions the user is allowed to perform. Absent values are assumed to be `true`.
55
+ */
56
+ userActions: {
57
+ [key in DiagramActions]?: boolean;
58
+ };
53
59
  /**
54
60
  * The list of validators used to check for errors in this canvas.
55
61
  */
@@ -8,6 +8,7 @@ export declare class ObjectEditorComponent {
8
8
  private cdr;
9
9
  private canvasProvider;
10
10
  get canvas(): Canvas;
11
+ get userCanEdit(): boolean;
11
12
  _valueSet?: ValueSet;
12
13
  get valueSet(): ValueSet | undefined;
13
14
  set valueSet(valueSet: ValueSet | undefined);
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.0.0",
4
+ "version": "1.2.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",