@node-projects/web-component-designer-mermaid 0.1.0 → 0.1.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.
Files changed (47) hide show
  1. package/{src/index.ts → dist/index.d.ts} +0 -3
  2. package/dist/index.js +17 -0
  3. package/dist/monaco/MermaidLanguage.d.ts +1 -0
  4. package/{src/monaco/MermaidLanguage.ts → dist/monaco/MermaidLanguage.js} +1 -4
  5. package/dist/services/MermaidConnectionRouting.d.ts +2 -0
  6. package/{src/services/MermaidConnectionRouting.ts → dist/services/MermaidConnectionRouting.js} +22 -45
  7. package/dist/services/MermaidDocumentPropertiesService.d.ts +24 -0
  8. package/{src/services/MermaidDocumentPropertiesService.ts → dist/services/MermaidDocumentPropertiesService.js} +25 -54
  9. package/dist/services/MermaidElementsService.d.ts +19 -0
  10. package/{src/services/MermaidElementsService.ts → dist/services/MermaidElementsService.js} +18 -35
  11. package/dist/services/MermaidLayoutCopyPasteService.d.ts +5 -0
  12. package/{src/services/MermaidLayoutCopyPasteService.ts → dist/services/MermaidLayoutCopyPasteService.js} +4 -6
  13. package/dist/services/MermaidLayoutPlacementService.d.ts +8 -0
  14. package/{src/services/MermaidLayoutPlacementService.ts → dist/services/MermaidLayoutPlacementService.js} +6 -11
  15. package/dist/services/MermaidParserService.d.ts +7 -0
  16. package/{src/services/MermaidParserService.ts → dist/services/MermaidParserService.js} +410 -705
  17. package/dist/services/MermaidPropertyGroupsService.d.ts +8 -0
  18. package/{src/services/MermaidPropertyGroupsService.ts → dist/services/MermaidPropertyGroupsService.js} +2 -7
  19. package/dist/services/mermaidGeometry.d.ts +31 -0
  20. package/{src/services/mermaidGeometry.ts → dist/services/mermaidGeometry.js} +13 -43
  21. package/dist/setupMermaidServiceContainer.d.ts +2 -0
  22. package/{src/setupMermaidServiceContainer.ts → dist/setupMermaidServiceContainer.js} +8 -28
  23. package/dist/toolbar/ConnectMermaidNodesTool.d.ts +20 -0
  24. package/{src/toolbar/ConnectMermaidNodesTool.ts → dist/toolbar/ConnectMermaidNodesTool.js} +26 -58
  25. package/dist/widgets/mermaid-edge.d.ts +45 -0
  26. package/{src/widgets/mermaid-edge.ts → dist/widgets/mermaid-edge.js} +39 -60
  27. package/dist/widgets/mermaid-flowchart-directive.d.ts +16 -0
  28. package/{src/widgets/mermaid-flowchart-directive.ts → dist/widgets/mermaid-flowchart-directive.js} +11 -23
  29. package/dist/widgets/mermaid-mindmap-node.d.ts +37 -0
  30. package/{src/widgets/mermaid-mindmap-node.ts → dist/widgets/mermaid-mindmap-node.js} +36 -55
  31. package/dist/widgets/mermaid-node.d.ts +75 -0
  32. package/{src/widgets/mermaid-node.ts → dist/widgets/mermaid-node.js} +78 -105
  33. package/dist/widgets/mermaid-requirement-node.d.ts +37 -0
  34. package/{src/widgets/mermaid-requirement-node.ts → dist/widgets/mermaid-requirement-node.js} +30 -49
  35. package/dist/widgets/mermaid-requirement-relationship.d.ts +28 -0
  36. package/{src/widgets/mermaid-requirement-relationship.ts → dist/widgets/mermaid-requirement-relationship.js} +21 -38
  37. package/dist/widgets/mermaid-sequence-message.d.ts +34 -0
  38. package/{src/widgets/mermaid-sequence-message.ts → dist/widgets/mermaid-sequence-message.js} +30 -44
  39. package/dist/widgets/mermaid-sequence-participant.d.ts +24 -0
  40. package/{src/widgets/mermaid-sequence-participant.ts → dist/widgets/mermaid-sequence-participant.js} +17 -28
  41. package/dist/widgets/mermaid-subgraph.d.ts +20 -0
  42. package/{src/widgets/mermaid-subgraph.ts → dist/widgets/mermaid-subgraph.js} +13 -25
  43. package/dist/widgets/views/mermaid-demo-view.d.ts +11 -0
  44. package/{src/widgets/views/mermaid-demo-view.ts → dist/widgets/views/mermaid-demo-view.js} +8 -18
  45. package/package.json +6 -1
  46. package/tsconfig.json +0 -20
  47. /package/{src → dist}/widgets/elements.json +0 -0
