@cardenelabs/cdl 0.23.0 → 0.25.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/dist/react.cjs CHANGED
@@ -629,6 +629,12 @@ function rowBaselineY(kind, index) {
629
629
  if (!rendersRows(kind)) return null;
630
630
  return kind === "storage" ? ROW_TOP_STORAGE + index * ROW_PITCH_STORAGE : ROW_TOP_GENERIC + genericTextShift(kind) + index * ROW_PITCH_GENERIC;
631
631
  }
632
+ function rowStripeBand(kind, index, shift) {
633
+ const baseline = rowBaselineY(kind, index);
634
+ if (baseline === null) return null;
635
+ const pitch = ROW_PITCH_STORAGE ;
636
+ return { y: baseline + shift - pitch / 2, h: pitch };
637
+ }
632
638
  function genericTextShift(kind) {
633
639
  return KINDS_SHAPE_CYLINDER.has(kind ?? "") ? GENERIC_TEXT_SHIFT_CYLINDER : 0;
634
640
  }
@@ -8980,6 +8986,12 @@ function layout(diag) {
8980
8986
  ...diag.derived ? { derived: diag.derived } : {},
8981
8987
  // 矢印をいつ出すか (#582)。 描き手が読む欄なので、そのまま持ち越す
8982
8988
  ...diag.edgeReveal ? { edgeReveal: diag.edgeReveal } : {},
8989
+ // どの配色で描くか (#1553)。 空文字は書かなかった扱いにする = 空の目印を出すと、
8990
+ // 消費側の `[data-cdl-palette]` が配色を書いていない図にも当たる。
8991
+ //
8992
+ // **遮断はここだけに置く**。 描画は必ず組み立てを通り、組み立て API も `er` も
8993
+ // 素通しにしてある。 上流にも置くと、どの入力でも通らない分岐が残る
8994
+ ...diag.palette ? { palette: diag.palette } : {},
8983
8995
  bboxes,
8984
8996
  collisions,
8985
8997
  nearCollisions,
@@ -9489,6 +9501,12 @@ function edgeHeadPaint(head, fill, color) {
9489
9501
  }
9490
9502
  return { fill: color, stroke: "none" };
9491
9503
  }
9504
+ function defaultEdgeWidth(active) {
9505
+ return active ? 2.5 : 1.25;
9506
+ }
9507
+ function edgeColor(edge) {
9508
+ return edge.role === "main" ? "var(--cdl-now, #c0421f)" : toneColor(edge.tone);
9509
+ }
9492
9510
  function opacityAttr(opacity) {
9493
9511
  return opacity < 1 ? opacity : void 0;
9494
9512
  }
