import type { FC } from 'react' import { useState } from 'react' import { useTranslation } from 'react-i18next' import Uploader from './uploader' import ImageLinkInput from './image-link-input' import cn from '@/utils/classnames' import { ImagePlus } from '@/app/components/base/icons/src/vender/line/images' import { TransferMethod } from '@/types/app' import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger, } from '@/app/components/base/portal-to-follow-elem' import { Upload03 } from '@/app/components/base/icons/src/vender/line/general' import type { ImageFile, VisionSettings } from '@/types/app' type UploadOnlyFromLocalProps = { onUpload: (imageFile: ImageFile) => void disabled?: boolean limit?: number } const UploadOnlyFromLocal: FC = ({ onUpload, disabled, limit, }) => { return ( {hovering => (
)}
) } type UploaderButtonProps = { methods: VisionSettings['transfer_methods'] onUpload: (imageFile: ImageFile) => void disabled?: boolean limit?: number } const UploaderButton: FC = ({ methods, onUpload, disabled, limit, }) => { const { t } = useTranslation() const [open, setOpen] = useState(false) const hasUploadFromLocal = methods.find( method => method === TransferMethod.local_file, ) const handleUpload = (imageFile: ImageFile) => { onUpload(imageFile) } const closePopover = () => setOpen(false) const handleToggle = () => { if (disabled) return setOpen(v => !v) } return (
{hasUploadFromLocal && ( <>
OR
{hovering => (
{t('common.imageUploader.uploadFromComputer')}
)}
)}
) } type ChatImageUploaderProps = { settings: VisionSettings onUpload: (imageFile: ImageFile) => void disabled?: boolean } const ChatImageUploader: FC = ({ settings, onUpload, disabled, }) => { const onlyUploadLocal = settings.transfer_methods.length === 1 && settings.transfer_methods[0] === TransferMethod.local_file if (onlyUploadLocal) { return ( ) } return ( ) } export default ChatImageUploader