@node-projects/web-component-designer-mermaid 0.1.0 → 0.3.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 (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} +25 -46
  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 +23 -0
  10. package/{src/services/MermaidElementsService.ts → dist/services/MermaidElementsService.js} +35 -36
  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} +441 -707
  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} +27 -36
  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 +46 -0
  26. package/{src/widgets/mermaid-edge.ts → dist/widgets/mermaid-edge.js} +63 -61
  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 +7 -2
  46. package/tsconfig.json +0 -20
  47. /package/{src → dist}/widgets/elements.json +0 -0
@@ -1,20 +1,19 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
2
  import { boundsFromWaypoints, decodeWaypoints, midpointFromWaypoints, pathDataFromWaypoints } from "../services/mermaidGeometry.js";
3
3
  import { escapeLabel, sanitizeId } from "./mermaid-node.js";
4
-
5
- enum MermaidEdgeType {
6
- arrow = "arrow",
7
- open = "open",
8
- dotted = "dotted",
9
- thick = "thick",
10
- invisible = "invisible",
11
- circle = "circle",
12
- cross = "cross",
13
- multi = "multi",
14
- }
15
-
4
+ var MermaidEdgeType;
5
+ (function (MermaidEdgeType) {
6
+ MermaidEdgeType["arrow"] = "arrow";
7
+ MermaidEdgeType["open"] = "open";
8
+ MermaidEdgeType["dotted"] = "dotted";
9
+ MermaidEdgeType["thick"] = "thick";
10
+ MermaidEdgeType["invisible"] = "invisible";
11
+ MermaidEdgeType["circle"] = "circle";
12
+ MermaidEdgeType["cross"] = "cross";
13
+ MermaidEdgeType["multi"] = "multi";
14
+ })(MermaidEdgeType || (MermaidEdgeType = {}));
16
15
  export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
17
- static override readonly style = css`
16
+ static style = css `
18
17
  * {
19
18
  box-sizing: border-box;
20
19
  }
@@ -52,9 +51,14 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
52
51
  font-size: 12px;
53
52
  pointer-events: none;
54
53
  }
55
- `;
56
54
 
57
- static override readonly template = html`
55
+ @keyframes mermaid-edge-flow {
56
+ to {
57
+ stroke-dashoffset: -28;
58
+ }
59
+ }
60
+ `;
61
+ static template = html `
58
62
  <svg id="svg" viewBox="0 0 10 10" preserveAspectRatio="none">
59
63
  <defs>
60
64
  <marker id="marker" viewBox="0 0 12 12" markerWidth="10" markerHeight="10" refX="10.5" refY="6" orient="auto" markerUnits="userSpaceOnUse">
@@ -73,24 +77,20 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
73
77
  <path id="path"></path>
74
78
  <text id="label"></text>
