import { FormControl, HStack, Input, Text } from '@chakra-ui/react'; import React, { ChangeEventHandler } from 'react'; interface TextFieldProps { domId: string; label?: string; inputType?: string; inputProps?: {}; containerProps?: {}; placeholder?: string; value?: string | number; onChange?: ChangeEventHandler; children?: React.ReactNode; } export default function TextField({ domId, label, inputType, placeholder, value, onChange, children, inputProps, containerProps = {}, }: TextFieldProps) { const [isFocused, setIsFocused] = React.useState(false); const textFieldInputProps = { textStyle: 'body2', color: 'cld.fg1', fontSize: '0.875rem', _placeholder: { color: 'cld.fg4' }, focusBorderColor: 'cld.fg1', borderColor: 'cld.separator2', variant: 'flushed', ...inputProps, }; const { __focus: focusContainerProps, ...rest } = containerProps as any; const finalContainerProps = { ...rest, ...(isFocused ? focusContainerProps : {}), }; return ( {label && ( {label} )} setIsFocused(true)} onBlur={(e) => setIsFocused(false)} {...textFieldInputProps} /> {children} ); }