// Auswahl beim IFC-Import ([B3]/[B4]): als Kontext-Meshes (Standard, wie bisher) oder als echte // Bauteile (Kern `import_ifc.rs`). Overlay-Muster wie `UnsavedChangesDialog` (kein `window.confirm`). import { useEffect, useState } from "react"; import { t } from "../i18n"; import { useModalFocus } from "./modalFocus"; import type { IfcElementsSummary } from "../io/ifcImport"; export type IfcImportMode = "mesh" | "elements"; export interface IfcImportDialogProps { fileName: string; onImport: (mode: IfcImportMode) => void; onCancel: () => void; } export function IfcImportDialog({ fileName, onImport, onCancel }: IfcImportDialogProps) { const [mode, setMode] = useState("mesh"); const dialogRef = useModalFocus({}); useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onCancel(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [onCancel]); return (
e.stopPropagation()} >
{t("ifc.importDialog.title")}
{fileName}
{t("ifc.importDialog.asMeshHint")}
{t("ifc.importDialog.asElementsHint")}
); } /** Zeilen „erkannt" des Berichts: Zähler aus der Zusammenfassung des Kerns. */ const RECOGNIZED: ReadonlyArray<[string, (s: IfcElementsSummary) => number]> = [ ["ifc.importReport.walls", (s) => s.walls], ["ifc.importReport.openings", (s) => s.openings], ["ifc.importReport.ceilings", (s) => s.ceilings], ["ifc.importReport.roofs", (s) => s.roofs ?? 0], ["ifc.importReport.stairs", (s) => s.stairs ?? 0], ["ifc.importReport.beams", (s) => s.beams ?? 0], ["ifc.importReport.railings", (s) => s.railings ?? 0], ["ifc.importReport.columns", (s) => s.columns], ["ifc.importReport.rooms", (s) => s.rooms], ["ifc.importReport.floors", (s) => s.floors], [ "ifc.importReport.types", (s) => s.wallTypes + s.ceilingTypes + (s.roofTypes ?? 0) + (s.doorTypes ?? 0) + (s.windowTypes ?? 0), ], ["ifc.importReport.meshes", (s) => s.meshes], ]; /** Bericht nach dem Bauteil-Import ([B4]): was erkannt wurde und was mit welchem Grund Mesh blieb. */ export function IfcImportReportDialog({ fileName, summary, onClose, }: { fileName: string; summary: IfcElementsSummary; onClose: () => void; }) { const dialogRef = useModalFocus({}); useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key === "Escape" || e.key === "Enter") onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [onClose]); const kept = Object.entries(summary.keptReasons ?? {}).flatMap(([cls, reasons]) => Object.entries(reasons).map(([why, n]) => ({ cls, why, n })), ); return (
e.stopPropagation()} >
{t("ifc.importReport.title")}
{fileName} · {t("ifc.importReport.recognized")}
{RECOGNIZED.map(([key, n]) => ( ))}
{t(key)} {n(summary)}
{t("ifc.importReport.kept")}
{kept.length === 0 ? (
{t("ifc.importReport.keptNone")}
) : ( {kept.map(({ cls, why, n }) => ( ))}
{cls} {t(`ifc.reason.${why}`)} {n}
)}
); }