@@ -0,0 +1,34 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ declare enum MermaidSequenceMessageType {
3
+ solid = "solid",
4
+ dotted = "dotted",
5
+ open = "open",
6
+ cross = "cross",
7
+ async = "async"
8
+ }
9
+ export declare class MermaidSequenceMessage extends BaseCustomWebComponentConstructorAppend {
10
+ static readonly style: CSSStyleSheet;
11
+ static readonly template: HTMLTemplateElement;
12
+ static readonly is = "mermaid-sequence-message";
13
+ from: string;
14
+ to: string;
15
+ label: string;
16
+ messageType: MermaidSequenceMessageType;
17
+ connector: string;
18
+ private _label;
19
+ private _path;
20
+ private _svg;
21
+ static readonly properties: {
22
+ from: StringConstructor;
23
+ to: StringConstructor;
24
+ label: StringConstructor;
25
+ messageType: typeof MermaidSequenceMessageType;
26
+ connector: StringConstructor;
27
+ };
28
+ constructor();
29
+ ready(): Promise<void>;
30
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
31
+ private _render;
32
+ createMermaid(): string;
33
+ }
34
+ export {};
@@ -1,16 +1,15 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
2
  import { escapeLabel, sanitizeId } from "./mermaid-node.js";
3
-
4
- enum MermaidSequenceMessageType {
5
- solid = "solid",
6
- dotted = "dotted",
7
- open = "open",
8
- cross = "cross",
9
- async = "async",
10
- }
11
-
3
+ var MermaidSequenceMessageType;
4
+ (function (MermaidSequenceMessageType) {
5
+ MermaidSequenceMessageType["solid"] = "solid";
6
+ MermaidSequenceMessageType["dotted"] = "dotted";
7
+ MermaidSequenceMessageType["open"] = "open";
8
+ MermaidSequenceMessageType["cross"] = "cross";
9
+ MermaidSequenceMessageType["async"] = "async";
10
+ })(MermaidSequenceMessageType || (MermaidSequenceMessageType = {}));
12
11
  export class MermaidSequenceMessage extends BaseCustomWebComponentConstructorAppend {
13
- static override readonly style = css`
12
+ static style = css `
14
13
  * {
15
14
  box-sizing: border-box;
16
15
  }
@@ -49,8 +48,7 @@ export class MermaidSequenceMessage extends BaseCustomWebComponentConstructorApp
49
48
  pointer-events: none;
50
49
  }
51
50
  `;
52
-
53
- static override readonly template = html`
51
+ static template = html `
54
52
  <svg id="svg" viewBox="0 0 10 10" preserveAspectRatio="none">
55
53
  <defs>
56
54
  <marker id="marker" viewBox="0 0 12 12" markerWidth="10" markerHeight="10" refX="10.5" refY="6" orient="auto" markerUnits="userSpaceOnUse">
@@ -60,54 +58,45 @@ export class MermaidSequenceMessage extends BaseCustomWebComponentConstructorApp
60
58
  <path id="path"></path>
61
59
  <text id="label"></text>
62
60
  </svg>`;
63
-
64
- static readonly is = "mermaid-sequence-message";
65
-
66
- public from: string = "Alice";
67
- public to: string = "Bob";
68
- public label: string = "Message";
69
- public messageType: MermaidSequenceMessageType = MermaidSequenceMessageType.solid;
70
- public connector: string = "->>";
71
-
72
- private _label: SVGTextElement;
73
- private _path: SVGPathElement;
74
- private _svg: SVGSVGElement;
75
-
76
- static readonly properties = {
61
+ static is = "mermaid-sequence-message";
62
+ from = "Alice";
63
+ to = "Bob";
64
+ label = "Message";
65
+ messageType = MermaidSequenceMessageType.solid;
66
+ connector = "->>";
67
+ _label;
68
+ _path;
69
+ _svg;
70
+ static properties = {
77
71
  from: String,
78
72
  to: String,
79
73
  label: String,
80
74
  messageType: MermaidSequenceMessageType,
81
75
  connector: String,
82
- }
83
-
76
+ };
84
77
  constructor() {
85
78
  super();
86
79
  this._restoreCachedInititalValues();
87
- this._label = this._getDomElement<SVGTextElement>("label");
88
- this._path = this._getDomElement<SVGPathElement>("path");
89
- this._svg = this._getDomElement<SVGSVGElement>("svg");
80
+ this._label = this._getDomElement("label");
81
+ this._path = this._getDomElement("path");
82
+ this._svg = this._getDomElement("svg");
90
83
  }
