'use client'; import { Search, X } from 'lucide-react'; interface Props { value: string; onChange: (v: string) => void; placeholder?: string; className?: string; } /** * 列表搜索框(标题 + 编号模糊匹配,外部需配合 useDebouncedValue 防抖) */ export function SearchInput({ value, onChange, placeholder = '搜索标题或编号', className = '' }: Props) { return (
onChange(e.target.value)} placeholder={placeholder} className="h-6 w-72 pl-7 pr-6 rounded border border-[var(--line)] bg-[var(--bg-card)] text-[11px] text-[var(--ink)] focus:border-[var(--accent)] focus:outline-none" /> {value && ( )}
); } /** * 标题 + 编号模糊匹配(case-insensitive) */ export function matchTitleOrNo(item: { title: string; no?: string }, keyword: string): boolean { if (!keyword) return true; const k = keyword.trim().toLowerCase(); if (!k) return true; if (item.title.toLowerCase().includes(k)) return true; if (item.no && item.no.toLowerCase().includes(k)) return true; return false; }