import React from 'react' import classNames from 'classnames' import { useOption } from 'react-aria' import { Icon } from '~components/Icon' import { Radio } from '~components/Radio' import { type ListItemProps, type SelectItem } from '../../types' import styles from './ListItem.module.css' export const ListItem = ({ item, state, selectedIcon = 'check', selectedPosition = 'end', className, }: ListItemProps): JSX.Element => { const ref = React.useRef(null) const { optionProps, isSelected, isDisabled, isFocused } = useOption( { key: item.key }, state, ref, ) const isStart = selectedPosition === 'start' const isEnd = selectedPosition === 'end' const isCheck = selectedIcon === 'check' const isRadio = selectedIcon === 'radio' const renderSelectionIcon = (): JSX.Element | null => { if (isCheck) { if (isSelected) { return (
) } return isStart ?
: null } if (isRadio) { return (
) } return null } return (
  • {isStart && renderSelectionIcon()} {typeof item.rendered === 'string' ? ( {item.rendered} ) : ( {item.rendered} )} {isEnd && renderSelectionIcon()}
  • ) }