@@ -9502,7 +9520,7 @@ function CdlEdgeView({
9502
9520
  progress,
9503
9521
  stateValues
9504
9522
  }) {
9505
- const color = toneColor(edge.tone);
9523
+ const color = edgeColor(edge);
9506
9524
  const \u7AEF\u306E\u540D\u524D = (h, f) => {
9507
9525
  const \u5F62 = h ?? EDGE_HEAD_DEFAULT;
9508
9526
  if (\u5F62 === "none") return void 0;
@@ -9592,7 +9610,7 @@ function SolidEdgePath({
9592
9610
  stateValues
9593
9611
  }) {
9594
9612
  const visibleD = drawing ? pathSubpath(edge.d, progress) : edge.d;
9595
- const defaultWidth = active ? 5 : 2.5;
9613
+ const defaultWidth = defaultEdgeWidth(active);
9596
9614
  const boundWidth = edge.widthBind && stateValues ? resolveNumericAttr(edge.widthBind, stateValues, defaultWidth) : defaultWidth;
9597
9615
  const boundStroke = edge.strokeBind && stateValues ? interpolate(edge.strokeBind, stateValues) : color;
9598
9616
  const boundDashOffset = edge.dashOffsetBind && stateValues ? resolveNumericAttr(edge.dashOffsetBind, stateValues, 0) : void 0;
@@ -9669,7 +9687,7 @@ function CdlEdgeGlowView({
9669
9687
  active
9670
9688
  }) {
9671
9689
  if (!active) return null;
9672
- const color = toneColor(edge.tone);
9690
+ const color = edgeColor(edge);
9673
9691
  return /* @__PURE__ */ jsxRuntime.jsx(EdgeGlowCircles, { color, edgeId: edge.id });
9674
9692
  }
9675
9693
  function CdlEdgeLabelView({
@@ -9677,7 +9695,7 @@ function CdlEdgeLabelView({
9677
9695
  active
9678
9696
  }) {
9679
9697
  if (!hasRenderedLabel(edge)) return null;
9680
- const color = toneColor(edge.tone);
9698
+ const color = edgeColor(edge);
9681
9699
  const bbox = computeLabelBBoxWorld(edge);
9682
9700
  const boxW = bbox.w;
9683
9701
  const boxH = bbox.h;
@@ -9695,7 +9713,7 @@ function CdlEdgeLabelView({
9695
9713
  "data-cdl-edge-label-text": edge.label,
9696
9714
  "data-cdl-edge-sub-text": edge.sub ?? "",
9697
9715
  children: [
9698
- /* @__PURE__ */ jsxRuntime.jsx(
9716
+ edge.labelPlate !== false && /* @__PURE__ */ jsxRuntime.jsx(
9699
9717
  "rect",
9700
9718
  {
9701
9719
  "data-cdl-role": "edge-label-bg",
@@ -10308,6 +10326,25 @@ function StorageNode({
10308
10326
  strokeWidth: active ? 3 : 1.25
10309
10327
  }
10310
10328
  ),
10329
+ node.rowStripe && rows.map((_, idx) => {
10330
+ if (idx % 2 !== 0) return null;
10331
+ const \u5E2F = rowStripeBand("storage", idx, \u884C\u306E\u4E0B\u3052);
10332
+ if (!\u5E2F) return null;
10333
+ if (\u5E2F.y + \u5E2F.h > node.h) return null;
10334
+ return /* @__PURE__ */ jsxRuntime.jsx(
10335
+ "rect",
10336
+ {
10337
+ "data-cdl-role": "node-row-stripe",
10338
+ "data-cdl-row-index": idx,
10339
+ x: 1,
10340
+ y: \u5E2F.y,
10341
+ width: node.w - 2,
10342
+ height: \u5E2F.h,
10343
+ fill: "var(--cdl-row-stripe, var(--cdl-label-bg, #f3f4f6))"
10344
+ },
10345
+ `stripe-${idx}`
10346
+ );
10347
+ }),
10311
10348
  node.eyebrow && /* @__PURE__ */ jsxRuntime.jsx("text", { x: 26, y: 38, fontSize: 18, fontWeight: 700, letterSpacing: 2, fill: accent, children: node.eyebrow }),
10312
10349
  \u5370\u3067\u5206\u3051\u308B && node.subtitle && // 呼び名は **印で分ける箱でだけ** 出す (#578)。 従来の箱は題の下に区切り線が来るので
10313
10350
  // 置き場が無い
@@ -10415,9 +10452,29 @@ function StorageNode({
10415
10452
  })
10416
10453
  ] });
10417
10454
  }
10455
+ var TINT_FILL = "color-mix(in srgb, var(--cdl-text, #1a1f2a) 6%, transparent)";
10456
+ function lookPaint(look, accent, active) {
10457
+ const \u65E2\u5B9A\u67A0 = active ? accent : "var(--cdl-divider, #d4d4d8)";
10458
+ const \u65E2\u5B9A\u592A\u3055 = active ? 3 : 1.25;
10459
+ switch (look) {
10460
+ case "outline":
10461
+ return { fill: "none", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: false };
10462
+ case "tint":
10463
+ return { fill: TINT_FILL, stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: false };
10464
+ case "solid":
10465
+ return { fill: "var(--cdl-text, #1a1f2a)", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: true };
10466
+ case "ledger":
10467
+ return { fill: "var(--cdl-node-fill, #ffffff)", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: false };
10468
+ case "dashed":
10469
+ return { fill: "none", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, dash: "6 4", onSolid: false };
10470
+ default:
10471
+ return { fill: "var(--cdl-node-fill, #ffffff)", stroke: \u65E2\u5B9A\u67A0, strokeWidth: \u65E2\u5B9A\u592A\u3055, onSolid: false };
10472
+ }
10473
+ }
10418
10474
  var STYLES = {
10419
10475
  // 人系
10420
10476
  person: {
10477
+ look: "outline",
10421
10478
  accent: "var(--cdl-tone-accent, #2d6a8f)",
10422
10479
  eyebrowColor: "var(--cdl-tone-accent, #2d6a8f)",
10423
10480
  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"
@@ -10450,11 +10507,13 @@ var STYLES = {
10450
10507
  shape: "cylinder"
10451
10508
  },
10452
10509
  cache: {
10510
+ look: "dashed",
10453
10511
  accent: "var(--cdl-tone-warning, #a67a2e)",
10454
10512
  eyebrowColor: "var(--cdl-tone-warning, #a67a2e)",
10455
10513
  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"
10456
10514
  },
10457
10515
  queue: {
10516
+ look: "ledger",
10458
10517
  accent: "var(--cdl-tone-warning, #a67a2e)",
10459
10518
  eyebrowColor: "var(--cdl-tone-warning, #a67a2e)",
10460
10519
  icon: "M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z"
@@ -10471,12 +10530,14 @@ var STYLES = {
10471
10530
  shape: "cloud"
10472
10531
  },
10473
10532
  cdn: {
10533
+ look: "tint",
10474
10534
  accent: "var(--cdl-tone-info, #5a8ec1)",
10475
10535
  eyebrowColor: "var(--cdl-tone-info, #5a8ec1)",
10476
10536
  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"
10477
10537
  },
10478
10538
  // アプリ系
10479
10539
  service: {
10540
+ look: "solid",
10480
10541
  accent: "var(--cdl-tone-teal, #2f8770)",
10481
10542
  eyebrowColor: "var(--cdl-tone-teal, #2f8770)",
10482
10543
  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"
@@ -10548,6 +10609,7 @@ function GenericNode({
10548
10609
  const w = node.w;
10549
10610
  const h = node.h;
10550
10611
  const shape = style.shape ?? "rect";
10612
+ const paint = lookPaint(style.look, style.accent, active);
10551
10613
  const shapeEl = (() => {
10552
10614
  if (shape === "cylinder") {
10553
10615
  const rx = w / 2;
@@ -10605,19 +10667,23 @@ function GenericNode({
10605
10667
  circles.map((c, i) => /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: c.cx, cy: c.cy, r: c.r - (active ? 1.5 : 0.75), fill: "var(--cdl-node-fill, #ffffff)" }, `mask-${i}`))
10606
10668
  ] });
10607
10669
  }
10608
- return /* @__PURE__ */ jsxRuntime.jsx(
10609
- "rect",
10610
- {
10611
- x: 0,
10612
- y: 0,
10613
- width: w,
10614
- height: h,
10615
- rx: 18,
10616
- fill: "var(--cdl-node-fill, #ffffff)",
10617
- stroke: active ? style.accent : "var(--cdl-divider, #d4d4d8)",
10618
- strokeWidth: active ? 3 : 1.25
10619
- }
10620
- );
10670
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10671
+ /* @__PURE__ */ jsxRuntime.jsx(
10672
+ "rect",
10673
+ {
10674
+ x: 0,
10675
+ y: 0,
10676
+ width: w,
10677
+ height: h,
10678
+ rx: 18,
10679
+ fill: paint.fill,
10680
+ stroke: paint.stroke,
10681
+ strokeWidth: paint.strokeWidth,
10682
+ strokeDasharray: paint.dash
10683
+ }
10684
+ ),
10685
+ style.look === "ledger" && /* @__PURE__ */ jsxRuntime.jsx("line", { x1: 1, y1: h - 7, x2: w - 1, y2: h - 7, stroke: paint.stroke, strokeWidth: 1 })
10686
+ ] });
10621
10687
  })();
10622
10688
  const resolvedValue = value !== void 0 ? interpolate(value, stateValues) : void 0;
10623
10689
  const hasRows = (node.rows?.length ?? 0) > 0;
@@ -10640,56 +10706,64 @@ function GenericNode({
10640
10706
  const iconX = centered ? w / 2 + 40 : w - 48;
10641
10707
  const iconY = centered ? h / 2 - 44 - \u7D75\u306E\u82AF : 18 + cylinderShift;
10642
10708
  const dominantBaseline = centered ? "middle" : void 0;
10643
- return /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${x} ${y})`, "data-cdl-role": "node-body", children: [
10644
- shapeEl,
10645
- /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${iconX} ${iconY}) scale(1)`, "data-cdl-role": "node-kind-icon", children: [
10646
- /* @__PURE__ */ jsxRuntime.jsx("rect", { width: 24, height: 24, fill: "transparent" }),
10647
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: style.icon, fill: style.eyebrowColor, opacity: 0.7, transform: "scale(1)" })
10648
- ] }),
10649
- node.eyebrow && /* @__PURE__ */ jsxRuntime.jsx("text", { x: textX, y: eyebrowY, fontSize: 17, fontWeight: 700, letterSpacing: 1.5, fill: style.eyebrowColor, textAnchor, dominantBaseline, children: node.eyebrow }),
10650
- /* @__PURE__ */ jsxRuntime.jsx("text", { "data-cdl-role": "node-label", x: textX, y: titleY, fontSize: 20, fontWeight: 700, fill: "var(--cdl-text, #1a1f2a)", textAnchor, dominantBaseline, style: node.kind === "function" || node.kind === "api" ? { fontFamily: "'JetBrains Mono', monospace" } : void 0, children: node.title }),
10651
- node.subtitle && /* @__PURE__ */ jsxRuntime.jsx("text", { x: textX, y: subtitleY, fontSize: 17, fill: "var(--cdl-text-dim, #5a6270)", textAnchor, dominantBaseline, style: { fontFamily: "'JetBrains Mono', monospace" }, children: node.subtitle }),
10652
- resolvedValue && /* @__PURE__ */ jsxRuntime.jsx(
10653
- "text",
10654
- {
10655
- x: w - 20,
10656
- y: h - 24,
10657
- fontSize: 32,
10658
- fontWeight: 700,
10659
- textAnchor: "end",
10660
- fill: "var(--cdl-text, #1a1f2a)",
10661
- style: { fontFamily: "'JetBrains Mono', monospace" },
10662
- children: resolvedValue
10663
- }
10664
- ),
10665
- node.rows && node.rows.length > 0 && (() => {
10666
- const resolved = node.rows.map((row) => interpolate(row, stateValues));
10667
- const splits = resolved.map(splitRow);
10668
- const leftMaxWidth = splits.reduce(
10669
- (m, s) => Math.max(m, rowColumnWidth(s.left, GENERIC_ROW_LEFT_SIZE_PX, false)),
10670
- 0
10671
- );
10672
- const rightColX = ROW_PAD_X_PX + leftMaxWidth + ROW_COL_GAP_PX;
10673
- return /* @__PURE__ */ jsxRuntime.jsx("g", { children: splits.map((s, i) => /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(0 ${rowBaselineY(node.kind, i)})`, children: [
10674
- /* @__PURE__ */ jsxRuntime.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 }),
10675
- /* @__PURE__ */ jsxRuntime.jsx(
10709
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10710
+ "g",
10711
+ {
10712
+ transform: `translate(${x} ${y})`,
10713
+ "data-cdl-role": "node-body",
10714
+ "data-cdl-look": style.look,
10715
+ children: [
10716
+ shapeEl,
10717
+ /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${iconX} ${iconY}) scale(1)`, "data-cdl-role": "node-kind-icon", children: [
10718
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: 24, height: 24, fill: "transparent" }),
10719
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: style.icon, fill: style.eyebrowColor, opacity: 0.7, transform: "scale(1)" })
10720
+ ] }),
10721
+ node.eyebrow && /* @__PURE__ */ jsxRuntime.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 }),
10722
+ /* @__PURE__ */ jsxRuntime.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 }),
10723
+ node.subtitle && /* @__PURE__ */ jsxRuntime.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 }),
10724
+ resolvedValue && /* @__PURE__ */ jsxRuntime.jsx(
10676
10725
  "text",
10677
10726
  {
10678
- "data-cdl-role": "node-row",
10679
- "data-cdl-row-index": i,
10680
- x: rightColX,
10681
- y: 0,
10682
- fontSize: 21,
10727
+ x: w - 20,
10728
+ y: h - 24,
10729
+ fontSize: 32,
10683
10730
  fontWeight: 700,
10684
- textAnchor: "start",
10731
+ textAnchor: "end",
10685
10732
  fill: "var(--cdl-text, #1a1f2a)",
10686
10733
  style: { fontFamily: "'JetBrains Mono', monospace" },
10687
- children: s.right
10734
+ children: resolvedValue
10688
10735
  }
10689
- )
10690
- ] }, i)) });
10691
- })()
10692
- ] });
10736
+ ),
10737
+ node.rows && node.rows.length > 0 && (() => {
10738
+ const resolved = node.rows.map((row) => interpolate(row, stateValues));
10739
+ const splits = resolved.map(splitRow);
10740
+ const leftMaxWidth = splits.reduce(
10741
+ (m, s) => Math.max(m, rowColumnWidth(s.left, GENERIC_ROW_LEFT_SIZE_PX, false)),
10742
+ 0
10743
+ );
10744
+ const rightColX = ROW_PAD_X_PX + leftMaxWidth + ROW_COL_GAP_PX;
10745
+ return /* @__PURE__ */ jsxRuntime.jsx("g", { children: splits.map((s, i) => /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(0 ${rowBaselineY(node.kind, i)})`, children: [
10746
+ /* @__PURE__ */ jsxRuntime.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 }),
10747
+ /* @__PURE__ */ jsxRuntime.jsx(
10748
+ "text",
10749
+ {
10750
+ "data-cdl-role": "node-row",
10751
+ "data-cdl-row-index": i,
10752
+ x: rightColX,
10753
+ y: 0,
10754
+ fontSize: 21,
10755
+ fontWeight: 700,
10756
+ textAnchor: "start",
10757
+ fill: "var(--cdl-text, #1a1f2a)",
10758
+ style: { fontFamily: "'JetBrains Mono', monospace" },
10759
+ children: s.right
10760
+ }
10761
+ )
10762
+ ] }, i)) });
10763
+ })()
10764
+ ]
10765
+ }
10766
+ );
10693
10767
  }
10694
10768
  var MARK_INNER_RATIO = 0.56;
10695
10769
  var RING_WIDTH_ACTIVE = 6;
@@ -17118,6 +17192,7 @@ function CdlStage({
17118
17192
  "aria-label": buildDiagramAltText(laid.topic, currentPhase),
17119
17193
  "data-cdl-stage": "",
17120
17194
  "data-cdl-scale": diagramScale === 1 ? void 0 : diagramScale,
17195
+ "data-cdl-palette": laid.palette,
17121
17196
  children: [
17122
17197
  /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
17123
17198
  Object.entries(TONE).flatMap(