import * as React from 'react'; import BaseComponent from '../_base/baseComponent'; import cls from "classnames"; import "@douyinfe/semi-foundation/aiChatDialogue/aiChatDialogue.scss"; import { cssClasses, strings } from '@douyinfe/semi-foundation/aiChatDialogue/constants'; import { Checkbox } from '../checkbox'; import DialogueTitle from './widgets/dialogueTitle'; import DialogueAvatar from './widgets/dialogueAvatar'; import DialogueAction from './widgets/dialogueAction'; import DialogueContent from './widgets/dialogueContent'; import Hint from './widgets/dialogueHint'; import { AIChatDialogueItemProps } from './interface'; const prefixCls = cssClasses.PREFIX; const { ROLE, DIALOGUE_ALIGN } = strings; interface AIChatDialogueState {} class Dialogue extends BaseComponent { constructor(props: AIChatDialogueItemProps) { super(props); } getRoleInfo = () => { const { role, message } = this.props; if (role instanceof Map) { return role.get(message?.name); } return role; } avatarNode = () => { const { role, dialogueRenderConfig, continueSend, message } = this.props; return ; }; titleNode = () => { const { role, dialogueRenderConfig, message } = this.props; return ; }; contentNode = () => { const { message, mode, dialogueRenderConfig, markdownRenderProps, messageEditRender, disabledFileItemClick, renderDialogueContentItem, onFileClick, onImageClick, onAnnotationClick, onReferenceClick, showReference, escapeHtml } = this.props; return ; }; actionNode = () => { const { role, message, showReset, isLastChat, dialogueRenderConfig, onMessageReset, onMessageGoodFeedback, onMessageBadFeedback, onMessageCopy, onMessageShare, messageEditRender, onMessageEdit, onMessageDelete } = this.props; return ; }; render() { const { message, selecting, align, isSelected, onSelectChange, continueSend } = this.props; const id = message.id; const isRightAlign = message.role === ROLE.USER && align === DIALOGUE_ALIGN.LEFT_RIGHT; const containerCls = cls({ [`${prefixCls}-container`]: true, [`${prefixCls}-container-right`]: isRightAlign, }); return (
{ selecting && (
onSelectChange(e.target.checked, id)} />
) }
{this.avatarNode()}
{!continueSend && this.titleNode()} {this.contentNode()} {this.actionNode()}
); } } export default Dialogue;