import React, { useCallback, useState } from 'react'; import { NativeSyntheticEvent, StyleProp, Text, TextInput, TextInputChangeEventData, TouchableOpacity, View, ViewStyle } from 'react-native'; import Icon from '../../../icons/components/Icon'; import { IconCloseCircle } from '../../../icons/svg'; import BaseTheme from '../../../ui/components/BaseTheme.native'; import { InputProps } from '../types'; import styles from './inputStyles'; interface IInputProps extends InputProps { /** * Custom styles to be applied to the component. */ customStyles?: CustomStyles; } interface CustomStyles { container?: Object; input?: Object; } const Input = ({ clearable, customStyles, disabled, error, icon, label, onChange, placeholder, value }: IInputProps) => { const [ focused, setFocused ] = useState(false); const handleChange = useCallback((e: NativeSyntheticEvent) => { const { nativeEvent: { text } } = e; onChange(text); }, []); const clearInput = useCallback(() => { onChange(''); }, []); const blur = useCallback(() => { setFocused(false); }, []); const focus = useCallback(() => { setFocused(true); }, []); return ( {label && {label}} }> {icon && } {clearable && !disabled && value !== '' && ( }> )} ); }; export default Input;