import clsx from 'clsx'; import { Icon as ReactFeatherComponentType, Check } from 'lucide-react'; import { Fragment } from 'react'; import { Icon } from '@/react/components/Icon'; import { BadgeIcon } from '@@/BadgeIcon'; import { getFeatureDetails } from '@@/BEFeatureIndicator/utils'; import styles from './BoxSelectorItem.module.css'; import { BoxSelectorOption, Value } from './types'; import { LimitedToBeBoxSelectorIndicator } from './LimitedToBeBoxSelectorIndicator'; import { BoxOption } from './BoxOption'; import { LogoIcon } from './LogoIcon'; type Props = { option: BoxSelectorOption; radioName: string; disabled?: boolean; tooltip?: string; onSelect(value: T, limitedToBE: boolean): void; isSelected(value: T): boolean; type?: 'radio' | 'checkbox'; slim?: boolean; checkIcon?: ReactFeatherComponentType; }; export function BoxSelectorItem({ radioName, option, onSelect = () => {}, disabled, tooltip, type = 'radio', isSelected, slim = false, checkIcon = Check, }: Props) { const { limitedToBE = false, url: featureUrl } = getFeatureDetails( option.feature ); const ContentBox = slim ? 'div' : Fragment; return ( onSelect(value, limitedToBE)} tooltip={tooltip} type={type} checkIcon={checkIcon} > {limitedToBE && ( )}
{renderIcon()}
{option.label}

{option.description}

); function isDisabled() { return disabled || (limitedToBE && option.disabledWhenLimited); } function renderIcon() { if (!option.icon) { return null; } if (option.iconType === 'badge') { return ; } if (option.iconType === 'raw') { return ( ); } return ; } }