@cardenelabs/cdl 0.23.0 → 0.24.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/CHANGELOG.md +60 -1
- package/dist/index.cjs +109 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +109 -62
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +105 -62
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +105 -62
- package/dist/react.js.map +1 -1
- package/dist/{render-Czv0tUon.d.cts → render-CfXUl0Yz.d.cts} +18 -1
- package/dist/{render-Czv0tUon.d.ts → render-CfXUl0Yz.d.ts} +18 -1
- package/package.json +1 -1
- package/src/builder.ts +7 -0
- package/src/kinds/generic.tsx +92 -14
- package/src/presets.ts +7 -1
- package/src/render/edges.tsx +42 -17
- package/src/types.ts +18 -0
package/dist/react.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export {
|
|
2
|
+
export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-CfXUl0Yz.cjs';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export {
|
|
2
|
+
export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-CfXUl0Yz.js';
|
package/dist/react.js
CHANGED
|
@@ -9487,6 +9487,12 @@ function edgeHeadPaint(head, fill, color) {
|
|
|
9487
9487
|
}
|
|
9488
9488
|
return { fill: color, stroke: "none" };
|
|
9489
9489
|
}
|
|
9490
|
+
function defaultEdgeWidth(active) {
|
|
9491
|
+
return active ? 2.5 : 1.25;
|
|
9492
|
+
}
|
|
9493
|
+
function edgeColor(edge) {
|
|
9494
|
+
return edge.role === "main" ? "var(--cdl-now, #c0421f)" : toneColor(edge.tone);
|
|
9495
|
+
}
|
|
9490
9496
|
function opacityAttr(opacity) {
|
|
9491
9497
|
return opacity < 1 ? opacity : void 0;
|
|
9492
9498
|
}
|
|
@@ -9500,7 +9506,7 @@ function CdlEdgeView({
|
|
|
9500
9506
|
progress,
|
|
9501
9507
|
stateValues
|
|
9502
9508
|
}) {
|
|
9503
|
-
const color =
|
|
9509
|
+
const color = edgeColor(edge);
|
|
9504
9510
|
const \u7AEF\u306E\u540D\u524D = (h, f) => {
|
|
9505
9511
|
const \u5F62 = h ?? EDGE_HEAD_DEFAULT;
|
|
9506
9512
|
if (\u5F62 === "none") return void 0;
|
|
@@ -9590,7 +9596,7 @@ function SolidEdgePath({
|
|
|
9590
9596
|
stateValues
|
|
9591
9597
|
}) {
|
|
9592
9598
|
const visibleD = drawing ? pathSubpath(edge.d, progress) : edge.d;
|
|
9593
|
-
const defaultWidth = active
|
|
9599
|
+
const defaultWidth = defaultEdgeWidth(active);
|
|
9594
9600
|
const boundWidth = edge.widthBind && stateValues ? resolveNumericAttr(edge.widthBind, stateValues, defaultWidth) : defaultWidth;
|
|
9595
9601
|
const boundStroke = edge.strokeBind && stateValues ? interpolate(edge.strokeBind, stateValues) : color;
|
|
9596
9602
|
const boundDashOffset = edge.dashOffsetBind && stateValues ? resolveNumericAttr(edge.dashOffsetBind, stateValues, 0) : void 0;
|
|
@@ -9667,7 +9673,7 @@ function CdlEdgeGlowView({
|
|
|
9667
9673
|
active
|
|
9668
9674
|
}) {
|
|
9669
9675
|
if (!active) return null;
|
|
9670
|
-
const color =
|
|
9676
|
+
const color = edgeColor(edge);
|
|
9671
9677
|
return /* @__PURE__ */ jsx(EdgeGlowCircles, { color, edgeId: edge.id });
|
|
9672
9678
|
}
|
|
9673
9679
|
function CdlEdgeLabelView({
|
|
@@ -9675,7 +9681,7 @@ function CdlEdgeLabelView({
|
|
|
9675
9681
|
active
|
|
9676
9682
|
}) {
|
|
9677
9683
|
if (!hasRenderedLabel(edge)) return null;
|
|
9678
|
-
const color =
|
|
9684
|
+
const color = edgeColor(edge);
|
|
9679
9685
|
const bbox = computeLabelBBoxWorld(edge);
|
|
9680
9686
|
const boxW = bbox.w;
|
|
9681
9687
|
const boxH = bbox.h;
|
|
@@ -9693,7 +9699,7 @@ function CdlEdgeLabelView({
|
|
|
9693
9699
|
"data-cdl-edge-label-text": edge.label,
|
|
9694
9700
|
"data-cdl-edge-sub-text": edge.sub ?? "",
|
|
9695
9701
|
children: [
|
|
9696
|
-
/* @__PURE__ */ jsx(
|
|
9702
|
+
edge.labelPlate !== false && /* @__PURE__ */ jsx(
|
|
9697
9703
|
"rect",
|
|
9698
9704
|
{
|
|
9699
9705
|
"data-cdl-role": "edge-label-bg",
|
|
@@ -10413,9 +10419,29 @@ function StorageNode({
|
|
|
10413
10419
|
})
|
|
10414
10420
|
] });
|
|
10415
10421
|
}
|
|
10422
|
+
var TINT_FILL = "color-mix(in srgb, var(--cdl-text, #1a1f2a) 6%, transparent)";
|
|
10423
|
+
function lookPaint(look, accent, active) {
|
|
10424
|
+
const \u65E2\u5B9A\u67A0 = active ? accent : "var(--cdl-divider, #d4d4d8)";
|
|
10425
|
+
const \u65E2\u5B9A\u592A\u3055 = active ? 3 : 1.25;
|
|
10426
|
+
switch (look) {
|
|
10427
|
+
case "outline":
|
|
10428
|
+
return { fill: "none", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: false };
|
|
10429
|
+
case "tint":
|
|
10430
|
+
return { fill: TINT_FILL, stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: false };
|
|
10431
|
+
case "solid":
|
|
10432
|
+
return { fill: "var(--cdl-text, #1a1f2a)", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: true };
|
|
10433
|
+
case "ledger":
|
|
10434
|
+
return { fill: "var(--cdl-node-fill, #ffffff)", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: false };
|
|
10435
|
+
case "dashed":
|
|
10436
|
+
return { fill: "none", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, dash: "6 4", onSolid: false };
|
|
10437
|
+
default:
|
|
10438
|
+
return { fill: "var(--cdl-node-fill, #ffffff)", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: false };
|
|
10439
|
+
}
|
|
10440
|
+
}
|
|
10416
10441
|
var STYLES = {
|
|
10417
10442
|
// 人系
|
|
10418
10443
|
person: {
|
|
10444
|
+
look: "outline",
|
|
10419
10445
|
accent: "var(--cdl-tone-accent, #2d6a8f)",
|
|
10420
10446
|
eyebrowColor: "var(--cdl-tone-accent, #2d6a8f)",
|
|
10421
10447
|
icon: "M12 12c2.2 0 4-1.8 4-4s-1.8-4-4-4-4 1.8-4 4 1.8 4 4 4zm0 2c-2.7 0-8 1.3-8 4v2h16v-2c0-2.7-5.3-4-8-4z"
|
|
@@ -10448,11 +10474,13 @@ var STYLES = {
|
|
|
10448
10474
|
shape: "cylinder"
|
|
10449
10475
|
},
|
|
10450
10476
|
cache: {
|
|
10477
|
+
look: "dashed",
|
|
10451
10478
|
accent: "var(--cdl-tone-warning, #a67a2e)",
|
|
10452
10479
|
eyebrowColor: "var(--cdl-tone-warning, #a67a2e)",
|
|
10453
10480
|
icon: "M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"
|
|
10454
10481
|
},
|
|
10455
10482
|
queue: {
|
|
10483
|
+
look: "ledger",
|
|
10456
10484
|
accent: "var(--cdl-tone-warning, #a67a2e)",
|
|
10457
10485
|
eyebrowColor: "var(--cdl-tone-warning, #a67a2e)",
|
|
10458
10486
|
icon: "M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z"
|
|
@@ -10469,12 +10497,14 @@ var STYLES = {
|
|
|
10469
10497
|
shape: "cloud"
|
|
10470
10498
|
},
|
|
10471
10499
|
cdn: {
|
|
10500
|
+
look: "tint",
|
|
10472
10501
|
accent: "var(--cdl-tone-info, #5a8ec1)",
|
|
10473
10502
|
eyebrowColor: "var(--cdl-tone-info, #5a8ec1)",
|
|
10474
10503
|
icon: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"
|
|
10475
10504
|
},
|
|
10476
10505
|
// アプリ系
|
|
10477
10506
|
service: {
|
|
10507
|
+
look: "solid",
|
|
10478
10508
|
accent: "var(--cdl-tone-teal, #2f8770)",
|
|
10479
10509
|
eyebrowColor: "var(--cdl-tone-teal, #2f8770)",
|
|
10480
10510
|
icon: "M19.43 12.98c.04-.32.07-.64.07-.98 0-.34-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98 0 .33.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"
|
|
@@ -10546,6 +10576,7 @@ function GenericNode({
|
|
|
10546
10576
|
const w = node.w;
|
|
10547
10577
|
const h = node.h;
|
|
10548
10578
|
const shape = style.shape ?? "rect";
|
|
10579
|
+
const paint = lookPaint(style.look, style.accent, active);
|
|
10549
10580
|
const shapeEl = (() => {
|
|
10550
10581
|
if (shape === "cylinder") {
|
|
10551
10582
|
const rx = w / 2;
|
|
@@ -10603,19 +10634,23 @@ function GenericNode({
|
|
|
10603
10634
|
circles.map((c, i) => /* @__PURE__ */ jsx("circle", { cx: c.cx, cy: c.cy, r: c.r - (active ? 1.5 : 0.75), fill: "var(--cdl-node-fill, #ffffff)" }, `mask-${i}`))
|
|
10604
10635
|
] });
|
|
10605
10636
|
}
|
|
10606
|
-
return /* @__PURE__ */
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10637
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10638
|
+
/* @__PURE__ */ jsx(
|
|
10639
|
+
"rect",
|
|
10640
|
+
{
|
|
10641
|
+
x: 0,
|
|
10642
|
+
y: 0,
|
|
10643
|
+
width: w,
|
|
10644
|
+
height: h,
|
|
10645
|
+
rx: 18,
|
|
10646
|
+
fill: paint.fill,
|
|
10647
|
+
stroke: paint.stroke,
|
|
10648
|
+
strokeWidth: paint.strokeWidth,
|
|
10649
|
+
strokeDasharray: paint.dash
|
|
10650
|
+
}
|
|
10651
|
+
),
|
|
10652
|
+
style.look === "ledger" && /* @__PURE__ */ jsx("line", { x1: 1, y1: h - 7, x2: w - 1, y2: h - 7, stroke: paint.stroke, strokeWidth: 1 })
|
|
10653
|
+
] });
|
|
10619
10654
|
})();
|
|
10620
10655
|
const resolvedValue = value !== void 0 ? interpolate(value, stateValues) : void 0;
|
|
10621
10656
|
const hasRows = (node.rows?.length ?? 0) > 0;
|
|
@@ -10638,56 +10673,64 @@ function GenericNode({
|
|
|
10638
10673
|
const iconX = centered ? w / 2 + 40 : w - 48;
|
|
10639
10674
|
const iconY = centered ? h / 2 - 44 - \u7D75\u306E\u82AF : 18 + cylinderShift;
|
|
10640
10675
|
const dominantBaseline = centered ? "middle" : void 0;
|
|
10641
|
-
return /* @__PURE__ */ jsxs(
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
x:
|
|
10654
|
-
y:
|
|
10655
|
-
fontSize:
|
|
10656
|
-
|
|
10657
|
-
textAnchor: "end",
|
|
10658
|
-
fill: "var(--cdl-text, #1a1f2a)",
|
|
10659
|
-
style: { fontFamily: "'JetBrains Mono', monospace" },
|
|
10660
|
-
children: resolvedValue
|
|
10661
|
-
}
|
|
10662
|
-
),
|
|
10663
|
-
node.rows && node.rows.length > 0 && (() => {
|
|
10664
|
-
const resolved = node.rows.map((row) => interpolate(row, stateValues));
|
|
10665
|
-
const splits = resolved.map(splitRow);
|
|
10666
|
-
const leftMaxWidth = splits.reduce(
|
|
10667
|
-
(m, s) => Math.max(m, rowColumnWidth(s.left, GENERIC_ROW_LEFT_SIZE_PX, false)),
|
|
10668
|
-
0
|
|
10669
|
-
);
|
|
10670
|
-
const rightColX = ROW_PAD_X_PX + leftMaxWidth + ROW_COL_GAP_PX;
|
|
10671
|
-
return /* @__PURE__ */ jsx("g", { children: splits.map((s, i) => /* @__PURE__ */ jsxs("g", { transform: `translate(0 ${rowBaselineY(node.kind, i)})`, children: [
|
|
10672
|
-
/* @__PURE__ */ jsx("text", { "data-cdl-role": "node-row", "data-cdl-row-index": i, x: ROW_PAD_X_PX, y: 0, fontSize: 18, fill: "var(--cdl-text-dim, #5a6270)", children: s.left }),
|
|
10673
|
-
/* @__PURE__ */ jsx(
|
|
10676
|
+
return /* @__PURE__ */ jsxs(
|
|
10677
|
+
"g",
|
|
10678
|
+
{
|
|
10679
|
+
transform: `translate(${x} ${y})`,
|
|
10680
|
+
"data-cdl-role": "node-body",
|
|
10681
|
+
"data-cdl-look": style.look,
|
|
10682
|
+
children: [
|
|
10683
|
+
shapeEl,
|
|
10684
|
+
/* @__PURE__ */ jsxs("g", { transform: `translate(${iconX} ${iconY}) scale(1)`, "data-cdl-role": "node-kind-icon", children: [
|
|
10685
|
+
/* @__PURE__ */ jsx("rect", { width: 24, height: 24, fill: "transparent" }),
|
|
10686
|
+
/* @__PURE__ */ jsx("path", { d: style.icon, fill: style.eyebrowColor, opacity: 0.7, transform: "scale(1)" })
|
|
10687
|
+
] }),
|
|
10688
|
+
node.eyebrow && /* @__PURE__ */ jsx("text", { x: textX, y: eyebrowY, fontSize: 17, fontWeight: 700, letterSpacing: 1.5, fill: paint.onSolid ? "var(--cdl-node-fill, #ffffff)" : style.eyebrowColor, textAnchor, dominantBaseline, children: node.eyebrow }),
|
|
10689
|
+
/* @__PURE__ */ jsx("text", { "data-cdl-role": "node-label", x: textX, y: titleY, fontSize: 20, fontWeight: 700, fill: paint.onSolid ? "var(--cdl-node-fill, #ffffff)" : "var(--cdl-text, #1a1f2a)", textAnchor, dominantBaseline, style: node.kind === "function" || node.kind === "api" ? { fontFamily: "'JetBrains Mono', monospace" } : void 0, children: node.title }),
|
|
10690
|
+
node.subtitle && /* @__PURE__ */ jsx("text", { x: textX, y: subtitleY, fontSize: 17, fill: paint.onSolid ? "var(--cdl-node-fill, #ffffff)" : "var(--cdl-text-dim, #5a6270)", textAnchor, dominantBaseline, style: { fontFamily: "'JetBrains Mono', monospace" }, children: node.subtitle }),
|
|
10691
|
+
resolvedValue && /* @__PURE__ */ jsx(
|
|
10674
10692
|
"text",
|
|
10675
10693
|
{
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
y: 0,
|
|
10680
|
-
fontSize: 21,
|
|
10694
|
+
x: w - 20,
|
|
10695
|
+
y: h - 24,
|
|
10696
|
+
fontSize: 32,
|
|
10681
10697
|
fontWeight: 700,
|
|
10682
|
-
textAnchor: "
|
|
10698
|
+
textAnchor: "end",
|
|
10683
10699
|
fill: "var(--cdl-text, #1a1f2a)",
|
|
10684
10700
|
style: { fontFamily: "'JetBrains Mono', monospace" },
|
|
10685
|
-
children:
|
|
10701
|
+
children: resolvedValue
|
|
10686
10702
|
}
|
|
10687
|
-
)
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10703
|
+
),
|
|
10704
|
+
node.rows && node.rows.length > 0 && (() => {
|
|
10705
|
+
const resolved = node.rows.map((row) => interpolate(row, stateValues));
|
|
10706
|
+
const splits = resolved.map(splitRow);
|
|
10707
|
+
const leftMaxWidth = splits.reduce(
|
|
10708
|
+
(m, s) => Math.max(m, rowColumnWidth(s.left, GENERIC_ROW_LEFT_SIZE_PX, false)),
|
|
10709
|
+
0
|
|
10710
|
+
);
|
|
10711
|
+
const rightColX = ROW_PAD_X_PX + leftMaxWidth + ROW_COL_GAP_PX;
|
|
10712
|
+
return /* @__PURE__ */ jsx("g", { children: splits.map((s, i) => /* @__PURE__ */ jsxs("g", { transform: `translate(0 ${rowBaselineY(node.kind, i)})`, children: [
|
|
10713
|
+
/* @__PURE__ */ jsx("text", { "data-cdl-role": "node-row", "data-cdl-row-index": i, x: ROW_PAD_X_PX, y: 0, fontSize: 18, fill: "var(--cdl-text-dim, #5a6270)", children: s.left }),
|
|
10714
|
+
/* @__PURE__ */ jsx(
|
|
10715
|
+
"text",
|
|
10716
|
+
{
|
|
10717
|
+
"data-cdl-role": "node-row",
|
|
10718
|
+
"data-cdl-row-index": i,
|
|
10719
|
+
x: rightColX,
|
|
10720
|
+
y: 0,
|
|
10721
|
+
fontSize: 21,
|
|
10722
|
+
fontWeight: 700,
|
|
10723
|
+
textAnchor: "start",
|
|
10724
|
+
fill: "var(--cdl-text, #1a1f2a)",
|
|
10725
|
+
style: { fontFamily: "'JetBrains Mono', monospace" },
|
|
10726
|
+
children: s.right
|
|
10727
|
+
}
|
|
10728
|
+
)
|
|
10729
|
+
] }, i)) });
|
|
10730
|
+
})()
|
|
10731
|
+
]
|
|
10732
|
+
}
|
|
10733
|
+
);
|
|
10691
10734
|
}
|
|
10692
10735
|
var MARK_INNER_RATIO = 0.56;
|
|
10693
10736
|
var RING_WIDTH_ACTIVE = 6;
|