@cardenelabs/cdl 0.21.0 → 0.21.2
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/CHANGELOG.md +37 -1
- package/dist/index.cjs +70 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +70 -29
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +70 -29
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +70 -29
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/kinds/generic.tsx +24 -17
- package/src/layout/collisions.ts +72 -10
- package/src/layout/spec.ts +31 -0
package/dist/react.js
CHANGED
|
@@ -846,6 +846,18 @@ function \u4E2D\u8EAB\u304B\u3089\u51FA\u3059\u9AD8\u3055(kind, \u6E80\u8F09h, \
|
|
|
846
846
|
return Math.max(MIN_BOX_H, \u6E80\u8F09h - \u5F15\u304F);
|
|
847
847
|
}
|
|
848
848
|
var MIN_BOX_H = 44;
|
|
849
|
+
var CLOUD_CIRCLES = [
|
|
850
|
+
{ cx: -0.8, cy: -0.05 + 0.08, r: 0.32 },
|
|
851
|
+
{ cx: -0.4, cy: -0.05 - 0.05, r: 0.4 },
|
|
852
|
+
{ cx: 0, cy: -0.05 - 0.1, r: 0.46 },
|
|
853
|
+
{ cx: 0.4, cy: -0.05 - 0.05, r: 0.4 },
|
|
854
|
+
{ cx: 0.8, cy: -0.05 + 0.08, r: 0.32 }
|
|
855
|
+
];
|
|
856
|
+
var CLOUD_ART_CENTER_RISE = (() => {
|
|
857
|
+
const \u4E0A = Math.min(...CLOUD_CIRCLES.map((c) => c.cy - c.r));
|
|
858
|
+
const \u4E0B = Math.max(...CLOUD_CIRCLES.map((c) => c.cy + c.r));
|
|
859
|
+
return -(\u4E0A + \u4E0B) / 2;
|
|
860
|
+
})();
|
|
849
861
|
|
|
850
862
|
// src/layout/footer-shape.ts
|
|
851
863
|
var SHAPE_DRAW_UP_EXTENT = {
|
|
@@ -1754,8 +1766,12 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
|
|
|
1754
1766
|
for (const { p } of ordered) {
|
|
1755
1767
|
const axis = p.axis;
|
|
1756
1768
|
if (!pathShiftIsSafe(e.id, axis, p.sign, amount)) continue;
|
|
1769
|
+
const \u52D5\u304B\u3057\u305F\u5F8C = measurePathLabelGapSegs(
|
|
1770
|
+
simulateShiftedSegments(e, axis === "x" ? p.sign * amount : 0, axis === "y" ? p.sign * amount : 0),
|
|
1771
|
+
label
|
|
1772
|
+
);
|
|
1757
1773
|
out.push({ target: { kind: "edge-path", id: e.id }, axis, sign: p.sign, amount });
|
|
1758
|
-
\u7DDA\u3092\u52D5\u304B\u305B\u305F =
|
|
1774
|
+
\u7DDA\u3092\u52D5\u304B\u305B\u305F = \u52D5\u304B\u3057\u305F\u5F8C > gap;
|
|
1759
1775
|
break;
|
|
1760
1776
|
}
|
|
1761
1777
|
if (!\u7DDA\u3092\u52D5\u304B\u305B\u305F) {
|
|
@@ -1778,16 +1794,49 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
|
|
|
1778
1794
|
if (\u8FD1\u3044\u70B9) {
|
|
1779
1795
|
const dx = \u82AF.x - \u8FD1\u3044\u70B9.x;
|
|
1780
1796
|
const dy = \u82AF.y - \u8FD1\u3044\u70B9.y;
|
|
1781
|
-
const
|
|
1782
|
-
const \
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
axis,
|
|
1787
|
-
sign
|
|
1788
|
-
|
|
1789
|
-
|
|
1797
|
+
const \u91CF = pathLabelClearance - gap + NEAR_MISS_MARGIN;
|
|
1798
|
+
const \u5019\u88DC = Math.abs(dx) >= Math.abs(dy) ? [
|
|
1799
|
+
{ axis: "x", sign: dx >= 0 ? 1 : -1 },
|
|
1800
|
+
{ axis: "y", sign: dy >= 0 ? 1 : -1 }
|
|
1801
|
+
] : [
|
|
1802
|
+
{ axis: "y", sign: dy >= 0 ? 1 : -1 },
|
|
1803
|
+
{ axis: "x", sign: dx >= 0 ? 1 : -1 }
|
|
1804
|
+
];
|
|
1805
|
+
const \u52D5\u304B\u3057\u305F\u7BB1 = (axis, sign) => ({
|
|
1806
|
+
...label,
|
|
1807
|
+
x: label.x + (axis === "x" ? sign * \u91CF : 0),
|
|
1808
|
+
y: label.y + (axis === "y" ? sign * \u91CF : 0)
|
|
1790
1809
|
});
|
|
1810
|
+
const \u7DDA\u3054\u3068\u306E\u8DDD\u96E2 = (\u7BB1) => {
|
|
1811
|
+
const \u51FA = /* @__PURE__ */ new Map();
|
|
1812
|
+
for (const \u4ED6 of edges) {
|
|
1813
|
+
if (\u4ED6.id === label.id) continue;
|
|
1814
|
+
const segs2 = segmentsExcludingOwnPath(shiftedSegments(\u4ED6.id, \u4ED6.d), ownSegsOf(label.id));
|
|
1815
|
+
if (segs2.length === 0) continue;
|
|
1816
|
+
\u51FA.set(\u4ED6.id, measurePathLabelGapSegs(segs2, \u7BB1));
|
|
1817
|
+
}
|
|
1818
|
+
return \u51FA;
|
|
1819
|
+
};
|
|
1820
|
+
const \u3044\u307E\u306E\u8DDD\u96E2 = \u7DDA\u3054\u3068\u306E\u8DDD\u96E2(label);
|
|
1821
|
+
const \u60AA\u304F\u3059\u308B = (\u7BB1) => {
|
|
1822
|
+
const \u5F8C = \u7DDA\u3054\u3068\u306E\u8DDD\u96E2(\u7BB1);
|
|
1823
|
+
for (const [id, \u524D\u306E\u5024] of \u3044\u307E\u306E\u8DDD\u96E2) {
|
|
1824
|
+
const \u5F8C\u306E\u5024 = \u5F8C.get(id) ?? Infinity;
|
|
1825
|
+
if (\u5F8C\u306E\u5024 < Math.min(\u524D\u306E\u5024, pathLabelClearance)) return true;
|
|
1826
|
+
}
|
|
1827
|
+
return false;
|
|
1828
|
+
};
|
|
1829
|
+
for (const \u5019 of \u5019\u88DC) {
|
|
1830
|
+
if (\u60AA\u304F\u3059\u308B(\u52D5\u304B\u3057\u305F\u7BB1(\u5019.axis, \u5019.sign))) continue;
|
|
1831
|
+
out.push({
|
|
1832
|
+
target: { kind: "label", id: label.id },
|
|
1833
|
+
axis: \u5019.axis,
|
|
1834
|
+
sign: \u5019.sign,
|
|
1835
|
+
amount: \u91CF,
|
|
1836
|
+
chain: false
|
|
1837
|
+
});
|
|
1838
|
+
break;
|
|
1839
|
+
}
|
|
1791
1840
|
}
|
|
1792
1841
|
}
|
|
1793
1842
|
}
|
|
@@ -6816,21 +6865,12 @@ function GenericNode({
|
|
|
6816
6865
|
if (shape === "cloud") {
|
|
6817
6866
|
const cx = w / 2;
|
|
6818
6867
|
const cy = h / 2;
|
|
6819
|
-
const
|
|
6820
|
-
const
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
{ cx: cx - halfW * 0.4, cy: cloudCenterY - h * 0.05, r: h * 0.4 },
|
|
6826
|
-
// 左
|
|
6827
|
-
{ cx, cy: cloudCenterY - h * 0.1, r: h * 0.46 },
|
|
6828
|
-
// 中央 (最大)
|
|
6829
|
-
{ cx: cx + halfW * 0.4, cy: cloudCenterY - h * 0.05, r: h * 0.4 },
|
|
6830
|
-
// 右
|
|
6831
|
-
{ cx: cx + halfW * 0.8, cy: cloudCenterY + h * 0.08, r: h * 0.32 }
|
|
6832
|
-
// 右端
|
|
6833
|
-
];
|
|
6868
|
+
const halfW = w * 0.85 / 2;
|
|
6869
|
+
const circles = CLOUD_CIRCLES.map((c) => ({
|
|
6870
|
+
cx: cx + halfW * c.cx,
|
|
6871
|
+
cy: cy + h * c.cy,
|
|
6872
|
+
r: h * c.r
|
|
6873
|
+
}));
|
|
6834
6874
|
return /* @__PURE__ */ jsxs("g", { children: [
|
|
6835
6875
|
circles.map((c, i) => /* @__PURE__ */ jsx("circle", { cx: c.cx, cy: c.cy, r: c.r, fill: "var(--cdl-node-fill, #ffffff)" }, `fill-${i}`)),
|
|
6836
6876
|
circles.map((c, i) => /* @__PURE__ */ jsx(
|
|
@@ -6869,11 +6909,12 @@ function GenericNode({
|
|
|
6869
6909
|
const textX = centered ? w / 2 : 20;
|
|
6870
6910
|
const cylinderShift = genericTextShift(node.kind);
|
|
6871
6911
|
const \u7E70\u308A\u4E0A\u3052 = node.eyebrow || centered ? 0 : \u76EE\u5370\u306A\u3057\u306E\u7E70\u308A\u4E0A\u3052(node.kind, hasRows);
|
|
6872
|
-
const
|
|
6873
|
-
const
|
|
6874
|
-
const
|
|
6912
|
+
const \u7D75\u306E\u82AF = centered && STYLES[node.kind]?.shape === "cloud" ? h * CLOUD_ART_CENTER_RISE : 0;
|
|
6913
|
+
const eyebrowY = centered ? h / 2 - 26 - \u7D75\u306E\u82AF : 32 + cylinderShift;
|
|
6914
|
+
const titleY = genericTitleBaselineY(node.kind, h, hasRows) - \u7E70\u308A\u4E0A\u3052 - \u7D75\u306E\u82AF;
|
|
6915
|
+
const subtitleY = centered ? h / 2 + 28 - \u7D75\u306E\u82AF : 96 + cylinderShift - \u7E70\u308A\u4E0A\u3052;
|
|
6875
6916
|
const iconX = centered ? w / 2 + 40 : w - 48;
|
|
6876
|
-
const iconY = centered ? h / 2 - 44 : 18 + cylinderShift;
|
|
6917
|
+
const iconY = centered ? h / 2 - 44 - \u7D75\u306E\u82AF : 18 + cylinderShift;
|
|
6877
6918
|
const dominantBaseline = centered ? "middle" : void 0;
|
|
6878
6919
|
return /* @__PURE__ */ jsxs("g", { transform: `translate(${x} ${y})`, "data-cdl-role": "node-body", children: [
|
|
6879
6920
|
shapeEl,
|