Created
March 30, 2021 11:32
-
-
Save evasconcelos/81c745f9c2a33a3ea34fda9a7ba3fb9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { FC } from "react"; | |
interface InputProps { | |
inputRef: React.RefObject< | |
HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | |
>; | |
className?: string; | |
containerClassName?: string; | |
formGroupClassName?: string; | |
type?: "text" | "search" | "password" | "email" | "textarea" | "select"; | |
textareaRows?: number; | |
name?: string; | |
value: string; | |
isTouched: boolean; | |
onChange: React.ChangeEventHandler< | |
HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | |
>; | |
onInput: React.FormEventHandler<HTMLInputElement | HTMLTextAreaElement>; | |
onClearClick: React.MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>; | |
onBlur: React.FocusEventHandler< | |
HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | |
>; | |
onInvalid: React.FormEventHandler< | |
HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | |
>; | |
placeholder?: string; | |
id: string; | |
maxLength?: number; | |
hasClearButton?: boolean; | |
label?: React.ReactNode; | |
labelStyle?: "onTop" | "onLeft"; | |
addonLeft?: React.ReactNode; | |
addonRight?: React.ReactNode; | |
addonLeftClassName?: string; | |
addonRightClassName?: string; | |
helpText?: React.ReactNode; | |
isShortInput?: boolean; | |
isLoading?: boolean; | |
} | |
const Input: FC<InputProps> = ({ | |
className, | |
containerClassName, | |
formGroupClassName, | |
type = "text", | |
name, | |
value = "", | |
placeholder, | |
id, | |
onChange, | |
onInput, | |
onInvalid, | |
onBlur, | |
maxLength, | |
hasClearButton, | |
label, | |
isTouched, | |
onClearClick, | |
addonLeft, | |
addonRight, | |
addonLeftClassName, | |
addonRightClassName, | |
inputRef, | |
helpText, | |
labelStyle, | |
textareaRows, | |
isShortInput, | |
isLoading, | |
...validationProps | |
}) => { | |
return <div><input />...</div>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment