@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.
- package/{src/index.ts → dist/index.d.ts} +0 -3
- package/dist/index.js +17 -0
- package/dist/monaco/MermaidLanguage.d.ts +1 -0
- package/{src/monaco/MermaidLanguage.ts → dist/monaco/MermaidLanguage.js} +1 -4
- package/dist/services/MermaidConnectionRouting.d.ts +2 -0
- package/{src/services/MermaidConnectionRouting.ts → dist/services/MermaidConnectionRouting.js} +25 -46
- package/dist/services/MermaidDocumentPropertiesService.d.ts +24 -0
- package/{src/services/MermaidDocumentPropertiesService.ts → dist/services/MermaidDocumentPropertiesService.js} +25 -54
- package/dist/services/MermaidElementsService.d.ts +23 -0
- package/{src/services/MermaidElementsService.ts → dist/services/MermaidElementsService.js} +35 -36
- package/dist/services/MermaidLayoutCopyPasteService.d.ts +5 -0
- package/{src/services/MermaidLayoutCopyPasteService.ts → dist/services/MermaidLayoutCopyPasteService.js} +4 -6
- package/dist/services/MermaidLayoutPlacementService.d.ts +8 -0
- package/{src/services/MermaidLayoutPlacementService.ts → dist/services/MermaidLayoutPlacementService.js} +6 -11
- package/dist/services/MermaidParserService.d.ts +7 -0
- package/{src/services/MermaidParserService.ts → dist/services/MermaidParserService.js} +441 -707
- package/dist/services/MermaidPropertyGroupsService.d.ts +8 -0
- package/{src/services/MermaidPropertyGroupsService.ts → dist/services/MermaidPropertyGroupsService.js} +2 -7
- package/dist/services/mermaidGeometry.d.ts +31 -0
- package/{src/services/mermaidGeometry.ts → dist/services/mermaidGeometry.js} +13 -43
- package/dist/setupMermaidServiceContainer.d.ts +2 -0
- package/{src/setupMermaidServiceContainer.ts → dist/setupMermaidServiceContainer.js} +27 -36
- package/dist/toolbar/ConnectMermaidNodesTool.d.ts +20 -0
- package/{src/toolbar/ConnectMermaidNodesTool.ts → dist/toolbar/ConnectMermaidNodesTool.js} +26 -58
- package/dist/widgets/mermaid-edge.d.ts +46 -0
- package/{src/widgets/mermaid-edge.ts → dist/widgets/mermaid-edge.js} +63 -61
- package/dist/widgets/mermaid-flowchart-directive.d.ts +16 -0
- package/{src/widgets/mermaid-flowchart-directive.ts → dist/widgets/mermaid-flowchart-directive.js} +11 -23
- package/dist/widgets/mermaid-mindmap-node.d.ts +37 -0
- package/{src/widgets/mermaid-mindmap-node.ts → dist/widgets/mermaid-mindmap-node.js} +36 -55
- package/dist/widgets/mermaid-node.d.ts +75 -0
- package/{src/widgets/mermaid-node.ts → dist/widgets/mermaid-node.js} +78 -105
- package/dist/widgets/mermaid-requirement-node.d.ts +37 -0
- package/{src/widgets/mermaid-requirement-node.ts → dist/widgets/mermaid-requirement-node.js} +30 -49
- package/dist/widgets/mermaid-requirement-relationship.d.ts +28 -0
- package/{src/widgets/mermaid-requirement-relationship.ts → dist/widgets/mermaid-requirement-relationship.js} +21 -38
- package/dist/widgets/mermaid-sequence-message.d.ts +34 -0
- package/{src/widgets/mermaid-sequence-message.ts → dist/widgets/mermaid-sequence-message.js} +30 -44
- package/dist/widgets/mermaid-sequence-participant.d.ts +24 -0
- package/{src/widgets/mermaid-sequence-participant.ts → dist/widgets/mermaid-sequence-participant.js} +17 -28
- package/dist/widgets/mermaid-subgraph.d.ts +20 -0
- package/{src/widgets/mermaid-subgraph.ts → dist/widgets/mermaid-subgraph.js} +13 -25
- package/dist/widgets/views/mermaid-demo-view.d.ts +11 -0
- package/{src/widgets/views/mermaid-demo-view.ts → dist/widgets/views/mermaid-demo-view.js} +8 -18
- package/package.json +7 -2
- package/tsconfig.json +0 -20
- /package/{src → dist}/widgets/elements.json +0 -0
|
@@ -1,57 +1,56 @@
|
|
|
1
1
|
import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
rectangle = "rectangle"
|
|
5
|
-
round = "round"
|
|
6
|
-
stadium = "stadium"
|
|
7
|
-
circle = "circle"
|
|
8
|
-
decision = "decision"
|
|
9
|
-
subroutine = "subroutine"
|
|
10
|
-
cylinder = "cylinder"
|
|
11
|
-
asymmetric = "asymmetric"
|
|
12
|
-
hexagon = "hexagon"
|
|
13
|
-
parallelogram = "parallelogram"
|
|
14
|
-
parallelogramAlt = "parallelogramAlt"
|
|
15
|
-
trapezoid = "trapezoid"
|
|
16
|
-
trapezoidAlt = "trapezoidAlt"
|
|
17
|
-
doubleCircle = "doubleCircle"
|
|
18
|
-
bang = "bang"
|
|
19
|
-
cloud = "cloud"
|
|
20
|
-
hourglass = "hourglass"
|
|
21
|
-
bolt = "bolt"
|
|
22
|
-
brace = "brace"
|
|
23
|
-
braceRight = "brace-r"
|
|
24
|
-
braces = "braces"
|
|
25
|
-
dataStore = "datastore"
|
|
26
|
-
delay = "delay"
|
|
27
|
-
horizontalCylinder = "h-cyl"
|
|
28
|
-
linedCylinder = "lin-cyl"
|
|
29
|
-
curvedTrapezoid = "curv-trap"
|
|
30
|
-
dividedRectangle = "div-rect"
|
|
31
|
-
document = "doc"
|
|
32
|
-
triangle = "tri"
|
|
33
|
-
fork = "fork"
|
|
34
|
-
windowPane = "win-pane"
|
|
35
|
-
filledCircle = "f-circ"
|
|
36
|
-
linedDocument = "lin-doc"
|
|
37
|
-
linedRectangle = "lin-rect"
|
|
38
|
-
notchedPentagon = "notch-pent"
|
|
39
|
-
flippedTriangle = "flip-tri"
|
|
40
|
-
slopedRectangle = "sl-rect"
|
|
41
|
-
stackedDocument = "docs"
|
|
42
|
-
stackedRectangle = "st-rect"
|
|
43
|
-
flag = "flag"
|
|
44
|
-
bowTieRectangle = "bow-rect"
|
|
45
|
-
framedCircle = "fr-circ"
|
|
46
|
-
crossedCircle = "cross-circ"
|
|
47
|
-
taggedDocument = "tag-doc"
|
|
48
|
-
taggedRectangle = "tag-rect"
|
|
49
|
-
text = "text"
|
|
50
|
-
card = "notch-rect"
|
|
51
|
-
}
|
|
52
|
-
|
|
2
|
+
var MermaidNodeShape;
|
|
3
|
+
(function (MermaidNodeShape) {
|
|
4
|
+
MermaidNodeShape["rectangle"] = "rectangle";
|
|
5
|
+
MermaidNodeShape["round"] = "round";
|
|
6
|
+
MermaidNodeShape["stadium"] = "stadium";
|
|
7
|
+
MermaidNodeShape["circle"] = "circle";
|
|
8
|
+
MermaidNodeShape["decision"] = "decision";
|
|
9
|
+
MermaidNodeShape["subroutine"] = "subroutine";
|
|
10
|
+
MermaidNodeShape["cylinder"] = "cylinder";
|
|
11
|
+
MermaidNodeShape["asymmetric"] = "asymmetric";
|
|
12
|
+
MermaidNodeShape["hexagon"] = "hexagon";
|
|
13
|
+
MermaidNodeShape["parallelogram"] = "parallelogram";
|
|
14
|
+
MermaidNodeShape["parallelogramAlt"] = "parallelogramAlt";
|
|
15
|
+
MermaidNodeShape["trapezoid"] = "trapezoid";
|
|
16
|
+
MermaidNodeShape["trapezoidAlt"] = "trapezoidAlt";
|
|
17
|
+
MermaidNodeShape["doubleCircle"] = "doubleCircle";
|
|
18
|
+
MermaidNodeShape["bang"] = "bang";
|
|
19
|
+
MermaidNodeShape["cloud"] = "cloud";
|
|
20
|
+
MermaidNodeShape["hourglass"] = "hourglass";
|
|
21
|
+
MermaidNodeShape["bolt"] = "bolt";
|
|
22
|
+
MermaidNodeShape["brace"] = "brace";
|
|
23
|
+
MermaidNodeShape["braceRight"] = "brace-r";
|
|
24
|
+
MermaidNodeShape["braces"] = "braces";
|
|
25
|
+
MermaidNodeShape["dataStore"] = "datastore";
|
|
26
|
+
MermaidNodeShape["delay"] = "delay";
|
|
27
|
+
MermaidNodeShape["horizontalCylinder"] = "h-cyl";
|
|
28
|
+
MermaidNodeShape["linedCylinder"] = "lin-cyl";
|
|
29
|
+
MermaidNodeShape["curvedTrapezoid"] = "curv-trap";
|
|
30
|
+
MermaidNodeShape["dividedRectangle"] = "div-rect";
|
|
31
|
+
MermaidNodeShape["document"] = "doc";
|
|
32
|
+
MermaidNodeShape["triangle"] = "tri";
|
|
33
|
+
MermaidNodeShape["fork"] = "fork";
|
|
34
|
+
MermaidNodeShape["windowPane"] = "win-pane";
|
|
35
|
+
MermaidNodeShape["filledCircle"] = "f-circ";
|
|
36
|
+
MermaidNodeShape["linedDocument"] = "lin-doc";
|
|
37
|
+
MermaidNodeShape["linedRectangle"] = "lin-rect";
|
|
38
|
+
MermaidNodeShape["notchedPentagon"] = "notch-pent";
|
|
39
|
+
MermaidNodeShape["flippedTriangle"] = "flip-tri";
|
|
40
|
+
MermaidNodeShape["slopedRectangle"] = "sl-rect";
|
|
41
|
+
MermaidNodeShape["stackedDocument"] = "docs";
|
|
42
|
+
MermaidNodeShape["stackedRectangle"] = "st-rect";
|
|
43
|
+
MermaidNodeShape["flag"] = "flag";
|
|
44
|
+
MermaidNodeShape["bowTieRectangle"] = "bow-rect";
|
|
45
|
+
MermaidNodeShape["framedCircle"] = "fr-circ";
|
|
46
|
+
MermaidNodeShape["crossedCircle"] = "cross-circ";
|
|
47
|
+
MermaidNodeShape["taggedDocument"] = "tag-doc";
|
|
48
|
+
MermaidNodeShape["taggedRectangle"] = "tag-rect";
|
|
49
|
+
MermaidNodeShape["text"] = "text";
|
|
50
|
+
MermaidNodeShape["card"] = "notch-rect";
|
|
51
|
+
})(MermaidNodeShape || (MermaidNodeShape = {}));
|
|
53
52
|
export class MermaidNode extends BaseCustomWebComponentConstructorAppend {
|
|
54
|
-
static
|
|
53
|
+
static style = css `
|
|
55
54
|
* {
|
|
56
55
|
box-sizing: border-box;
|
|
57
56
|
}
|
|
@@ -255,38 +254,30 @@ export class MermaidNode extends BaseCustomWebComponentConstructorAppend {
|
|
|
255
254
|
border-color: transparent;
|
|
256
255
|
}
|
|
257
256
|
`;
|
|
258
|
-
|
|
259
|
-
static
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
public shape: MermaidNodeShape = MermaidNodeShape.rectangle;
|
|
266
|
-
|
|
267
|
-
private _node: HTMLDivElement;
|
|
268
|
-
|
|
269
|
-
static readonly properties = {
|
|
257
|
+
static template = html `<div id="node"></div>`;
|
|
258
|
+
static is = "mermaid-node";
|
|
259
|
+
nodeId = "A";
|
|
260
|
+
label = "Node";
|
|
261
|
+
shape = MermaidNodeShape.rectangle;
|
|
262
|
+
_node;
|
|
263
|
+
static properties = {
|
|
270
264
|
nodeId: String,
|
|
271
265
|
label: String,
|
|
272
266
|
shape: MermaidNodeShape,
|
|
273
|
-
}
|
|
274
|
-
|
|
267
|
+
};
|
|
275
268
|
constructor() {
|
|
276
269
|
super();
|
|
277
270
|
this._restoreCachedInititalValues();
|
|
278
|
-
this._node = this._getDomElement
|
|
271
|
+
this._node = this._getDomElement("node");
|
|
279
272
|
}
|
|
280
|
-
|
|
281
273
|
async ready() {
|
|
282
274
|
this._parseAttributesToProperties();
|
|
283
275
|
this._render();
|
|
284
276
|
}
|
|
285
|
-
|
|
286
|
-
private _render() {
|
|
277
|
+
_render() {
|
|
287
278
|
const label = this.getAttribute("label") ?? this.label;
|
|
288
279
|
const nodeId = this.getAttribute("node-id") ?? this.nodeId;
|
|
289
|
-
const shape = this.getAttribute("shape")
|
|
280
|
+
const shape = this.getAttribute("shape") ?? this.shape;
|
|
290
281
|
renderMarkdownLabel(this._node, label || nodeId);
|
|
291
282
|
this._node.dataset.shape = shape;
|
|
292
283
|
this._node.style.clipPath = "";
|
|
@@ -315,12 +306,10 @@ export class MermaidNode extends BaseCustomWebComponentConstructorAppend {
|
|
|
315
306
|
break;
|
|
316
307
|
}
|
|
317
308
|
}
|
|
318
|
-
|
|
319
|
-
public createMermaid() {
|
|
309
|
+
createMermaid() {
|
|
320
310
|
const id = sanitizeId(this.getAttribute("node-id") ?? this.nodeId);
|
|
321
311
|
const label = formatMermaidLabel((this.getAttribute("label") ?? this.label) || id);
|
|
322
|
-
const shape = this.getAttribute("shape")
|
|
323
|
-
|
|
312
|
+
const shape = this.getAttribute("shape") ?? this.shape;
|
|
324
313
|
switch (shape) {
|
|
325
314
|
case MermaidNodeShape.round:
|
|
326
315
|
return `${id}(${label})`;
|
|
@@ -355,31 +344,25 @@ export class MermaidNode extends BaseCustomWebComponentConstructorAppend {
|
|
|
355
344
|
}
|
|
356
345
|
}
|
|
357
346
|
}
|
|
358
|
-
|
|
359
|
-
function isExpandedShape(shape: string) {
|
|
347
|
+
function isExpandedShape(shape) {
|
|
360
348
|
return !!shape && shape !== MermaidNodeShape.rectangle;
|
|
361
349
|
}
|
|
362
|
-
|
|
363
|
-
export function sanitizeId(id: string) {
|
|
350
|
+
export function sanitizeId(id) {
|
|
364
351
|
return (id || "A").replace(/[^a-zA-Z0-9_]/g, "_");
|
|
365
352
|
}
|
|
366
|
-
|
|
367
|
-
export function escapeLabel(label: string) {
|
|
353
|
+
export function escapeLabel(label) {
|
|
368
354
|
return (label || "").replaceAll("\"", "#quot;");
|
|
369
355
|
}
|
|
370
|
-
|
|
371
|
-
export function formatMermaidLabel(label: string) {
|
|
356
|
+
export function formatMermaidLabel(label) {
|
|
372
357
|
const escaped = escapeLabel(label);
|
|
373
358
|
if (shouldWriteMarkdownLabel(escaped))
|
|
374
359
|
return "\"`" + escaped + "`\"";
|
|
375
360
|
return escaped.includes("`") ? `"${escaped}"` : escaped;
|
|
376
361
|
}
|
|
377
|
-
|
|
378
|
-
export function stripMarkdownLabel(label: string) {
|
|
362
|
+
export function stripMarkdownLabel(label) {
|
|
379
363
|
return normalizeLabelLineBreaks((label || "").replace(/^`|`$/g, ""));
|
|
380
364
|
}
|
|
381
|
-
|
|
382
|
-
export function renderMarkdownLabel(container: HTMLElement | SVGTextElement, label: string) {
|
|
365
|
+
export function renderMarkdownLabel(container, label) {
|
|
383
366
|
container.replaceChildren();
|
|
384
367
|
const normalizedLabel = stripMarkdownLabel(label);
|
|
385
368
|
const lines = splitMarkdownLines(normalizedLabel);
|
|
@@ -389,8 +372,7 @@ export function renderMarkdownLabel(container: HTMLElement | SVGTextElement, lab
|
|
|
389
372
|
renderInlineMarkdown(container, lines[i]);
|
|
390
373
|
}
|
|
391
374
|
}
|
|
392
|
-
|
|
393
|
-
function renderInlineMarkdown(container: Element, text: string) {
|
|
375
|
+
function renderInlineMarkdown(container, text) {
|
|
394
376
|
let position = 0;
|
|
395
377
|
while (position < text.length) {
|
|
396
378
|
const nextDelimiter = findNextMarkdownDelimiter(text, position);
|
|
@@ -398,27 +380,23 @@ function renderInlineMarkdown(container: Element, text: string) {
|
|
|
398
380
|
appendText(container, text.substring(position));
|
|
399
381
|
return;
|
|
400
382
|
}
|
|
401
|
-
|
|
402
383
|
if (nextDelimiter.index > position)
|
|
403
384
|
appendText(container, text.substring(position, nextDelimiter.index));
|
|
404
|
-
|
|
405
385
|
const end = text.indexOf(nextDelimiter.token, nextDelimiter.index + nextDelimiter.token.length);
|
|
406
386
|
if (end < 0) {
|
|
407
387
|
appendText(container, text.substring(nextDelimiter.index, nextDelimiter.index + nextDelimiter.token.length));
|
|
408
388
|
position = nextDelimiter.index + nextDelimiter.token.length;
|
|
409
389
|
continue;
|
|
410
390
|
}
|
|
411
|
-
|
|
412
391
|
const element = document.createElement(nextDelimiter.token.length === 2 ? "strong" : "em");
|
|
413
392
|
renderInlineMarkdown(element, text.substring(nextDelimiter.index + nextDelimiter.token.length, end));
|
|
414
393
|
container.appendChild(element);
|
|
415
394
|
position = end + nextDelimiter.token.length;
|
|
416
395
|
}
|
|
417
396
|
}
|
|
418
|
-
|
|
419
|
-
function findNextMarkdownDelimiter(text: string, start: number) {
|
|
397
|
+
function findNextMarkdownDelimiter(text, start) {
|
|
420
398
|
const tokens = ["**", "__", "*", "_"];
|
|
421
|
-
let result
|
|
399
|
+
let result = null;
|
|
422
400
|
for (const token of tokens) {
|
|
423
401
|
const index = text.indexOf(token, start);
|
|
424
402
|
if (index >= 0 && (!result || index < result.index || (index === result.index && token.length > result.token.length)))
|
|
@@ -426,14 +404,12 @@ function findNextMarkdownDelimiter(text: string, start: number) {
|
|
|
426
404
|
}
|
|
427
405
|
return result;
|
|
428
406
|
}
|
|
429
|
-
|
|
430
|
-
function appendText(container: Element, text: string) {
|
|
407
|
+
function appendText(container, text) {
|
|
431
408
|
if (text)
|
|
432
409
|
container.appendChild(document.createTextNode(text));
|
|
433
410
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
const lines: string[] = [];
|
|
411
|
+
function splitMarkdownLines(text) {
|
|
412
|
+
const lines = [];
|
|
437
413
|
let start = 0;
|
|
438
414
|
for (let i = 0; i < text.length; i++) {
|
|
439
415
|
if (text[i] === "\n") {
|
|
@@ -444,13 +420,10 @@ function splitMarkdownLines(text: string) {
|
|
|
444
420
|
lines.push(text.substring(start));
|
|
445
421
|
return lines;
|
|
446
422
|
}
|
|
447
|
-
|
|
448
|
-
function shouldWriteMarkdownLabel(label: string) {
|
|
423
|
+
function shouldWriteMarkdownLabel(label) {
|
|
449
424
|
return label.includes("\n") || label.includes("**") || label.includes("_") || label.includes("*");
|
|
450
425
|
}
|
|
451
|
-
|
|
452
|
-
export function normalizeLabelLineBreaks(label: string) {
|
|
426
|
+
export function normalizeLabelLineBreaks(label) {
|
|
453
427
|
return label.replaceAll("<br>", "\n").replaceAll("<br/>", "\n").replaceAll("<br />", "\n");
|
|
454
428
|
}
|
|
455
|
-
|
|
456
429
|
customElements.define(MermaidNode.is, MermaidNode);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
type RequirementNodeKind = "requirement" | "element";
|
|
3
|
+
export declare class MermaidRequirementNode extends BaseCustomWebComponentConstructorAppend {
|
|
4
|
+
static readonly style: CSSStyleSheet;
|
|
5
|
+
static readonly template: HTMLTemplateElement;
|
|
6
|
+
static readonly is = "mermaid-requirement-node";
|
|
7
|
+
nodeKind: RequirementNodeKind;
|
|
8
|
+
requirementType: string;
|
|
9
|
+
requirementId: string;
|
|
10
|
+
label: string;
|
|
11
|
+
text: string;
|
|
12
|
+
risk: string;
|
|
13
|
+
verifyMethod: string;
|
|
14
|
+
elementType: string;
|
|
15
|
+
docRef: string;
|
|
16
|
+
private _body;
|
|
17
|
+
private _name;
|
|
18
|
+
private _stereotype;
|
|
19
|
+
static readonly properties: {
|
|
20
|
+
nodeKind: StringConstructor;
|
|
21
|
+
requirementType: StringConstructor;
|
|
22
|
+
requirementId: StringConstructor;
|
|
23
|
+
label: StringConstructor;
|
|
24
|
+
text: StringConstructor;
|
|
25
|
+
risk: StringConstructor;
|
|
26
|
+
verifyMethod: StringConstructor;
|
|
27
|
+
elementType: StringConstructor;
|
|
28
|
+
docRef: StringConstructor;
|
|
29
|
+
};
|
|
30
|
+
constructor();
|
|
31
|
+
ready(): Promise<void>;
|
|
32
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
33
|
+
private _render;
|
|
34
|
+
private _appendRow;
|
|
35
|
+
createMermaid(): string;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
package/{src/widgets/mermaid-requirement-node.ts → dist/widgets/mermaid-requirement-node.js}
RENAMED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
|
|
2
2
|
import { escapeLabel, renderMarkdownLabel, sanitizeId } from "./mermaid-node.js";
|
|
3
|
-
|
|
4
|
-
type RequirementNodeKind = "requirement" | "element";
|
|
5
|
-
|
|
6
3
|
export class MermaidRequirementNode extends BaseCustomWebComponentConstructorAppend {
|
|
7
|
-
static
|
|
4
|
+
static style = css `
|
|
8
5
|
* {
|
|
9
6
|
box-sizing: border-box;
|
|
10
7
|
}
|
|
@@ -62,31 +59,26 @@ export class MermaidRequirementNode extends BaseCustomWebComponentConstructorApp
|
|
|
62
59
|
white-space: pre-line;
|
|
63
60
|
}
|
|
64
61
|
`;
|
|
65
|
-
|
|
66
|
-
static override readonly template = html`
|
|
62
|
+
static template = html `
|
|
67
63
|
<div id="header">
|
|
68
64
|
<span id="stereotype"></span>
|
|
69
65
|
<div id="name"></div>
|
|
70
66
|
</div>
|
|
71
67
|
<div id="body"></div>`;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
private _name: HTMLDivElement;
|
|
87
|
-
private _stereotype: HTMLSpanElement;
|
|
88
|
-
|
|
89
|
-
static readonly properties = {
|
|
68
|
+
static is = "mermaid-requirement-node";
|
|
69
|
+
nodeKind = "requirement";
|
|
70
|
+
requirementType = "requirement";
|
|
71
|
+
requirementId = "Req";
|
|
72
|
+
label = "Req";
|
|
73
|
+
text = "";
|
|
74
|
+
risk = "low";
|
|
75
|
+
verifyMethod = "test";
|
|
76
|
+
elementType = "";
|
|
77
|
+
docRef = "";
|
|
78
|
+
_body;
|
|
79
|
+
_name;
|
|
80
|
+
_stereotype;
|
|
81
|
+
static properties = {
|
|
90
82
|
nodeKind: String,
|
|
91
83
|
requirementType: String,
|
|
92
84
|
requirementId: String,
|
|
@@ -96,50 +88,44 @@ export class MermaidRequirementNode extends BaseCustomWebComponentConstructorApp
|
|
|
96
88
|
verifyMethod: String,
|
|
97
89
|
elementType: String,
|
|
98
90
|
docRef: String,
|
|
99
|
-
}
|
|
100
|
-
|
|
91
|
+
};
|
|
101
92
|
constructor() {
|
|
102
93
|
super();
|
|
103
94
|
this._restoreCachedInititalValues();
|
|
104
|
-
this._body = this._getDomElement
|
|
105
|
-
this._name = this._getDomElement
|
|
106
|
-
this._stereotype = this._getDomElement
|
|
95
|
+
this._body = this._getDomElement("body");
|
|
96
|
+
this._name = this._getDomElement("name");
|
|
97
|
+
this._stereotype = this._getDomElement("stereotype");
|
|
107
98
|
}
|
|
108
|
-
|
|
109
99
|
async ready() {
|
|
110
100
|
this._parseAttributesToProperties();
|
|
111
101
|
this._render();
|
|
112
102
|
}
|
|
113
|
-
|
|
114
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
103
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
115
104
|
if (oldValue !== newValue) {
|
|
116
105
|
this._parseAttributesToProperties();
|
|
117
106
|
this._render();
|
|
118
107
|
}
|
|
119
108
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const kind = this.getAttribute("node-kind") as RequirementNodeKind ?? this.nodeKind;
|
|
109
|
+
_render() {
|
|
110
|
+
const kind = this.getAttribute("node-kind") ?? this.nodeKind;
|
|
123
111
|
const name = this.getAttribute("label") ?? this.label;
|
|
124
112
|
this._stereotype.textContent = kind === "element" ? "<<Element>>" : "<<" + getRequirementTypeLabel(this.getAttribute("requirement-type") ?? this.requirementType) + ">>";
|
|
125
113
|
renderMarkdownLabel(this._name, name);
|
|
126
114
|
this._body.replaceChildren();
|
|
127
|
-
|
|
128
115
|
if (kind === "element") {
|
|
129
116
|
this._appendRow("Type", this.getAttribute("element-type") ?? this.elementType);
|
|
130
117
|
this._appendRow("DocRef", this.getAttribute("doc-ref") ?? this.docRef);
|
|
131
|
-
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
132
120
|
this._appendRow("Id", this.getAttribute("requirement-id") ?? this.requirementId);
|
|
133
121
|
this._appendRow("Text", this.getAttribute("text") ?? this.text);
|
|
134
122
|
this._appendRow("Risk", this.getAttribute("risk") ?? this.risk);
|
|
135
123
|
this._appendRow("Verification", this.getAttribute("verify-method") ?? this.verifyMethod);
|
|
136
124
|
}
|
|
137
125
|
}
|
|
138
|
-
|
|
139
|
-
private _appendRow(label: string, value: string) {
|
|
126
|
+
_appendRow(label, value) {
|
|
140
127
|
if (!value)
|
|
141
128
|
return;
|
|
142
|
-
|
|
143
129
|
const row = document.createElement("div");
|
|
144
130
|
row.className = "row";
|
|
145
131
|
const labelElement = document.createElement("span");
|
|
@@ -151,9 +137,8 @@ export class MermaidRequirementNode extends BaseCustomWebComponentConstructorApp
|
|
|
151
137
|
row.append(labelElement, valueElement);
|
|
152
138
|
this._body.appendChild(row);
|
|
153
139
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const kind = this.getAttribute("node-kind") as RequirementNodeKind ?? this.nodeKind;
|
|
140
|
+
createMermaid() {
|
|
141
|
+
const kind = this.getAttribute("node-kind") ?? this.nodeKind;
|
|
157
142
|
const name = sanitizeId(this.getAttribute("label") ?? this.label);
|
|
158
143
|
if (kind === "element") {
|
|
159
144
|
const lines = [`element ${name} {`];
|
|
@@ -166,7 +151,6 @@ export class MermaidRequirementNode extends BaseCustomWebComponentConstructorApp
|
|
|
166
151
|
lines.push("}");
|
|
167
152
|
return lines.join("\n");
|
|
168
153
|
}
|
|
169
|
-
|
|
170
154
|
const requirementType = this.getAttribute("requirement-type") ?? this.requirementType;
|
|
171
155
|
const lines = [`${requirementType} ${name} {`];
|
|
172
156
|
lines.push("id: " + formatRequirementValue(this.getAttribute("requirement-id") ?? this.requirementId));
|
|
@@ -177,10 +161,8 @@ export class MermaidRequirementNode extends BaseCustomWebComponentConstructorApp
|
|
|
177
161
|
return lines.join("\n");
|
|
178
162
|
}
|
|
179
163
|
}
|
|
180
|
-
|
|
181
164
|
customElements.define(MermaidRequirementNode.is, MermaidRequirementNode);
|
|
182
|
-
|
|
183
|
-
function getRequirementTypeLabel(type: string) {
|
|
165
|
+
function getRequirementTypeLabel(type) {
|
|
184
166
|
switch (type) {
|
|
185
167
|
case "functionalRequirement":
|
|
186
168
|
return "Functional Requirement";
|
|
@@ -196,7 +178,6 @@ function getRequirementTypeLabel(type: string) {
|
|
|
196
178
|
return "Requirement";
|
|
197
179
|
}
|
|
198
180
|
}
|
|
199
|
-
|
|
200
|
-
function formatRequirementValue(value: string) {
|
|
181
|
+
function formatRequirementValue(value) {
|
|
201
182
|
return escapeLabel(value ?? "");
|
|
202
183
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
export declare class MermaidRequirementRelationship extends BaseCustomWebComponentConstructorAppend {
|
|
3
|
+
static readonly style: CSSStyleSheet;
|
|
4
|
+
static readonly template: HTMLTemplateElement;
|
|
5
|
+
static readonly is = "mermaid-requirement-relationship";
|
|
6
|
+
from: string;
|
|
7
|
+
to: string;
|
|
8
|
+
relationshipType: string;
|
|
9
|
+
syntaxDirection: string;
|
|
10
|
+
waypoints: string;
|
|
11
|
+
private _previewWaypoints;
|
|
12
|
+
private _label;
|
|
13
|
+
private _path;
|
|
14
|
+
private _svg;
|
|
15
|
+
static readonly properties: {
|
|
16
|
+
from: StringConstructor;
|
|
17
|
+
to: StringConstructor;
|
|
18
|
+
relationshipType: StringConstructor;
|
|
19
|
+
syntaxDirection: StringConstructor;
|
|
20
|
+
waypoints: StringConstructor;
|
|
21
|
+
};
|
|
22
|
+
constructor();
|
|
23
|
+
ready(): Promise<void>;
|
|
24
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
25
|
+
setPreviewWaypoints(waypoints: string | null): void;
|
|
26
|
+
private _render;
|
|
27
|
+
createMermaid(): string;
|
|
28
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
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 { sanitizeId } from "./mermaid-node.js";
|
|
4
|
-
|
|
5
4
|
export class MermaidRequirementRelationship extends BaseCustomWebComponentConstructorAppend {
|
|
6
|
-
static
|
|
5
|
+
static style = css `
|
|
7
6
|
:host {
|
|
8
7
|
display: block;
|
|
9
8
|
overflow: visible;
|
|
@@ -38,8 +37,7 @@ export class MermaidRequirementRelationship extends BaseCustomWebComponentConstr
|
|
|
38
37
|
pointer-events: none;
|
|
39
38
|
}
|
|
40
39
|
`;
|
|
41
|
-
|
|
42
|
-
static override readonly template = html`
|
|
40
|
+
static template = html `
|
|
43
41
|
<svg id="svg" viewBox="0 0 10 10" preserveAspectRatio="none">
|
|
44
42
|
<defs>
|
|
45
43
|
<marker id="marker" viewBox="0 0 12 12" markerWidth="10" markerHeight="10" refX="10.5" refY="6" orient="auto" markerUnits="userSpaceOnUse">
|
|
@@ -49,74 +47,61 @@ export class MermaidRequirementRelationship extends BaseCustomWebComponentConstr
|
|
|
49
47
|
<path id="path" marker-end="url(#marker)"></path>
|
|
50
48
|
<text id="label"></text>
|
|
51
49
|
</svg>`;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
private _path: SVGPathElement;
|
|
64
|
-
private _svg: SVGSVGElement;
|
|
65
|
-
|
|
66
|
-
static readonly properties = {
|
|
50
|
+
static is = "mermaid-requirement-relationship";
|
|
51
|
+
from = "source";
|
|
52
|
+
to = "target";
|
|
53
|
+
relationshipType = "satisfies";
|
|
54
|
+
syntaxDirection = "forward";
|
|
55
|
+
waypoints = "";
|
|
56
|
+
_previewWaypoints;
|
|
57
|
+
_label;
|
|
58
|
+
_path;
|
|
59
|
+
_svg;
|
|
60
|
+
static properties = {
|
|
67
61
|
from: String,
|
|
68
62
|
to: String,
|
|
69
63
|
relationshipType: String,
|
|
70
64
|
syntaxDirection: String,
|
|
71
65
|
waypoints: String,
|
|
72
|
-
}
|
|
73
|
-
|
|
66
|
+
};
|
|
74
67
|
constructor() {
|
|
75
68
|
super();
|
|
76
69
|
this._restoreCachedInititalValues();
|
|
77
|
-
this._label = this._getDomElement
|
|
78
|
-
this._path = this._getDomElement
|
|
79
|
-
this._svg = this._getDomElement
|
|
70
|
+
this._label = this._getDomElement("label");
|
|
71
|
+
this._path = this._getDomElement("path");
|
|
72
|
+
this._svg = this._getDomElement("svg");
|
|
80
73
|
}
|
|
81
|
-
|
|
82
74
|
async ready() {
|
|
83
75
|
this._parseAttributesToProperties();
|
|
84
76
|
this._render();
|
|
85
77
|
}
|
|
86
|
-
|
|
87
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
78
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
88
79
|
if (oldValue !== newValue) {
|
|
89
80
|
this._parseAttributesToProperties();
|
|
90
81
|
this._render();
|
|
91
82
|
}
|
|
92
83
|
}
|
|
93
|
-
|
|
94
|
-
public setPreviewWaypoints(waypoints: string | null) {
|
|
84
|
+
setPreviewWaypoints(waypoints) {
|
|
95
85
|
this._previewWaypoints = waypoints;
|
|
96
86
|
this._render();
|
|
97
87
|
}
|
|
98
|
-
|
|
99
|
-
private _render() {
|
|
88
|
+
_render() {
|
|
100
89
|
let waypoints = decodeWaypoints(this._previewWaypoints ?? this.getAttribute("waypoints") ?? this.waypoints);
|
|
101
90
|
if (waypoints.length < 2)
|
|
102
91
|
waypoints = [{ x: 0, y: 12 }, { x: 180, y: 12 }];
|
|
103
|
-
|
|
104
92
|
const padding = 16;
|
|
105
93
|
const bounds = boundsFromWaypoints(waypoints);
|
|
106
94
|
const width = Math.max(24, Math.round(bounds.width + padding * 2));
|
|
107
95
|
const height = Math.max(24, Math.round(bounds.height + padding * 2));
|
|
108
96
|
const offsetX = (width - bounds.width) / 2;
|
|
109
97
|
const offsetY = (height - bounds.height) / 2;
|
|
110
|
-
|
|
111
98
|
this.style.left = `${Math.round(bounds.x - offsetX)}px`;
|
|
112
99
|
this.style.top = `${Math.round(bounds.y - offsetY)}px`;
|
|
113
100
|
this.style.width = `${width}px`;
|
|
114
101
|
this.style.height = `${height}px`;
|
|
115
|
-
|
|
116
102
|
const shifted = waypoints.map(point => ({ x: point.x - bounds.x + offsetX, y: point.y - bounds.y + offsetY }));
|
|
117
103
|
const middle = midpointFromWaypoints(shifted);
|
|
118
104
|
const relationshipType = this.getAttribute("relationship-type") ?? this.relationshipType;
|
|
119
|
-
|
|
120
105
|
this._svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
121
106
|
this._path.setAttribute("d", pathDataFromWaypoints(shifted));
|
|
122
107
|
this._label.textContent = relationshipType;
|
|
@@ -124,8 +109,7 @@ export class MermaidRequirementRelationship extends BaseCustomWebComponentConstr
|
|
|
124
109
|
this._label.setAttribute("y", (middle.y - 8).toString());
|
|
125
110
|
this._label.setAttribute("text-anchor", "middle");
|
|
126
111
|
}
|
|
127
|
-
|
|
128
|
-
public createMermaid() {
|
|
112
|
+
createMermaid() {
|
|
129
113
|
const from = sanitizeId(this.getAttribute("from") ?? this.from);
|
|
130
114
|
const to = sanitizeId(this.getAttribute("to") ?? this.to);
|
|
131
115
|
const relationshipType = this.getAttribute("relationship-type") ?? this.relationshipType;
|
|
@@ -135,5 +119,4 @@ export class MermaidRequirementRelationship extends BaseCustomWebComponentConstr
|
|
|
135
119
|
return `${from} - ${relationshipType} -> ${to}`;
|
|
136
120
|
}
|
|
137
121
|
}
|
|
138
|
-
|
|
139
122
|
customElements.define(MermaidRequirementRelationship.is, MermaidRequirementRelationship);
|