@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.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 { r as CdlDiagramView, n as CdlDiagramViewProps } from './render-MbIjRWdX.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 { r as CdlDiagramView, n as CdlDiagramViewProps } from './render-MbIjRWdX.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":
@@ -20567,6 +20585,8 @@ function useInteractiveIntegration(diagram, options = {}) {
20567
20585
  const readouts = diagram.readouts ?? [];
20568
20586
  if (inputs.length === 0 && scrolls.length === 0 && formulasList.length === 0 && readouts.length === 0)
20569
20587
  return null;
20588
+ const \u540D\u672D = /* @__PURE__ */ new Map();
20589
+ for (const x of [...inputs, ...formulasList]) if (x.label) \u540D\u672D.set(x.id, x.label);
20570
20590
  return (
20571
20591
  // 操作部の中の読み出しと入力欄へ、図の言語を届ける (#849)。 型の外の値は英語に落ちる
20572
20592
  /* @__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 +20595,13 @@ function useInteractiveIntegration(diagram, options = {}) {
20575
20595
  FormulaReadout,
20576
20596
  {
20577
20597
  id: f.id,
20578
- expression: f.expression,
20598
+ name: f.label || f.id,
20599
+ expression: f.label ? \u5F0F\u3092\u540D\u672D\u3067\u8AAD\u3080(f.expression, \u540D\u672D) : f.expression,
20579
20600
  value: stateOverrides[f.id]
20580
20601
  },
20581
20602
  f.id
20582
20603
  )) }),
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)) }),
20604
+ 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
20605
  readouts.length > 0 && /* @__PURE__ */ jsx("div", { className: "cdl-ip-group", children: readouts.map((r) => /* @__PURE__ */ jsx(ReadoutWidget, { readout: r, stateOverrides: mergedStateValues }, r.id)) })
20585
20606
  ] }) })
20586
20607
  );
@@ -20837,11 +20858,12 @@ function NumberInputWidget({
20837
20858
  }
20838
20859
  function FormulaReadout({
20839
20860
  id,
20861
+ name,
20840
20862
  expression,
20841
20863
  value
20842
20864
  }) {
20843
20865
  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 }),
20866
+ /* @__PURE__ */ jsx("span", { className: "cdl-ip-label", children: name }),
20845
20867
  /* @__PURE__ */ jsxs("code", { className: "cdl-ip-formula-expr", children: [
20846
20868
  "= ",
20847
20869
  expression
@@ -20849,11 +20871,11 @@ function FormulaReadout({
20849
20871
  /* @__PURE__ */ jsx("span", { className: "cdl-ip-formula-value", children: String(value ?? "") })
20850
20872
  ] });
20851
20873
  }
20852
- function ScrollReadout({ id, progress }) {
20874
+ function ScrollReadout({ id, name, progress }) {
20853
20875
  const p = typeof progress === "number" ? progress : 0;
20854
20876
  const pct = Math.round(p * 100);
20855
20877
  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 }),
20878
+ /* @__PURE__ */ jsx("span", { className: "cdl-ip-label", children: name }),
20857
20879
  /* @__PURE__ */ jsx("div", { className: "cdl-ip-scroll-track", children: /* @__PURE__ */ jsx("div", { className: "cdl-ip-scroll-fill", style: { width: `${pct}%` } }) }),
20858
20880
  /* @__PURE__ */ jsxs("span", { className: "cdl-ip-scroll-value", children: [
20859
20881
  pct,