import React, { Fragment } from "react" import { ArrowRight, ArrowDown, ArrowLeftRight, ArrowUpDown } from "lucide-react" import { cn } from "@/lib/utils" type NodeVariant = "source" | "bridge" | "target" export interface DataFlowNode { label: string detail?: string variant?: NodeVariant } export interface DataFlowDiagramProps { nodes: DataFlowNode[] arrowLabel?: string bidirectional?: boolean command?: string caption?: string className?: string } const variantStyles: Record = { source: "border-blue-300 bg-blue-50", bridge: "border-gray-300 bg-gray-50", target: "border-amber-300 bg-amber-50", } const variantLabel: Record = { source: "text-blue-800", bridge: "text-gray-700", target: "text-amber-800", } export const DataFlowDiagram: React.FC = ({ nodes, arrowLabel, bidirectional = false, command, caption, className, }) => { const HorizArrow = bidirectional ? ArrowLeftRight : ArrowRight const VertArrow = bidirectional ? ArrowUpDown : ArrowDown return (
{nodes.map((node, i) => { const variant = node.variant ?? "bridge" return (
{node.label}
{node.detail && (
{node.detail}
)}
{i < nodes.length - 1 && (
{arrowLabel && ( {arrowLabel} )}
)}
) })}
{command && (
          {command}
        
)} {caption && (

{caption}

)}
) }