[195b] e2e an eingebetteten Öffnungs-Editor angepasst; MixedMark/useMulti ohne Zusatz-Renders je Projektänderung ([121])
This commit is contained in:
4 files changed
+18
-17
No files matched your search
@@ -6,12 +6,13 @@ import { usePanelHost } from "../host";
|
||||
import { t } from "../../i18n";
|
||||
import type { VerticalAnchor } from "../../model/types";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
import { useState, useRef } from "react";
|
||||
import { memo, useState, useRef } from "react";
|
||||
|
||||
/** [195b] Kennzeichnung „gemischt": Die gewählten Elemente haben für dieses Feld verschiedene Werte. */
|
||||
export function MixedMark({ on, what }: { on: boolean | undefined; what: string }) {
|
||||
// memo: Props sind Grundwerte; der Abschnitt rendert bei jeder Projektänderung neu, die Marke nur bei Wechsel ([121]).
|
||||
export const MixedMark = memo(function MixedMark({ on, what }: { on: boolean | undefined; what: string }) {
|
||||
return on ? <span className="attr-mixed" data-mixed={what}>{t("objsettings.mixed")}</span> : null;
|
||||
}
|
||||
});
|
||||
|
||||
// ── Decken-Attribut-Abschnitt ────────────────────────────────────────────────
|
||||
// Aufbau-Typ (einschichtig/mehrschichtig), Dicke/Preset, Referenzgeschoss +
|
||||
|
||||
@@ -7,8 +7,10 @@ import { useStore } from "../../state/appStore";
|
||||
import type { Selection } from "../../state/selection";
|
||||
|
||||
export function useMulti<T>(kind: "walls" | "ceilings" | "roofs" | "openings" | "stairs" | "rooms" | "columns" | "solids", compute: (p: Project, sel: Selection) => T): T | null {
|
||||
const project = useStore((s) => s.project);
|
||||
const multi = useStore((s) => s.selection[kind].length > 1);
|
||||
const selection = useStore((s) => s.selection);
|
||||
// Projekt nur bei Mehrfachauswahl abonnieren: bei einem Element kein Neurendern je Projektänderung ([121]).
|
||||
const project = useStore((s) => (multi ? s.project : null));
|
||||
// `compute` ist je Aufrufstelle eine Modul-Funktion (stabil).
|
||||
return useMemo(() => (selection[kind].length > 1 ? compute(project, selection) : null), [project, selection, kind, compute]);
|
||||
return useMemo(() => (multi && project ? compute(project, selection) : null), [multi, project, selection, compute]);
|
||||
}
|
||||
Reference in new issue
Block a user