"use client"; import { Handle, Position } from "@xyflow/react"; import { NODE_SOCKETS, SOCKET_COLORS, type SocketDef } from "./types"; function SocketHandle({ socket, isInput, topPercent, }: { socket: SocketDef; isInput: boolean; topPercent: number; }) { const color = SOCKET_COLORS[socket.type]; const isFlow = socket.type === "flow"; return (
{socket.label && ( {socket.label} )}
); } interface NodeShellProps { nodeType: string; dynamicInputs?: SocketDef[]; dynamicOutputs?: SocketDef[]; children: React.ReactNode; className?: string; } export function NodeShell({ nodeType, dynamicInputs, dynamicOutputs, children, className = "", }: NodeShellProps) { const config = NODE_SOCKETS[nodeType]; if (!config) return
{children}
; const inputs = dynamicInputs ?? config.inputs; const outputs = dynamicOutputs ?? config.outputs; const maxSlots = Math.max(inputs.length, outputs.length, 1); return (
{/* Input handles - positioned on left edge */} {inputs.map((socket, i) => { const top = maxSlots === 1 ? 50 : (i / (maxSlots - 1)) * 80 + 10; return ; })} {/* Output handles - positioned on right edge */} {outputs.map((socket, i) => { const top = maxSlots === 1 ? 50 : (i / (maxSlots - 1)) * 80 + 10; return ; })} {/* Content area with padding to avoid handle overlap */}
{children}
); }