From 5284f38c002e5bf88e308e208456d41d4126b30e Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 22 Aug 2023 00:10:30 +0800 Subject: ... --- FrontEnd/src/views/common/SearchInput.tsx | 93 +++++++++++-------------------- 1 file changed, 32 insertions(+), 61 deletions(-) (limited to 'FrontEnd/src/views/common/SearchInput.tsx') diff --git a/FrontEnd/src/views/common/SearchInput.tsx b/FrontEnd/src/views/common/SearchInput.tsx index 9d644ab7..e3216b86 100644 --- a/FrontEnd/src/views/common/SearchInput.tsx +++ b/FrontEnd/src/views/common/SearchInput.tsx @@ -1,79 +1,50 @@ -import { useCallback } from "react"; -import * as React from "react"; -import classnames from "classnames"; -import { useTranslation } from "react-i18next"; +import classNames from "classnames"; +import { useC, Text } from "./common"; import LoadingButton from "./button/LoadingButton"; import "./SearchInput.css"; -export interface SearchInputProps { +interface SearchInputProps { value: string; onChange: (value: string) => void; onButtonClick: () => void; - className?: string; loading?: boolean; - buttonText?: string; - placeholder?: string; - additionalButton?: React.ReactNode; - alwaysOneline?: boolean; + className?: string; + buttonText?: Text; } -const SearchInput: React.FC = (props) => { - const { onChange, onButtonClick, alwaysOneline } = props; - - const { t } = useTranslation(); - - const onInputChange = useCallback( - (event: React.ChangeEvent): void => { - onChange(event.currentTarget.value); - }, - [onChange] - ); - - const onInputKeyPress = useCallback( - (event: React.KeyboardEvent): void => { - if (event.key === "Enter") { - onButtonClick(); - event.preventDefault(); - } - }, - [onButtonClick] - ); +export default function SearchInput({ + value, + onChange, + onButtonClick, + loading, + className, + buttonText, +}: SearchInputProps) { + const c = useC(); return ( -
+
{ + const { value } = event.currentTarget; + onChange(value); + }} + onKeyDown={(event) => { + if (event.key === "Enter") { + onButtonClick(); + event.preventDefault(); + } + }} /> - {props.additionalButton ? ( -
- {props.additionalButton} -
- ) : null} -
- - {props.buttonText ?? t("search")} - -
+ + + {c(buttonText ?? "search")} +
); -}; - -export default SearchInput; +} -- cgit v1.2.3