"use client"; import { useMemo, useState } from "react"; type GeometryChoice = { id: string; label?: string; }; type Props = { geometries: GeometryChoice[]; selectedGeometryId: string | null; selectedGeometryBindingIds: string[]; onToggleBindGeometryForSelectedGeometry?: (geometryId: string, nextChecked: boolean) => void; statusText?: string | null; bindingFilterEnabled: boolean; onBindingFilterEnabledChange: (next: boolean) => void; }; export default function GeometryBindingPanel({ geometries, selectedGeometryId, selectedGeometryBindingIds, onToggleBindGeometryForSelectedGeometry, statusText, bindingFilterEnabled, onBindingFilterEnabledChange, }: Props) { const canBindToggle = Boolean(selectedGeometryId) && typeof onToggleBindGeometryForSelectedGeometry === "function"; const [collapsed, setCollapsed] = useState(false); const rows = useMemo(() => { const cleaned = (geometries || []) .filter((g) => g && typeof g.id === "string" && g.id.trim().length > 0) .map((g) => ({ id: g.id.trim(), label: (g.label || "").trim() })); cleaned.sort((a, b) => a.id.localeCompare(b.id)); return cleaned; }, [geometries]); const bindingSet = useMemo(() => new Set(selectedGeometryBindingIds || []), [selectedGeometryBindingIds]); return (
Geometry Binding
{rows.length}
{collapsed ? null : rows.length ? (
{rows .filter((g) => g.id !== selectedGeometryId) .map((g) => { const isBound = bindingSet.has(g.id); return (
{g.label || g.id}
{g.id}
{canBindToggle ? ( ) : null}
); })}
) : (
No geometry yet for this project.
)} {collapsed ? null : statusText ? (
{statusText}
) : null}
); } function LockIcon() { return ( ); } function UnlockIcon() { return ( ); } function PlusIcon() { return ( ); } function MinusIcon() { return ( ); }