"use client"; import { motion } from "motion/react"; import { ChartFrame } from "@/components/charts/chart-frame"; import { treeLayout, type TreeNode } from "@/lib/layout"; type OrgChartProps = { root: TreeNode; width?: number; height?: number; className?: string; }; const BOX_W = 132; const BOX_H = 46; /** OrgChart — tidy top-down tree. Boxes reveal level by level; elbow connectors draw with pathLength. */ export function OrgChart({ root, width = 720, height = 380, className }: OrgChartProps) { const { nodes, edges } = treeLayout(root, width, height); const depthDelay = (d: number) => 0.1 + d * 0.25; return ( {({ inView, reduce }) => ( <> {edges.map((e, i) => { const midY = (e.from.y + BOX_H / 2 + (e.to.y - BOX_H / 2)) / 2; const d = `M${e.from.x},${e.from.y + BOX_H / 2} V${midY} H${e.to.x} V${e.to.y - BOX_H / 2}`; return ( n.x === e.to.x && n.y === e.to.y)?.depth ?? 0) - 0.1, ease: [0.22, 1, 0.36, 1] }} /> ); })} {nodes.map((n) => ( {n.label} ))} )} ); }