75
79
  </svg>`;
76
-
77
- static readonly is = "mermaid-edge";
78
-
79
- public from: string = "A";
80
- public to: string = "B";
81
- public label: string = "";
82
- public edgeType: MermaidEdgeType = MermaidEdgeType.arrow;
83
- public connector: string = "-->";
84
- public edgeId: string = "";
85
- public animation: string = "";
86
- public waypoints: string = "";
87
- private _previewWaypoints: string;
88
-
89
- private _label: SVGTextElement;
90
- private _path: SVGPathElement;
91
- private _svg: SVGSVGElement;
92
-
93
- static readonly properties = {
80
+ static is = "mermaid-edge";
81
+ from = "A";
82
+ to = "B";
83
+ label = "";
84
+ edgeType = MermaidEdgeType.arrow;
85
+ connector = "-->";
86
+ edgeId = "";
87
+ animation = "";
88
+ waypoints = "";
89
+ _previewWaypoints;
90
+ _label;
91
+ _path;
92
+ _svg;
93
+ static properties = {
94
94
  from: String,
95
95
  to: String,
96
96
  label: String,
@@ -99,38 +99,32 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
99
99
  edgeId: String,
100
100
  animation: String,
101
101
  waypoints: String,
102
- }
103
-
102
+ };
104
103
  constructor() {
105
104
  super();
106
105
  this._restoreCachedInititalValues();
107
- this._label = this._getDomElement<SVGTextElement>("label");
108
- this._path = this._getDomElement<SVGPathElement>("path");
109
- this._svg = this._getDomElement<SVGSVGElement>("svg");
106
+ this._label = this._getDomElement("label");
107
+ this._path = this._getDomElement("path");
108
+ this._svg = this._getDomElement("svg");
110
109
  }
111
-
112
110
  async ready() {
113
111
  this._parseAttributesToProperties();
114
112
  this._render();
115
113
  }
116
-
117
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
114
+ attributeChangedCallback(name, oldValue, newValue) {
118
115
  if (oldValue !== newValue) {
119
116
  this._parseAttributesToProperties();
120
117
  this._render();
121
118
  }
122
119
  }
123
-
124
- public setPreviewWaypoints(waypoints: string | null) {
120
+ setPreviewWaypoints(waypoints) {
125
121
  this._previewWaypoints = waypoints;
126
122
  this._render();
127
123
  }
128
-
129
- private _render() {
124
+ _render() {
130
125
  let waypoints = decodeWaypoints(this._previewWaypoints ?? this.getAttribute("waypoints") ?? this.waypoints);
131
126
  if (waypoints.length < 2)
132
127
  waypoints = [{ x: 0, y: 12 }, { x: 180, y: 12 }];
133
-
134
128
  const padding = 16;
135
129
  const minCrossAxisSize = 24;
136
130
  const bounds = boundsFromWaypoints(waypoints);
@@ -138,23 +132,22 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
138
132
  const height = Math.max(minCrossAxisSize, Math.round(bounds.height + padding * 2));
139
133
  const offsetX = (width - bounds.width) / 2;
140
134
  const offsetY = (height - bounds.height) / 2;
141
-
142
135
  this.style.left = `${Math.round(bounds.x - offsetX)}px`;
143
136
  this.style.top = `${Math.round(bounds.y - offsetY)}px`;
144
137
  this.style.width = `${width}px`;
145
138
  this.style.height = `${height}px`;
146
-
147
139
  const shifted = waypoints.map(point => ({ x: point.x - bounds.x + offsetX, y: point.y - bounds.y + offsetY }));
148
140
  const middle = midpointFromWaypoints(shifted);
149
-
150
141
  this._svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
151
142
  this._path.setAttribute("d", pathDataFromWaypoints(shifted));
152
- const edgeType = this.getAttribute("edge-type") as MermaidEdgeType ?? this.edgeType;
143
+ const edgeType = this.getAttribute("edge-type") ?? this.edgeType;
153
144
  const connector = this.getAttribute("connector") ?? this.connector;
154
145
  const label = this.getAttribute("label") ?? this.label ?? "";
155
146
  this._path.setAttribute("marker-start", connector.startsWith("<") || edgeType === MermaidEdgeType.multi ? "url(#marker-start)" : "");
156
147
  this._path.setAttribute("marker-end", getMarkerEnd(edgeType, connector));
157
- this._path.style.strokeDasharray = edgeType === MermaidEdgeType.dotted ? "4 4" : "";
148
+ const animation = this.getAttribute("animation") ?? this.animation;
149
+ this._path.style.strokeDasharray = animation ? "8 6" : edgeType === MermaidEdgeType.dotted ? "4 4" : "";
150
+ this._path.style.animation = animation ? `mermaid-edge-flow ${getAnimationDuration(animation)} linear infinite` : "";
158
151
  this._path.style.strokeWidth = edgeType === MermaidEdgeType.thick ? "4" : "2.5";
159
152
  this._path.style.opacity = edgeType === MermaidEdgeType.invisible ? "0" : "";
160
153
  this._label.textContent = label;
@@ -163,25 +156,36 @@ export class MermaidEdge extends BaseCustomWebComponentConstructorAppend {
163
156
  this._label.setAttribute("y", (middle.y - 8).toString());
164
157
  this._label.setAttribute("text-anchor", "middle");
165
158
  }
166
-
167
- public createMermaid() {
159
+ createMermaid() {
168
160
  const from = sanitizeId(this.getAttribute("from") ?? this.from);
169
161
  const to = sanitizeId(this.getAttribute("to") ?? this.to);
170
162
  const label = this.getAttribute("label") ?? this.label;
171
163
  const explicitConnector = this.getAttribute("connector") ?? this.connector;
172
- const connector = explicitConnector ? { plain: explicitConnector, label: explicitConnector } : getConnector(this.getAttribute("edge-type") as MermaidEdgeType ?? this.edgeType);
164
+ const connector = explicitConnector ? { plain: explicitConnector, label: explicitConnector } : getConnector(this.getAttribute("edge-type") ?? this.edgeType);
173
165
  const rawEdgeId = this.getAttribute("edge-id") ?? this.edgeId;
174
166
  const edgeId = rawEdgeId ? sanitizeId(rawEdgeId) : "";
175
167
  const prefix = edgeId ? edgeId + "@" : "";
176
-
177
168
  if (label)
178
169
  return `${from} ${prefix}${connector.label}|${escapeLabel(label)}| ${to}`;
179
-
180
170
  return `${from} ${prefix}${connector.plain} ${to}`;
181
171
  }
172
+ createMermaidDirective() {
173
+ const rawEdgeId = this.getAttribute("edge-id") ?? this.edgeId;
174
+ const edgeId = rawEdgeId ? sanitizeId(rawEdgeId) : "";
175
+ const animation = this.getAttribute("animation") ?? this.animation;
176
+ if (!edgeId || !animation)
177
+ return "";
178
+ return `${edgeId}@{ animation: ${animation} }`;
179
+ }
182
180
  }
183
-
184
- function getMarkerEnd(edgeType: MermaidEdgeType, connector: string) {
181
+ function getAnimationDuration(animation) {
182
+ if (animation === "fast")
183
+ return "0.8s";
184
+ if (animation === "slow")
185
+ return "2s";
186
+ return "1.3s";
187
+ }
188
+ function getMarkerEnd(edgeType, connector) {
185
189
  if (edgeType === MermaidEdgeType.open || edgeType === MermaidEdgeType.invisible || connector.endsWith("---") || connector.endsWith("===") || connector.endsWith("-.-"))
186
190
  return "";
187
191
  if (edgeType === MermaidEdgeType.circle || connector.includes("o"))
@@ -190,8 +194,7 @@ function getMarkerEnd(edgeType: MermaidEdgeType, connector: string) {
190
194
  return "url(#cross-marker)";
191
195
  return "url(#marker)";
192
196
  }
193
-
194
- function getConnector(edgeType: MermaidEdgeType) {
197
+ function getConnector(edgeType) {
195
198
  switch (edgeType) {
196
199
  case MermaidEdgeType.open:
197
200
  return { plain: "---", label: "---" };
@@ -211,5 +214,4 @@ function getConnector(edgeType: MermaidEdgeType) {
211
214
  return { plain: "-->", label: "-->" };
212
215
  }
213
216
  }
214
-
215
217
  customElements.define(MermaidEdge.is, MermaidEdge);
@@ -0,0 +1,16 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ export declare class MermaidFlowchartDirective extends BaseCustomWebComponentConstructorAppend {
3
+ static readonly style: CSSStyleSheet;
4
+ static readonly template: HTMLTemplateElement;
5
+ static readonly is = "mermaid-flowchart-directive";
6
+ line: string;
7
+ private _text;
8
+ static readonly properties: {
9
+ line: StringConstructor;
10
+ };
11
+ constructor();
12
+ ready(): Promise<void>;
13
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
14
+ private _render;
15
+ createMermaid(): string;
16
+ }
@@ -1,7 +1,6 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
-
3
2
  export class MermaidFlowchartDirective extends BaseCustomWebComponentConstructorAppend {
4
- static override readonly style = css`
3
+ static style = css `
5
4
  :host {
6
5
  background: #fffbe6;
7
6
  border: 1px solid #d6b656;
@@ -15,44 +14,33 @@ export class MermaidFlowchartDirective extends BaseCustomWebComponentConstructor
15
14
  white-space: nowrap;
16
15
  }
17
16
  `;
