feat(map): add reference layers and stabilize workspace controls

This commit is contained in:
Codex
2026-07-25 13:12:24 +03:00
parent c859ae4db0
commit eaecce9f56
29 changed files with 1593 additions and 247 deletions
+14 -7
View File
@@ -16,21 +16,29 @@ export interface InspectorSectionSpec {
export interface InspectorProps {
sections: InspectorSectionSpec[];
defaultOpen?: string[];
openSections?: string[];
activeId?: string;
singleOpen?: boolean;
className?: string;
onOpenSectionsChange?: (ids: string[]) => void;
onActiveChange?: (id: string) => void;
}
export function Inspector({
sections,
defaultOpen = [],
openSections,
activeId,
singleOpen = false,
className,
onOpenSectionsChange,
onActiveChange,
}: InspectorProps) {
const [openIds, setOpenIds] = useState(() => new Set(defaultOpen));
const [internalOpenIds, setInternalOpenIds] = useState(() => new Set(defaultOpen));
const openIds = useMemo(
() => openSections === undefined ? internalOpenIds : new Set(openSections),
[internalOpenIds, openSections],
);
const groups = useMemo(() => {
const result: Array<{ label?: string; sections: InspectorSectionSpec[] }> = [];
sections.forEach((section) => {
@@ -45,12 +53,11 @@ export function Inspector({
}, [sections]);
const toggle = (id: string) => {
setOpenIds((current) => {
const next = singleOpen ? new Set<string>() : new Set(current);
if (current.has(id)) next.delete(id);
else next.add(id);
return next;
});
const next = singleOpen ? new Set<string>() : new Set(openIds);
if (openIds.has(id)) next.delete(id);
else next.add(id);
if (openSections === undefined) setInternalOpenIds(next);
onOpenSectionsChange?.([...next]);
onActiveChange?.(id);
};