Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/plus/chat/index-en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,7 @@ render(DefaultChat);
|------|--------|-------|-------|
| align | Dialog layout, supports `leftRight`,`leftAlign` | string | `leftRight` |
| bottomSlot | bottom slot for chat | React.ReactNode | - |
| canSend | Whether the send button is enabled. Normally, no settings are needed; the component internally determines whether sending is enabled. If settings are configured, the settings will prevail. Added in v2.90.0. | boolean |
| chatBoxRenderConfig | chatBox rendering configuration | ChatBoxRenderConfig | - |
| chats | Controlled conversation list | Message | - |
| className | Custom class name | string | - |
Expand Down
1 change: 1 addition & 0 deletions content/plus/chat/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,7 @@ render(DefaultChat);
|------|--------|-------|-------|
| align | 对话布局方式,支持 `leftRight`、`leftAlign` | string | `leftRight` |
| bottomSlot | 底部插槽 | React.ReactNode | - |
| canSend | 发送按钮是否可以发送。通常无需设置,由内部逻辑决定。如有设置,以此设置为准,v2.90.0 新增 | boolean |
| chatBoxRenderConfig | chatBox 渲染配置 | ChatBoxRenderConfig | - |
| chats | 受控对话列表 | Message | - |
| className | 自定义类名 | string | - |
Expand Down
7 changes: 6 additions & 1 deletion packages/semi-foundation/chat/inputboxFoundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ export default class InputBoxFoundation <P = Record<string, any>, S = Record<str

getDisableSend = () => {
const { content, attachment } = this.getStates();
const { disableSend: disableSendInProps } = this.getProps();
const { disableSend: disableSendInProps, canSend } = this.getProps();
// 如果用户设置了 canSend API,则使用 canSend 值
// If the user has configured the canSend API, then the canSend value will be used.
if (typeof canSend === 'boolean') {
return !canSend;
}
/** 不能发送的条件:(满足任1)
* 1. props 中禁止发送;2. 没有文本输入,且没有上传文件; 3.上传文件中有状态不为 success 的
* Conditions under which content cannot be sent: (any one of the following conditions must be met)
Expand Down
4 changes: 3 additions & 1 deletion packages/semi-ui/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ class Chat extends BaseComponent<ChatProps, ChatState> {
customMarkDownComponents, mode, showClearContext,
placeholder, inputBoxCls, inputBoxStyle,
hintStyle, hintCls, uploadProps, uploadTipProps,
sendHotKey, renderDivider, markdownRenderProps, enableUpload
sendHotKey, renderDivider, markdownRenderProps, enableUpload,
canSend,
} = this.props;
const { backBottomVisible, chats, wheelScroll, uploadAreaVisible } = this.state;
let showStopGenerateFlag = false;
Expand Down Expand Up @@ -389,6 +390,7 @@ class Chat extends BaseComponent<ChatProps, ChatState> {
</span>)}
{/* input area */}
<InputBox
canSend={canSend}
showClearContext={showClearContext}
uploadRef={this.uploadRef}
manualUpload={this.adapter.manualUpload}
Expand Down
2 changes: 2 additions & 0 deletions packages/semi-ui/chat/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface CommonChatsProps {
export interface ChatProps extends CommonChatsProps {
style?: React.CSSProperties;
className?: string;
canSend?: boolean;
hints?: string[];
renderHintBox?: (props: {content: string; index: number;onHintClick: () => void}) => React.ReactNode;
onHintClick?: (hint: string) => void;
Expand Down Expand Up @@ -158,6 +159,7 @@ export interface ChatBoxProps extends Omit<CommonChatsProps, "chats"> {
}

export interface InputBoxProps {
canSend?: boolean;
showClearContext?: boolean;
sendHotKey?: 'enter' | 'shift+enter';
placeholder: string;
Expand Down
Loading