// Tabs „Wandstile", „Deckenstile" und „Dachtypen" — geschichteter Aufbau. // Alle drei Ressourcen teilen Struktur (WallType/CeilingType/RoofType = // {id,name,layers[]}) und Editor: ein Master-Detail-Layout wie bei Schraffuren/ // Linien. Liste links = je Typ eine Zeile mit kleiner Querschnitt-Vorschau + // Name; Detail rechts = Aufbau-Editor (Schichten stapeln: Bauteil/Dicke/ // Fugenlinie, hinzufügen/entfernen/umordnen) + großer Live-Querschnitt. Ein // gemeinsames Detail-Panel {@link LayeredStyleDetail}, parametrisiert über die // Orientierung (Wand: Bänder nebeneinander / Decke+Dach: liegend gestapelt) // und die jeweiligen Handler. // // Funktion ([33]): `layer.function` (tragend, Dämmung, Unterlagsboden …) für Override-Regeln // („Deckenaufbau weiss", Lage zur tragenden Schicht); ohne Feld gilt die aus dem Baustoff // abgeleitete Funktion (Kern), die die Auswahl als Vorgabe anzeigt. // // Fugen: `layer[i].jointLineStyleId` ist der Linienstil der INNEREN Kante der // Schicht i (Fuge zur nächst-inneren Schicht). Die innerste Schicht hat keine // innere Fuge (ihre Kante ist der Innenumriss) → dort kein Dropdown. import { useMemo, useState } from "react"; import type { CeilingType, Layer, LayerFunction, Project, RoofType, WallType } from "../../model/types"; import { componentLayerFunctions, LAYER_FUNCTIONS } from "../../model/standards"; import { WallTypeSwatch } from "../hatchPreview"; import { UValueLine } from "../../panels/UValueRow"; import type { SwatchLayer } from "../hatchPreview"; import { t } from "../../i18n"; import { DeleteButton, FieldRow, NumberField, SelectField } from "./fields"; /** Wand-, Decken- und Dachtyp teilen dieselbe Form (`{id,name,layers}`). */ type LayeredStyle = WallType | CeilingType | RoofType; /** * Baut die Querschnitt-Bänder (eine je Schicht) aus den Bauteil-Schnitt- * schraffuren: Schicht → Bauteil → dessen `hatchId` → HatchStyle. Fehlt das * Bauteil/die Schraffur, bleibt das Band leer (weiß). */ function swatchLayersOf(style: LayeredStyle, project: Project): SwatchLayer[] { return style.layers.map((l) => { const comp = project.components.find((c) => c.id === l.componentId); const hatch = comp ? project.hatches.find((hh) => hh.id === comp.hatchId) : undefined; return { hatch, thickness: l.thickness }; }); } /** Detail-Panel EINES Wand-/Decken-/Dachtyps (rechte Seite des Master-Detail-Layouts). */ function LayeredStyleDetail({ style, project, orientation, uKind, onPatch, onDelete, deleteTitle, namePlaceholder, }: { style: LayeredStyle; project: Project; orientation: "wall" | "ceiling"; /** Bauteilart für den U-Wert ([71]). */ uKind: "wall" | "ceiling" | "roof"; onPatch: (patch: Partial) => void; onDelete: () => void; deleteTitle: string; namePlaceholder: string; }) { // Sentinel „— (Haarlinie)": kein Feld gesetzt → Standard-Haarlinie 0.02 mm. const DEFAULT = "__default__"; const jointOptions = [ { value: DEFAULT, label: t("resources.joint.default") }, ...project.lineStyles.map((l) => ({ value: l.id, label: l.name })), ]; const compOptions = project.components.length > 0 ? project.components.map((c) => ({ value: c.id, label: c.name })) : [{ value: "", label: "—" }]; // [33] Schichtfunktion: Sentinel „aus Baustoff" (kein Feld) zeigt den abgeleiteten Wert. const AUTO = "__auto__"; const derived = useMemo(() => componentLayerFunctions(project), [project]); const fnLabel = (f: LayerFunction) => t(`resources.overrides.val.layer_function.${f}`); const functionOptions = (componentId: string) => { const d = derived[componentId]; return [ { value: AUTO, label: t("resources.layer.functionAuto", { f: d ? fnLabel(d) : t("resources.layer.functionNone") }) }, ...LAYER_FUNCTIONS.map((f) => ({ value: f, label: fnLabel(f) })), ]; }; const layers = style.layers; const setLayers = (next: Layer[]) => onPatch({ layers: next }); const patchLayer = (i: number, patch: Partial) => setLayers(layers.map((l, k) => (k === i ? { ...l, ...patch } : l))); const addLayer = () => setLayers([ ...layers, { componentId: project.components[0]?.id ?? "", thickness: 0.1 }, ]); const removeLayer = (i: number) => { if (layers.length <= 1) return; setLayers(layers.filter((_, k) => k !== i)); }; const moveLayer = (i: number, dir: -1 | 1) => { const j = i + dir; if (j < 0 || j >= layers.length) return; const next = layers.slice(); [next[i], next[j]] = [next[j], next[i]]; setLayers(next); }; return (
onPatch({ name: e.target.value })} />
{layers.map((layer, i) => { const isInner = i === layers.length - 1; return (
patchLayer(i, { componentId })} options={compOptions} /> patchLayer(i, { function: v === AUTO ? undefined : (v as LayerFunction) })} options={functionOptions(layer.componentId)} /> patchLayer(i, { thickness: Math.max(0, mm) / 1000 }) } step={5} min={0} /> {isInner ? ( – ) : ( patchLayer(i, { jointLineStyleId: v === DEFAULT ? undefined : v, }) } options={jointOptions} /> )} {!isInner && ( patchLayer(i, { jointWeightMm: w > 0 ? w : undefined })} step={0.01} min={0} /> )}
removeLayer(i)} title={t("resources.layer.remove")} />
); })}
); } /** * Gemeinsamer Master-Detail-Tab-Rumpf für Wand-/Decken-/Dachstile: Liste links * (Querschnitt-Vorschau + Name, +-Neu in der Fusszeile), Detail rechts über * {@link LayeredStyleDetail}. Parametrisiert über die Ressource + Orientierung. */ function LayeredStylesTab({ project, types, orientation, uKind, hintKey, emptyKey, placeholderKey, deleteKeyPrefix, onPatch, onAdd, onDelete, }: { project: Project; types: LayeredStyle[]; orientation: "wall" | "ceiling"; uKind: "wall" | "ceiling" | "roof"; hintKey: string; emptyKey: string; placeholderKey: string; deleteKeyPrefix: string; onPatch: (id: string, patch: Partial) => void; onAdd: () => void; onDelete: (id: string) => void; }) { const [selectedId, setSelectedId] = useState(null); const selected = types.find((s) => s.id === selectedId) ?? types[0]; return (
{t(hintKey)}
{types.map((s) => ( ))} {types.length === 0 && (
{t(emptyKey)}
)}
{selected ? ( onPatch(selected.id, patch)} onDelete={() => onDelete(selected.id)} deleteTitle={t(deleteKeyPrefix, { name: selected.name })} namePlaceholder={t(placeholderKey)} /> ) : (
{t(emptyKey)}
)}
); } export function WallStylesTab({ project, onPatchWallType, onAddWallType, onDeleteWallType, }: { project: Project; onPatchWallType: (id: string, patch: Partial) => void; onAddWallType: () => void; onDeleteWallType: (id: string) => void; }) { return ( ); } /** * Tab „Deckenstile" — das liegende Gegenstück zu {@link WallStylesTab}: nutzt * denselben {@link LayeredStylesTab}-Rumpf, nur die Ressource (`ceilingTypes`), * die Orientierung (gestapelt) und die Handler unterscheiden sich. */ export function CeilingStylesTab({ project, onPatchCeilingType, onAddCeilingType, onDeleteCeilingType, }: { project: Project; onPatchCeilingType: (id: string, patch: Partial) => void; onAddCeilingType: () => void; onDeleteCeilingType: (id: string) => void; }) { return ( ); } /** * Tab „Dachtypen" — das geneigte Gegenstück zu {@link CeilingStylesTab}: gleicher * {@link LayeredStylesTab}-Rumpf (Schichtaufbau aussen/Eindeckung → innen/ * Verkleidung), Ressource `roofTypes`. Vorschau in Decken-Orientierung * (gestapelt) — für die Schichtreihenfolge/-dicken ausreichend. */ export function RoofStylesTab({ project, onPatchRoofType, onAddRoofType, onDeleteRoofType, }: { project: Project; onPatchRoofType: (id: string, patch: Partial) => void; onAddRoofType: () => void; onDeleteRoofType: (id: string) => void; }) { return ( ); }