export interface ProjectPathMatch { name: string; path: string; } export interface ProjectPathInputProps { value: string; onChange: (value: string) => void; onKeyDown: (event: React.KeyboardEvent) => void; suggestionTail: string; matchList: ProjectPathMatch[]; selectedMatch: number; onSelectMatch: (index: number) => void; onAcceptMatch: (path: string) => void; onCloseSuggestions: () => void; currentPartial: string; } function renderHighlightedMatch(text: string, query: string) { if (!query) return text; let qIndex = 0; const lowerQuery = query.toLowerCase(); const counts = new Map(); return text.split("").map((char) => { const isMatch = qIndex < lowerQuery.length && char.toLowerCase() === lowerQuery[qIndex]; if (isMatch) { qIndex += 1; } const count = counts.get(char) ?? 0; counts.set(char, count + 1); return ( {char} ); }); } export function ProjectPathInput({ value, onChange, onKeyDown, suggestionTail, matchList, selectedMatch, onSelectMatch, onAcceptMatch, onCloseSuggestions, currentPartial, }: ProjectPathInputProps) { return (
{value} {suggestionTail}
onChange(event.target.value)} onKeyDown={onKeyDown} style={{ width: "100%", padding: "10px", fontFamily: "monospace", background: "transparent", position: "relative", zIndex: 1, }} /> {matchList.length > 0 && (
{matchList.map((match, index) => { const isSelected = index === selectedMatch; return ( ); })}
)}
); }