[121] App.tsx zerlegt, Oberleiste/Statusleiste/Befehlszeile/Werkzeuge memoisiert
Herausgelöst: Befehls-Engine (state/useCommandEngineHost), 3D-Griffe (state/useGrip3dEditing), Layout-Blatt (state/useSheetPane), Darstellungs-Resolver (state/useDisplayResolvers). Stabile Handler über useEvent/useEventBundle; memo für TopBar (nur noch projectName), AppMenuBar, ViewRibbonTab, StatusBar, CommandLine, Werkzeug-/Befehls-Icons, Overlays. Panels: PanelHostProvider mit Store, usePanelHostSelect/usePanelHostAction — die Werkzeug-Palette abonniert nur ihre Felder. Wand-Änderung: 413 → 291 Renders.
This commit is contained in:
21 files changed
+1566
-1072
No files matched your search
@@ -1,13 +1,13 @@
|
||||
// [9] Kleines Protokoll der KI-Aufrufe (unten links, nur solange „KI-Zugriff erlauben“ an ist):
|
||||
// Verbindungsstand, Schalter „KI pausieren“, die letzten Aufrufe (Änderungen hervorgehoben).
|
||||
|
||||
import { useState } from "react";
|
||||
import { useState, memo } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { clearAiLog, setAiPaused, useAiAccess } from "../state/aiAccess";
|
||||
|
||||
const time = (ms: number) => new Date(ms).toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", second: "2-digit" });
|
||||
|
||||
export function AiActivityPanel() {
|
||||
export const AiActivityPanel = memo(function AiActivityPanel() {
|
||||
const ai = useAiAccess();
|
||||
const [open, setOpen] = useState(true);
|
||||
if (!ai.enabled) return null;
|
||||
@@ -49,4 +49,4 @@ export function AiActivityPanel() {
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
import { memo } from "react";
|
||||
// Klassische Menüleiste (Bearbeiten/Ansicht/Fenster) neben der Wortmarke in
|
||||
// der TopBar — ergänzt die bestehende Quick-Access-Icon-Leiste um textuelle
|
||||
// Menüs im Rhino-/Desktop-Stil. Reine Darstellung + Callbacks (voll gesteuert,
|
||||
@@ -57,7 +58,7 @@ export interface AppMenuBarProps {
|
||||
}
|
||||
|
||||
/** Menüleiste (Bearbeiten/Ansicht/Fenster) — sitzt in der TopBar neben der Wortmarke. */
|
||||
export function AppMenuBar({
|
||||
export const AppMenuBar = memo(function AppMenuBar({
|
||||
onNewProject,
|
||||
onNewProjectFromSample,
|
||||
onNewProjectFromComplexSample,
|
||||
@@ -195,4 +196,4 @@ export function AppMenuBar({
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
import { memo } from "react";
|
||||
import { useBusy } from "../state/busyStore";
|
||||
|
||||
/** Vollflächiger "Bitte warten"-Hinweis, solange `busyStore` ein Label hält. */
|
||||
export function BusyOverlay() {
|
||||
export const BusyOverlay = memo(function BusyOverlay() {
|
||||
const label = useBusy();
|
||||
if (!label) return null;
|
||||
return (
|
||||
@@ -12,4 +13,4 @@ export function BusyOverlay() {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -5,7 +5,7 @@
|
||||
// Rein gesteuert: alle Aktionen laufen über Callbacks an die Engine. Tab (global
|
||||
// in App) fokussiert das Eingabefeld. Bezeichner englisch, sichtbarer Text via t().
|
||||
|
||||
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
||||
import { forwardRef, memo, useImperativeHandle, useRef, useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { NON_LENGTH_FIELDS } from "../commands/parseInput";
|
||||
@@ -86,7 +86,8 @@ export interface CommandLineHandle {
|
||||
blur: () => void;
|
||||
}
|
||||
|
||||
export const CommandLine = forwardRef<CommandLineHandle, CommandLineProps>(
|
||||
// memo ([121]): App reicht stabile Handler; ohne Änderung an Prompt/Feldern kein Neurendern.
|
||||
export const CommandLine = memo(forwardRef<CommandLineHandle, CommandLineProps>(
|
||||
function CommandLine(
|
||||
{ active, promptKey, options, fields, onSubmit, onOption, onCycleField, onCancel, stillActive, steps, suggest, onTextChange, units = MODEL_UNITS },
|
||||
ref,
|
||||
@@ -258,4 +259,4 @@ export const CommandLine = forwardRef<CommandLineHandle, CommandLineProps>(
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
));
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
// Muster: PointCloudImportDialog (abgedunkeltes Overlay, Esc/Hintergrund schliessen).
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useRef, useState, memo } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { Dropdown } from "./Dropdown";
|
||||
import {
|
||||
@@ -195,7 +195,7 @@ function MeshImportDialog({ req, onImport, notify }: { req: MeshImportRequest }
|
||||
}
|
||||
|
||||
/** Verstecktes Datei-Feld (mehrere Dateien: Modell + `.mtl`/`.bin`) + Dialog; einmal in der App einhängen. */
|
||||
export function MeshImportHost(props: MeshImportHostProps) {
|
||||
export const MeshImportHost = memo(function MeshImportHost(props: MeshImportHostProps) {
|
||||
const req = useMeshImportRequest();
|
||||
return (
|
||||
<>
|
||||
@@ -216,4 +216,4 @@ export function MeshImportHost(props: MeshImportHostProps) {
|
||||
{req && <MeshImportDialog key={req.file.name + req.file.size + req.file.lastModified} req={req} {...props} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -6,7 +6,8 @@
|
||||
//
|
||||
// Muster: ExportDxfDialog (abgedunkeltes Overlay, Esc/Hintergrund schliessen).
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { memo, useEffect, useState } from "react";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { Dropdown } from "./Dropdown";
|
||||
@@ -211,8 +212,14 @@ function PointCloudImportDialog({ file, project }: { file: File; project: Projec
|
||||
);
|
||||
}
|
||||
|
||||
/** Verstecktes Datei-Feld + Dialog; einmal in der App einhängen. */
|
||||
export function PointCloudImportHost({ project }: { project: Project }) {
|
||||
/** Dialog mit dem aktuellen Projekt aus dem Store (nur solange er offen ist abonniert, [121]). */
|
||||
function ConnectedPointCloudImportDialog({ file }: { file: File }) {
|
||||
const project = useStore((s) => s.project);
|
||||
return <PointCloudImportDialog file={file} project={project} />;
|
||||
}
|
||||
|
||||
/** Verstecktes Datei-Feld + Dialog; einmal in der App einhängen. Liest das Projekt selbst. */
|
||||
export const PointCloudImportHost = memo(function PointCloudImportHost() {
|
||||
const file = usePointCloudImportRequest();
|
||||
return (
|
||||
<>
|
||||
@@ -228,7 +235,7 @@ export function PointCloudImportHost({ project }: { project: Project }) {
|
||||
if (f) requestPointCloudImport(f);
|
||||
}}
|
||||
/>
|
||||
{file && <PointCloudImportDialog key={file.name + file.size + file.lastModified} file={file} project={project} />}
|
||||
{file && <ConnectedPointCloudImportDialog key={file.name + file.size + file.lastModified} file={file} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
import { MODEL_UNITS, fmtDisplay, xToDisplay, yToDisplay, type DisplayUnits } from "../tools/displayUnits";
|
||||
import { useCursor } from "../state/cursorStore";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useRef, useState, memo } from "react";
|
||||
import type { SnapSettings } from "../tools/types";
|
||||
import { t } from "../i18n";
|
||||
|
||||
@@ -357,7 +357,7 @@ function Sep() {
|
||||
/** Eine Meterzahl für die Statusleiste (3 Nachkommastellen, ohne Einheit). */
|
||||
const fmt = (n: number): string => n.toFixed(3);
|
||||
|
||||
export function StatusBar({
|
||||
export const StatusBar = memo(function StatusBar({
|
||||
hint,
|
||||
showCursor,
|
||||
unit,
|
||||
@@ -423,4 +423,4 @@ export function StatusBar({
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
});
|
||||
+3
-3
@@ -10,7 +10,7 @@
|
||||
//
|
||||
// Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, memo } from "react";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { t } from "../i18n";
|
||||
import type { NotifyKind } from "../state/notifySlice";
|
||||
@@ -18,7 +18,7 @@ import type { NotifyKind } from "../state/notifySlice";
|
||||
const AUTO_DISMISS_MS = 4000;
|
||||
|
||||
/** Top-level Toast-Stack — einmal in App.tsx gerendert. */
|
||||
export function Toast() {
|
||||
export const Toast = memo(function Toast() {
|
||||
const notifications = useStore((s) => s.notifications);
|
||||
const dismissNotify = useStore((s) => s.dismissNotify);
|
||||
|
||||
@@ -37,7 +37,7 @@ export function Toast() {
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
function ToastItem({
|
||||
id,
|
||||
|
||||
+9
-52
@@ -8,11 +8,10 @@
|
||||
// aus App, Aktionen melden sich über Callbacks zurück. Bezeichner englisch,
|
||||
// UI-Text/Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
import { t } from "../i18n";
|
||||
import { checkForUpdate } from "../update/checkForUpdate";
|
||||
import { getRunningVersion } from "../update/version";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { memo, useEffect, useRef, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { Dropdown } from "./Dropdown";
|
||||
import type { DropdownItem, DropdownOption } from "./Dropdown";
|
||||
@@ -56,7 +55,8 @@ export const SCALE_PRESETS: number[] = [1, 5, 10, 20, 50, 100, 200, 500, 1000];
|
||||
const ZOOM_CLUSTER_WIDTH = 140;
|
||||
|
||||
export interface TopBarProps {
|
||||
project: Project;
|
||||
/** Projektname rechts in der Leiste (nur dieser, nicht das ganze Projekt: [121]). */
|
||||
projectName: string;
|
||||
|
||||
// Kein Ribbon-Tab-Reiter mehr (Werkzeuge leben im ToolsPanel, siehe
|
||||
// ribbonItems.ts/layout.ts v12) — die TopBar ist nur noch die schmale
|
||||
@@ -64,49 +64,6 @@ export interface TopBarProps {
|
||||
// Darstellungs-Steuerung folgt direkt darunter (siehe ViewRibbonTab, von
|
||||
// App unconditional gerendert statt über Tab-Umschaltung).
|
||||
|
||||
/** Ob Zoom/Plan aktiv ist — steuert nur noch, ob Export im Datei-Menü geht. */
|
||||
zoomEnabled: boolean;
|
||||
/** Öffnet den PDF-Export-Dialog (nur im Grundriss sinnvoll). */
|
||||
onExportPdf: () => void;
|
||||
/** Öffnet den DXF-Export-Dialog (nur im Grundriss sinnvoll). */
|
||||
onExportDxf: () => void;
|
||||
/** Lädt die Bauteilliste des Projekts als CSV herunter. */
|
||||
onExportSchedule: () => void;
|
||||
/** Lädt das Projekt als IFC4-STEP-Datei herunter. */
|
||||
onExportIfc: () => void;
|
||||
onExportObj: () => void;
|
||||
onExportStl: () => void;
|
||||
onExportGlb?: () => void;
|
||||
onExportStep?: () => void;
|
||||
|
||||
// Kamera-Settings (FOV), ZUSÄTZLICH zur bestehenden im „Ansichten"-Ribbon-
|
||||
// Tab (ViewRibbonTab) und im 3D-Ribbon-Tab (Ribbon3dTab) — hier direkt neben
|
||||
// dem CSV-Export in der schmalen Chrome-Zeile, damit sie immer erreichbar
|
||||
// ist (Nutzer-Wunsch). Dieselben Felder/Handler wie dort.
|
||||
viewType: ViewType;
|
||||
fov: number;
|
||||
onFov: (n: number) => void;
|
||||
/** Presets nur sinnvoll, solange ein Geschoss aktiv ist (wie `viewToggleEnabled`
|
||||
* in {@link ViewRibbonTabProps}). */
|
||||
cameraEnabled: boolean;
|
||||
|
||||
// Ressourcen-Fenster.
|
||||
resourcesOpen: boolean;
|
||||
onToggleResources: () => void;
|
||||
|
||||
/** Öffnet das Einstellungs-Fenster (Darstellungsfarben, Projekt-Felder). */
|
||||
onOpenSettings: () => void;
|
||||
|
||||
/** Layout-Menü (von App geliefert, damit dessen Logik dort bleibt). */
|
||||
|
||||
// ── Datei-Menü (Burger, ganz rechts) ───────────────────────────────────────
|
||||
/** Öffnet den DXF/DWG-Import-Datei-Dialog. */
|
||||
onImport: () => void;
|
||||
/** Projekt als Datei speichern (JSON-Export des gesamten Projekts). */
|
||||
onSaveProject: () => void;
|
||||
/** Projekt aus einer Datei laden. */
|
||||
onOpenProject: () => void;
|
||||
|
||||
/** Menüleiste (Bearbeiten/Ansicht/Fenster, {@link AppMenuBar}) — von App
|
||||
* zusammengesetzt (dort leben Undo/Redo/Auswahl/View-State), hier nur
|
||||
* platziert. `undefined` blendet sie aus (z. B. für künftige eingebettete
|
||||
@@ -1104,7 +1061,7 @@ export interface ViewRibbonTabProps {
|
||||
* Massstab/Zoom-Cluster und Darstellungsart. EIN Ribbon für alles; Handler/Setter
|
||||
* kommen unverändert von App (gleiche Props wie zuvor an die TopBar).
|
||||
*/
|
||||
export function ViewRibbonTab({
|
||||
export const ViewRibbonTab = memo(function ViewRibbonTab({
|
||||
viewToggleEnabled,
|
||||
viewType,
|
||||
onViewType,
|
||||
@@ -1389,10 +1346,10 @@ export function ViewRibbonTab({
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export function TopBar({
|
||||
project,
|
||||
export const TopBar = memo(function TopBar({
|
||||
projectName,
|
||||
menuBar,
|
||||
viewControls,
|
||||
}: TopBarProps) {
|
||||
@@ -1465,11 +1422,11 @@ export function TopBar({
|
||||
Projektname ganz rechts). Die Fensterknöpfe sitzen ganz links
|
||||
(macOS-Titelleisten-Konvention). */}
|
||||
<div className="topbar-right">
|
||||
<span className="project-name">{project.name}</span>
|
||||
<span className="project-name">{projectName}</span>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Hinweis: Die früheren Helfer SNAP_TOGGLES + SnapMenu (Fang-Optionen) und die
|
||||
// Zeichenwerkzeug-Buttons wurden aus der Oberleiste entfernt; sie leben jetzt
|
||||
|
||||
@@ -14,7 +14,9 @@ const common = {
|
||||
strokeLinejoin: "round" as const,
|
||||
};
|
||||
|
||||
export function CommandIcon({ name }: { name: string }) {
|
||||
import { memo } from "react";
|
||||
|
||||
export const CommandIcon = memo(function CommandIcon({ name }: { name: string }) {
|
||||
switch (name) {
|
||||
case "move":
|
||||
// Vier-Wege-Verschiebepfeil.
|
||||
@@ -307,4 +309,4 @@ export function CommandIcon({ name }: { name: string }) {
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user