import React, { type ChangeEvent } from 'react'; import { type Control, Controller, type FieldValues } from 'react-hook-form'; import { TextInput } from '@carbon/react'; import { type TextInputProps } from '@carbon/react/lib/components/TextInput/TextInput'; interface ControlledTextInputProps extends TextInputProps { controllerName: string; name: string; control: Control; } const ControlledTextInput = (props: ControlledTextInputProps) => { const { controllerName, control, ...textInputProps } = props; return ( ( ) => { onChange(e.target.value); // Fire prop change if (props.onChange) { props.onChange(e); } }} id={props.id} ref={ref} value={value ?? props.value} /> )} /> ); }; export default ControlledTextInput;