import Spinner from '@components/admin/Spinner.js'; import { Image } from '@components/common/Image.js'; import { drawerInputClass } from '@components/common/page-builder/drawer/index.js'; import { _ } from '@evershop/evershop/lib/locale/translate/_'; import { Check, Search } from 'lucide-react'; import React from 'react'; /** * Pure-presentational search-list primitive shared by the entity pickers * (Category / Product / Collection / CMS page). Doesn't talk to GraphQL — * the caller passes pre-fetched `items` + a search-input handler so each * picker can run whatever urql query it likes. * * Visually: a search box, a result list, a "selected" badge on the * matching row, and an optional empty/loading state. Selection is * controlled — caller owns the picked-id state. */ export interface SearchListItem { id: string; primary: string; secondary?: string | null; thumbnailUrl?: string | null; } export interface EntitySearchListProps { items: SearchListItem[]; selectedId: string | null; onSelect: (id: string, item: SearchListItem) => void; search: string; onSearchChange: (next: string) => void; loading?: boolean; emptyHint?: string; /** Optional caption rendered above the search box. */ caption?: string; /** * Render thumbnails with a plain img element instead of the resizing Image * component. Use when `thumbnailUrl` can be an arbitrary external URL (e.g. * blog thumbnails) that the `/images` resizer can't reliably fetch — * matching how those thumbnails render everywhere else in the app. */ rawThumbnails?: boolean; } export function EntitySearchList({ items, selectedId, onSelect, search, onSearchChange, loading, emptyHint = 'No matches.', caption, rawThumbnails = false }: EntitySearchListProps) { return (