import { useMemo, useState } from 'react'; import { useViewerStore } from '../../store/viewerStore'; export interface PartListPanelProps { className?: string; } export function PartListPanel({ className = '' }: PartListPanelProps) { const [query, setQuery] = useState(''); const parts = useViewerStore((state) => state.parts); const partSettings = useViewerStore((state) => state.partSettings); const selectedPartId = useViewerStore((state) => state.selectedPartId); const selectPart = useViewerStore((state) => state.selectPart); const setPartVisibility = useViewerStore((state) => state.setPartVisibility); const setPartOpacity = useViewerStore((state) => state.setPartOpacity); const setAllPartsVisibility = useViewerStore((state) => state.setAllPartsVisibility); const resetPartSettings = useViewerStore((state) => state.resetPartSettings); const filteredParts = useMemo(() => { const normalisedQuery = query.trim().toLowerCase(); if (!normalisedQuery) { return parts; } return parts.filter((part) => [part.name, part.shortName, part.description, ...(part.keywords ?? [])] .join(' ') .toLowerCase() .includes(normalisedQuery) ); }, [parts, query]); return ( ); }