"use client"; import React from "react"; import { SEARCH_SCOPE } from "@/lib/frontend/search/urlState"; import SearchQueryBox from "@/components/search/form/SearchQueryBox"; import SearchScopeSelect from "@/components/search/form/SearchScopeSelect"; import SearchLimitSelect from "@/components/search/form/SearchLimitSelect"; import SearchSingleBranchCombobox from "@/components/search/form/SearchSingleBranchCombobox"; import SearchMultiBranchPicker from "@/components/search/form/SearchMultiBranchPicker"; export default function SearchForm({ branch, qDraft, onQDraftChange, onSubmit, currentQuery, isSubmitting, isAdminDev, scope, onScopeChange, onSingleBranchChange, availableBranches, branchesStatus, selectedBranches, onToggleBranch, onClearAllBranches, limit, onLimitChange, }) { const canSearch = typeof qDraft === "string" && qDraft.trim().length > 0; // RHL-038 UI behavior: // - Single scope shows an extra combobox (branch picker). // - Multi/All does not. // - We animate the combobox container (max-width/max-height/opacity) so the // query block (input + search button) grows/shrinks smoothly. const showSingleBranchCombobox = Boolean( isAdminDev && scope === SEARCH_SCOPE.SINGLE ); return (
{ e.preventDefault(); if (!canSearch) return; onSubmit(); }} className="space-y-4" > {/* Layout goal: - Desktop: everything on one line (scope + optional single combobox | query | limit) - Mobile: stack to avoid horizontal overflow */}
{/* Left block: scope + (animated) single-branch combobox */} {isAdminDev ? (
{/* Animated presence (no mount/unmount): - When hidden: max-w-0/max-h-0 + opacity-0 so it takes no space. - When shown: expands to a reasonable max size. This animation drives the smooth resize of the query input block. */}
) : null} {/* Middle block: query must take the most space */}
{/* Right block: limit stays “content-sized” */}
{/* Multi scope branch picker remains below */} {isAdminDev && scope === SEARCH_SCOPE.MULTI ? ( ) : null}
); }