import { FormControl, useControl } from '@websolutespa/bom-mixer-forms'; import { useLabel } from '@websolutespa/bom-mixer-hooks'; import { ChangeEvent, FocusEvent, useId, useState } from 'react'; import { Field, Label, TextArea } from '../forms'; import { FieldError } from './field-error'; type FieldTextAreaProps = { control: FormControl; }; export function FieldTextArea({ control }: FieldTextAreaProps) { const uid = useId(); const label = useLabel(); const uniqueName = `${control.name}-${uid}`; const [state, setValue, setTouched] = useControl(control); const onChange = (event: ChangeEvent) => { // console.log('FieldTextArea', event.target.value); setValue(event.target.value); // control.value = event.target.value; }; const [focus, setFocus] = useState(false); const onBlur = (_: FocusEvent) => { setTouched(); setFocus(false); }; const onFocus = (_: FocusEvent) => { setFocus(true); }; const controlLabel = control.label && label(control.label); return ( state.flags.hidden ? ( ) : ( {controlLabel && ( )}