@cardenelabs/cdl 0.59.1 → 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.d.cts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { r as CdlDiagramView, n as CdlDiagramViewProps } from './render-DpwY2hzM.cjs';
2
+ export { s as CdlDiagramView, o as CdlDiagramViewProps } from './render-Dk8_6ua6.cjs';
package/dist/react.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { r as CdlDiagramView, n as CdlDiagramViewProps } from './render-DpwY2hzM.js';
2
+ export { s as CdlDiagramView, o as CdlDiagramViewProps } from './render-Dk8_6ua6.js';
package/dist/react.js CHANGED
@@ -3360,7 +3360,7 @@ function tokenize(src) {
3360
3360
  `invalid name "{${name}}" at position ${start} (\u7A7A\u767D / { } / . / [ ] \u306F\u540D\u524D\u306B\u4F7F\u3048\u306A\u3044)`
3361
3361
  );
3362
3362
  }
3363
- tokens.push({ kind: "id", name, pos: start });
3363
+ tokens.push({ kind: "id", name, pos: start, end: close + 1 });
3364
3364
  i = close + 1;
3365
3365
  continue;
3366
3366
  }
@@ -3409,7 +3409,7 @@ function tokenize(src) {
3409
3409
  `property access "${name}.${src[i + 1] ?? ""}..." at position ${start} is not allowed (only Math.* namespace is accessible)`
3410
3410
  );
3411
3411
  }
3412
- tokens.push({ kind: "id", name, pos: start });
3412
+ tokens.push({ kind: "id", name, pos: start, end: i });
3413
3413
  continue;
3414
3414
  }
3415
3415
  if (c === "+") {
@@ -3634,6 +3634,24 @@ function parseFormula(expression) {
3634
3634
  }
3635
3635
  return new Parser(tokens).parse();
3636
3636
  }
3637
+ function \u5F0F\u3092\u540D\u672D\u3067\u8AAD\u3080(expression, \u540D\u672D) {
3638
+ let tokens;
3639
+ try {
3640
+ tokens = tokenize(expression);
3641
+ } catch {
3642
+ return expression;
3643
+ }
3644
+ let \u8AAD\u307F = "";
3645
+ let \u524D = 0;
3646
+ for (const t of tokens) {
3647
+ if (t.kind !== "id") continue;
3648
+ const \u672D = \u540D\u672D.get(t.name);
3649
+ if (\u672D === void 0 || \u672D === "") continue;
3650
+ \u8AAD\u307F += expression.slice(\u524D, t.pos) + \u672D;
3651
+ \u524D = t.end;
3652
+ }
3653
+ return \u8AAD\u307F + expression.slice(\u524D);
3654
+ }
3637
3655
  function extractIdentifiers(ast, out = /* @__PURE__ */ new Set()) {
3638
3656
  switch (ast.type) {
3639
3657
  case "number":
@@ -3798,6 +3816,34 @@ function evaluateOne(entry, values) {
3798
3816
  }
3799
3817
  }
3800
3818
 
3819
+ // src/input-option.ts
3820
+ function \u9078\u629E\u80A2\u306E\u5024(option) {
3821
+ return typeof option === "string" ? option : option.value;
3822
+ }
3823
+ function \u9078\u629E\u80A2\u306E\u540D\u524D(option) {
3824
+ return typeof option === "string" || option.label === "" ? \u9078\u629E\u80A2\u306E\u5024(option) : option.label;
3825
+ }
3826
+ function \u5024\u306E\u540D\u524D\u306E\u8868\u3092\u4F5C\u308B(inputs) {
3827
+ const \u8868 = /* @__PURE__ */ new Map();
3828
+ for (const input of inputs ?? []) {
3829
+ const \u540D\u524D = /* @__PURE__ */ new Map();
3830
+ if (input.kind === "dropdown" || input.kind === "radio" || input.kind === "tabs" || input.kind === "multi-select") {
3831
+ for (const option of input.options) {
3832
+ if (typeof option !== "string" && option.label !== "") \u540D\u524D.set(option.value, option.label);
3833
+ }
3834
+ } else if (input.kind === "toggle") {
3835
+ if (input.onLabel) \u540D\u524D.set("true", input.onLabel);
3836
+ if (input.offLabel) \u540D\u524D.set("false", input.offLabel);
3837
+ }
3838
+ if (\u540D\u524D.size > 0) \u8868.set(input.id, { \u540D\u524D, \u8907\u6570: input.kind === "multi-select" });
3839
+ }
3840
+ return \u8868;
3841
+ }
3842
+ function \u5024\u3092\u540D\u524D\u3067\u8AAD\u3080(\u5165\u529B\u6B04, \u5024) {
3843
+ if (!\u5165\u529B\u6B04.\u8907\u6570) return \u5165\u529B\u6B04.\u540D\u524D.get(\u5024) ?? \u5024;
3844
+ return \u5024.split(",").map((v) => \u5165\u529B\u6B04.\u540D\u524D.get(v) ?? v).join(",");
3845
+ }
3846
+
3801
3847
  // src/render/utils.ts
3802
3848
  var TEMPLATE_REF_RE = new RegExp(TEMPLATE_REF_SRC, "g");
3803
3849
  var TEMPLATE_LEFTOVER_TEST_RE = new RegExp(TEMPLATE_LEFTOVER_SRC);
@@ -3846,11 +3892,14 @@ function mergeStateValues(base, overrides) {
3846
3892
  }
3847
3893
  return merged;
3848
3894
  }
