"use client"; import ClearIcon from "@mui/icons-material/Clear"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp"; import SearchIcon from "@mui/icons-material/Search"; import { Box, IconButton, InputAdornment, Paper, TextField, Tooltip, Typography, } from "@mui/material"; import { useTranslation } from "react-i18next"; type Props = { query: string; matchCount: number; activeIndex: number; onQueryChange: (value: string) => void; onPrev: () => void; onNext: () => void; onClear: () => void; }; /** FP-MTMS Version Checklist | Functions Ref. No. 15 | v1.0.0 | 2026-07-17 */ const ItemTracingFlowGraphSearch: React.FC = ({ query, matchCount, activeIndex, onQueryChange, onPrev, onNext, onClear, }) => { const { t } = useTranslation("itemTracing"); const trimmed = query.trim(); const hasQuery = trimmed.length > 0; const matchLabel = matchCount > 0 ? t("flowGraphSearchMatch", { current: activeIndex + 1, total: matchCount }) : hasQuery ? t("flowGraphSearchNoMatch") : ""; const handleKeyDown = (event: React.KeyboardEvent) => { if (event.key === "Enter") { event.preventDefault(); if (event.shiftKey) onPrev(); else onNext(); } else if (event.key === "Escape") { event.preventDefault(); onClear(); } }; return ( onQueryChange(e.target.value)} onKeyDown={handleKeyDown} InputProps={{ startAdornment: ( ), endAdornment: hasQuery ? ( ) : undefined, }} sx={{ "& .MuiOutlinedInput-root": { alignItems: "center", }, "& .MuiOutlinedInput-input": { color: "text.secondary", py: "8.5px", lineHeight: 1.4375, }, "& .MuiOutlinedInput-input::placeholder": { color: "text.disabled", opacity: 1, }, "& .MuiInputAdornment-root": { height: "100%", maxHeight: "none", alignItems: "center", }, }} /> {hasQuery && ( 0 ? "text.secondary" : "error"} noWrap> {matchLabel} )} ); }; export default ItemTracingFlowGraphSearch;