2025-08-08 23:23:07 +03:00
|
|
|
import { InputHTMLAttributes, RefObject } from "preact/compat";
|
2025-08-04 23:22:45 +03:00
|
|
|
|
2025-08-08 23:23:07 +03:00
|
|
|
interface FormTextBoxProps extends Pick<InputHTMLAttributes<HTMLInputElement>, "placeholder" | "autoComplete" | "className" | "type" | "name" | "pattern" | "title"> {
|
2025-08-04 23:22:45 +03:00
|
|
|
id?: string;
|
2025-08-03 21:18:18 +03:00
|
|
|
currentValue?: string;
|
|
|
|
|
onChange?(newValue: string): void;
|
2025-08-05 19:06:47 +03:00
|
|
|
inputRef?: RefObject<HTMLInputElement>;
|
2025-08-03 21:18:18 +03:00
|
|
|
}
|
|
|
|
|
|
2025-08-08 23:23:07 +03:00
|
|
|
export default function FormTextBox({ id, type, name, className, currentValue, onChange, autoComplete, inputRef, placeholder, title, pattern }: FormTextBoxProps) {
|
2025-08-03 21:18:18 +03:00
|
|
|
return (
|
2025-08-04 21:17:35 +03:00
|
|
|
<input
|
2025-08-05 19:06:47 +03:00
|
|
|
ref={inputRef}
|
2025-08-04 23:22:45 +03:00
|
|
|
type={type ?? "text"}
|
2025-08-05 19:06:47 +03:00
|
|
|
className={`form-control ${className ?? ""}`}
|
2025-08-04 23:22:45 +03:00
|
|
|
id={id}
|
2025-08-04 21:17:35 +03:00
|
|
|
name={name}
|
|
|
|
|
value={currentValue}
|
2025-08-04 23:22:45 +03:00
|
|
|
autoComplete={autoComplete}
|
2025-08-08 23:23:07 +03:00
|
|
|
placeholder={placeholder}
|
|
|
|
|
title={title}
|
|
|
|
|
pattern={pattern}
|
2025-08-04 21:17:35 +03:00
|
|
|
onInput={e => onChange?.(e.currentTarget.value)} />
|
2025-08-03 21:18:18 +03:00
|
|
|
);
|
|
|
|
|
}
|