Files
Trilium/apps/client/src/widgets/react/FormTextBox.tsx

25 lines
956 B
TypeScript
Raw Normal View History

import { InputHTMLAttributes, RefObject } from "preact/compat";
interface FormTextBoxProps extends Pick<InputHTMLAttributes<HTMLInputElement>, "placeholder" | "autoComplete" | "className" | "type" | "name" | "pattern" | "title"> {
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
}
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}
type={type ?? "text"}
2025-08-05 19:06:47 +03:00
className={`form-control ${className ?? ""}`}
id={id}
2025-08-04 21:17:35 +03:00
name={name}
value={currentValue}
autoComplete={autoComplete}
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
);
}