import React , { FunctionComponent , ReactElement } from 'react' ; import { RcList } from '@ringcentral/juno' ; import { ListViewItem , ListViewItemProps } from './ListViewItem' ; export type ListViewProps = { options ? : ListViewItemProps [ 'option' ] [ ] ; nonShow ? : ReactElement ; } & Pick < ListViewItemProps , 'onSelect' | 'renderFunction' | 'secondaryRenderFunction' | 'startAdornment' | 'filter' | 'valueFunction' | 'onChange' | 'value' | 'multiple' > ; export const ListView = ( { options = [ ] , nonShow , startAdornment , ... props } ) => { if ( nonShow && options . length === 0 ) { return nonShow ; } return ( < RcList > { options . map ( ( option , i ) => ( < ListViewItem key = { i } index = { i } option = { option } startAdornment = { startAdornment } { ... props } / > ) ) } < /RcList>); } ; ListView . defaultProps = { options : [ ] , nonShow : null , } ;