import { useState } from "react"; import type { DiffReport } from "@codarch/metrics/browser"; import type { FileDiffView } from "../platform"; import { changeFileGroups, filesSummary, scopeChangeFiles } from "../changeFiles"; import { CollapsibleSection, GroupHead } from "../CollapsibleSection"; import { FileChangeRow } from "./FileEntry"; /** * Los ficheros tocados, agrupados por estado. * * Qué filas están desplegadas es estado suyo y de nadie más: no es selección ni * foco, solo qué está abierto mientras se mira la lista. */ export function FilesSection({ report, loadDiff, onSelectPath, folder = null, onClearScope }: { report: DiffReport; loadDiff?: (path: string) => Promise; onSelectPath: (path: string) => void; /** La carpeta a la que se acota la lista, si se abrió desde su ficha (ADR 0092). */ folder?: string | null; /** Quita el filtro y vuelve al cambio entero. */ onClearScope?: () => void; }) { const [expanded, setExpanded] = useState>(() => new Set()); const toggle = (path: string): void => { setExpanded((open) => { const next = new Set(open); if (next.has(path)) next.delete(path); else next.add(path); return next; }); }; const groups = changeFileGroups( scopeChangeFiles(report.files, folder), undefined, report.symbols ); const total = groups.reduce((sum, group) => sum + group.count, 0); return ( {folder ? (
Solo {folder}
) : null} {total === 0 ? (

Sin ficheros tocados.

) : ( groups .filter((group) => group.count > 0) .map((group) => (
{group.files.map((file) => ( toggle(file.path)} onSelectPath={onSelectPath} /> ))}
{group.rest > 0 ? (

+{group.rest} más

) : null}
)) )}
); }