import React, { useCallback } from 'react'; import { cssClasses } from '@douyinfe/semi-foundation/aiChatDialogue/constants'; import { IconChevronRight } from '@douyinfe/semi-icons'; import { Annotation } from '@douyinfe/semi-foundation/aiChatDialogue/foundation'; import AvatarGroup from '../../../avatar/avatarGroup'; import Avatar from '../../../avatar'; import LocaleConsumer from "../../../locale/localeConsumer"; import { Locale } from '../../../locale/interface'; export interface AnnotationItemProps { title?: string; logo?: string; url?: string; detail?: string } export interface AnnotationWidgetProps { maxCount: number; annotation: AnnotationItemProps[] | Annotation[]; onClick?: (e: React.MouseEvent, item: AnnotationItemProps[]) => void; description?: string } const prefixCls = cssClasses.PREFIX_ANNOTATION; export const AnnotationWidget = (props: AnnotationWidgetProps) => { const { annotation, description, maxCount, onClick } = props; const handleClick = useCallback((e?: React.MouseEvent) => { onClick?.(e, annotation as AnnotationItemProps[]); }, [annotation, onClick]); const renderMore = useCallback((restNumber: number, restAvatars: React.ReactNode[]) => { return {`+${restNumber}`} ; }, []); const handleKeyDown = useCallback((e: React.KeyboardEvent) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); handleClick(); } }, [handleClick]); return (
{annotation.map((item: AnnotationItemProps, index: number) => { return item.logo && ; })}
{ description || ( componentName="AIChatDialogue" > {(locale: Locale["AIChatDialogue"]) => `${annotation.length} ${locale.annotationText}`} ) }
); };