import React from 'react' import MaskedInput, { MaskedInputProps } from 'react-text-mask' import { Box, Flex } from 'rebass' export interface Props extends React.InputHTMLAttributes, MaskedInputProps { valid: boolean focused: boolean label?: JSX.Element | string } export type PropsWithOptionalMask = Omit & { mask?: Props['mask'] } const Input = (props: Props) => { const { onChange, onFocus, onBlur, mask, valid, focused, label, className, style, ...otherProps } = props const onChangeHandler: ( ev: React.ChangeEvent ) => void = ev => { ev.persist() if (onChange) { onChange(ev) } } const onFocusHandler: ( ev: React.FocusEvent ) => void = ev => { ev.persist() if (onFocus) { onFocus(ev) } } const onBlurHandler: ( ev: React.FocusEvent ) => void = ev => { ev.persist() if (onBlur) { onBlur(ev) } } return ( {props.label ? ( {props.label} ) : null} ) } export default Input