import type { ChoicesProps } from 'react-admin' ; import { ReferenceInput , SelectInput } from 'react-admin' ; import { connectField } from 'uniforms' ; import React from 'react' ; type InputProps = { allowEmpty ? : boolean ; className ? : string ; filterToQuery ? : ( filter : string ) => any ; label ? : string | boolean ; perPage ? : number ; reference : string ; } ; type Props = InputProps & Pick < ChoicesProps , 'optionText' | 'optionValue' > ; /**
 * RaSelectReferenceInputField can be used in an autoform to
 */ const RaSelectReferenceInputField = connectField ( ( { allowEmpty = true , value = null , onChange , optionText , optionValue , label , ... props } ) => { return ( < ReferenceInput label = { label as string } reference = { props . reference } perPage = { props . perPage } allowEmpty = { allowEmpty } meta = { { } } input = { { value , onChange : ( e ) => { onChange ( e . target . value ) ; } , } as any } source = { null } > < SelectInput optionText = { optionText || 'id' } emptyValue = { null } optionValue = { optionValue || 'id' } options = { { value } } /> < /ReferenceInput>); } ) ; export default RaSelectReferenceInputField ;