3849
- function interpolate(template, values) {
3895
+ function interpolate(template, values, \u540D\u524D\u306E\u8868) {
3850
3896
  return template.replace(TEMPLATE_REF_RE, (_, id, accessor) => {
3851
3897
  const raw = Object.hasOwn(values, id) ? values[id] : void 0;
3852
3898
  if (raw === void 0) return `{${id}${accessor ?? ""}}`;
3853
- if (!accessor) return raw;
3899
+ if (!accessor) {
3900
+ const \u5165\u529B\u6B04 = \u540D\u524D\u306E\u8868?.get(id);
3901
+ return \u5165\u529B\u6B04 ? \u5024\u3092\u540D\u524D\u3067\u8AAD\u3080(\u5165\u529B\u6B04, raw) : raw;
3902
+ }
3854
3903
  const arr = parseArraySignal(raw);
3855
3904
  if (!arr) return `{${id}${accessor}}`;
3856
3905
  if (accessor === ".length") return String(arr.length);
@@ -12035,7 +12084,8 @@ function GenericNode({
12035
12084
  node,
12036
12085
  active,
12037
12086
  value,
12038
- stateValues
12087
+ stateValues,
12088
+ \u5024\u306E\u540D\u524D
12039
12089
  }) {
12040
12090
  const base = STYLES[node.kind] ?? FALLBACK;
12041
12091
  const toned = toneColor3(node.tone);
@@ -12121,7 +12171,7 @@ function GenericNode({
12121
12171
  style.look === "ledger" && /* @__PURE__ */ jsx("line", { x1: 1, y1: h - 7, x2: w - 1, y2: h - 7, stroke: paint.stroke, strokeWidth: 1 })
12122
12172
  ] });
12123
12173
  })();
12124
- const resolvedValue = value !== void 0 ? interpolate(value, stateValues) : void 0;
12174
+ const resolvedValue = value !== void 0 ? interpolate(value, stateValues, \u5024\u306E\u540D\u524D) : void 0;
12125
12175
  const hasRows = (node.rows?.length ?? 0) > 0;
12126
12176
  const centered = genericTextCentered(node.kind, hasRows);
12127
12177
  const textAnchor = centered ? "middle" : "start";
@@ -12171,7 +12221,7 @@ function GenericNode({
12171
12221
  }
12172
12222
  ),
12173
12223
  node.rows && node.rows.length > 0 && (() => {
12174
- const resolved = node.rows.map((row) => interpolate(row, stateValues));
12224
+ const resolved = node.rows.map((row) => interpolate(row, stateValues, \u5024\u306E\u540D\u524D));
12175
12225
  const splits = resolved.map(splitRow);
12176
12226
  const leftMaxWidth = splits.reduce(
12177
12227
  (m, s) => Math.max(m, rowColumnWidth(s.left, GENERIC_ROW_LEFT_SIZE_PX, false)),
@@ -18836,10 +18886,11 @@ function CdlNodeView({
18836
18886
  currentPhaseId,
18837
18887
  chartLineScale,
18838
18888
  \u95A2\u4FC2\u306E\u53D7\u3051\u53E3,
18839
- lang
18889
+ lang,
18890
+ \u5024\u306E\u540D\u524D
18840
18891
  }) {
18841
- const value = node.value ? interpolate(node.value, stateValues) : void 0;
18842
- const rows = (node.rows ?? []).map((r) => interpolate(r, stateValues));
18892
+ const value = node.value ? interpolate(node.value, stateValues, \u5024\u306E\u540D\u524D) : void 0;
18893
+ const rows = (node.rows ?? []).map((r) => interpolate(r, stateValues, \u5024\u306E\u540D\u524D));
18843
18894
  const boundW = node.wBind ? resolveNumericAttr(node.wBind, stateValues, node.w) : node.w;
18844
18895
  const boundH = node.hBind ? resolveNumericAttr(node.hBind, stateValues, node.h) : node.h;
18845
18896
  const boundOpacity = node.opacity !== void 0 ? Math.min(1, Math.max(0, resolveNumericAttr(node.opacity, stateValues, 1))) : void 0;
@@ -18853,9 +18904,9 @@ function CdlNodeView({
18853
18904
  }
18854
18905
  const resolvedNode = {
18855
18906
  ...node,
18856
- title: interpolate(node.title, stateValues),
18857
- subtitle: node.subtitle ? interpolate(node.subtitle, stateValues) : node.subtitle,
18858
- eyebrow: node.eyebrow ? interpolate(node.eyebrow, stateValues) : node.eyebrow,
18907
+ title: interpolate(node.title, stateValues, \u5024\u306E\u540D\u524D),
18908
+ subtitle: node.subtitle ? interpolate(node.subtitle, stateValues, \u5024\u306E\u540D\u524D) : node.subtitle,
18909
+ eyebrow: node.eyebrow ? interpolate(node.eyebrow, stateValues, \u5024\u306E\u540D\u524D) : node.eyebrow,
18859
18910
  w: boundW,
18860
18911
  h: boundH
18861
18912
  };
@@ -19136,7 +19187,7 @@ function CdlNodeView({
19136
19187
  case "mark-end":
19137
19188
  return /* @__PURE__ */ jsx(MarkEndNode, { node: resolvedNode, active });
19138
19189
  default:
19139
- return /* @__PURE__ */ jsx(GenericNode, { node: resolvedNode, active, value: node.value, stateValues });
19190
+ return /* @__PURE__ */ jsx(GenericNode, { node: resolvedNode, active, value: node.value, stateValues, \u5024\u306E\u540D\u524D });
19140
19191
  }
19141
19192
  })();
19142
19193
  const offsetX = node.renderOffsetX !== void 0 ? resolveNumericAttr(node.renderOffsetX, stateValues, 0) : 0;
@@ -19218,7 +19269,8 @@ function CdlStage({
19218
19269
  stateValues,
19219
19270
  debug,
19220
19271
  compact = false,
19221
- svgRef
19272
+ svgRef,
19273
+ \u5024\u306E\u540D\u524D
19222
19274
  }) {
19223
19275
  const [\u7126\u70B9, set\u7126\u70B9] = useState(null);
19224
19276
  const \u95A2\u4FC2\u3092\u5149\u3089\u305B\u308B = (laid.relationFocus ?? RELATION_FOCUS_DEFAULT) === "hover";
@@ -19498,6 +19550,7 @@ function CdlStage({
19498
19550
  drawing: \u63CF\u304F,
19499
19551
  progress: \u63CF\u304F ? \u63CF\u304F\u9032\u307F : progress,
19500
19552
  stateValues,
19553
+ \u5024\u306E\u540D\u524D,
19501
19554
  currentPhaseId: currentPhase?.id,
19502
19555
  chartLineScale: chartLineScales.get(node.id)
19503
19556
  }
@@ -20567,6 +20620,8 @@ function useInteractiveIntegration(diagram, options = {}) {
20567
20620
  const readouts = diagram.readouts ?? [];
20568
20621
  if (inputs.length === 0 && scrolls.length === 0 && formulasList.length === 0 && readouts.length === 0)
20569
20622
  return null;
20623
+ const \u540D\u672D = /* @__PURE__ */ new Map();
20624
+ for (const x of [...inputs, ...formulasList]) if (x.label) \u540D\u672D.set(x.id, x.label);
20570
20625
  return (
20571
20626
  // 操作部の中の読み出しと入力欄へ、図の言語を届ける (#849)。 型の外の値は英語に落ちる
20572
20627
  /* @__PURE__ */ jsx(\u64CD\u4F5C\u90E8\u306E\u8A00\u8A9E.Provider, { value: resolveLang(diagram.lang), children: /* @__PURE__ */ jsxs("div", { className: "cdl-ip-root", "data-cdl-interactive-panel": "true", children: [
@@ -20575,12 +20630,13 @@ function useInteractiveIntegration(diagram, options = {}) {
20575
20630
  FormulaReadout,
20576
20631
  {
20577
20632
  id: f.id,
20578
- expression: f.expression,
20633
+ name: f.label || f.id,
20634
+ expression: f.label ? \u5F0F\u3092\u540D\u672D\u3067\u8AAD\u3080(f.expression, \u540D\u672D) : f.expression,
20579
20635
  value: stateOverrides[f.id]
20580
20636
  },
20581
20637
  f.id
20582
20638
  )) }),
20583
- scrolls.length > 0 && /* @__PURE__ */ jsx("div", { className: "cdl-ip-group", children: scrolls.map((s) => /* @__PURE__ */ jsx(ScrollReadout, { id: s.id, progress: stateOverrides[s.id] }, s.id)) }),
20639
+ scrolls.length > 0 && /* @__PURE__ */ jsx("div", { className: "cdl-ip-group", children: scrolls.map((s) => /* @__PURE__ */ jsx(ScrollReadout, { id: s.id, name: s.label || s.id, progress: stateOverrides[s.id] }, s.id)) }),
20584
20640
  readouts.length > 0 && /* @__PURE__ */ jsx("div", { className: "cdl-ip-group", children: readouts.map((r) => /* @__PURE__ */ jsx(ReadoutWidget, { readout: r, stateOverrides: mergedStateValues }, r.id)) })
20585
20641
  ] }) })
20586
20642
  );
@@ -20663,7 +20719,7 @@ function InputWidget({
20663
20719
  },
20664
20720
  "data-cdl-input": input.id,
20665
20721
  className: "cdl-ip-dropdown-select",
20666
- children: input.options.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt))
20722
+ children: input.options.map((opt) => /* @__PURE__ */ jsx("option", { value: \u9078\u629E\u80A2\u306E\u5024(opt), children: \u9078\u629E\u80A2\u306E\u540D\u524D(opt) }, \u9078\u629E\u80A2\u306E\u5024(opt)))
20667
20723
  }
20668
20724
  )
20669
20725
  ] });
