import type { FormEvent, KeyboardEvent, FocusEvent, MutableRefObject } from "react"; import { StockSearchForm } from "@/features/trade/components/search/StockSearchForm"; import { StockSearchHistory } from "@/features/trade/components/search/StockSearchHistory"; import { StockSearchResults } from "@/features/trade/components/search/StockSearchResults"; import type { DashboardStockSearchHistoryItem, DashboardStockSearchItem, } from "@/features/trade/types/trade.types"; interface TradeSearchSectionProps { canSearch: boolean; isSearchPanelOpen: boolean; isSearching: boolean; keyword: string; selectedSymbol?: string; searchResults: DashboardStockSearchItem[]; searchHistory: DashboardStockSearchHistoryItem[]; searchShellRef: MutableRefObject; onKeywordChange: (value: string) => void; onSearchSubmit: (event: FormEvent) => void; onSearchFocus: () => void; onSearchShellBlur: (event: FocusEvent) => void; onSearchShellKeyDown: (event: KeyboardEvent) => void; onSelectStock: (item: DashboardStockSearchItem) => void; onRemoveHistory: (symbol: string) => void; onClearHistory: () => void; } /** * @description 트레이드 화면 상단의 검색 입력/결과/히스토리 드롭다운 영역을 렌더링합니다. * @see features/trade/components/TradeContainer.tsx TradeContainer에서 검색 섹션을 분리해 렌더 복잡도를 줄입니다. * @see features/trade/hooks/useTradeSearchPanel.ts 패널 열림/닫힘 및 포커스 핸들러를 전달받습니다. */ export function TradeSearchSection({ canSearch, isSearchPanelOpen, isSearching, keyword, selectedSymbol, searchResults, searchHistory, searchShellRef, onKeywordChange, onSearchSubmit, onSearchFocus, onSearchShellBlur, onSearchShellKeyDown, onSelectStock, onRemoveHistory, onClearHistory, }: TradeSearchSectionProps) { return (
{/* ========== SEARCH SHELL ========== */}
{/* ========== SEARCH DROPDOWN ========== */} {isSearchPanelOpen && canSearch && (
{searchResults.length > 0 ? ( ) : keyword.trim() ? (
{isSearching ? "검색 중..." : "검색 결과가 없습니다."}
) : searchHistory.length > 0 ? ( ) : (
최근 검색 종목이 없습니다.
)}
)}
); }