18
-
19
- static override readonly template = html`<span id="text"></span>`;
20
-
21
- static readonly is = "mermaid-flowchart-directive";
22
-
23
- public line: string = "";
24
-
25
- private _text: HTMLSpanElement;
26
-
27
- static readonly properties = {
17
+ static template = html `<span id="text"></span>`;
18
+ static is = "mermaid-flowchart-directive";
19
+ line = "";
20
+ _text;
21
+ static properties = {
28
22
  line: String,
29
- }
30
-
23
+ };
31
24
  constructor() {
32
25
  super();
33
26
  this._restoreCachedInititalValues();
34
- this._text = this._getDomElement<HTMLSpanElement>("text");
27
+ this._text = this._getDomElement("text");
35
28
  }
36
-
37
29
  async ready() {
38
30
  this._parseAttributesToProperties();
39
31
  this._render();
40
32
  }
41
-
42
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
33
+ attributeChangedCallback(name, oldValue, newValue) {
43
34
  if (oldValue !== newValue) {
44
35
  this._parseAttributesToProperties();
45
36
  this._render();
46
37
  }
47
38
  }
48
-
49
- private _render() {
39
+ _render() {
50
40
  this._text.textContent = this.getAttribute("line") ?? this.line;
51
41
  }
52
-
53
- public createMermaid() {
42
+ createMermaid() {
54
43
  return this.getAttribute("line") ?? this.line;
55
44
  }
56
45
  }
57
-
58
46
  customElements.define(MermaidFlowchartDirective.is, MermaidFlowchartDirective);
@@ -0,0 +1,37 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ declare enum MermaidMindmapNodeShape {
3
+ default = "default",
4
+ square = "square",
5
+ round = "round",
6
+ circle = "circle",
7
+ bang = "bang",
8
+ cloud = "cloud",
9
+ hexagon = "hexagon"
10
+ }
11
+ export declare class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend {
12
+ static readonly style: CSSStyleSheet;
13
+ static readonly template: HTMLTemplateElement;
14
+ static readonly is = "mermaid-mindmap-node";
15
+ mindmapId: string;
16
+ label: string;
17
+ shape: MermaidMindmapNodeShape;
18
+ private _node;
19
+ private _connections;
20
+ private _slot;
21
+ private _childObserver;
22
+ private _resizeObserver;
23
+ static readonly properties: {
24
+ mindmapId: StringConstructor;
25
+ label: StringConstructor;
26
+ shape: typeof MermaidMindmapNodeShape;
27
+ };
28
+ constructor();
29
+ ready(): Promise<void>;
30
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
31
+ private _render;
32
+ private _observeChildren;
33
+ private _renderConnections;
34
+ private _getMindmapChildren;
35
+ createMermaid(): string;
36
+ }
37
+ export {};
@@ -1,18 +1,17 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
2
  import { formatMermaidLabel, renderMarkdownLabel, sanitizeId } from "./mermaid-node.js";
3
-
4
- enum MermaidMindmapNodeShape {
5
- default = "default",
6
- square = "square",
7
- round = "round",
8
- circle = "circle",
9
- bang = "bang",
10
- cloud = "cloud",
11
- hexagon = "hexagon",
12
- }
13
-
3
+ var MermaidMindmapNodeShape;
4
+ (function (MermaidMindmapNodeShape) {
5
+ MermaidMindmapNodeShape["default"] = "default";
6
+ MermaidMindmapNodeShape["square"] = "square";
7
+ MermaidMindmapNodeShape["round"] = "round";
8
+ MermaidMindmapNodeShape["circle"] = "circle";
9
+ MermaidMindmapNodeShape["bang"] = "bang";
10
+ MermaidMindmapNodeShape["cloud"] = "cloud";
11
+ MermaidMindmapNodeShape["hexagon"] = "hexagon";
12
+ })(MermaidMindmapNodeShape || (MermaidMindmapNodeShape = {}));
14
13
  export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend {
15
- static override readonly style = css`
14
+ static style = css `
16
15
  * {
17
16
  box-sizing: border-box;
18
17
  }
@@ -81,35 +80,28 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
81
80
  padding: 8px 22px;
82
81
  }
83
82
  `;
84
-
85
- static override readonly template = html`<svg id="connections"></svg><div id="node"></div><slot id="children"></slot>`;
86
-
87
- static readonly is = "mermaid-mindmap-node";
88
-
89
- public mindmapId: string = "Root";
90
- public label: string = "Node";
91
- public shape: MermaidMindmapNodeShape = MermaidMindmapNodeShape.default;
92
-
93
- private _node: HTMLDivElement;
94
- private _connections: SVGSVGElement;
95
- private _slot: HTMLSlotElement;
96
- private _childObserver = new MutationObserver(() => this._renderConnections());
97
- private _resizeObserver = new ResizeObserver(() => this._renderConnections());
98
-
99
- static readonly properties = {
83
+ static template = html `<svg id="connections"></svg><div id="node"></div><slot id="children"></slot>`;
84
+ static is = "mermaid-mindmap-node";
85
+ mindmapId = "Root";
86
+ label = "Node";
87
+ shape = MermaidMindmapNodeShape.default;
88
+ _node;
89
+ _connections;
90
+ _slot;
91
+ _childObserver = new MutationObserver(() => this._renderConnections());
92
+ _resizeObserver = new ResizeObserver(() => this._renderConnections());
93
+ static properties = {
100
94
  mindmapId: String,
101
95
  label: String,
102
96
  shape: MermaidMindmapNodeShape,
103
- }
104
-
97
+ };
105
98
  constructor() {
106
99
  super();
107
100
  this._restoreCachedInititalValues();
108
- this._node = this._getDomElement<HTMLDivElement>("node");
109
- this._connections = this._getDomElement<SVGSVGElement>("connections");
110
- this._slot = this._getDomElement<HTMLSlotElement>("children");
101
+ this._node = this._getDomElement("node");
102
+ this._connections = this._getDomElement("connections");
103
+ this._slot = this._getDomElement("children");
111
104
  }
112
-
113
105
  async ready() {
114
106
  this._parseAttributesToProperties();
115
107
  this._render();
@@ -118,23 +110,20 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
118
110
  this._observeChildren();
119
111
  requestAnimationFrame(() => this._renderConnections());
120
112
  }
121
-
122
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
113
+ attributeChangedCallback(name, oldValue, newValue) {
123
114
  if (oldValue !== newValue) {
124
115
  this._parseAttributesToProperties();
125
116
  this._render();
126
117
  }
127
118
  }
128
-
129
- private _render() {
119
+ _render() {
130
120
  const label = this.getAttribute("label") ?? this.label ?? this.getAttribute("mindmap-id") ?? this.mindmapId;
131
- const shape = this.getAttribute("shape") as MermaidMindmapNodeShape ?? this.shape;
121
+ const shape = this.getAttribute("shape") ?? this.shape;
132
122
  renderMarkdownLabel(this._node, label);
133
123
  this._node.dataset.shape = shape;
134
124
  this._renderConnections();
135
125
  }
136
-
137
- private _observeChildren() {
126
+ _observeChildren() {
138
127
  this._childObserver.disconnect();
139
128
  this._resizeObserver.disconnect();
140
129
  this._resizeObserver.observe(this);
@@ -144,18 +133,15 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
144
133
  }
145
134
  this._renderConnections();
146
135
  }
147
-
148
- private _renderConnections() {
136
+ _renderConnections() {
149
137
  this._connections.replaceChildren();
150
138
  const children = this._getMindmapChildren();
151
139
  if (!children.length)
152
140
  return;
153
-
154
141
  const hostWidth = this.offsetWidth;
155
142
  const hostHeight = this.offsetHeight;
156
143
  const source = { x: hostWidth / 2, y: hostHeight / 2 };
157
144
  const strokeWidth = getConnectionStrokeWidth(this);
158
-
159
145
  for (const child of children) {
160
146
  const childLeft = Number.parseFloat(child.style.left || "0");
161
147
  const childTop = Number.parseFloat(child.style.top || "0");
@@ -175,16 +161,13 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
175
161
  this._connections.appendChild(path);
176
162
  }
177
163
  }
178
-
179
- private _getMindmapChildren() {
180
- return this._slot.assignedElements().filter((element): element is MermaidMindmapNode => element.localName === MermaidMindmapNode.is);
164
+ _getMindmapChildren() {
165
+ return this._slot.assignedElements().filter((element) => element.localName === MermaidMindmapNode.is);
181
166
  }
182
-
183
- public createMermaid() {
167
+ createMermaid() {
184
168
  const id = sanitizeId(this.getAttribute("mindmap-id") ?? this.mindmapId);
185
169
  const label = formatMermaidLabel((this.getAttribute("label") ?? this.label) || id);
186
- const shape = this.getAttribute("shape") as MermaidMindmapNodeShape ?? this.shape;
187
-
170
+ const shape = this.getAttribute("shape") ?? this.shape;
188
171
  switch (shape) {
189
172
  case MermaidMindmapNodeShape.square:
190
173
  return `${id}[${label}]`;
@@ -203,10 +186,8 @@ export class MermaidMindmapNode extends BaseCustomWebComponentConstructorAppend
203
186
  }
204
187
  }
205
188
  }
206
-
207
189
  customElements.define(MermaidMindmapNode.is, MermaidMindmapNode);
208
-
209
- function getConnectionStrokeWidth(element: Element) {
190
+ function getConnectionStrokeWidth(element) {
210
191
  let depth = 0;
211
192
  let current = element.parentElement;
212
193
  while (current) {
@@ -0,0 +1,75 @@
1
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
2
+ declare enum MermaidNodeShape {
3
+ rectangle = "rectangle",
4
+ round = "round",
5
+ stadium = "stadium",
6
+ circle = "circle",
7
+ decision = "decision",
8
+ subroutine = "subroutine",
9
+ cylinder = "cylinder",
10
+ asymmetric = "asymmetric",
11
+ hexagon = "hexagon",
12
+ parallelogram = "parallelogram",
13
+ parallelogramAlt = "parallelogramAlt",
14
+ trapezoid = "trapezoid",
15
+ trapezoidAlt = "trapezoidAlt",
16
+ doubleCircle = "doubleCircle",
17
+ bang = "bang",
18
+ cloud = "cloud",
19
+ hourglass = "hourglass",
20
+ bolt = "bolt",
21
+ brace = "brace",
22
+ braceRight = "brace-r",
23
+ braces = "braces",
24
+ dataStore = "datastore",
25
+ delay = "delay",
26
+ horizontalCylinder = "h-cyl",
27
+ linedCylinder = "lin-cyl",
28
+ curvedTrapezoid = "curv-trap",
29
+ dividedRectangle = "div-rect",
30
+ document = "doc",
31
+ triangle = "tri",
32
+ fork = "fork",
33
+ windowPane = "win-pane",
34
+ filledCircle = "f-circ",
35
+ linedDocument = "lin-doc",
36
+ linedRectangle = "lin-rect",
37
+ notchedPentagon = "notch-pent",
38
+ flippedTriangle = "flip-tri",
39
+ slopedRectangle = "sl-rect",
40
+ stackedDocument = "docs",
41
+ stackedRectangle = "st-rect",
42
+ flag = "flag",
43
+ bowTieRectangle = "bow-rect",
44
+ framedCircle = "fr-circ",
45
+ crossedCircle = "cross-circ",
46
+ taggedDocument = "tag-doc",
47
+ taggedRectangle = "tag-rect",
48
+ text = "text",
49
+ card = "notch-rect"
50
+ }
51
+ export declare class MermaidNode extends BaseCustomWebComponentConstructorAppend {
52
+ static readonly style: CSSStyleSheet;
53
+ static readonly template: HTMLTemplateElement;
54
+ static readonly is = "mermaid-node";
55
+ nodeId: string;
56
+ label: string;
57
+ shape: MermaidNodeShape;
58
+ private _node;
59
+ static readonly properties: {
60
+ nodeId: StringConstructor;
61
+ label: StringConstructor;
62
+ shape: typeof MermaidNodeShape;
63
+ };
64
+ constructor();
65
+ ready(): Promise<void>;
66
+ private _render;
67
+ createMermaid(): string;
68
+ }
69
+ export declare function sanitizeId(id: string): string;
70
+ export declare function escapeLabel(label: string): string;
71
+ export declare function formatMermaidLabel(label: string): string;
72
+ export declare function stripMarkdownLabel(label: string): string;
73
+ export declare function renderMarkdownLabel(container: HTMLElement | SVGTextElement, label: string): void;
74
+ export declare function normalizeLabelLineBreaks(label: string): string;
75
+ export {};