import React from 'react'; import { Box, Flex, useTheme, Grid, type GridProps, theme, Image, Radio } from '@chakra-ui/react'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useTranslation } from 'next-i18next'; import { useToast } from '@fastgpt/web/hooks/useToast'; // @ts-ignore interface Props extends GridProps { list: { icon?: string; title: string | React.ReactNode; desc?: string; value: any; forbidTip?: string; // If this value is exists, it will be prompted to disable when clicked }[]; iconSize?: string; align?: 'top' | 'center'; value: any; hiddenCircle?: boolean; onChange: (e: any) => void; } const MyRadio = ({ list, value, align = 'center', iconSize = '18px', hiddenCircle = false, p, onChange, ...props }: Props) => { const { t } = useTranslation(); const theme = useTheme(); const { toast } = useToast(); return ( {list.map((item) => ( { if (item.forbidTip) { toast({ status: 'warning', title: item.forbidTip }); } else { onChange(item.value); } }} > {!!item.icon && ( <> {item.icon.startsWith('/') ? ( {''} ) : ( )} )} {typeof item.title === 'string' ? t(item.title) : item.title} {!!item.desc && ( {t(item.desc)} )} ))} ); }; export default MyRadio;