@cardenelabs/cdl 0.59.1 → 0.60.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
@@ -3362,7 +3362,7 @@ function tokenize(src) {
3362
3362
  `invalid name "{${name}}" at position ${start} (\u7A7A\u767D / { } / . / [ ] \u306F\u540D\u524D\u306B\u4F7F\u3048\u306A\u3044)`
3363
3363
  );
3364
3364
  }
3365
- tokens.push({ kind: "id", name, pos: start });
3365
+ tokens.push({ kind: "id", name, pos: start, end: close + 1 });
3366
3366
  i = close + 1;
3367
3367
  continue;
3368
3368
  }
@@ -3411,7 +3411,7 @@ function tokenize(src) {
3411
3411
  `property access "${name}.${src[i + 1] ?? ""}..." at position ${start} is not allowed (only Math.* namespace is accessible)`
3412
3412
  );
3413
3413
  }
3414
- tokens.push({ kind: "id", name, pos: start });
3414
+ tokens.push({ kind: "id", name, pos: start, end: i });
3415
3415
  continue;
3416
3416
  }
3417
3417
  if (c === "+") {
@@ -3636,6 +3636,24 @@ function parseFormula(expression) {
3636
3636
  }
3637
3637
  return new Parser(tokens).parse();
3638
3638
  }
3639
+ function \u5F0F\u3092\u540D\u672D\u3067\u8AAD\u3080(expression, \u540D\u672D) {
3640
+ let tokens;
3641
+ try {
3642
+ tokens = tokenize(expression);
3643
+ } catch {
3644
+ return expression;
3645
+ }
3646
+ let \u8AAD\u307F = "";
3647
+ let \u524D = 0;
3648
+ for (const t of tokens) {
3649
+ if (t.kind !== "id") continue;
3650
+ const \u672D = \u540D\u672D.get(t.name);
3651
+ if (\u672D === void 0 || \u672D === "") continue;
3652
+ \u8AAD\u307F += expression.slice(\u524D, t.pos) + \u672D;
3653
+ \u524D = t.end;
3654
+ }
3655
+ return \u8AAD\u307F + expression.slice(\u524D);
3656
+ }
3639
3657
  function extractIdentifiers(ast, out = /* @__PURE__ */ new Set()) {
3640
3658
  switch (ast.type) {
3641
3659
  case "number":
@@ -20569,6 +20587,8 @@ function useInteractiveIntegration(diagram, options = {}) {
20569
20587
  const readouts = diagram.readouts ?? [];
20570
20588
  if (inputs.length === 0 && scrolls.length === 0 && formulasList.length === 0 && readouts.length === 0)
20571
20589
  return null;
20590
+ const \u540D\u672D = /* @__PURE__ */ new Map();
20591
+ for (const x of [...inputs, ...formulasList]) if (x.label) \u540D\u672D.set(x.id, x.label);
20572
20592
  return (
20573
20593
  // 操作部の中の読み出しと入力欄へ、図の言語を届ける (#849)。 型の外の値は英語に落ちる
20574
20594
  /* @__PURE__ */ jsxRuntime.jsx(\u64CD\u4F5C\u90E8\u306E\u8A00\u8A9E.Provider, { value: resolveLang(diagram.lang), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cdl-ip-root", "data-cdl-interactive-panel": "true", children: [
@@ -20577,12 +20597,13 @@ function useInteractiveIntegration(diagram, options = {}) {
20577
20597
  FormulaReadout,
20578
20598
  {
20579
20599
  id: f.id,
20580
- expression: f.expression,
20600
+ name: f.label || f.id,
20601
+ expression: f.label ? \u5F0F\u3092\u540D\u672D\u3067\u8AAD\u3080(f.expression, \u540D\u672D) : f.expression,
20581
20602
  value: stateOverrides[f.id]
20582
20603
  },
20583
20604
  f.id
20584
20605
  )) }),
20585
- scrolls.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cdl-ip-group", children: scrolls.map((s) => /* @__PURE__ */ jsxRuntime.jsx(ScrollReadout, { id: s.id, progress: stateOverrides[s.id] }, s.id)) }),
20606
+ scrolls.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cdl-ip-group", children: scrolls.map((s) => /* @__PURE__ */ jsxRuntime.jsx(ScrollReadout, { id: s.id, name: s.label || s.id, progress: stateOverrides[s.id] }, s.id)) }),
20586
20607
  readouts.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cdl-ip-group", children: readouts.map((r) => /* @__PURE__ */ jsxRuntime.jsx(ReadoutWidget, { readout: r, stateOverrides: mergedStateValues }, r.id)) })
20587
20608
  ] }) })
20588
20609
  );
@@ -20839,11 +20860,12 @@ function NumberInputWidget({
20839
20860
  }
20840
20861
  function FormulaReadout({
20841
20862
  id,
20863
+ name,
20842
20864
  expression,
20843
20865
  value
20844
20866
  }) {
20845
20867
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cdl-ip-item cdl-ip-formula", "data-cdl-formula": id, children: [
20846
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-label", children: id }),
20868
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-label", children: name }),
20847
20869
  /* @__PURE__ */ jsxRuntime.jsxs("code", { className: "cdl-ip-formula-expr", children: [
20848
20870
  "= ",
20849
20871
  expression
@@ -20851,11 +20873,11 @@ function FormulaReadout({
20851
20873
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-formula-value", children: String(value ?? "") })
20852
20874
  ] });
20853
20875
  }
20854
- function ScrollReadout({ id, progress }) {
20876
+ function ScrollReadout({ id, name, progress }) {
20855
20877
  const p = typeof progress === "number" ? progress : 0;
20856
20878
  const pct = Math.round(p * 100);
20857
20879
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cdl-ip-item cdl-ip-scroll", "data-cdl-scroll": id, children: [
20858
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-label", children: id }),
20880
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-label", children: name }),
20859
20881
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cdl-ip-scroll-track", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cdl-ip-scroll-fill", style: { width: `${pct}%` } }) }),
20860
20882
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "cdl-ip-scroll-value", children: [
20861
20883
  pct,