"use client"; import type { Control, FieldPath, FieldValues } from "react-hook-form"; import { ListOrdered } from "lucide-react"; import { cn } from "@/lib/utils"; import { FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { useI18n } from "@/i18n/i18n-context"; import { RETRIEVAL_RESULT_COUNT_MIN, parseRetrievalResultCountInput, } from "./retrieval-result-count"; interface RetrievalResultCountFieldProps { control: Control; name: FieldPath; label?: string; description?: string; min?: number; max?: number; muted?: boolean; className?: string; } export function RetrievalResultCountField({ control, name, label, description, min = RETRIEVAL_RESULT_COUNT_MIN, max, muted = false, className, }: RetrievalResultCountFieldProps) { const { t } = useI18n(); const resolvedLabel = label ?? t("knowledgeBase.resultCountField.label"); const resolvedDescription = description ?? t("knowledgeBase.resultCountField.description"); return ( { const inputValue = typeof field.value === "number" && Number.isFinite(field.value) ? String(field.value) : ""; return (
{resolvedLabel}

{resolvedDescription}

field.onChange( parseRetrievalResultCountInput(event.target.value), ) } /> {t("knowledgeBase.resultCountField.unit")}
); }} /> ); }