'use client' /** * Single row in the `` dropdown — the standard layout * used by every doc-search-backed surface (company-hub data-room * search bar, onboarding-guide catalog search, …). Single source of * truth for the row appearance so search dropdowns are visually * identical everywhere. * * Resolves the source icon via the same `resolveSourceIcon()` * registry the inline chat-card refs use, so a row pointing at e.g. * an onboarding-guide surfaces the SAME `` glyph the * chat card surfaces — no cross-surface drift. */ import { resolveSourceIcon } from '../../chat/utils/source-row-cta' import { formatRelativePath } from './format-relative-path' /** * Minimal result shape this row renders. Compatible with any * doc-search hook whose result type exposes `{ title?, path?, * metadata? }`. The two hub consumers (onboarding-guide catalog, * data-room sidebar) both satisfy this shape via their * `useDocSearch` hook result. */ export interface DocSearchResultRowEntry { title?: string path?: string metadata?: Record } export interface DocSearchResultRowProps { result: DocSearchResultRowEntry isHighlighted: boolean } export function DocSearchResultRow({ result, isHighlighted, }: DocSearchResultRowProps) { const docType = (result.metadata?.documentType as string) || undefined const sourceRepo = (result.metadata?.sourceRepo as string) || undefined const { Icon: SourceIcon, label: iconLabel } = resolveSourceIcon({ sourceRepo, documentType: docType, }) const isGroup = result.metadata?.isGroup as boolean | undefined return (
{result.title || result.path}
{!isGroup && result.path?.includes('/') && (
{formatRelativePath(result.path)}
)}
) }