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