import { Handle, type NodeProps, Position } from "@xyflow/react" import { LayoutDashboard, LogIn, LogOut, Workflow } from "lucide-react" import { memo } from "react" import { useIsMobile } from "@/hooks/useMobile" import { cn } from "@/lib/utils" import type { EndpointNodeData } from "./endpoints" const KIND_ICONS = { dashboard: LayoutDashboard, flow: Workflow, input: LogIn, output: LogOut, } as const /** * A thing wired into this flow that is not a node in it. * * Drawn as a label rather than a card on purpose: a dashboard with twenty * tiles would otherwise bury the logic the canvas exists to show, which is * the same reason dashboards are their own documents. It is here to account * for a value, not to compete with the nodes for attention. */ function EndpointNodeComponent({ data, selected }: NodeProps) { const { label, kind, detail, provides, requires } = data as EndpointNodeData const Icon = KIND_ICONS[kind as keyof typeof KIND_ICONS] ?? Workflow const messages = [...provides, ...requires] // Follows the graph's own direction; see DESIGN-GUIDELINES.md → Responsive. const vertical = useIsMobile() return (
{/* Both sides always exist so an edge can attach; only one is used. */} {requires.map((message) => ( ))} {provides.map((message) => ( ))} {label} {detail}
) } export const EndpointNode = memo(EndpointNodeComponent) export default EndpointNode