mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-25 17:15:19 +08:00
chore: add type field to TextField
This commit is contained in:
@ -253,6 +253,7 @@ const CreateConnectionModal = (props: Props) => {
|
|||||||
<label className="block text-sm font-medium text-gray-700 mb-1">{t("connection.password")}</label>
|
<label className="block text-sm font-medium text-gray-700 mb-1">{t("connection.password")}</label>
|
||||||
<TextField
|
<TextField
|
||||||
placeholder="Connection password"
|
placeholder="Connection password"
|
||||||
|
type="password"
|
||||||
value={connection.password || ""}
|
value={connection.password || ""}
|
||||||
onChange={(value) => setPartialConnection({ password: value })}
|
onChange={(value) => setPartialConnection({ password: value })}
|
||||||
/>
|
/>
|
||||||
|
@ -1,18 +1,30 @@
|
|||||||
|
import { HTMLInputTypeAttribute } from "react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value: string;
|
value: string;
|
||||||
onChange: (value: string) => void;
|
onChange?: (value: string) => void;
|
||||||
|
type?: HTMLInputTypeAttribute;
|
||||||
className?: string;
|
className?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getDefaultProps = () => ({
|
||||||
|
value: "",
|
||||||
|
onChange: () => {},
|
||||||
|
type: "text",
|
||||||
|
className: "",
|
||||||
|
disabled: false,
|
||||||
|
placeholder: "",
|
||||||
|
});
|
||||||
|
|
||||||
const TextField = (props: Props) => {
|
const TextField = (props: Props) => {
|
||||||
const { value, disabled, className, placeholder, onChange } = props;
|
const { value, disabled, className, placeholder, type, onChange } = { ...getDefaultProps(), ...props };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
className={`${className || ""} w-full border px-3 py-2 rounded-lg dark:border-zinc-700 dark:bg-zinc-800 focus:outline-2`}
|
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}
|
disabled={disabled}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
value={value}
|
value={value}
|
||||||
|
Reference in New Issue
Block a user