@cardenelabs/cdl 0.55.0 → 0.57.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.js CHANGED
@@ -10864,6 +10864,55 @@ function ActorNode({ node, active, value }) {
10864
10864
  )
10865
10865
  ] });
10866
10866
  }
10867
+
10868
+ // src/kinds/subtitle-lines.ts
10869
+ var SUBTITLE_SIZE = 21;
10870
+ var SUBTITLE_MIN_SIZE = 12;
10871
+ var \u884C\u9001\u308A\u306E\u500D\u7387 = 1.2;
10872
+ function \u8AAC\u660E\u6587\u3092\u5272\u308A\u4ED8\u3051\u308B(text, maxWidth, opts) {
10873
+ const \u76EE\u6A19 = opts.targetSize ?? SUBTITLE_SIZE;
10874
+ const \u8AAD\u3081\u308B\u5927\u304D\u3055 = fitTextSize(text, maxWidth, \u76EE\u6A19, SUBTITLE_MIN_SIZE);
10875
+ if (estimateTextWidth(text, \u8AAD\u3081\u308B\u5927\u304D\u3055) <= maxWidth) return { size: \u8AAD\u3081\u308B\u5927\u304D\u3055, lines: [text] };
10876
+ if (opts.\u4E8C\u884C\u307E\u3067) {
10877
+ for (let size = \u76EE\u6A19; size >= SUBTITLE_MIN_SIZE; size -= 1) {
10878
+ const \u884C = \u4E8C\u884C\u306B\u5272\u308B(text, maxWidth, size);
10879
+ if (\u884C) return { size, lines: \u884C };
10880
+ }
10881
+ }
10882
+ return { size: fitTextSize(text, maxWidth, \u76EE\u6A19, MIN_TEXT_SIZE), lines: [text] };
10883
+ }
10884
+ function \u4E8C\u884C\u306B\u5272\u308B(text, maxWidth, size) {
10885
+ let \u4E00\u756A\u826F\u3044;
10886
+ let \u4E00\u756A\u72ED\u3044 = Infinity;
10887
+ for (const [\u5DE6, \u53F3] of \u5272\u308B\u5019\u88DC(text)) {
10888
+ const \u5E45 = Math.max(estimateTextWidth(\u5DE6, size), estimateTextWidth(\u53F3, size));
10889
+ if (\u5E45 > maxWidth || \u5E45 >= \u4E00\u756A\u72ED\u3044) continue;
10890
+ \u4E00\u756A\u72ED\u3044 = \u5E45;
10891
+ \u4E00\u756A\u826F\u3044 = [\u5DE6, \u53F3];
10892
+ }
10893
+ return \u4E00\u756A\u826F\u3044;
10894
+ }
10895
+ function \u5272\u308B\u5019\u88DC(text) {
10896
+ const \u533A\u5207\u308A = [];
10897
+ for (const m of text.matchAll(/\s*\/\s*/g)) {
10898
+ \u533A\u5207\u308A.push([text.slice(0, m.index).trim(), text.slice(m.index + m[0].length).trim()]);
10899
+ }
10900
+ if (\u533A\u5207\u308A.length > 0) return \u533A\u5207\u308A.filter(\u5165\u3063\u3066\u3044\u308B);
10901
+ const \u7A7A\u767D = [];
10902
+ for (const m of text.matchAll(/\s+/g)) {
10903
+ \u7A7A\u767D.push([text.slice(0, m.index).trim(), text.slice(m.index + m[0].length).trim()]);
10904
+ }
10905
+ if (\u7A7A\u767D.length > 0) return \u7A7A\u767D.filter(\u5165\u3063\u3066\u3044\u308B);
10906
+ const \u5B57 = [];
10907
+ const \u4E26\u3073 = [...text];
10908
+ for (let i = 1; i < \u4E26\u3073.length; i += 1) {
10909
+ \u5B57.push([\u4E26\u3073.slice(0, i).join(""), \u4E26\u3073.slice(i).join("")]);
10910
+ }
10911
+ return \u5B57.filter(\u5165\u3063\u3066\u3044\u308B);
10912
+ }
10913
+ function \u5165\u3063\u3066\u3044\u308B([\u5DE6, \u53F3]) {
10914
+ return \u5DE6 !== "" && \u53F3 !== "";
10915
+ }
10867
10916
  function CardNode({ node, active }) {
10868
10917
  const accent = nodeAccent(node, "var(--cdl-tone-accent, #2d6a8f)");
10869
10918
  const x = node.cx - node.w / 2;
@@ -10888,7 +10937,12 @@ function CardNode({ node, active }) {
10888
10937
  const initialTitleSize = compact ? 20 : 24;
10889
10938
  const titleSize = fitTextSize(node.title, availableW, initialTitleSize, 11);
10890
10939
  const textAnchor = compact ? "middle" : "start";
10891
- const subtitleSize = node.subtitle ? fitTextSize(node.subtitle, availableW, 21, 11) : 21;
10940
+ const subtitleY = 124 - \u305A\u3089\u3057;
10941
+ const \u6700\u5927\u306E\u884C\u9001\u308A = SUBTITLE_SIZE * \u884C\u9001\u308A\u306E\u500D\u7387;
10942
+ const \u4E8C\u884C\u304C\u5165\u308B = !compact && subtitleY - \u6700\u5927\u306E\u884C\u9001\u308A / 2 - SUBTITLE_SIZE * ASCENT2 > titleY + titleSize * DESCENT2 && subtitleY + \u6700\u5927\u306E\u884C\u9001\u308A / 2 + SUBTITLE_SIZE * DESCENT2 <= node.h - 4;
10943
+ const \u8AAC\u660E = node.subtitle ? \u8AAC\u660E\u6587\u3092\u5272\u308A\u4ED8\u3051\u308B(node.subtitle, availableW, { \u4E8C\u884C\u307E\u3067: \u4E8C\u884C\u304C\u5165\u308B }) : void 0;
10944
+ const subtitleSize = \u8AAC\u660E?.size ?? 21;
10945
+ const \u884C\u9001\u308A = subtitleSize * \u884C\u9001\u308A\u306E\u500D\u7387;
10892
10946
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x} ${y})`, children: [
10893
10947
  /* @__PURE__ */ jsx(
10894
10948
  "rect",
@@ -10918,7 +10972,17 @@ function CardNode({ node, active }) {
10918
10972
  children: node.title
10919
10973
  }
10920
10974
  ),
10921
- !compact && node.subtitle && /* @__PURE__ */ jsx("text", { x: 26, y: 124 - \u305A\u3089\u3057, fontSize: subtitleSize, fill: "var(--cdl-text-dim, #5a6270)", children: node.subtitle }),
10975
+ !compact && \u8AAC\u660E?.lines.map((\u884C, i) => /* @__PURE__ */ jsx(
10976
+ "text",
10977
+ {
10978
+ x: 26,
10979
+ y: subtitleY + (i - (\u8AAC\u660E.lines.length - 1) / 2) * \u884C\u9001\u308A,
10980
+ fontSize: subtitleSize,
10981
+ fill: "var(--cdl-text-dim, #5a6270)",
10982
+ children: \u884C
10983
+ },
10984
+ `sub-${i}`
10985
+ )),
10922
10986
  \u5C0F\u578B\u306B\u547C\u3073\u540D && /* @__PURE__ */ jsx(
10923
10987
  "text",
10924
10988
  {
@@ -14450,6 +14514,13 @@ function UserJourneyNode({
14450
14514
  frustrated: "\u{1F615}",
14451
14515
  angry: "\u{1F620}"
14452
14516
  };
14517
+ const emotionLabel = {
14518
+ delighted: "\u5927\u6E80\u8DB3",
14519
+ happy: "\u6E80\u8DB3",
14520
+ neutral: "\u3075\u3064\u3046",
14521
+ frustrated: "\u4E0D\u6E80",
14522
+ angry: "\u6012\u308A"
14523
+ };
14453
14524
  const rowH = canvasH / 5;
14454
14525
  const colW = canvasW / Math.max(steps.length, 1);
14455
14526
  const xAt = (idx) => PAD_LEFT2 + (steps.length <= 1 ? canvasW / 2 : colW / 2 + colW * idx);
@@ -14514,7 +14585,7 @@ function UserJourneyNode({
14514
14585
  fontWeight: 600,
14515
14586
  textAnchor: "end",
14516
14587
  fill: emotionColor[e],
14517
- children: e
14588
+ children: emotionLabel[e]
14518
14589
  }
14519
14590
  )
14520
14591
  ] }, `band-${e}`)),