@bian-womp/spark-workbench 0.1.23 → 0.1.25

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,kDA4HA"}
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,kDAmKA"}
package/lib/esm/index.js CHANGED
@@ -1754,8 +1754,13 @@ 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
+ const [query, setQuery] = useState("");
1758
+ const q = query.trim().toLowerCase();
1759
+ const filteredIds = q
1760
+ ? ids.filter((id) => id.toLowerCase().includes(q))
1761
+ : ids;
1757
1762
  const root = { __children: {} };
1758
- for (const id of ids) {
1763
+ for (const id of filteredIds) {
1759
1764
  const parts = id.split(".");
1760
1765
  let node = root;
1761
1766
  for (let i = 0; i < parts.length; i++) {
@@ -1766,7 +1771,7 @@ function DefaultContextMenu({ open, clientPos, onAdd, onClose, }) {
1766
1771
  node.__self = id;
1767
1772
  }
1768
1773
  }
1769
- const totalCount = ids.length;
1774
+ const totalCount = filteredIds.length;
1770
1775
  // Ref for focus/outside click handling
1771
1776
  const ref = useRef(null);
1772
1777
  // Close on outside click and on ESC
@@ -1790,10 +1795,12 @@ function DefaultContextMenu({ open, clientPos, onAdd, onClose, }) {
1790
1795
  window.removeEventListener("keydown", onKey);
1791
1796
  };
1792
1797
  }, [open, onClose]);
1793
- // Focus for keyboard accessibility
1798
+ // Focus search input when menu opens
1799
+ const inputRef = useRef(null);
1794
1800
  useEffect(() => {
1795
- if (open)
1796
- ref.current?.focus();
1801
+ if (open) {
1802
+ setTimeout(() => inputRef.current?.focus(), 0);
1803
+ }
1797
1804
  }, [open]);
1798
1805
  if (!open || !clientPos)
1799
1806
  return null;
@@ -1814,14 +1821,19 @@ function DefaultContextMenu({ open, clientPos, onAdd, onClose, }) {
1814
1821
  return (jsx("div", { children: entries.map(([key, child]) => {
1815
1822
  const label = key;
1816
1823
  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(".")));
1824
+ const idKey = [...path, key].join(".");
1825
+ if (!hasChildren) {
1826
+ // Leaf: render only the action button, no group header
1827
+ return 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: label }, idKey)) : null;
1828
+ }
1829
+ // Group: show label, optional action for id at this level, and children
1830
+ 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: label })), jsx("div", { className: "pl-2 border-l border-gray-200 ml-2", children: renderTree(child, [...path, key]) })] }, idKey));
1819
1831
  }) }));
1820
1832
  };
1821
1833
  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) => {
1822
1834
  e.preventDefault();
1823
1835
  e.stopPropagation();
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) })] }));
1836
+ }, 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: "px-2 pb-1", children: jsx("input", { ref: inputRef, type: "text", value: query, onChange: (e) => setQuery(e.target.value), placeholder: "Filter nodes...", className: "w-full border border-gray-300 px-2 py-1 text-sm outline-none focus:border-gray-400", onClick: (e) => e.stopPropagation(), onMouseDown: (e) => e.stopPropagation(), onWheel: (e) => e.stopPropagation() }) }), jsx("div", { className: "max-h-60 overflow-auto", children: totalCount > 0 ? (renderTree(root)) : (jsx("div", { className: "px-3 py-2 text-gray-400", children: "No matches" })) })] }));
1825
1837
  }
1826
1838
 
1827
1839
  function NodeContextMenu({ open, clientPos, nodeId, onClose, }) {