import React from 'react'; import { Pressable, PressableProps } from 'react-native'; import { Icon } from '../../foundation'; import { LayoutStyleProp } from '../../internal/utils/utilTypes'; type Props = Omit & { selected?: boolean; size?: 'small' | 'medium'; }; /** * # RadioButton 컴포넌트 * * - onPress가 지정되지 않으면 pointerEvents='none' 상태로 터치 이벤트를 차단합니다. * - onPress가 지정되면 pointerEvents='auto'로 터치 이벤트를 허용합니다. * - layoutStyle을 통해 컴포넌트의 스타일을 지정할 수 있습니다. * * * * ### `selected` * - 라디오버튼의 선택 상태 * - 기본값 false * * * ### `size` * - 라디오버튼의 크기 ('small' = 20, 'medium' = 24) * - 기본값 'medium' * */ export function RadioButton(props: Props & LayoutStyleProp): React.JSX.Element { const { onPress, disabled, selected = false, size = 'medium', layoutStyle, pointerEvents, ...rest } = props; const _size = size === 'medium' ? 24 : 20; const _pointerEvents = pointerEvents ?? (onPress ? 'auto' : 'none'); const radioIcon = (() => { if (!selected) { return ; } if (selected && disabled === true) { return ; } return ; })(); return ( {radioIcon} ); }