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

26 lines
802 B
TypeScript
Raw Normal View History

2025-08-05 19:06:47 +03:00
import { HTMLInputTypeAttribute, RefObject } from "preact/compat";
2025-08-03 21:18:18 +03:00
interface FormTextBoxProps {
id?: string;
2025-08-03 21:18:18 +03:00
name: string;
type?: HTMLInputTypeAttribute;
2025-08-03 21:18:18 +03:00
currentValue?: string;
className?: string;
autoComplete?: string;
2025-08-03 21:18:18 +03:00
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-05 19:06:47 +03:00
export default function FormTextBox({ id, type, name, className, currentValue, onChange, autoComplete, inputRef }: 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}
2025-08-04 21:17:35 +03:00
onInput={e => onChange?.(e.currentTarget.value)} />
2025-08-03 21:18:18 +03:00
);
}