91
-
92
84
  async ready() {
93
85
  this._parseAttributesToProperties();
94
86
  this._render();
95
87
  }
96
-
97
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
88
+ attributeChangedCallback(name, oldValue, newValue) {
98
89
  if (oldValue !== newValue) {
99
90
  this._parseAttributesToProperties();
100
91
  this._render();
101
92
  }
102
93
  }
103
-
104
- private _render() {
94
+ _render() {
105
95
  const width = Math.max(1, parseFloat(this.style.width || "220"));
106
96
  const height = Math.max(28, parseFloat(this.style.height || "36"));
107
97
  const y = height / 2;
108
- const messageType = this.getAttribute("message-type") as MermaidSequenceMessageType ?? this.messageType;
98
+ const messageType = this.getAttribute("message-type") ?? this.messageType;
109
99
  const label = this.getAttribute("label") ?? this.label ?? "";
110
-
111
100
  this._svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
112
101
  this._path.setAttribute("d", `M 0 ${y} L ${width} ${y}`);
113
102
  this._path.setAttribute("marker-end", messageType === MermaidSequenceMessageType.open ? "" : "url(#marker)");
@@ -117,17 +106,15 @@ export class MermaidSequenceMessage extends BaseCustomWebComponentConstructorApp
117
106
  this._label.setAttribute("y", (y - 8).toString());
118
107
  this._label.setAttribute("text-anchor", "middle");
119
108
  }
120
-
121
- public createMermaid() {
109
+ createMermaid() {
122
110
  const from = sanitizeId(this.getAttribute("from") ?? this.from);
123
111
  const to = sanitizeId(this.getAttribute("to") ?? this.to);
124
112
  const label = this.getAttribute("label") ?? this.label ?? "";
125
- const connector = this.getAttribute("connector") ?? getConnector(this.getAttribute("message-type") as MermaidSequenceMessageType ?? this.messageType);
113
+ const connector = this.getAttribute("connector") ?? getConnector(this.getAttribute("message-type") ?? this.messageType);
126
114
  return `${from}${connector}${to}: ${escapeLabel(label)}`;
127
115
  }
128
116
  }
129
-
130
- function getConnector(messageType: MermaidSequenceMessageType) {
117
+ function getConnector(messageType) {
131
118
  switch (messageType) {
132
119
  case MermaidSequenceMessageType.dotted:
133
120
  return "-->>";
@@ -141,5 +128,4 @@ function getConnector(messageType: MermaidSequenceMessageType) {
141
128
  return "->>";
142
129
  }
143
130
  }
144
-
145
131
  customElements.define(MermaidSequenceMessage.is, MermaidSequenceMessage);
@@ -0,0 +1,24 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ declare enum MermaidSequenceParticipantType {
3
+ participant = "participant",
4
+ actor = "actor"
5
+ }
6
+ export declare class MermaidSequenceParticipant extends BaseCustomWebComponentConstructorAppend {
7
+ static readonly style: CSSStyleSheet;
8
+ static readonly template: HTMLTemplateElement;
9
+ static readonly is = "mermaid-sequence-participant";
10
+ participantId: string;
11
+ label: string;
12
+ participantType: MermaidSequenceParticipantType;
13
+ private _participant;
14
+ static readonly properties: {
15
+ participantId: StringConstructor;
16
+ label: StringConstructor;
17
+ participantType: typeof MermaidSequenceParticipantType;
18
+ };
19
+ constructor();
20
+ ready(): Promise<void>;
21
+ private _render;
22
+ createMermaid(): string;
23
+ }
24
+ export {};
@@ -1,13 +1,12 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
2
  import { escapeLabel, sanitizeId } from "./mermaid-node.js";
3
-
4
- enum MermaidSequenceParticipantType {
5
- participant = "participant",
6
- actor = "actor",
7
- }
8
-
3
+ var MermaidSequenceParticipantType;
4
+ (function (MermaidSequenceParticipantType) {
5
+ MermaidSequenceParticipantType["participant"] = "participant";
6
+ MermaidSequenceParticipantType["actor"] = "actor";
7
+ })(MermaidSequenceParticipantType || (MermaidSequenceParticipantType = {}));
9
8
  export class MermaidSequenceParticipant extends BaseCustomWebComponentConstructorAppend {
10
- static override readonly style = css`
9
+ static style = css `
11
10
  * {
12
11
  box-sizing: border-box;
13
12
  }
@@ -35,40 +34,31 @@ export class MermaidSequenceParticipant extends BaseCustomWebComponentConstructo
35
34
  border-radius: 999px;
36
35
  }
37
36
  `;
38
-
39
- static override readonly template = html`<div id="participant"></div>`;
40
-
41
- static readonly is = "mermaid-sequence-participant";
42
-
43
- public participantId: string = "Alice";
44
- public label: string = "Alice";
45
- public participantType: MermaidSequenceParticipantType = MermaidSequenceParticipantType.participant;
46
-
47
- private _participant: HTMLDivElement;
48
-
49
- static readonly properties = {
37
+ static template = html `<div id="participant"></div>`;
38
+ static is = "mermaid-sequence-participant";
39
+ participantId = "Alice";
40
+ label = "Alice";
41
+ participantType = MermaidSequenceParticipantType.participant;
42
+ _participant;
43
+ static properties = {
50
44
  participantId: String,
51
45
  label: String,
52
46
  participantType: MermaidSequenceParticipantType,
53
- }
54
-
47
+ };
55
48
  constructor() {
56
49
  super();
57
50
  this._restoreCachedInititalValues();
58
- this._participant = this._getDomElement<HTMLDivElement>("participant");
51
+ this._participant = this._getDomElement("participant");
59
52
  }
60
-
61
53
  async ready() {
62
54
  this._parseAttributesToProperties();
63
55
  this._render();
64
56
  }
65
-
66
- private _render() {
57
+ _render() {
67
58
  this._participant.textContent = this.getAttribute("label") ?? this.label ?? this.getAttribute("participant-id") ?? this.participantId;
68
59
  this._participant.dataset.participantType = this.getAttribute("participant-type") ?? this.participantType;
69
60
  }
70
-
71
- public createMermaid() {
61
+ createMermaid() {
72
62
  const id = sanitizeId(this.getAttribute("participant-id") ?? this.participantId);
73
63
  const label = this.getAttribute("label") ?? this.label ?? id;
74
64
  const type = this.getAttribute("participant-type") ?? this.participantType;
@@ -76,5 +66,4 @@ export class MermaidSequenceParticipant extends BaseCustomWebComponentConstructo
76
66
  return label && label !== id ? `${keyword} ${id} as ${escapeLabel(label)}` : `${keyword} ${id}`;
77
67
  }
78
68
  }
79
-
80
69
  customElements.define(MermaidSequenceParticipant.is, MermaidSequenceParticipant);
@@ -0,0 +1,20 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ export declare class MermaidSubgraph extends BaseCustomWebComponentConstructorAppend {
3
+ static readonly style: CSSStyleSheet;
4
+ static readonly template: HTMLTemplateElement;
5
+ static readonly is = "mermaid-subgraph";
6
+ subgraphId: string;
7
+ title: string;
8
+ direction: string;
9
+ private _titleElement;
10
+ static readonly properties: {
11
+ subgraphId: StringConstructor;
12
+ title: StringConstructor;
13
+ direction: StringConstructor;
14
+ };
15
+ constructor();
16
+ ready(): Promise<void>;
17
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
18
+ private _render;
19
+ createMermaidStart(): string;
20
+ }
@@ -1,8 +1,7 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
2
  import { escapeLabel, sanitizeId } from "./mermaid-node.js";
3
-
4
3
  export class MermaidSubgraph extends BaseCustomWebComponentConstructorAppend {
5
- static override readonly style = css`
4
+ static style = css `
6
5
  :host {
7
6
  background: rgba(245, 245, 245, 0.55);
8
7
  border: 2px dashed #777;
@@ -29,46 +28,36 @@ export class MermaidSubgraph extends BaseCustomWebComponentConstructorAppend {
29
28
  white-space: nowrap;
30
29
  }
31
30
  `;
32
-
33
- static override readonly template = html`<div id="title"></div><slot></slot>`;
34
-
35
- static readonly is = "mermaid-subgraph";
36
-
37
- public subgraphId: string = "";
38
- public override title: string = "Subgraph";
39
- public direction: string = "";
40
-
41
- private _titleElement: HTMLDivElement;
42
-
43
- static readonly properties = {
31
+ static template = html `<div id="title"></div><slot></slot>`;
32
+ static is = "mermaid-subgraph";
33
+ subgraphId = "";
34
+ title = "Subgraph";
35
+ direction = "";
36
+ _titleElement;
37
+ static properties = {
44
38
  subgraphId: String,
45
39
  title: String,
46
40
  direction: String,
47
- }
48
-
41
+ };
49
42
  constructor() {
50
43
  super();
51
44
  this._restoreCachedInititalValues();
52
- this._titleElement = this._getDomElement<HTMLDivElement>("title");
45
+ this._titleElement = this._getDomElement("title");
53
46
  }
54
-
55
47
  async ready() {
56
48
  this._parseAttributesToProperties();
57
49
  this._render();
58
50
  }
59
-
60
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
51
+ attributeChangedCallback(name, oldValue, newValue) {
61
52
  if (oldValue !== newValue) {
62
53
  this._parseAttributesToProperties();
63
54
  this._render();
64
55
  }
65
56
  }
66
-
67
- private _render() {
57
+ _render() {
68
58
  this._titleElement.textContent = this.getAttribute("title") ?? this.title;
69
59
  }
70
-
71
- public createMermaidStart() {
60
+ createMermaidStart() {
72
61
  const id = this.getAttribute("subgraph-id") ?? this.subgraphId;
73
62
  const title = this.getAttribute("title") ?? this.title;
74
63
  if (id && title && id !== title)
@@ -76,5 +65,4 @@ export class MermaidSubgraph extends BaseCustomWebComponentConstructorAppend {
76
65
  return `subgraph ${escapeLabel(title || id || "Subgraph")}`;
77
66
  }
78
67
  }
79
-
80
68
  customElements.define(MermaidSubgraph.is, MermaidSubgraph);
@@ -0,0 +1,11 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ import { IUiCommand, InstanceServiceContainer, ServiceContainer } from "@node-projects/web-component-designer";
3
+ import { IDemoView } from "@node-projects/web-component-designer/src/elements/widgets/demoView/IDemoView.js";
4
+ export declare class MermaidDemoView extends BaseCustomWebComponentConstructorAppend implements IDemoView {
5
+ static readonly template: HTMLTemplateElement;
6
+ static readonly style: CSSStyleSheet;
7
+ executeCommand(command: IUiCommand): void;
8
+ canExecuteCommand(command: IUiCommand): boolean;
9
+ dispose(): void;
10
+ display(serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string, style: string): Promise<void>;
11
+ }
@@ -1,11 +1,7 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
- import { IUiCommand, InstanceServiceContainer, ServiceContainer } from "@node-projects/web-component-designer";
3
- import { IDemoView } from "@node-projects/web-component-designer/src/elements/widgets/demoView/IDemoView.js";
4
-
5
- export class MermaidDemoView extends BaseCustomWebComponentConstructorAppend implements IDemoView {
6
- static override readonly template = html`<div id="preview"></div>`;
7
-
8
- static override readonly style = css`
2
+ export class MermaidDemoView extends BaseCustomWebComponentConstructorAppend {
3
+ static template = html `<div id="preview"></div>`;
4
+ static style = css `
9
5
  :host {
10
6
  background: white;
11
7
  display: block;
@@ -22,26 +18,20 @@ export class MermaidDemoView extends BaseCustomWebComponentConstructorAppend imp
22
18
  width: 100%;
23
19
  }
24
20
  `;
25
-
26
- executeCommand(command: IUiCommand) {
21
+ executeCommand(command) {
27
22
  }
28
-
29
- canExecuteCommand(command: IUiCommand) {
23
+ canExecuteCommand(command) {
30
24
  return false;
31
25
  }
32
-
33
- dispose(): void {
26
+ dispose() {
34
27
  }
35
-
36
- async display(serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string, style: string) {
37
- const preview = this._getDomElement<HTMLDivElement>("preview");
28
+ async display(serviceContainer, instanceServiceContainer, code, style) {
29
+ const preview = this._getDomElement("preview");
38
30
  const mermaid = await import("mermaid");
39
31
  const id = "mermaid-preview-" + crypto.randomUUID();
40
-
41
32
  mermaid.default.initialize({ startOnLoad: false, securityLevel: "strict" });
42
33
  const result = await mermaid.default.render(id, code || "flowchart TD\n A[Node]");
43
34
  preview.innerHTML = result.svg;
44
35
  }
45
36
  }
46
-
47
37
  customElements.define("node-projects-mermaid-demo-view", MermaidDemoView);
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "description": "web-component-designer addon: Widgets and Services for creating a Mermaid Designer",
3
3
  "name": "@node-projects/web-component-designer-mermaid",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
7
12
  "author": "jochen.kuehner@gmx.de",
8
13
  "license": "MIT",
9
14
  "scripts": {
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "outDir": "./dist",
6
- "rootDir": "./src",
7
- "noEmit": false,
8
- "resolveJsonModule": true
9
- },
10
- "include": [
11
- "src/**/*.ts",
12
- "src/**/*.js",
13
- "src/**/*.json"
14
- ],
15
- "references": [
16
- {
17
- "path": "../web-component-designer/tsconfig.json"
18
- }
19
- ]
20
- }
File without changes