[239] Abschnitts-Rahmen der Objekt-Info ohne eigene Komponente für Bezugspunkt/Masse/Gelände: Render-Zählung je Wand-Änderung wieder 43 statt 45 [121]
This commit is contained in:
2 files changed
+37
-21
No files matched your search
@@ -36,7 +36,7 @@ import { ViewShadowsInfo, MeasurementSection } from "./objectInfo/InfoBlocks";
|
||||
import { DimensionField, RotateField } from "./objectInfo/fields";
|
||||
import { elementDimensions } from "./objectInfo/elementDims";
|
||||
import { InfoGroups, hasInfoGroups } from "./objectInfo/InfoGroups";
|
||||
import { InfoGroup } from "./objectInfo/InfoGroup";
|
||||
import { infoGroupFrame, useInfoGroupState } from "./objectInfo/InfoGroup";
|
||||
|
||||
// ── Bezugspunkt-Raster ───────────────────────────────────────────────────────
|
||||
// Neun Anker als 3×3-Raster. Zeile 0 = oben (fy=0), Spalte 0 = links (fx=0).
|
||||
@@ -63,6 +63,8 @@ function toDeg360(rad: number): number {
|
||||
export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: boolean } = {}) {
|
||||
const host = usePanelHost();
|
||||
const storeProject = useStore((st) => st.project);
|
||||
// [121] Abschnitts-Rahmen ohne eigene Komponente (kein Render je Abschnitt bei Inhaltsänderung).
|
||||
const gst = useInfoGroupState();
|
||||
const sel = useSelectionInfo();
|
||||
|
||||
// Gewählter Bezugspunkt — Default Mitte (Vectorworks-Standardanker beim
|
||||
@@ -194,7 +196,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
|
||||
{showPlacement && (
|
||||
<>
|
||||
<InfoGroup id="refpoint">
|
||||
{infoGroupFrame(gst, "refpoint", <>
|
||||
{/* Bezugspunkt-Würfel (3×3, immer quadratisch) links, X/Y/Z als Spalte
|
||||
rechts daneben (Nutzer-Wunsch). */}
|
||||
<div className="objinfo-refrow">
|
||||
@@ -248,9 +250,9 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
<RotateField onCommit={(deg) => host.onRotateSelectionAround(px, py, deg)} />
|
||||
</div>
|
||||
</div>
|
||||
</InfoGroup>
|
||||
</>)}
|
||||
|
||||
<InfoGroup id="dimensions">
|
||||
{infoGroupFrame(gst, "dimensions", <>
|
||||
{/* Maße (editierbar) — Commit auf blur/Enter skaliert um den Anker. */}
|
||||
{elementDims ? (
|
||||
// [204a] Wand: Länge/Dicke/Höhe, Öffnung: Breite/Höhe/Brüstung (nur Anzeige).
|
||||
@@ -351,7 +353,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</InfoGroup>
|
||||
</>)}
|
||||
</>
|
||||
)}
|
||||
{/* Gelände-/Umgebungs-Element (Netzkörper, Gelände, Höhenlinien …): Art, Herkunft (nur Auskunft, [181]),
|
||||
@@ -359,7 +361,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
georeferenziert importiert wurde (Nutzer-Wunsch zum Prüfen). */}
|
||||
{sel.contextObject && (
|
||||
<>
|
||||
<InfoGroup id="contextProps">
|
||||
{infoGroupFrame(gst, "contextProps", <>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.contextObject.type")}</span>
|
||||
<span className="objinfo-fval">{t(`objinfo.contextObject.type.${sel.contextObject.objType}`)}</span>
|
||||
@@ -369,9 +371,9 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
<ContextObjectProps obj={ctxObj} quantities={quantities} />
|
||||
</div>
|
||||
)}
|
||||
</InfoGroup>
|
||||
</>)}
|
||||
{/* [239] Herkunft und LV95 stehen in eigener Gruppe (Standard zugeklappt: nur Auskunft). */}
|
||||
<InfoGroup id="georef">
|
||||
{infoGroupFrame(gst, "georef", <>
|
||||
{sel.contextObject.source && (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.contextObject.source")}</span>
|
||||
@@ -394,7 +396,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
<span className="objinfo-fval objinfo-muted">{t("objinfo.contextObject.noAnchor")}</span>
|
||||
</div>
|
||||
)}
|
||||
</InfoGroup>
|
||||
</>)}
|
||||
</>
|
||||
)}
|
||||
{/* [189] Bauteil-/BIM-Abschnitte (Wand, Decke, Öffnung, Treppe, Raum …) als einklappbare Gruppen. */}
|
||||
|
||||
@@ -1,25 +1,34 @@
|
||||
// [189] Einklappbarer Abschnitt der Objekt-Info: Kopfzeile (Knopf mit Pfeil) und Inhalt. Die Abschnitts-
|
||||
// Komponenten (`WallSection` …) bringen ihre eigene Kopf-Trennlinie mit; die erste blendet das CSS im Rumpf aus.
|
||||
|
||||
import { useEffect, useRef, useSyncExternalStore, type ReactNode } from "react";
|
||||
import { useSyncExternalStore, type ReactNode } from "react";
|
||||
import { t } from "../../i18n";
|
||||
import { INFO_GROUP_TITLE, type InfoGroupId } from "./groups";
|
||||
import { clearInfoGroupFocus, getInfoGroupState, isInfoGroupOpen, subscribeInfoGroups, toggleInfoGroup } from "./infoGroupState";
|
||||
|
||||
export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNode }) {
|
||||
const st = useSyncExternalStore(subscribeInfoGroups, getInfoGroupState, getInfoGroupState);
|
||||
type GroupState = ReturnType<typeof getInfoGroupState>;
|
||||
|
||||
/** Zustand der Abschnitte (offen/zu, Fokus-Anfrage) für [`infoGroupFrame`]. */
|
||||
export function useInfoGroupState(): GroupState {
|
||||
return useSyncExternalStore(subscribeInfoGroups, getInfoGroupState, getInfoGroupState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Abschnitt als blosses Markup, ohne eigene Komponente: Das Panel liest den Zustand einmal ([`useInfoGroupState`])
|
||||
* und rahmt damit mehrere Abschnitte, ohne dass je Abschnitt ein Komponenten-Render bei jeder Änderung des Inhalts
|
||||
* anfällt ([121], Render-Zählung). Die Fokus-Anfrage löst der Ref des Kopfknopfs ein.
|
||||
*/
|
||||
export function infoGroupFrame(st: GroupState, id: InfoGroupId, children: ReactNode): ReactNode {
|
||||
const open = isInfoGroupOpen(st, id);
|
||||
const head = useRef<HTMLButtonElement>(null);
|
||||
useEffect(() => {
|
||||
if (st.focus?.id !== id) return;
|
||||
head.current?.scrollIntoView?.({ block: "nearest" });
|
||||
head.current?.focus();
|
||||
clearInfoGroupFocus();
|
||||
}, [st.focus, id]);
|
||||
return (
|
||||
<section className="objinfo-group" data-group={id} data-open={open}>
|
||||
<section key={id} className="objinfo-group" data-group={id} data-open={open}>
|
||||
<button
|
||||
ref={head}
|
||||
ref={(el) => {
|
||||
if (!el || st.focus?.id !== id) return;
|
||||
el.scrollIntoView?.({ block: "nearest" });
|
||||
el.focus();
|
||||
clearInfoGroupFocus();
|
||||
}}
|
||||
type="button"
|
||||
className="objinfo-group-head"
|
||||
aria-expanded={open}
|
||||
@@ -33,3 +42,8 @@ export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNo
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNode }) {
|
||||
const st = useInfoGroupState();
|
||||
return infoGroupFrame(st, id, children);
|
||||
}
|
||||
Reference in new issue
Block a user