@cardenelabs/cdl 0.60.0 → 0.61.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
@@ -3818,6 +3818,34 @@ function evaluateOne(entry, values) {
3818
3818
  }
3819
3819
  }
3820
3820
 
3821
+ // src/input-option.ts
3822
+ function \u9078\u629E\u80A2\u306E\u5024(option) {
3823
+ return typeof option === "string" ? option : option.value;
3824
+ }
3825
+ function \u9078\u629E\u80A2\u306E\u540D\u524D(option) {
3826
+ return typeof option === "string" || option.label === "" ? \u9078\u629E\u80A2\u306E\u5024(option) : option.label;
3827
+ }
3828
+ function \u5024\u306E\u540D\u524D\u306E\u8868\u3092\u4F5C\u308B(inputs) {
3829
+ const \u8868 = /* @__PURE__ */ new Map();
3830
+ for (const input of inputs ?? []) {
3831
+ const \u540D\u524D = /* @__PURE__ */ new Map();
3832
+ if (input.kind === "dropdown" || input.kind === "radio" || input.kind === "tabs" || input.kind === "multi-select") {
3833
+ for (const option of input.options) {
3834
+ if (typeof option !== "string" && option.label !== "") \u540D\u524D.set(option.value, option.label);
3835
+ }
3836
+ } else if (input.kind === "toggle") {
3837
+ if (input.onLabel) \u540D\u524D.set("true", input.onLabel);
3838
+ if (input.offLabel) \u540D\u524D.set("false", input.offLabel);
3839
+ }
3840
+ if (\u540D\u524D.size > 0) \u8868.set(input.id, { \u540D\u524D, \u8907\u6570: input.kind === "multi-select" });
3841
+ }
3842
+ return \u8868;
3843
+ }
3844
+ function \u5024\u3092\u540D\u524D\u3067\u8AAD\u3080(\u5165\u529B\u6B04, \u5024) {
3845
+ if (!\u5165\u529B\u6B04.\u8907\u6570) return \u5165\u529B\u6B04.\u540D\u524D.get(\u5024) ?? \u5024;
3846
+ return \u5024.split(",").map((v) => \u5165\u529B\u6B04.\u540D\u524D.get(v) ?? v).join(",");
3847
+ }
3848
+
3821
3849
  // src/render/utils.ts
3822
3850
  var TEMPLATE_REF_RE = new RegExp(TEMPLATE_REF_SRC, "g");
3823
3851
  var TEMPLATE_LEFTOVER_TEST_RE = new RegExp(TEMPLATE_LEFTOVER_SRC);
@@ -3866,11 +3894,14 @@ function mergeStateValues(base, overrides) {
3866
3894
  }
3867
3895
  return merged;
3868
3896
  }
