@cardenelabs/cdl 0.59.0 → 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/CHANGELOG.md +46 -1
- package/dist/index.cjs +110 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +110 -70
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +61 -22
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +61 -22
- package/dist/react.js.map +1 -1
- package/dist/{render-DpwY2hzM.d.cts → render-MbIjRWdX.d.cts} +7 -0
- package/dist/{render-DpwY2hzM.d.ts → render-MbIjRWdX.d.ts} +7 -0
- package/package.json +1 -1
- package/src/builder.ts +13 -5
- package/src/formula/parser.ts +32 -3
- package/src/kinds/row-align.ts +30 -0
- package/src/render/interactive-panel.tsx +37 -20
- package/src/types.ts +7 -0
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":
|
|
@@ -9544,6 +9562,22 @@ function displayWidth(text) {
|
|
|
9544
9562
|
}
|
|
9545
9563
|
return w;
|
|
9546
9564
|
}
|
|
9565
|
+
function \u6841\u3067\u5272\u308B(text, \u6841) {
|
|
9566
|
+
let w = 0;
|
|
9567
|
+
let \u53D6\u3063\u305F = "";
|
|
9568
|
+
for (const ch of text) {
|
|
9569
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
9570
|
+
const \u5B57\u306E\u6841 = code >= 32 && code <= 126 ? 1 : 2;
|
|
9571
|
+
if (w + \u5B57\u306E\u6841 > \u6841) break;
|
|
9572
|
+
w += \u5B57\u306E\u6841;
|
|
9573
|
+
\u53D6\u3063\u305F += ch;
|
|
9574
|
+
}
|
|
9575
|
+
return [\u53D6\u3063\u305F, text.slice(\u53D6\u3063\u305F.length)];
|
|
9576
|
+
}
|
|
9577
|
+
function \u6841\u3067\u7701\u304F(text, \u4E0A\u9650) {
|
|
9578
|
+
if (displayWidth(text) <= \u4E0A\u9650) return text;
|
|
9579
|
+
return `${\u6841\u3067\u5272\u308B(text, \u4E0A\u9650 - 1)[0]}\u2026`;
|
|
9580
|
+
}
|
|
9547
9581
|
function requiredRowsWidth(rows, kind) {
|
|
9548
9582
|
if (!rows || rows.length === 0) return 0;
|
|
9549
9583
|
const splits = rows.map(splitRow);
|
|
@@ -20553,6 +20587,8 @@ function useInteractiveIntegration(diagram, options = {}) {
|
|
|
20553
20587
|
const readouts = diagram.readouts ?? [];
|
|
20554
20588
|
if (inputs.length === 0 && scrolls.length === 0 && formulasList.length === 0 && readouts.length === 0)
|
|
20555
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);
|
|
20556
20592
|
return (
|
|
20557
20593
|
// 操作部の中の読み出しと入力欄へ、図の言語を届ける (#849)。 型の外の値は英語に落ちる
|
|
20558
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: [
|
|
@@ -20561,12 +20597,13 @@ function useInteractiveIntegration(diagram, options = {}) {
|
|
|
20561
20597
|
FormulaReadout,
|
|
20562
20598
|
{
|
|
20563
20599
|
id: f.id,
|
|
20564
|
-
|
|
20600
|
+
name: f.label || f.id,
|
|
20601
|
+
expression: f.label ? \u5F0F\u3092\u540D\u672D\u3067\u8AAD\u3080(f.expression, \u540D\u672D) : f.expression,
|
|
20565
20602
|
value: stateOverrides[f.id]
|
|
20566
20603
|
},
|
|
20567
20604
|
f.id
|
|
20568
20605
|
)) }),
|
|
20569
|
-
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)) }),
|
|
20570
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)) })
|
|
20571
20608
|
] }) })
|
|
20572
20609
|
);
|
|
@@ -20823,11 +20860,12 @@ function NumberInputWidget({
|
|
|
20823
20860
|
}
|
|
20824
20861
|
function FormulaReadout({
|
|
20825
20862
|
id,
|
|
20863
|
+
name,
|
|
20826
20864
|
expression,
|
|
20827
20865
|
value
|
|
20828
20866
|
}) {
|
|
20829
20867
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cdl-ip-item cdl-ip-formula", "data-cdl-formula": id, children: [
|
|
20830
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-label", children:
|
|
20868
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-label", children: name }),
|
|
20831
20869
|
/* @__PURE__ */ jsxRuntime.jsxs("code", { className: "cdl-ip-formula-expr", children: [
|
|
20832
20870
|
"= ",
|
|
20833
20871
|
expression
|
|
@@ -20835,11 +20873,11 @@ function FormulaReadout({
|
|
|
20835
20873
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-formula-value", children: String(value ?? "") })
|
|
20836
20874
|
] });
|
|
20837
20875
|
}
|
|
20838
|
-
function ScrollReadout({ id, progress }) {
|
|
20876
|
+
function ScrollReadout({ id, name, progress }) {
|
|
20839
20877
|
const p = typeof progress === "number" ? progress : 0;
|
|
20840
20878
|
const pct = Math.round(p * 100);
|
|
20841
20879
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cdl-ip-item cdl-ip-scroll", "data-cdl-scroll": id, children: [
|
|
20842
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-label", children:
|
|
20880
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-label", children: name }),
|
|
20843
20881
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "cdl-ip-scroll-track", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cdl-ip-scroll-fill", style: { width: `${pct}%` } }) }),
|
|
20844
20882
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "cdl-ip-scroll-value", children: [
|
|
20845
20883
|
pct,
|
|
@@ -26165,7 +26203,7 @@ function KanbanBoardReadout({
|
|
|
26165
26203
|
style: { userSelect: "none" },
|
|
26166
26204
|
children: [
|
|
26167
26205
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: task.title }),
|
|
26168
|
-
task.title
|
|
26206
|
+
\u6841\u3067\u7701\u304F(task.title, 18)
|
|
26169
26207
|
]
|
|
26170
26208
|
}
|
|
26171
26209
|
)
|
|
@@ -26302,7 +26340,7 @@ function TimelineVerticalReadout({
|
|
|
26302
26340
|
style: { userSelect: "none" },
|
|
26303
26341
|
children: [
|
|
26304
26342
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: ev.title }),
|
|
26305
|
-
ev.title
|
|
26343
|
+
\u6841\u3067\u7701\u304F(ev.title, 38)
|
|
26306
26344
|
]
|
|
26307
26345
|
}
|
|
26308
26346
|
),
|
|
@@ -26316,7 +26354,7 @@ function TimelineVerticalReadout({
|
|
|
26316
26354
|
style: { userSelect: "none" },
|
|
26317
26355
|
children: [
|
|
26318
26356
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: ev.description }),
|
|
26319
|
-
ev.description
|
|
26357
|
+
\u6841\u3067\u7701\u304F(ev.description, 44)
|
|
26320
26358
|
]
|
|
26321
26359
|
}
|
|
26322
26360
|
) : null
|
|
@@ -26659,7 +26697,7 @@ function StepProgressReadout({
|
|
|
26659
26697
|
style: { userSelect: "none" },
|
|
26660
26698
|
children: [
|
|
26661
26699
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: s }),
|
|
26662
|
-
s
|
|
26700
|
+
\u6841\u3067\u7701\u304F(s, 10)
|
|
26663
26701
|
]
|
|
26664
26702
|
}
|
|
26665
26703
|
)
|
|
@@ -26720,7 +26758,7 @@ function UserPresenceReadout({
|
|
|
26720
26758
|
fontWeight: 500,
|
|
26721
26759
|
fill: "#0f172a",
|
|
26722
26760
|
style: { userSelect: "none" },
|
|
26723
|
-
children: u.name
|
|
26761
|
+
children: \u6841\u3067\u7701\u304F(u.name, 24)
|
|
26724
26762
|
}
|
|
26725
26763
|
),
|
|
26726
26764
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -26882,7 +26920,7 @@ function OrgChartMiniReadout({
|
|
|
26882
26920
|
style: { userSelect: "none" },
|
|
26883
26921
|
children: [
|
|
26884
26922
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: n.name }),
|
|
26885
|
-
n.name
|
|
26923
|
+
\u6841\u3067\u7701\u304F(n.name, 10)
|
|
26886
26924
|
]
|
|
26887
26925
|
}
|
|
26888
26926
|
),
|
|
@@ -27462,7 +27500,7 @@ function FileDropzoneReadout({
|
|
|
27462
27500
|
),
|
|
27463
27501
|
/* @__PURE__ */ jsxRuntime.jsxs("text", { x: 54, y: 34, fontSize: 12, fontWeight: 600, fill: "#0f172a", style: { userSelect: "none" }, children: [
|
|
27464
27502
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: filename }),
|
|
27465
|
-
filename
|
|
27503
|
+
\u6841\u3067\u7701\u304F(filename, 26)
|
|
27466
27504
|
] }),
|
|
27467
27505
|
/* @__PURE__ */ jsxRuntime.jsx("text", { x: 54, y: 50, fontSize: 10, fill: "#64748b", style: { userSelect: "none" }, children: /* @__PURE__ */ jsxRuntime.jsx(\u5B57, { k: "readout.dropzone.uploaded" }) })
|
|
27468
27506
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs("g", { "data-cdl-dropzone-empty": "1", children: [
|
|
@@ -27541,7 +27579,7 @@ function LogStreamReadout({
|
|
|
27541
27579
|
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: 0, y: 0, width, height, fill: "#0f172a", rx: 4 }),
|
|
27542
27580
|
shown.map((r, i) => {
|
|
27543
27581
|
const y = 4 + i * rowH;
|
|
27544
|
-
const displayMsg = r.msg
|
|
27582
|
+
const displayMsg = \u6841\u3067\u7701\u304F(r.msg, 24);
|
|
27545
27583
|
return /* @__PURE__ */ jsxRuntime.jsxs("g", { "data-cdl-log-row": i, children: [
|
|
27546
27584
|
/* @__PURE__ */ jsxRuntime.jsx("text", { x: 6, y: y + 12, fontSize: 9, fill: "#94a3b8", fontFamily: "monospace", style: { userSelect: "none" }, children: r.ts }),
|
|
27547
27585
|
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: 62, y: y + 3, width: 26, height: 12, fill: levelColors[r.level] ?? "#94a3b8", rx: 2 }),
|
|
@@ -27641,7 +27679,7 @@ function AlertBannerReadout({
|
|
|
27641
27679
|
style: { userSelect: "none" },
|
|
27642
27680
|
children: [
|
|
27643
27681
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: message }),
|
|
27644
|
-
message
|
|
27682
|
+
\u6841\u3067\u7701\u304F(message, 32)
|
|
27645
27683
|
]
|
|
27646
27684
|
}
|
|
27647
27685
|
)
|
|
@@ -27711,7 +27749,7 @@ function ServiceHealthReadout({
|
|
|
27711
27749
|
style: { userSelect: "none" },
|
|
27712
27750
|
children: [
|
|
27713
27751
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: s.name }),
|
|
27714
|
-
s.name
|
|
27752
|
+
\u6841\u3067\u7701\u304F(s.name, 10)
|
|
27715
27753
|
]
|
|
27716
27754
|
}
|
|
27717
27755
|
)
|
|
@@ -27890,7 +27928,7 @@ function PricingTierReadout({
|
|
|
27890
27928
|
),
|
|
27891
27929
|
features.slice(0, 3).map((f, i) => {
|
|
27892
27930
|
const y = 96 + i * 18;
|
|
27893
|
-
const displayF = f
|
|
27931
|
+
const displayF = \u6841\u3067\u7701\u304F(f, 24);
|
|
27894
27932
|
return /* @__PURE__ */ jsxRuntime.jsxs("g", { "data-cdl-tier-feature": i, children: [
|
|
27895
27933
|
/* @__PURE__ */ jsxRuntime.jsx("text", { x: 16, y, fontSize: 11, fill: colorAccent, style: { userSelect: "none" }, children: "\u2713" }),
|
|
27896
27934
|
/* @__PURE__ */ jsxRuntime.jsxs("text", { x: 30, y, fontSize: 11, fill: "#0f172a", style: { userSelect: "none" }, children: [
|
|
@@ -28041,6 +28079,7 @@ function ArticlePreviewReadout({
|
|
|
28041
28079
|
const width = 300;
|
|
28042
28080
|
const height = 116;
|
|
28043
28081
|
const thumbW = 80;
|
|
28082
|
+
const [\u629C\u7C8B\u306E\u4E00\u884C\u76EE, \u629C\u7C8B\u306E\u6B8B\u308A] = \u6841\u3067\u5272\u308B(excerpt, 28);
|
|
28044
28083
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cdl-ip-item cdl-ip-readout-article-preview", "data-cdl-readout": id, children: [
|
|
28045
28084
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cdl-ip-label", children: label }),
|
|
28046
28085
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -28077,15 +28116,15 @@ function ArticlePreviewReadout({
|
|
|
28077
28116
|
style: { userSelect: "none" },
|
|
28078
28117
|
children: [
|
|
28079
28118
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: title }),
|
|
28080
|
-
title
|
|
28119
|
+
\u6841\u3067\u7701\u304F(title, 26)
|
|
28081
28120
|
]
|
|
28082
28121
|
}
|
|
28083
28122
|
),
|
|
28084
28123
|
/* @__PURE__ */ jsxRuntime.jsxs("text", { x: thumbW + 20, y: 44, fontSize: 10, fill: "#334155", style: { userSelect: "none" }, children: [
|
|
28085
28124
|
/* @__PURE__ */ jsxRuntime.jsx("title", { children: excerpt }),
|
|
28086
|
-
|
|
28125
|
+
\u629C\u7C8B\u306E\u4E00\u884C\u76EE
|
|
28087
28126
|
] }),
|
|
28088
|
-
/* @__PURE__ */ jsxRuntime.jsx("text", { x: thumbW + 20, y: 60, fontSize: 10, fill: "#334155", style: { userSelect: "none" }, children:
|
|
28127
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: thumbW + 20, y: 60, fontSize: 10, fill: "#334155", style: { userSelect: "none" }, children: \u6841\u3067\u7701\u304F(\u629C\u7C8B\u306E\u6B8B\u308A, 28) }),
|
|
28089
28128
|
/* @__PURE__ */ jsxRuntime.jsx("text", { x: thumbW + 20, y: height - 14, fontSize: 10, fontWeight: 600, fill: "#64748b", style: { userSelect: "none" }, children: /* @__PURE__ */ jsxRuntime.jsx(\u5B57, { k: "readout.article.by", v: { author } }) }),
|
|
28090
28129
|
/* @__PURE__ */ jsxRuntime.jsx("text", { x: width - 8, y: height - 14, fontSize: 10, textAnchor: "end", fill: "#94a3b8", style: { userSelect: "none" }, children: timeAgo })
|
|
28091
28130
|
]
|
|
@@ -28137,7 +28176,7 @@ function TocNavReadout({
|
|
|
28137
28176
|
shown.map((it, i) => {
|
|
28138
28177
|
const y = 4 + i * rowH;
|
|
28139
28178
|
const indent = 12 + it.level * 16;
|
|
28140
|
-
const displayT = it.title
|
|
28179
|
+
const displayT = \u6841\u3067\u7701\u304F(it.title, 30);
|
|
28141
28180
|
return /* @__PURE__ */ jsxRuntime.jsxs("g", { "data-cdl-toc-item": i, children: [
|
|
28142
28181
|
it.active ? /* @__PURE__ */ jsxRuntime.jsx("rect", { x: 4, y, width: 3, height: rowH - 4, fill: colorActive, rx: 1 }) : null,
|
|
28143
28182
|
/* @__PURE__ */ jsxRuntime.jsxs(
|