mirror of
				https://github.com/langgenius/dify.git
				synced 2025-10-31 10:53:02 +00:00 
			
		
		
		
	 7709d9df20
			
		
	
	
		7709d9df20
		
			
		
	
	
	
	
		
			
			Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: jZonG <jzongcode@gmail.com>
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| 'use client'
 | |
| import type { FC } from 'react'
 | |
| import React, { useCallback } from 'react'
 | |
| import FileIcon from '../document-file-icon'
 | |
| import cn from '@/utils/classnames'
 | |
| import type { DocumentItem } from '@/models/datasets'
 | |
| 
 | |
| type Props = {
 | |
|   className?: string
 | |
|   list: DocumentItem[]
 | |
|   onChange: (value: DocumentItem) => void
 | |
| }
 | |
| 
 | |
| const DocumentList: FC<Props> = ({
 | |
|   className,
 | |
|   list,
 | |
|   onChange,
 | |
| }) => {
 | |
|   const handleChange = useCallback((item: DocumentItem) => {
 | |
|     return () => onChange(item)
 | |
|   }, [onChange])
 | |
| 
 | |
|   return (
 | |
|     <div className={cn(className)}>
 | |
|       {list.map((item) => {
 | |
|         const { id, name, extension } = item
 | |
|         return (
 | |
|           <div
 | |
|             key={id}
 | |
|             className='flex h-8 cursor-pointer items-center space-x-2 rounded-lg px-2 hover:bg-state-base-hover'
 | |
|             onClick={handleChange(item)}
 | |
|           >
 | |
|             <FileIcon name={item.name} extension={extension} size='md' />
 | |
|             <div className='truncate text-sm text-text-secondary'>{name}</div>
 | |
|           </div>
 | |
|         )
 | |
|       })}
 | |
|     </div>
 | |
|   )
 | |
| }
 | |
| 
 | |
| export default React.memo(DocumentList)
 |