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