import { useState } from "react"; import { Box, IconButton, TextField, SxProps } from "@mui/material"; import { AccessTimeRounded, MyLocationRounded, NetworkCheckRounded, FilterAltRounded, FilterAltOffRounded, VisibilityRounded, VisibilityOffRounded, WifiTetheringRounded, WifiTetheringOffRounded, SortByAlphaRounded, SortRounded, } from "@mui/icons-material"; import type { ProxySortType } from "./use-filter-proxy"; interface Props { sx?: SxProps; showType: boolean; sortType: ProxySortType; urlText: string; filterText: string; onLocation: () => void; onCheckDelay: () => void; onShowType: (val: boolean) => void; onSortType: (val: ProxySortType) => void; onUrlText: (val: string) => void; onFilterText: (val: string) => void; } const ProxyHead = (props: Props) => { const { sx = {}, showType, sortType, urlText, filterText } = props; const [textState, setTextState] = useState<"url" | "filter" | null>(null); return ( props.onSortType(((sortType + 1) % 3) as ProxySortType)} > {sortType === 0 && } {sortType === 1 && } {sortType === 2 && } setTextState((ts) => (ts === "url" ? null : "url"))} > {textState === "url" ? ( ) : ( )} props.onShowType(!showType)} > {showType ? : } setTextState((ts) => (ts === "filter" ? null : "filter")) } > {textState === "filter" ? ( ) : ( )} {textState === "filter" && ( props.onFilterText(e.target.value)} sx={{ ml: 0.5, flex: "1 1 auto", input: { py: 0.65, px: 1 } }} /> )} {textState === "url" && ( props.onUrlText(e.target.value)} sx={{ ml: 0.5, flex: "1 1 auto", input: { py: 0.65, px: 1 } }} /> )} ); }; export default ProxyHead;