@bian-womp/spark-workbench 0.1.3 → 0.1.5
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/lib/cjs/index.cjs +18 -8
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/examples/reactflow/WorkbenchStudio.d.ts.map +1 -1
- package/lib/cjs/src/misc/Inspector.d.ts.map +1 -1
- package/lib/esm/index.js +18 -8
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/examples/reactflow/WorkbenchStudio.d.ts.map +1 -1
- package/lib/esm/src/misc/Inspector.d.ts.map +1 -1
- package/package.json +4 -4
package/lib/cjs/index.cjs
CHANGED
|
@@ -1186,7 +1186,9 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
|
|
|
1186
1186
|
.join("; ");
|
|
1187
1187
|
return (jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-1", children: [jsxRuntime.jsxs("label", { className: "w-28", children: [h, jsxRuntime.jsx("span", { className: "text-gray-500 ml-1 text-[11px]", children: selectedDesc?.inputs?.[h] })] }), hasValidation && (jsxRuntime.jsx(IssueBadge, { level: hasErr ? "error" : "warning", size: 24, className: "ml-1 w-6 h-6", title: title })), isEnum ? (jsxRuntime.jsxs("select", { className: "border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500 w-full", value: drafts[h] ?? toDisplay(typeId, current), onChange: (e) => {
|
|
1188
1188
|
const label = String(e.target.value);
|
|
1189
|
-
const byLabel = registry.
|
|
1189
|
+
const byLabel = registry.enums
|
|
1190
|
+
.get(typeId)
|
|
1191
|
+
?.labelToValue.get(label.toLowerCase());
|
|
1190
1192
|
let raw = (byLabel !== undefined ? byLabel : Number(label));
|
|
1191
1193
|
if (!Number.isFinite(raw))
|
|
1192
1194
|
raw = undefined;
|
|
@@ -1194,7 +1196,7 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
|
|
|
1194
1196
|
const display = toDisplay(typeId, raw);
|
|
1195
1197
|
setDrafts((d) => ({ ...d, [h]: display }));
|
|
1196
1198
|
setOriginals((o) => ({ ...o, [h]: display }));
|
|
1197
|
-
}, ...commonProps, children: [jsxRuntime.jsx("option", { value: "", children: "(select)" }), registry.
|
|
1199
|
+
}, ...commonProps, children: [jsxRuntime.jsx("option", { value: "", children: "(select)" }), registry.enums.get(typeId)?.options.map((opt) => (jsxRuntime.jsx("option", { value: opt.label, children: opt.label }, opt.value)))] })) : (jsxRuntime.jsx("input", { className: "border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500 w-full", placeholder: isLinked ? "wired" : undefined, value: value, onChange: (e) => onChangeText(e.target.value), onBlur: commit, onKeyDown: (e) => {
|
|
1198
1200
|
if (e.key === "Enter")
|
|
1199
1201
|
commit();
|
|
1200
1202
|
if (e.key === "Escape")
|
|
@@ -1551,11 +1553,19 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
1551
1553
|
const r = new sparkGraph.Registry();
|
|
1552
1554
|
// Types
|
|
1553
1555
|
for (const t of desc.types) {
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1556
|
+
if (t.options) {
|
|
1557
|
+
r.registerEnum({
|
|
1558
|
+
id: t.id,
|
|
1559
|
+
options: t.options,
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
else {
|
|
1563
|
+
r.registerType({
|
|
1564
|
+
id: t.id,
|
|
1565
|
+
displayName: t.displayName,
|
|
1566
|
+
validate: (_v) => true,
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1559
1569
|
}
|
|
1560
1570
|
// Categories: create placeholders for display name
|
|
1561
1571
|
for (const c of desc.categories || []) {
|
|
@@ -1721,7 +1731,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
1721
1731
|
return "";
|
|
1722
1732
|
if (typeId && typeId.includes("enum:")) {
|
|
1723
1733
|
const n = Number(value);
|
|
1724
|
-
const label = registry.
|
|
1734
|
+
const label = registry.enums.get(typeId)?.valueToLabel.get(n);
|
|
1725
1735
|
return label ?? String(n);
|
|
1726
1736
|
}
|
|
1727
1737
|
const round4 = (n) => Math.round(Number(n) * 10000) / 10000;
|