@mxmweb/aichat 2.1.4 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
1
+ import { default as React } from 'react';
1
2
  import { ConversationData } from './AiChat.types';
2
3
  import { Styles } from '@mxmweb/zui';
4
+ import { AIChatLocale, AIChatMessages } from '../i18n';
3
5
  export interface ListItemType {
4
6
  label: string;
5
7
  sessionId: string;
@@ -33,6 +35,8 @@ export interface AppStatusManager {
33
35
  app: 'ready' | 'initializing' | 'error';
34
36
  }
35
37
  export interface SenderConfig {
38
+ /** 输入框 placeholder,用于 i18n;未传时使用 AIChat messages.sender.placeholder */
39
+ placeholder?: string;
36
40
  upload_size_limit?: number;
37
41
  upload_number_limit?: number;
38
42
  upload_file_type_limit?: string[];
@@ -81,6 +85,8 @@ interface AiChatProps {
81
85
  title?: string;
82
86
  tools?: React.ReactNode;
83
87
  };
88
+ locale?: AIChatLocale;
89
+ messages?: Partial<AIChatMessages>;
84
90
  }
85
- export default function AiChat({ chatData, sidebar, eventsEmit, status, CustomComponents, recommandQuestions, styles, senderConfig, fileUploadStatus, onSenderConfigChange, activeSessionId, scrollOld, rightbarInitialCollapsed, rightbarWidth, onRightbarChange, disclaimer, chatHeader, }: AiChatProps): import("react/jsx-runtime").JSX.Element;
91
+ export default function AiChat({ chatData, sidebar, eventsEmit, status, CustomComponents, recommandQuestions, styles, senderConfig, fileUploadStatus, onSenderConfigChange, activeSessionId, scrollOld, rightbarInitialCollapsed, rightbarWidth, onRightbarChange, disclaimer, chatHeader, locale, messages: messagesOverride, }: AiChatProps): import("react/jsx-runtime").JSX.Element;
86
92
  export {};
@@ -0,0 +1,20 @@
1
+ import { default as React } from 'react';
2
+ import { AIChatLocale, AIChatMessages } from './types';
3
+ export interface AIChatI18nContextValue {
4
+ locale: AIChatLocale;
5
+ messages: AIChatMessages;
6
+ /** 取文案,支持点路径如 'sender.placeholder' */
7
+ t: (key: string) => string;
8
+ }
9
+ declare const AIChatI18nContext: React.Context<AIChatI18nContextValue>;
10
+ export { AIChatI18nContext };
11
+ export declare function useAIChatI18n(): AIChatI18nContextValue;
12
+ export interface AIChatI18nProviderProps {
13
+ locale?: AIChatLocale;
14
+ messages?: Partial<AIChatMessages>;
15
+ children: React.ReactNode;
16
+ }
17
+ /**
18
+ * AIChat 根组件内使用的 i18n Provider,提供 locale 与合并后的 messages
19
+ */
20
+ export declare function AIChatI18nProvider({ locale, messages: overrides, children, }: AIChatI18nProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export type { AIChatLocale, AIChatMessages } from './types';
2
+ export { messagesZh, messagesEn, messagesJa, getMessages, interpolate } from './messages';
3
+ export { AIChatI18nContext, AIChatI18nProvider, useAIChatI18n, type AIChatI18nContextValue, type AIChatI18nProviderProps, } from './context';
@@ -0,0 +1,17 @@
1
+ import { AIChatMessages } from './types';
2
+ /** 中文文案(默认) */
3
+ export declare const messagesZh: AIChatMessages;
4
+ /** 英文文案 */
5
+ export declare const messagesEn: AIChatMessages;
6
+ /** 日语文案 */
7
+ export declare const messagesJa: AIChatMessages;
8
+ /**
9
+ * 根据 locale 与可选覆盖得到合并后的 messages
10
+ * @param locale 语言
11
+ * @param overrides 部分覆盖的文案(与内置合并)
12
+ */
13
+ export declare function getMessages(locale: 'zh' | 'en' | 'ja', overrides?: Partial<AIChatMessages>): AIChatMessages;
14
+ /**
15
+ * 替换文案中的 {{key}} 占位符
16
+ */
17
+ export declare function interpolate(template: string, params: Record<string, string | number>): string;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * AIChat 组件 i18n 文案键类型定义
3
+ * 用于中/英/日三语及业务自定义覆盖
4
+ */
5
+ export type AIChatLocale = 'zh' | 'en' | 'ja';
6
+ export interface AIChatMessages {
7
+ sender: {
8
+ placeholder: string;
9
+ clearTip: string;
10
+ send: string;
11
+ stop: string;
12
+ uploadHint: string;
13
+ selectPlaceholder: string;
14
+ };
15
+ fileStatus: {
16
+ pending: string;
17
+ uploading: string;
18
+ parsing: string;
19
+ done: string;
20
+ error: string;
21
+ unknown: string;
22
+ };
23
+ file: {
24
+ scrollLeft: string;
25
+ scrollRight: string;
26
+ remove: string;
27
+ };
28
+ welcome: {
29
+ title: string;
30
+ description: string;
31
+ };
32
+ app: {
33
+ loading: string;
34
+ error: string;
35
+ };
36
+ display: {
37
+ loading: string;
38
+ error: string;
39
+ };
40
+ aiChatBox: {
41
+ copy: string;
42
+ like: string;
43
+ likeShort: string;
44
+ dislike: string;
45
+ dislikeShort: string;
46
+ };
47
+ validation: {
48
+ fileCountExceeded: string;
49
+ fileTypeNotAllowed: string;
50
+ totalSizeExceeded: string;
51
+ totalSizeExceededWithExisting: string;
52
+ };
53
+ }