import React from "react"; import { Box, Text } from "ink"; interface ProgressBarProps { label: string; current: number; total: number; width?: number; } /** * Render a progress bar with label and percentage */ export function ProgressBar({ label, current, total, width = 20 }: ProgressBarProps) { const percent = total > 0 ? Math.round((current / total) * 100) : 0; const filled = Math.max(0, Math.min(width, Math.round((percent / 100) * width))); const empty = width - filled; const bar = "█".repeat(filled) + "░".repeat(empty); return ( {label} [{bar}] {current}/{total} ({percent}%) ); } /** * Simple spinner for indeterminate progress */ export function Spinner({ label }: { label: string }) { const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]; const [frameIndex, setFrameIndex] = React.useState(0); React.useEffect(() => { const timer = setInterval(() => { setFrameIndex((prev) => (prev + 1) % frames.length); }, 80); return () => clearInterval(timer); }, []); return ( {frames[frameIndex]} {label} ); }