import { RcListItem } from '@ringcentral/juno'; import clsx from 'clsx'; import type { FunctionComponent } from 'react'; import React from 'react'; import { useScrollIntoView } from '../../react-hooks/useScrollIntoView'; import styles from './styles.scss'; export interface ListItemProps { onClick?(): void; selected?: boolean; className?: string; } /** * if you want to make that can be auto scroll, should add `SelectListContext` and pass scrollElmRef into. * example: * ```tsx * const scrollElmRef = useRef(); * * return ( * . * .. * * ); * ``` */ export const ListItem: FunctionComponent = ({ selected, onClick, children, className, // rest is need for data-sign or other data-* ...rest }) => { const itemRef = useScrollIntoView(selected); return ( { e.preventDefault(); // @ts-expect-error TS(2722): Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message onClick(); }} {...rest} > {children} ); }; ListItem.defaultProps = { selected: false, onClick() {}, };