3869
- function interpolate(template, values) {
3897
+ function interpolate(template, values, \u540D\u524D\u306E\u8868) {
3870
3898
  return template.replace(TEMPLATE_REF_RE, (_, id, accessor) => {
3871
3899
  const raw = Object.hasOwn(values, id) ? values[id] : void 0;
3872
3900
  if (raw === void 0) return `{${id}${accessor ?? ""}}`;
3873
- if (!accessor) return raw;
3901
+ if (!accessor) {
3902
+ const \u5165\u529B\u6B04 = \u540D\u524D\u306E\u8868?.get(id);
3903
+ return \u5165\u529B\u6B04 ? \u5024\u3092\u540D\u524D\u3067\u8AAD\u3080(\u5165\u529B\u6B04, raw) : raw;
3904
+ }
3874
3905
  const arr = parseArraySignal(raw);
3875
3906
  if (!arr) return `{${id}${accessor}}`;
3876
3907
  if (accessor === ".length") return String(arr.length);
@@ -12055,7 +12086,8 @@ function GenericNode({
12055
12086
  node,
12056
12087
  active,
12057
12088
  value,
12058
- stateValues
12089
+ stateValues,
12090
+ \u5024\u306E\u540D\u524D
12059
12091
  }) {
12060
12092
  const base = STYLES[node.kind] ?? FALLBACK;
12061
12093
  const toned = toneColor3(node.tone);
@@ -12141,7 +12173,7 @@ function GenericNode({
12141
12173
  style.look === "ledger" && /* @__PURE__ */ jsxRuntime.jsx("line", { x1: 1, y1: h - 7, x2: w - 1, y2: h - 7, stroke: paint.stroke, strokeWidth: 1 })
12142
12174
  ] });
12143
12175
  })();
12144
- const resolvedValue = value !== void 0 ? interpolate(value, stateValues) : void 0;
12176
+ const resolvedValue = value !== void 0 ? interpolate(value, stateValues, \u5024\u306E\u540D\u524D) : void 0;
12145
12177
  const hasRows = (node.rows?.length ?? 0) > 0;
12146
12178
  const centered = genericTextCentered(node.kind, hasRows);
12147
12179
  const textAnchor = centered ? "middle" : "start";
@@ -12191,7 +12223,7 @@ function GenericNode({
12191
12223
  }
12192
12224
  ),
12193
12225
  node.rows && node.rows.length > 0 && (() => {
12194
- const resolved = node.rows.map((row) => interpolate(row, stateValues));
12226
+ const resolved = node.rows.map((row) => interpolate(row, stateValues, \u5024\u306E\u540D\u524D));
12195
12227
  const splits = resolved.map(splitRow);
12196
12228
  const leftMaxWidth = splits.reduce(
12197
12229
  (m, s) => Math.max(m, rowColumnWidth(s.left, GENERIC_ROW_LEFT_SIZE_PX, false)),
@@ -18856,10 +18888,11 @@ function CdlNodeView({
18856
18888
  currentPhaseId,
18857
18889
  chartLineScale,
18858
18890
  \u95A2\u4FC2\u306E\u53D7\u3051\u53E3,
18859
- lang
18891
+ lang,
18892
+ \u5024\u306E\u540D\u524D
18860
18893
  }) {
18861
- const value = node.value ? interpolate(node.value, stateValues) : void 0;
18862
- const rows = (node.rows ?? []).map((r) => interpolate(r, stateValues));
18894
+ const value = node.value ? interpolate(node.value, stateValues, \u5024\u306E\u540D\u524D) : void 0;
18895
+ const rows = (node.rows ?? []).map((r) => interpolate(r, stateValues, \u5024\u306E\u540D\u524D));
18863
18896
  const boundW = node.wBind ? resolveNumericAttr(node.wBind, stateValues, node.w) : node.w;
18864
18897
  const boundH = node.hBind ? resolveNumericAttr(node.hBind, stateValues, node.h) : node.h;
18865
18898
  const boundOpacity = node.opacity !== void 0 ? Math.min(1, Math.max(0, resolveNumericAttr(node.opacity, stateValues, 1))) : void 0;
@@ -18873,9 +18906,9 @@ function CdlNodeView({
18873
18906
  }
18874
18907
  const resolvedNode = {
18875
18908
  ...node,
18876
- title: interpolate(node.title, stateValues),
18877
- subtitle: node.subtitle ? interpolate(node.subtitle, stateValues) : node.subtitle,
18878
- eyebrow: node.eyebrow ? interpolate(node.eyebrow, stateValues) : node.eyebrow,
18909
+ title: interpolate(node.title, stateValues, \u5024\u306E\u540D\u524D),
18910
+ subtitle: node.subtitle ? interpolate(node.subtitle, stateValues, \u5024\u306E\u540D\u524D) : node.subtitle,
18911
+ eyebrow: node.eyebrow ? interpolate(node.eyebrow, stateValues, \u5024\u306E\u540D\u524D) : node.eyebrow,
18879
18912
  w: boundW,
18880
18913
  h: boundH
18881
18914
  };
@@ -19156,7 +19189,7 @@ function CdlNodeView({
19156
19189
  case "mark-end":
19157
19190
  return /* @__PURE__ */ jsxRuntime.jsx(MarkEndNode, { node: resolvedNode, active });
19158
19191
  default:
19159
- return /* @__PURE__ */ jsxRuntime.jsx(GenericNode, { node: resolvedNode, active, value: node.value, stateValues });
19192
+ return /* @__PURE__ */ jsxRuntime.jsx(GenericNode, { node: resolvedNode, active, value: node.value, stateValues, \u5024\u306E\u540D\u524D });
19160
19193
  }
19161
19194
  })();
19162
19195
  const offsetX = node.renderOffsetX !== void 0 ? resolveNumericAttr(node.renderOffsetX, stateValues, 0) : 0;
@@ -19238,7 +19271,8 @@ function CdlStage({
19238
19271
  stateValues,
19239
19272
  debug,
19240
19273
  compact = false,
19241
- svgRef
19274
+ svgRef,
19275
+ \u5024\u306E\u540D\u524D
19242
19276
  }) {
19243
19277
  const [\u7126\u70B9, set\u7126\u70B9] = react.useState(null);
19244
19278
  const \u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B = (laid.relationFocus ?? RELATION_FOCUS_DEFAULT) === "hover";
@@ -19518,6 +19552,7 @@ function CdlStage({
19518
19552
  drawing: \u63CF\u304F,
19519
19553
  progress: \u63CF\u304F ? \u63CF\u304F\u9032\u307F : progress,
19520
19554
  stateValues,
19555
+ \u5024\u306E\u540D\u524D,
19521
19556
  currentPhaseId: currentPhase?.id,
19522
19557
  chartLineScale: chartLineScales.get(node.id)
19523
19558
  }
@@ -20686,7 +20721,7 @@ function InputWidget({
20686
20721
  },
20687
20722
  "data-cdl-input": input.id,
20688
20723
  className: "cdl-ip-dropdown-select",
20689
- children: input.options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt))
20724
+ children: input.options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: \u9078\u629E\u80A2\u306E\u5024(opt), children: \u9078\u629E\u80A2\u306E\u540D\u524D(opt) }, \u9078\u629E\u80A2\u306E\u5024(opt)))
20690
20725
  }
20691
20726
  )
20692
20727
  ] });
