import React from 'react' import classNames from '@/utils/classnames' import type { RemixiconComponentType } from '@remixicon/react' import Divider from '../divider' // Updated generic type to allow enum values type SegmentedControlProps = { options: { Icon: RemixiconComponentType, text: string, value: T }[] value: T onChange: (value: T) => void className?: string } export const SegmentedControl = ({ options, value, onChange, className, }: SegmentedControlProps): JSX.Element => { const selectedOptionIndex = options.findIndex(option => option.value === value) return (
{options.map((option, index) => { const { Icon } = option const isSelected = index === selectedOptionIndex const isNextSelected = index === selectedOptionIndex - 1 const isLast = index === options.length - 1 return ( ) })}
) } export default React.memo(SegmentedControl) as typeof SegmentedControl