import { Info, Search } from "lucide-react"; import { getFieldError } from "@/client/lib/forms"; import { isResultLimit, normalizeKeywordMode, } from "@/client/features/keywords/keywordSearchParams"; import { MAX_KEYWORDS_PER_SUBMIT, RESULT_LIMITS, } from "@/client/features/keywords/keywordResearchTypes"; import { isLabsLocationCode } from "@/client/features/keywords/locations"; import { LocationSelect } from "@/client/components/LocationSelect"; import type { KeywordResearchControllerState } from "./types"; type Props = { controller: KeywordResearchControllerState; }; function getTextareaRows(value: string): number { const newlines = (value.match(/\n/g) ?? []).length; const lines = newlines + 1; return Math.min(MAX_KEYWORDS_PER_SUBMIT, Math.max(1, lines)); } export function KeywordResearchSearchBar({ controller }: Props) { const { controlsForm, handleSearchSubmit } = controller; return (
{(field) => { const keywordError = getFieldError(field.state.meta.errors); const rows = getTextareaRows(field.state.value); return (