import React from 'react'; import { func, array, number } from 'prop-types'; import cx from 'classnames'; import s from './Selection.module.css'; export default function Selection({ OptionComponent, optionPropsList, selectedIndex, onChange }) { return ( // TODO a11y // tabIndex="0"
{optionPropsList.map((props, idx) => { const className = cx(s.item, { [s.itemActive]: idx === selectedIndex }); return (
{ ev.preventDefault(); if (idx !== selectedIndex) { onChange(idx); } }} >
); })}
); } Selection.propTypes = { OptionComponent: func, optionPropsList: array, selectedIndex: number, onChange: func }; // for test export function Option({ title }) { // eslint-disable-next-line no-undef if (__DEV__) { return (
{title}
); } }