dify/web/app/components/base/file-uploader/file-uploader-in-chat-input/index.tsx
Stephen Zhou f2842da397
chore(web): new lint setup (#30020)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
2025-12-23 16:58:55 +08:00

42 lines
1.1 KiB
TypeScript

import type { FileUpload } from '@/app/components/base/features/types'
import {
RiAttachmentLine,
} from '@remixicon/react'
import {
memo,
useCallback,
} from 'react'
import ActionButton from '@/app/components/base/action-button'
import { TransferMethod } from '@/types/app'
import { cn } from '@/utils/classnames'
import FileFromLinkOrLocal from '../file-from-link-or-local'
type FileUploaderInChatInputProps = {
fileConfig: FileUpload
}
const FileUploaderInChatInput = ({
fileConfig,
}: FileUploaderInChatInputProps) => {
const renderTrigger = useCallback((open: boolean) => {
return (
<ActionButton
size="l"
className={cn(open && 'bg-state-base-hover')}
>
<RiAttachmentLine className="h-5 w-5" />
</ActionButton>
)
}, [])
return (
<FileFromLinkOrLocal
trigger={renderTrigger}
fileConfig={fileConfig}
showFromLocal={fileConfig?.allowed_file_upload_methods?.includes(TransferMethod.local_file)}
showFromLink={fileConfig?.allowed_file_upload_methods?.includes(TransferMethod.remote_url)}
/>
)
}
export default memo(FileUploaderInChatInput)