import cs from 'classnames' import React, { KeyboardEvent, ReactNode, useRef } from 'react' import { partial, uniqueId } from 'lodash' import VisuallyHidden from '@reach/visually-hidden' import useSelect from './use-select' interface Props { value: string children?: ReactNode selectItem?: boolean } const SelectItem = ({ value, children, ...rest }: Props) => { const { name, handleChange, handleKeyDown, isSelected } = useSelect() const liRef = useRef(null) const inputRef = useRef(null) const id = uniqueId('select-item-') const onKeyDown = (e: KeyboardEvent) => { // ensure it's not an element in children that's being keyed down if (e.target && e.target !== liRef.current && e.target !== inputRef.current) { return } handleKeyDown(e) } return (
  • ) } SelectItem.defaultProps = { selectItem: true, } export default SelectItem