@bian-womp/spark-workbench 0.1.22 → 0.1.23
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultContextMenu.d.ts","sourceRoot":"","sources":["../../../../src/misc/DefaultContextMenu.tsx"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,SAAS,EACT,KAAK,EACL,OAAO,GACR,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC3C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACpE,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"DefaultContextMenu.d.ts","sourceRoot":"","sources":["../../../../src/misc/DefaultContextMenu.tsx"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,SAAS,EACT,KAAK,EACL,OAAO,GACR,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC3C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACpE,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,kDA4HA"}
|
package/lib/esm/index.js
CHANGED
|
@@ -871,7 +871,7 @@ function preformatValueForDisplay(typeId, value, registry) {
|
|
|
871
871
|
return preformatValueForDisplay(getTypedOutputTypeId(value), getTypedOutputValue(value), registry);
|
|
872
872
|
}
|
|
873
873
|
// Enums
|
|
874
|
-
if (typeId && typeId.
|
|
874
|
+
if (typeId && typeId.startsWith("enum:") && registry) {
|
|
875
875
|
const n = Number(value);
|
|
876
876
|
const label = registry.enums.get(typeId)?.valueToLabel.get(n);
|
|
877
877
|
if (label)
|
|
@@ -1638,7 +1638,7 @@ function Inspector({ debug, autoScroll, hideWorkbench, onAutoScrollChange, onHid
|
|
|
1638
1638
|
const orig = originals[h] ?? safeToString(typeId, current);
|
|
1639
1639
|
setDrafts((d) => ({ ...d, [h]: orig }));
|
|
1640
1640
|
};
|
|
1641
|
-
const isEnum = typeId?.
|
|
1641
|
+
const isEnum = typeId?.startsWith("enum:");
|
|
1642
1642
|
const inIssues = selectedNodeHandleValidation.inputs.filter((m) => m.handle === h);
|
|
1643
1643
|
const hasValidation = inIssues.length > 0;
|
|
1644
1644
|
const hasErr = inIssues.some((m) => m.level === "error");
|
|
@@ -1754,16 +1754,18 @@ function DefaultContextMenu({ open, clientPos, onAdd, onClose, }) {
|
|
|
1754
1754
|
const { registry } = useWorkbenchContext();
|
|
1755
1755
|
const rf = useReactFlow();
|
|
1756
1756
|
const ids = Array.from(registry.nodes.keys());
|
|
1757
|
-
|
|
1758
|
-
const grouped = {};
|
|
1757
|
+
const root = { __children: {} };
|
|
1759
1758
|
for (const id of ids) {
|
|
1760
1759
|
const parts = id.split(".");
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1760
|
+
let node = root;
|
|
1761
|
+
for (let i = 0; i < parts.length; i++) {
|
|
1762
|
+
const key = parts[i];
|
|
1763
|
+
node.__children[key] = node.__children[key] || { __children: {} };
|
|
1764
|
+
node = node.__children[key];
|
|
1765
|
+
if (i === parts.length - 1)
|
|
1766
|
+
node.__self = id;
|
|
1767
|
+
}
|
|
1764
1768
|
}
|
|
1765
|
-
const cats = Object.keys(grouped).sort((a, b) => a.localeCompare(b));
|
|
1766
|
-
cats.forEach((c) => grouped[c].sort((a, b) => a.label.localeCompare(b.label)));
|
|
1767
1769
|
const totalCount = ids.length;
|
|
1768
1770
|
// Ref for focus/outside click handling
|
|
1769
1771
|
const ref = useRef(null);
|
|
@@ -1807,10 +1809,19 @@ function DefaultContextMenu({ open, clientPos, onAdd, onClose, }) {
|
|
|
1807
1809
|
onAdd(typeId, p);
|
|
1808
1810
|
onClose();
|
|
1809
1811
|
};
|
|
1812
|
+
const renderTree = (tree, path = []) => {
|
|
1813
|
+
const entries = Object.entries(tree.__children).sort((a, b) => a[0].localeCompare(b[0]));
|
|
1814
|
+
return (jsx("div", { children: entries.map(([key, child]) => {
|
|
1815
|
+
const label = key;
|
|
1816
|
+
const hasChildren = Object.keys(child.__children).length > 0;
|
|
1817
|
+
!!child.__self && !hasChildren;
|
|
1818
|
+
return (jsxs("div", { children: [jsx("div", { className: "px-2 py-1 text-[11px] uppercase tracking-wide text-gray-400", children: label }), child.__self && (jsx("button", { onClick: () => handleClick(child.__self), className: "block w-full text-left px-3 py-1 hover:bg-gray-100 cursor-pointer", title: child.__self, children: child.__self.split(".").slice(-1)[0] })), hasChildren && (jsx("div", { className: "pl-2 border-l border-gray-200 ml-2", children: renderTree(child, [...path, key]) }))] }, [...path, key].join(".")));
|
|
1819
|
+
}) }));
|
|
1820
|
+
};
|
|
1810
1821
|
return (jsxs("div", { ref: ref, tabIndex: -1, className: "fixed z-[1000] bg-white border border-gray-300 rounded-none shadow-lg p-1 min-w-[180px] text-sm text-gray-700", style: { left: x, top: y }, onClick: (e) => e.stopPropagation(), onMouseDown: (e) => e.stopPropagation(), onWheel: (e) => e.stopPropagation(), onContextMenu: (e) => {
|
|
1811
1822
|
e.preventDefault();
|
|
1812
1823
|
e.stopPropagation();
|
|
1813
|
-
}, children: [jsxs("div", { className: "px-2 py-1 font-semibold text-gray-700", children: ["Add Node ", jsxs("span", { className: "text-gray-500 font-normal", children: ["(", totalCount, ")"] })] }), jsx("div", { className: "max-h-60 overflow-auto", children:
|
|
1824
|
+
}, children: [jsxs("div", { className: "px-2 py-1 font-semibold text-gray-700", children: ["Add Node ", jsxs("span", { className: "text-gray-500 font-normal", children: ["(", totalCount, ")"] })] }), jsx("div", { className: "max-h-60 overflow-auto", children: renderTree(root) })] }));
|
|
1814
1825
|
}
|
|
1815
1826
|
|
|
1816
1827
|
function NodeContextMenu({ open, clientPos, nodeId, onClose, }) {
|
|
@@ -2345,7 +2356,7 @@ function WorkbenchStudioCanvas({ setRegistry, autoScroll, onAutoScrollChange, ex
|
|
|
2345
2356
|
// value.ts handles data URL formatting
|
|
2346
2357
|
return title || url.slice(0, 32) + (url.length > 32 ? "…" : "");
|
|
2347
2358
|
}
|
|
2348
|
-
if (typeId && typeId.
|
|
2359
|
+
if (typeId && typeId.startsWith("enum:")) {
|
|
2349
2360
|
const n = Number(value);
|
|
2350
2361
|
const label = registry.enums.get(typeId)?.valueToLabel.get(n);
|
|
2351
2362
|
return label ?? String(n);
|