@@ -20703,17 +20738,17 @@ function InputWidget({
20703
20738
  {
20704
20739
  type: "radio",
20705
20740
  name: input.id,
20706
- value: opt,
20707
- checked: value === opt,
20741
+ value: \u9078\u629E\u80A2\u306E\u5024(opt),
20742
+ checked: value === \u9078\u629E\u80A2\u306E\u5024(opt),
20708
20743
  onChange: () => {
20709
- signal2.value = opt;
20744
+ signal2.value = \u9078\u629E\u80A2\u306E\u5024(opt);
20710
20745
  },
20711
20746
  "data-cdl-input": input.id,
20712
20747
  className: "cdl-ip-radio-input"
20713
20748
  }
20714
20749
  ),
20715
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-radio-label", children: opt })
20716
- ] }, opt)) })
20750
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-radio-label", children: \u9078\u629E\u80A2\u306E\u540D\u524D(opt) })
20751
+ ] }, \u9078\u629E\u80A2\u306E\u5024(opt))) })
20717
20752
  ] });
20718
20753
  case "color":
20719
20754
  return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "cdl-ip-item cdl-ip-color", "data-cdl-input-kind": "color", children: [
@@ -20763,14 +20798,14 @@ function InputWidget({
20763
20798
  {
20764
20799
  type: "button",
20765
20800
  role: "tab",
20766
- className: `cdl-ip-tabs-btn ${value === opt ? "cdl-ip-tabs-active" : ""}`,
20801
+ className: `cdl-ip-tabs-btn ${value === \u9078\u629E\u80A2\u306E\u5024(opt) ? "cdl-ip-tabs-active" : ""}`,
20767
20802
  onClick: () => {
20768
- signal2.value = opt;
20803
+ signal2.value = \u9078\u629E\u80A2\u306E\u5024(opt);
20769
20804
  },
20770
20805
  "data-cdl-input": input.id,
20771
- children: opt
20806
+ children: \u9078\u629E\u80A2\u306E\u540D\u524D(opt)
20772
20807
  },
20773
- opt
20808
+ \u9078\u629E\u80A2\u306E\u5024(opt)
20774
20809
  )) })
20775
20810
  ] });
20776
20811
  case "datetime":
@@ -22825,13 +22860,13 @@ function MultiSelectWidget({
22825
22860
  "button",
22826
22861
  {
22827
22862
  type: "button",
22828
- className: `cdl-ip-multi-select-chip ${selected.has(opt) ? "cdl-ip-multi-select-active" : ""}`,
22829
- onClick: () => toggle(opt),
22863
+ className: `cdl-ip-multi-select-chip ${selected.has(\u9078\u629E\u80A2\u306E\u5024(opt)) ? "cdl-ip-multi-select-active" : ""}`,
22864
+ onClick: () => toggle(\u9078\u629E\u80A2\u306E\u5024(opt)),
22830
22865
  "data-cdl-input": input.id,
22831
- "data-cdl-multi-value": opt,
22832
- children: opt
22866
+ "data-cdl-multi-value": \u9078\u629E\u80A2\u306E\u5024(opt),
22867
+ children: \u9078\u629E\u80A2\u306E\u540D\u524D(opt)
22833
22868
  },
22834
- opt
22869
+ \u9078\u629E\u80A2\u306E\u5024(opt)
22835
22870
  )) })
22836
22871
  ] });
22837
22872
  }
@@ -28363,6 +28398,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
28363
28398
  if (!isInteractive) return baseStateValues;
28364
28399
  return mergeStateValues(baseStateValues, interactive.stateOverrides);
28365
28400
  }, [isInteractive, baseStateValues, interactive.stateOverrides]);
28401
+ const \u5024\u306E\u540D\u524D = react.useMemo(() => \u5024\u306E\u540D\u524D\u306E\u8868\u3092\u4F5C\u308B(diagram.inputs), [diagram.inputs]);
28366
28402
  return /* @__PURE__ */ jsxRuntime.jsxs(
28367
28403
  "div",
28368
28404
  {
@@ -28391,7 +28427,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
28391
28427
  }
28392
28428
  ),
28393
28429
  isInteractive && interactive.panel,
28394
- /* @__PURE__ */ jsxRuntime.jsx(CdlStage, { laid, currentPhase, progress, drawProgress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
28430
+ /* @__PURE__ */ jsxRuntime.jsx(CdlStage, { laid, currentPhase, progress, drawProgress, stateValues, \u5024\u306E\u540D\u524D, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
28395
28431
  hideHeader && !hideMiniPhaseIndicator && currentPhase && laid.phases.length > 1 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3 border-t border-[var(--cdl-divider,#d4d4d8)]/40 bg-[var(--cdl-stage-bg,#f1f5f9)]/50 px-3 py-2 text-xs", children: [
28396
28432
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
28397
28433
  laid.phases.map((p, i) => /* @__PURE__ */ jsxRuntime.jsx(