@zukhruf/diagram 0.3.32 → 0.3.33
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/dist/lib/layouts/graph/attach.d.ts +25 -0
- package/dist/lib/layouts/graph/attach.d.ts.map +1 -0
- package/dist/lib/layouts/graph/attach.js +216 -0
- package/dist/lib/layouts/graph/attach.js.map +1 -0
- package/dist/lib/layouts/graph/connections.d.ts +38 -0
- package/dist/lib/layouts/graph/connections.d.ts.map +1 -0
- package/dist/lib/layouts/graph/connections.js +112 -0
- package/dist/lib/layouts/graph/connections.js.map +1 -0
- package/dist/lib/layouts/graph/graph-layout-result.d.ts +1 -1
- package/dist/lib/layouts/graph/graph-layout-result.d.ts.map +1 -1
- package/dist/lib/layouts/graph/graph-layout-result.js.map +1 -1
- package/dist/lib/layouts/graph/gutters.js +5 -5
- package/dist/lib/layouts/graph/gutters.js.map +1 -1
- package/dist/lib/layouts/graph/labels.d.ts +16 -0
- package/dist/lib/layouts/graph/labels.d.ts.map +1 -0
- package/dist/lib/layouts/graph/labels.js +76 -0
- package/dist/lib/layouts/graph/labels.js.map +1 -0
- package/dist/lib/layouts/graph/layout.d.ts.map +1 -1
- package/dist/lib/layouts/graph/layout.js +31 -9
- package/dist/lib/layouts/graph/layout.js.map +1 -1
- package/dist/lib/layouts/graph/measure.d.ts +7 -6
- package/dist/lib/layouts/graph/measure.d.ts.map +1 -1
- package/dist/lib/layouts/graph/measure.js +35 -29
- package/dist/lib/layouts/graph/measure.js.map +1 -1
- package/dist/lib/layouts/graph/min-heap.d.ts +12 -0
- package/dist/lib/layouts/graph/min-heap.d.ts.map +1 -0
- package/dist/lib/layouts/graph/min-heap.js +60 -0
- package/dist/lib/layouts/graph/min-heap.js.map +1 -0
- package/dist/lib/layouts/graph/node-content.d.ts +1 -2
- package/dist/lib/layouts/graph/node-content.d.ts.map +1 -1
- package/dist/lib/layouts/graph/node-content.js +43 -42
- package/dist/lib/layouts/graph/node-content.js.map +1 -1
- package/dist/lib/layouts/graph/path.d.ts +14 -0
- package/dist/lib/layouts/graph/path.d.ts.map +1 -0
- package/dist/lib/layouts/graph/path.js +55 -0
- package/dist/lib/layouts/graph/path.js.map +1 -0
- package/dist/lib/layouts/graph/route-search.d.ts +34 -0
- package/dist/lib/layouts/graph/route-search.d.ts.map +1 -0
- package/dist/lib/layouts/graph/route-search.js +208 -0
- package/dist/lib/layouts/graph/route-search.js.map +1 -0
- package/dist/lib/layouts/graph/route.d.ts +16 -0
- package/dist/lib/layouts/graph/route.d.ts.map +1 -0
- package/dist/lib/layouts/graph/route.js +241 -0
- package/dist/lib/layouts/graph/route.js.map +1 -0
- package/dist/lib/layouts/graph/sides.d.ts +23 -0
- package/dist/lib/layouts/graph/sides.d.ts.map +1 -0
- package/dist/lib/layouts/graph/sides.js +91 -0
- package/dist/lib/layouts/graph/sides.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export const OPPOSITE = {
|
|
2
|
+
top: 'bottom',
|
|
3
|
+
bottom: 'top',
|
|
4
|
+
left: 'right',
|
|
5
|
+
right: 'left'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/** The heading of a line that leaves a box through `side`. */
|
|
9
|
+
export const OUTWARD = {
|
|
10
|
+
right: 0,
|
|
11
|
+
left: 1,
|
|
12
|
+
bottom: 2,
|
|
13
|
+
top: 3
|
|
14
|
+
};
|
|
15
|
+
export function isVertical(side) {
|
|
16
|
+
return side === 'top' || side === 'bottom';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The sides a connection leaves and enters by, read from the cells: areas
|
|
21
|
+
* that share rows face left and right, areas that share columns face top
|
|
22
|
+
* and bottom, and otherwise the axis with the larger cell delta wins, the
|
|
23
|
+
* vertical one on a tie.
|
|
24
|
+
*/
|
|
25
|
+
export function facingSides(from, to) {
|
|
26
|
+
const shareRows = Math.max(from.row, to.row) < Math.min(from.row + from.rowSpan, to.row + to.rowSpan);
|
|
27
|
+
const shareCols = Math.max(from.col, to.col) < Math.min(from.col + from.colSpan, to.col + to.colSpan);
|
|
28
|
+
const dr = to.row + to.rowSpan / 2 - (from.row + from.rowSpan / 2);
|
|
29
|
+
const dc = to.col + to.colSpan / 2 - (from.col + from.colSpan / 2);
|
|
30
|
+
const horizontal = shareRows !== shareCols ? shareRows : Math.abs(dc) > Math.abs(dr);
|
|
31
|
+
if (horizontal) return dc > 0 ? ['right', 'left'] : ['left', 'right'];
|
|
32
|
+
return dr >= 0 ? ['bottom', 'top'] : ['top', 'bottom'];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The coordinate of the side's line: x for left and right, y for top and bottom. */
|
|
36
|
+
export function sideLine(box, side) {
|
|
37
|
+
switch (side) {
|
|
38
|
+
case 'top':
|
|
39
|
+
return box.y;
|
|
40
|
+
case 'bottom':
|
|
41
|
+
return box.y + box.h;
|
|
42
|
+
case 'left':
|
|
43
|
+
return box.x;
|
|
44
|
+
case 'right':
|
|
45
|
+
return box.x + box.w;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Where the side runs along its line: [start, end] in x for top and bottom, in y for left and right. */
|
|
50
|
+
export function sideSpan(box, side) {
|
|
51
|
+
return isVertical(side) ? [box.x, box.x + box.w] : [box.y, box.y + box.h];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The point on `side` of `box` at `along` on the side's span. */
|
|
55
|
+
export function pointOnSide(box, side, along) {
|
|
56
|
+
const line = sideLine(box, side);
|
|
57
|
+
return isVertical(side) ? {
|
|
58
|
+
x: along,
|
|
59
|
+
y: line
|
|
60
|
+
} : {
|
|
61
|
+
x: line,
|
|
62
|
+
y: along
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The point `distance` beyond `point` out of `side`. */
|
|
67
|
+
export function beyond(point, side, distance) {
|
|
68
|
+
switch (side) {
|
|
69
|
+
case 'top':
|
|
70
|
+
return {
|
|
71
|
+
x: point.x,
|
|
72
|
+
y: point.y - distance
|
|
73
|
+
};
|
|
74
|
+
case 'bottom':
|
|
75
|
+
return {
|
|
76
|
+
x: point.x,
|
|
77
|
+
y: point.y + distance
|
|
78
|
+
};
|
|
79
|
+
case 'left':
|
|
80
|
+
return {
|
|
81
|
+
x: point.x - distance,
|
|
82
|
+
y: point.y
|
|
83
|
+
};
|
|
84
|
+
case 'right':
|
|
85
|
+
return {
|
|
86
|
+
x: point.x + distance,
|
|
87
|
+
y: point.y
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=sides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sides.js","names":["OPPOSITE","top","bottom","left","right","OUTWARD","isVertical","side","facingSides","from","to","shareRows","Math","max","row","min","rowSpan","shareCols","col","colSpan","dr","dc","horizontal","abs","sideLine","box","y","h","x","w","sideSpan","pointOnSide","along","line","beyond","point","distance"],"sources":["../../../../src/lib/layouts/graph/sides.ts"],"sourcesContent":["import type { Box, DiagramSide, Point } from '../../model/diagram-ir.ts';\nimport type { CellArea } from './areas.ts';\nimport type { Heading } from './route-search.ts';\n\nexport const OPPOSITE: Record<DiagramSide, DiagramSide> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n};\n\n/** The heading of a line that leaves a box through `side`. */\nexport const OUTWARD: Record<DiagramSide, Heading> = {\n right: 0,\n left: 1,\n bottom: 2,\n top: 3,\n};\n\nexport function isVertical(side: DiagramSide): boolean {\n return side === 'top' || side === 'bottom';\n}\n\n/**\n * The sides a connection leaves and enters by, read from the cells: areas\n * that share rows face left and right, areas that share columns face top\n * and bottom, and otherwise the axis with the larger cell delta wins, the\n * vertical one on a tie.\n */\nexport function facingSides(\n from: CellArea,\n to: CellArea,\n): [DiagramSide, DiagramSide] {\n const shareRows =\n Math.max(from.row, to.row) <\n Math.min(from.row + from.rowSpan, to.row + to.rowSpan);\n const shareCols =\n Math.max(from.col, to.col) <\n Math.min(from.col + from.colSpan, to.col + to.colSpan);\n const dr = to.row + to.rowSpan / 2 - (from.row + from.rowSpan / 2);\n const dc = to.col + to.colSpan / 2 - (from.col + from.colSpan / 2);\n const horizontal =\n shareRows !== shareCols ? shareRows : Math.abs(dc) > Math.abs(dr);\n if (horizontal) return dc > 0 ? ['right', 'left'] : ['left', 'right'];\n return dr >= 0 ? ['bottom', 'top'] : ['top', 'bottom'];\n}\n\n/** The coordinate of the side's line: x for left and right, y for top and bottom. */\nexport function sideLine(box: Box, side: DiagramSide): number {\n switch (side) {\n case 'top':\n return box.y;\n case 'bottom':\n return box.y + box.h;\n case 'left':\n return box.x;\n case 'right':\n return box.x + box.w;\n }\n}\n\n/** Where the side runs along its line: [start, end] in x for top and bottom, in y for left and right. */\nexport function sideSpan(box: Box, side: DiagramSide): [number, number] {\n return isVertical(side) ? [box.x, box.x + box.w] : [box.y, box.y + box.h];\n}\n\n/** The point on `side` of `box` at `along` on the side's span. */\nexport function pointOnSide(box: Box, side: DiagramSide, along: number): Point {\n const line = sideLine(box, side);\n return isVertical(side) ? { x: along, y: line } : { x: line, y: along };\n}\n\n/** The point `distance` beyond `point` out of `side`. */\nexport function beyond(\n point: Point,\n side: DiagramSide,\n distance: number,\n): Point {\n switch (side) {\n case 'top':\n return { x: point.x, y: point.y - distance };\n case 'bottom':\n return { x: point.x, y: point.y + distance };\n case 'left':\n return { x: point.x - distance, y: point.y };\n case 'right':\n return { x: point.x + distance, y: point.y };\n }\n}\n"],"mappings":"AAIA,OAAO,MAAMA,QAA0C,GAAG;EACxDC,GAAG,EAAE,QAAQ;EACbC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE,OAAO;EACbC,KAAK,EAAE;AACT,CAAC;;AAED;AACA,OAAO,MAAMC,OAAqC,GAAG;EACnDD,KAAK,EAAE,CAAC;EACRD,IAAI,EAAE,CAAC;EACPD,MAAM,EAAE,CAAC;EACTD,GAAG,EAAE;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AC;QAAEF,CAAC,EAAES,KAAK,CAACT,CAAC,GAAGU;MAAS,CAAC;IAC9C,KAAK,QAAQ;MACX,OAAO;QAAER,CAAC,EAAEO,KAAK,CAACP,CAAC;QAAEF,CAAC,EAAES,KAAK,CAACT,CAAC,GAAGU;MAAS,CAAC;IAC9C,KAAK,MAAM;MACT,OAAO;QAAER,CAAC,EAAEO,KAAK,CAACP,CAAC,GAAGQ,QAAQ;QAAEV,CAAC,EAAES,KAAK,CAACT;MAAE,CAAC;IAC9C,KAAK,OAAO;MACV,OAAO;QAAEE,CAAC,EAAEO,KAAK,CAACP,CAAC,GAAGQ,QAAQ;QAAEV,CAAC,EAAES,KAAK,CAACT;MAAE,CAAC;EAChD;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/diagram",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.33",
|
|
4
4
|
"description": "Architecture and sequence diagrams as React components: declare nodes, edges, lanes and signals, and render them as SVG, HTML or canvas.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|