/** * WordPress dependencies */ import { privateApis } from '@wordpress/components'; import { useCallback } from '@wordpress/element'; /** * Internal dependencies */ import type { DataFormControlProps } from '../../types'; import { unlock } from '../../lock-unlock'; import getCustomValidity from './utils/get-custom-validity'; const { ValidatedTextareaControl } = unlock( privateApis ); export default function Textarea< Item >( { data, field, onChange, hideLabelFromVision, markWhenOptional, config, validity, }: DataFormControlProps< Item > ) { const { rows = 4 } = config || {}; const { label, placeholder, description, setValue, isValid } = field; const value = field.getValue( { item: data } ); const onChangeControl = useCallback( ( newValue: string ) => onChange( setValue( { item: data, value: newValue } ) ), [ data, onChange, setValue ] ); return ( ); }