chore: add type field to TextField

This commit is contained in:
Steven
2023-04-20 03:59:29 +08:00
parent 86f1171c34
commit 4abe81f351
2 changed files with 16 additions and 3 deletions

View File

@ -253,6 +253,7 @@ const CreateConnectionModal = (props: Props) => {
<label className="block text-sm font-medium text-gray-700 mb-1">{t("connection.password")}</label>
<TextField
placeholder="Connection password"
type="password"
value={connection.password || ""}
onChange={(value) => setPartialConnection({ password: value })}
/>

View File

@ -1,18 +1,30 @@
import { HTMLInputTypeAttribute } from "react";
interface Props {
value: string;
onChange: (value: string) => void;
onChange?: (value: string) => void;
type?: HTMLInputTypeAttribute;
className?: string;
disabled?: boolean;
placeholder?: string;
}
const getDefaultProps = () => ({
value: "",
onChange: () => {},
type: "text",
className: "",
disabled: false,
placeholder: "",
});
const TextField = (props: Props) => {
const { value, disabled, className, placeholder, onChange } = props;
const { value, disabled, className, placeholder, type, onChange } = { ...getDefaultProps(), ...props };
return (
<input
className={`${className || ""} w-full border px-3 py-2 rounded-lg dark:border-zinc-700 dark:bg-zinc-800 focus:outline-2`}
type="text"
type={type}
disabled={disabled}
placeholder={placeholder}
value={value}