Files
Trilium/apps/client/src/widgets/react/FormTextBox.tsx
2025-08-08 23:23:07 +03:00

25 lines
956 B
TypeScript

import { InputHTMLAttributes, RefObject } from "preact/compat";
interface FormTextBoxProps extends Pick<InputHTMLAttributes<HTMLInputElement>, "placeholder" | "autoComplete" | "className" | "type" | "name" | "pattern" | "title"> {
id?: string;
currentValue?: string;
onChange?(newValue: string): void;
inputRef?: RefObject<HTMLInputElement>;
}
export default function FormTextBox({ id, type, name, className, currentValue, onChange, autoComplete, inputRef, placeholder, title, pattern }: FormTextBoxProps) {
return (
<input
ref={inputRef}
type={type ?? "text"}
className={`form-control ${className ?? ""}`}
id={id}
name={name}
value={currentValue}
autoComplete={autoComplete}
placeholder={placeholder}
title={title}
pattern={pattern}
onInput={e => onChange?.(e.currentTarget.value)} />
);
}