You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
429 B
TypeScript

import { h, JSX } from "preact";
import { useRef } from "preact/hooks";
import { Callback } from "../../../utils.ts";
export const TextInput = (
p: Omit<JSX.HTMLAttributes<HTMLInputElement>, "onInput"> & {
placeholder?: string;
value: string;
onInput: Callback<[string]>;
},
) => {
const ref = useRef<HTMLInputElement>(null);
return h("input", {
...p,
ref,
onInput: () => p.onInput(ref.current!.value),
});
};