import type { ReactNode } from "react";
interface ConfirmDialogProps {
open: boolean;
title: string;
description: ReactNode;
confirmLabel: string;
danger?: boolean;
busy?: boolean;
onConfirm: () => void;
onCancel: () => void;
children?: ReactNode;
}
export function ConfirmDialog({ open, title, description, confirmLabel, danger, busy, onConfirm, onCancel, children }: ConfirmDialogProps) {
if (!open) {
return null;
}
return (
event.stopPropagation()}>
{title}
{description}
{children}
);
}
interface UsageMeterProps {
label: string;
percent?: number;
}
export function UsageMeter({ label, percent }: UsageMeterProps) {
const known = typeof percent === "number" && Number.isFinite(percent);
const clamped = known ? Math.max(0, Math.min(100, percent)) : 0;
return (
{label}
{known && = 85 ? " usage-high" : ""}`} style={{ width: `${clamped}%` }} />}
{known ? `${Math.round(clamped)}%` : "--"}
);
}
interface DiffViewProps {
lines: Array<{ kind: "same" | "added" | "removed"; text: string }>;
}
export function DiffView({ lines }: DiffViewProps) {
return (
{lines.map((line, index) => (
{line.kind === "added" ? "+" : line.kind === "removed" ? "-" : " "}
{line.text || " "}
))}
);
}