import React from 'react'; import { type Control, Controller, type FieldValues } from 'react-hook-form'; import { ComboBox, type ComboBoxProps } from '@carbon/react'; interface ControlledComboBoxProps extends Omit, 'onChange' | 'id' | 'ref' | 'value'> { controllerName: string; name: string; control: Control; onChange?: (e: { selectedItem: ItemType | null | undefined }) => void; } const ControlledComboBox = (props: ControlledComboBoxProps) => { const { controllerName, name, control, onChange: onChangeProp, ...comboBoxProps } = props; return ( ( { onChange(e.selectedItem); // Fire prop change if (onChangeProp) { onChangeProp(e); } }} id={name} ref={ref} value={value} /> )} /> ); }; export default ControlledComboBox;