import React from 'react'; import { VisuallyHidden } from 'react-aria'; import classNames from 'classnames'; import { RadioGroup as CoreRadioGroup } from '@shoptet/ui-core-web'; import type { SafePick } from '@shoptet/utils'; import { Icon } from '../../Icon/Icon'; import type { ImageProps } from '../../Image/Image'; import { Image } from '../../Image/Image'; import type { SelectKey } from './RadioGroup'; import type { RenderRadioGroupOptionProps } from './types'; /** @inheritdoc */ export interface RadioGroupImageOptionInheritedImageProps extends SafePick, SafePick, 'alt'> {} /** @inheritdoc */ export interface RadioGroupImageOptionInheritedRadioOptionProps< V extends SelectKey = SelectKey, > extends RenderRadioGroupOptionProps {} /** @inheritdoc */ export interface RadioGroupImageOptionProps extends RadioGroupImageOptionInheritedImageProps, RadioGroupImageOptionInheritedRadioOptionProps {} export function RadioGroupImageOption({ value, checked, disabled, required, textLabel, description, validity, onChange, ref, src, alt, fit = 'contain', aspectRatio = '3 / 2', size = 'md', ...rest }: RadioGroupImageOptionProps) { rest satisfies Record; const resolvedAlt = alt ?? (description ? `${textLabel} ${description}` : textLabel); return ( label={textLabel} value={value} checked={checked} onChange={onChange} required={required} disabled={disabled} invalid={validity === 'error'} > {resolvedAlt} {checked ? ( ) : ( )} ); }