import cx from 'classnames' ; import getMenuItemId from './getMenuItemId' ; import hasOwnProperty from './hasOwnProperty' ; import { TypeaheadManagerProps } from '../types' ; const getInputProps = ( { activeIndex , id , isFocused , isMenuShown , multiple , onClick , onFocus , placeholder , ... rest } ) => ( inputProps = { } ) => { const className = hasOwnProperty ( inputProps , 'className' ) ? inputProps . className : undefined ; const props = { autoComplete : 'off' , placeholder , type : 'text' , ... inputProps , ... rest , 'aria-activedescendant' : activeIndex >= 0 ? getMenuItemId ( id , activeIndex ) : undefined , 'aria-autocomplete' : 'both' , 'aria-expanded' : isMenuShown , 'aria-haspopup' : 'listbox' , 'aria-owns' : isMenuShown ? id : undefined , className : cx ( { [ ( className || '' ) as string ] : ! multiple , focus : isFocused , } ) , onClick , onFocus , role : 'combobox' , } ; if ( ! multiple ) { return props ; } return { ... props , 'aria-autocomplete' : 'list' , 'aria-expanded' : undefined , inputClassName : className , role : undefined , } ; } ; export default getInputProps ;