@@ -20680,17 +20736,17 @@ function InputWidget({
20680
20736
  {
20681
20737
  type: "radio",
20682
20738
  name: input.id,
20683
- value: opt,
20684
- checked: value === opt,
20739
+ value: \u9078\u629E\u80A2\u306E\u5024(opt),
20740
+ checked: value === \u9078\u629E\u80A2\u306E\u5024(opt),
20685
20741
  onChange: () => {
20686
- signal2.value = opt;
20742
+ signal2.value = \u9078\u629E\u80A2\u306E\u5024(opt);
20687
20743
  },
20688
20744
  "data-cdl-input": input.id,
20689
20745
  className: "cdl-ip-radio-input"
20690
20746
  }
20691
20747
  ),
20692
- /* @__PURE__ */ jsx("span", { className: "cdl-ip-radio-label", children: opt })
20693
- ] }, opt)) })
20748
+ /* @__PURE__ */ jsx("span", { className: "cdl-ip-radio-label", children: \u9078\u629E\u80A2\u306E\u540D\u524D(opt) })
20749
+ ] }, \u9078\u629E\u80A2\u306E\u5024(opt))) })
20694
20750
  ] });
20695
20751
  case "color":
20696
20752
  return /* @__PURE__ */ jsxs("label", { className: "cdl-ip-item cdl-ip-color", "data-cdl-input-kind": "color", children: [
@@ -20740,14 +20796,14 @@ function InputWidget({
20740
20796
  {
20741
20797
  type: "button",
20742
20798
  role: "tab",
20743
- className: `cdl-ip-tabs-btn ${value === opt ? "cdl-ip-tabs-active" : ""}`,
20799
+ className: `cdl-ip-tabs-btn ${value === \u9078\u629E\u80A2\u306E\u5024(opt) ? "cdl-ip-tabs-active" : ""}`,
20744
20800
  onClick: () => {
20745
- signal2.value = opt;
20801
+ signal2.value = \u9078\u629E\u80A2\u306E\u5024(opt);
20746
20802
  },
20747
20803
  "data-cdl-input": input.id,
20748
- children: opt
20804
+ children: \u9078\u629E\u80A2\u306E\u540D\u524D(opt)
20749
20805
  },
20750
- opt
20806
+ \u9078\u629E\u80A2\u306E\u5024(opt)
20751
20807
  )) })
20752
20808
  ] });
