import {FunctionalComponent} from "preact"; import {useState} from "preact/hooks"; import cn from "classnames"; import {JSX} from "preact"; // import GenericEventHandler = JSXInternal.GenericEventHandler; import style from "./style.module.scss"; import {Settings} from "preact-feather"; import {FeatherProps} from "preact-feather/src/types"; interface InputProps { type: "text" | "number" | "email" | "password"; icon: FunctionalComponent; value: T; placeholder?: string; onChange: (value: T) => void; className?: string; disabled?: boolean; id?: string; name?: string; } export const Input: FunctionalComponent> = ({ type, icon, value, placeholder, onChange, className, disabled, id, name, }) => { const [focused, setFocused] = useState(false); const inputClass = cn(style.input, "generic-input", className, { focused, disabled, }); const handleInputChange: JSX.GenericEventHandler = (event) => { console.log("handleInputChange") const target = event.target as HTMLInputElement; onChange(type === "number" ? (parseFloat(target.value) || 0) : target.value); }; const Icon = icon; return (
setFocused(true)} onBlur={() => setFocused(false)} />
) return ( setFocused(true)} onBlur={() => setFocused(false)} /> ); };