@bian-womp/spark-workbench 0.1.4 → 0.1.6
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 -9
- 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/cjs/src/misc/WorkbenchCanvas.d.ts +0 -1
- package/lib/cjs/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/lib/esm/index.js +18 -9
- 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/lib/esm/src/misc/WorkbenchCanvas.d.ts +0 -1
- package/lib/esm/src/misc/WorkbenchCanvas.d.ts.map +1 -1
- package/package.json +8 -8
package/lib/cjs/index.cjs
CHANGED
|
@@ -5,7 +5,6 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var sparkRemote = require('@bian-womp/spark-remote');
|
|
7
7
|
var ReactFlow = require('reactflow');
|
|
8
|
-
require('reactflow/dist/style.css');
|
|
9
8
|
var cx = require('classnames');
|
|
10
9
|
var react = require('@phosphor-icons/react');
|
|
11
10
|
|
|
@@ -1186,7 +1185,9 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
|
|
|
1186
1185
|
.join("; ");
|
|
1187
1186
|
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
1187
|
const label = String(e.target.value);
|
|
1189
|
-
const byLabel = registry.
|
|
1188
|
+
const byLabel = registry.enums
|
|
1189
|
+
.get(typeId)
|
|
1190
|
+
?.labelToValue.get(label.toLowerCase());
|
|
1190
1191
|
let raw = (byLabel !== undefined ? byLabel : Number(label));
|
|
1191
1192
|
if (!Number.isFinite(raw))
|
|
1192
1193
|
raw = undefined;
|
|
@@ -1194,7 +1195,7 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
|
|
|
1194
1195
|
const display = toDisplay(typeId, raw);
|
|
1195
1196
|
setDrafts((d) => ({ ...d, [h]: display }));
|
|
1196
1197
|
setOriginals((o) => ({ ...o, [h]: display }));
|
|
1197
|
-
}, ...commonProps, children: [jsxRuntime.jsx("option", { value: "", children: "(select)" }), registry.
|
|
1198
|
+
}, ...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
1199
|
if (e.key === "Enter")
|
|
1199
1200
|
commit();
|
|
1200
1201
|
if (e.key === "Escape")
|
|
@@ -1551,11 +1552,19 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
1551
1552
|
const r = new sparkGraph.Registry();
|
|
1552
1553
|
// Types
|
|
1553
1554
|
for (const t of desc.types) {
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1555
|
+
if (t.options) {
|
|
1556
|
+
r.registerEnum({
|
|
1557
|
+
id: t.id,
|
|
1558
|
+
options: t.options,
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
else {
|
|
1562
|
+
r.registerType({
|
|
1563
|
+
id: t.id,
|
|
1564
|
+
displayName: t.displayName,
|
|
1565
|
+
validate: (_v) => true,
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1559
1568
|
}
|
|
1560
1569
|
// Categories: create placeholders for display name
|
|
1561
1570
|
for (const c of desc.categories || []) {
|
|
@@ -1721,7 +1730,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
1721
1730
|
return "";
|
|
1722
1731
|
if (typeId && typeId.includes("enum:")) {
|
|
1723
1732
|
const n = Number(value);
|
|
1724
|
-
const label = registry.
|
|
1733
|
+
const label = registry.enums.get(typeId)?.valueToLabel.get(n);
|
|
1725
1734
|
return label ?? String(n);
|
|
1726
1735
|
}
|
|
1727
1736
|
const round4 = (n) => Math.round(Number(n) * 10000) / 10000;
|