20753
20809
  case "datetime":
@@ -20837,11 +20893,12 @@ function NumberInputWidget({
20837
20893
  }
20838
20894
  function FormulaReadout({
20839
20895
  id,
20896
+ name,
20840
20897
  expression,
20841
20898
  value
20842
20899
  }) {
20843
20900
  return /* @__PURE__ */ jsxs("div", { className: "cdl-ip-item cdl-ip-formula", "data-cdl-formula": id, children: [
20844
- /* @__PURE__ */ jsx("span", { className: "cdl-ip-label", children: id }),
20901
+ /* @__PURE__ */ jsx("span", { className: "cdl-ip-label", children: name }),
20845
20902
  /* @__PURE__ */ jsxs("code", { className: "cdl-ip-formula-expr", children: [
20846
20903
  "= ",
20847
20904
  expression
@@ -20849,11 +20906,11 @@ function FormulaReadout({
20849
20906
  /* @__PURE__ */ jsx("span", { className: "cdl-ip-formula-value", children: String(value ?? "") })
20850
20907
  ] });
20851
20908
  }
20852
- function ScrollReadout({ id, progress }) {
20909
+ function ScrollReadout({ id, name, progress }) {
20853
20910
  const p = typeof progress === "number" ? progress : 0;
20854
20911
  const pct = Math.round(p * 100);
20855
20912
  return /* @__PURE__ */ jsxs("div", { className: "cdl-ip-item cdl-ip-scroll", "data-cdl-scroll": id, children: [
20856
- /* @__PURE__ */ jsx("span", { className: "cdl-ip-label", children: id }),
20913
+ /* @__PURE__ */ jsx("span", { className: "cdl-ip-label", children: name }),
20857
20914
  /* @__PURE__ */ jsx("div", { className: "cdl-ip-scroll-track", children: /* @__PURE__ */ jsx("div", { className: "cdl-ip-scroll-fill", style: { width: `${pct}%` } }) }),
20858
20915
  /* @__PURE__ */ jsxs("span", { className: "cdl-ip-scroll-value", children: [
20859
20916
  pct,
@@ -22801,13 +22858,13 @@ function MultiSelectWidget({
22801
22858
  "button",
22802
22859
  {
22803
22860
  type: "button",
22804
- className: `cdl-ip-multi-select-chip ${selected.has(opt) ? "cdl-ip-multi-select-active" : ""}`,
22805
- onClick: () => toggle(opt),
22861
+ className: `cdl-ip-multi-select-chip ${selected.has(\u9078\u629E\u80A2\u306E\u5024(opt)) ? "cdl-ip-multi-select-active" : ""}`,
22862
+ onClick: () => toggle(\u9078\u629E\u80A2\u306E\u5024(opt)),
22806
22863
  "data-cdl-input": input.id,
22807
- "data-cdl-multi-value": opt,
22808
- children: opt
22864
+ "data-cdl-multi-value": \u9078\u629E\u80A2\u306E\u5024(opt),
22865
+ children: \u9078\u629E\u80A2\u306E\u540D\u524D(opt)
22809
22866
  },
22810
- opt
22867
+ \u9078\u629E\u80A2\u306E\u5024(opt)
22811
22868
  )) })
22812
22869
  ] });
22813
22870
  }
@@ -28339,6 +28396,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
28339
28396
  if (!isInteractive) return baseStateValues;
28340
28397
  return mergeStateValues(baseStateValues, interactive.stateOverrides);
28341
28398
  }, [isInteractive, baseStateValues, interactive.stateOverrides]);
28399
+ const \u5024\u306E\u540D\u524D = useMemo(() => \u5024\u306E\u540D\u524D\u306E\u8868\u3092\u4F5C\u308B(diagram.inputs), [diagram.inputs]);
28342
28400
  return /* @__PURE__ */ jsxs(
28343
28401
  "div",
28344
28402
  {
@@ -28367,7 +28425,7 @@ function CdlDiagramView({ diagram, laid: laidProp, hideHeader = false, hideMiniP
28367
28425
  }
28368
28426
  ),
28369
28427
  isInteractive && interactive.panel,
28370
- /* @__PURE__ */ jsx(CdlStage, { laid, currentPhase, progress, drawProgress, stateValues, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
28428
+ /* @__PURE__ */ jsx(CdlStage, { laid, currentPhase, progress, drawProgress, stateValues, \u5024\u306E\u540D\u524D, debug, compact: hideHeader, svgRef: isInteractive ? interactive.svgRef : void 0 }),
28371
28429
  hideHeader && !hideMiniPhaseIndicator && currentPhase && laid.phases.length > 1 && /* @__PURE__ */ 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: [
28372
28430
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
28373
28431
  laid.phases.map((p, i) => /* @__PURE__ */ jsx(