mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-08-01 09:43:12 +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>
|
||||
<TextField
|
||||
placeholder="Connection password"
|
||||
type="password"
|
||||
value={connection.password || ""}
|
||||
onChange={(value) => setPartialConnection({ password: value })}
|
||||
/>
|
||||
|
@ -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}
|
||||
|
Reference in New Issue
Block a user