yt-chat-components 0.1.0
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.
- package/.idea/langflow-embedded-chat.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/sonarlint/issuestore/0/f/0f8c0c92cf798431ebb931ff6e997b1af86ecee5 +0 -0
- package/.idea/sonarlint/issuestore/3/9/39129446b425a1d640160c068e4194e96639eedf +0 -0
- package/.idea/sonarlint/issuestore/4/a/4a2f33951ce07c1ff7184f91877aa13db05d3785 +0 -0
- package/.idea/sonarlint/issuestore/4/a/4a7b99bdbee5792679d347b6474463bf5e14b66d +0 -0
- package/.idea/sonarlint/issuestore/4/b/4b6989b8ccae808ebc45d02230d336ea53800365 +0 -0
- package/.idea/sonarlint/issuestore/6/c/6c024c1d0ad64656b9d4b0695ec3c49c0454addf +0 -0
- package/.idea/sonarlint/issuestore/8/d/8d6123af13a140f93e06299fff7ea23c547e9ec8 +0 -0
- package/.idea/sonarlint/issuestore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d +0 -0
- package/.idea/sonarlint/issuestore/d/9/d938938695d447dadda115e28781c6541f53fc4f +0 -0
- package/.idea/sonarlint/issuestore/index.pb +19 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +274 -0
- package/build/asset-manifest.json +16 -0
- package/build/index.html +1 -0
- package/build/static/css/main.6f7c593d.css +2 -0
- package/build/static/css/main.6f7c593d.css.map +1 -0
- package/build/static/js/bundle.min.js +2 -0
- package/build/static/js/bundle.min.js.LICENSE.txt +124 -0
- package/build/static/js/main.cb252095.js +3 -0
- package/build/static/js/main.cb252095.js.LICENSE.txt +134 -0
- package/build/static/js/main.cb252095.js.map +1 -0
- package/build/static/media/aiavatar.74bafa995cce4c01b804.png +0 -0
- package/build/static/media/history-list-empty.1eb65b1550aef4e8c8a4.png +0 -0
- package/build/static/media/moreBg.9fc998472925cecd89f2.png +0 -0
- package/package.json +75 -0
- package/public/index.html +47 -0
- package/src/YtChatView/chatWidget/chatWindow/chatMessage/index.module.css +86 -0
- package/src/YtChatView/chatWidget/chatWindow/chatMessage/index.tsx +211 -0
- package/src/YtChatView/chatWidget/chatWindow/chatPlaceholder/index.module.css +9 -0
- package/src/YtChatView/chatWidget/chatWindow/chatPlaceholder/index.tsx +23 -0
- package/src/YtChatView/chatWidget/chatWindow/controllers/index.ts +236 -0
- package/src/YtChatView/chatWidget/chatWindow/index.module.css +197 -0
- package/src/YtChatView/chatWidget/chatWindow/index.tsx +791 -0
- package/src/YtChatView/chatWidget/chatWindow/types/chatWidget/index.ts +37 -0
- package/src/YtChatView/chatWidget/chatWindow/utils.ts +75 -0
- package/src/YtChatView/chatWidget/index.tsx +2289 -0
- package/src/YtChatView/logoBtn/index.css +4 -0
- package/src/YtChatView/logoBtn/index.jsx +65 -0
- package/src/YtChatView/logoSplitBtn/index.css +4 -0
- package/src/YtChatView/logoSplitBtn/index.jsx +67 -0
- package/src/YtChatView/previewDialog/index.jsx +431 -0
- package/src/YtChatView/previewDialog/index.module.css +144 -0
- package/src/assets/aicenter/add.png +0 -0
- package/src/assets/aicenter/aiavatar.png +0 -0
- package/src/assets/aicenter/aicenterbg.png +0 -0
- package/src/assets/aicenter/aicenterbgdark.png +0 -0
- package/src/assets/aicenter/close.png +0 -0
- package/src/assets/aicenter/closex.png +0 -0
- package/src/assets/aicenter/copy.png +0 -0
- package/src/assets/aicenter/file.png +0 -0
- package/src/assets/aicenter/fileupload.png +0 -0
- package/src/assets/aicenter/history-list-empty.png +0 -0
- package/src/assets/aicenter/history.png +0 -0
- package/src/assets/aicenter/luyin.png +0 -0
- package/src/assets/aicenter/moreAi.png +0 -0
- package/src/assets/aicenter/moreBg.png +0 -0
- package/src/assets/aicenter/play-run.gif +0 -0
- package/src/assets/aicenter/play.png +0 -0
- package/src/assets/aicenter/send-img.png +0 -0
- package/src/assets/aicenter/send-question-black.png +0 -0
- package/src/assets/aicenter/send-question.png +0 -0
- package/src/assets/aicenter/sendmessage.png +0 -0
- package/src/assets/aicenter/sound-wave.gif +0 -0
- package/src/assets/aicenter/toLeft.png +0 -0
- package/src/assets/aicenter/toRight.png +0 -0
- package/src/assets/aicenter/type-excel.png +0 -0
- package/src/assets/aicenter/type-markdown.png +0 -0
- package/src/assets/aicenter/type-mobi.png +0 -0
- package/src/assets/aicenter/type-pdf.png +0 -0
- package/src/assets/aicenter/type-rpub.png +0 -0
- package/src/assets/aicenter/type-text.png +0 -0
- package/src/assets/aicenter/type-word.png +0 -0
- package/src/assets/aicenter/upfile.png +0 -0
- package/src/chatPlaceholder/index.tsx +18 -0
- package/src/chatWidget/chatTrigger/index.tsx +15 -0
- package/src/chatWidget/chatWindow/chatMessage/index.tsx +42 -0
- package/src/chatWidget/chatWindow/index.tsx +426 -0
- package/src/chatWidget/index.tsx +2195 -0
- package/src/chatWidget/utils.ts +76 -0
- package/src/controllers/index.ts +205 -0
- package/src/index.tsx +60 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/setupTests.ts +5 -0
- package/src/types/chatWidget/index.ts +13 -0
- package/tsconfig.json +26 -0
- package/webpack.config.js +51 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type ChatMessageType = {
|
|
2
|
+
message: {
|
|
3
|
+
message: string; // 真正的文本消息
|
|
4
|
+
isSend: boolean; // true为用户发送,false为机器人发送
|
|
5
|
+
rawInfo?: any; // 消息的原始信息,对应数据库字段
|
|
6
|
+
};
|
|
7
|
+
isSend: boolean;
|
|
8
|
+
error?: boolean;
|
|
9
|
+
host_url: string;
|
|
10
|
+
bot_message_style?: React.CSSProperties;
|
|
11
|
+
user_message_style?: React.CSSProperties;
|
|
12
|
+
error_message_style?: React.CSSProperties;
|
|
13
|
+
rawInfo?: any;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type ChatMessagePlaceholderType = {
|
|
17
|
+
bot_message_style?: React.CSSProperties;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type embedAppExtend = {
|
|
21
|
+
http_extend: {
|
|
22
|
+
bd:{},
|
|
23
|
+
header: {
|
|
24
|
+
appId: string;
|
|
25
|
+
metaId: string;
|
|
26
|
+
menuId: string;
|
|
27
|
+
};
|
|
28
|
+
params: {
|
|
29
|
+
code: string;
|
|
30
|
+
};
|
|
31
|
+
body: {
|
|
32
|
+
code: string
|
|
33
|
+
}
|
|
34
|
+
operator_id: string;
|
|
35
|
+
upload_file_path_list: string[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export function getChatPosition(
|
|
2
|
+
triggerPosition: DOMRect,
|
|
3
|
+
Cwidth:number,
|
|
4
|
+
Cheight:number,
|
|
5
|
+
position?: string,
|
|
6
|
+
): { top: string; left: string;
|
|
7
|
+
position?: string, } {
|
|
8
|
+
if (!triggerPosition) {
|
|
9
|
+
return { top: "0px", left: "0px" }; // Return empty string if trigger position is not available
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { top, left, width, height } = triggerPosition;
|
|
13
|
+
|
|
14
|
+
const distance = 5; // Adjust this value to set the desired distance from the trigger
|
|
15
|
+
if(!position) return { top: distance + height+ "px", left: width + "px" };
|
|
16
|
+
|
|
17
|
+
switch (position) {
|
|
18
|
+
case "top-left":
|
|
19
|
+
return { top: - distance - Cheight + "px", left: -Cwidth + "px" };
|
|
20
|
+
case "top-center":
|
|
21
|
+
return { top: - distance - Cheight + "px", left: width/2-Cwidth / 2 + "px" };
|
|
22
|
+
case "top-right":
|
|
23
|
+
return { top: - distance - Cheight + "px", left: width+ "px" };
|
|
24
|
+
case "center-left":
|
|
25
|
+
return { top: width/2-Cheight/2 + "px", left: -Cwidth - distance + "px" };
|
|
26
|
+
case "center-right":
|
|
27
|
+
return {
|
|
28
|
+
top: width/2-Cheight/2 + "px",
|
|
29
|
+
left: width + distance + "px",
|
|
30
|
+
};
|
|
31
|
+
case "bottom-right":
|
|
32
|
+
return { top: distance + height+ "px", left: width + "px" };
|
|
33
|
+
case "bottom-center":
|
|
34
|
+
return {
|
|
35
|
+
top: distance + height+ "px",
|
|
36
|
+
left: width/2-Cwidth / 2 + "px",
|
|
37
|
+
};
|
|
38
|
+
case "bottom-left":
|
|
39
|
+
return { top: distance + height+ "px", left: -Cwidth + "px"};
|
|
40
|
+
default:
|
|
41
|
+
return { top: distance + height+ "px", left: width + "px" };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function getAnimationOrigin(position?:string) {
|
|
46
|
+
if(!position) return "origin-top-left";
|
|
47
|
+
switch (position) {
|
|
48
|
+
case "top-left":
|
|
49
|
+
return 'origin-bottom-right'
|
|
50
|
+
case "top-center":
|
|
51
|
+
return "origin-bottom";
|
|
52
|
+
case "top-right":
|
|
53
|
+
return "origin-bottom-left";
|
|
54
|
+
case "center-left":
|
|
55
|
+
return "origin-center";
|
|
56
|
+
case "center-right":
|
|
57
|
+
return "origin-center";
|
|
58
|
+
case "bottom-right":
|
|
59
|
+
return "origin-top-left";
|
|
60
|
+
case "bottom-center":
|
|
61
|
+
return "origin-top";
|
|
62
|
+
case "bottom-left":
|
|
63
|
+
return "origin-top-right"
|
|
64
|
+
default:
|
|
65
|
+
return "origin-top-left"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function extractMessageFromOutput(output:{type:string, message:any}){
|
|
70
|
+
const {type, message} = output;
|
|
71
|
+
if(type === "text") return message;
|
|
72
|
+
if (type ==="message") return message.text;
|
|
73
|
+
if(type==="object") return message.text;
|
|
74
|
+
return "Unknown message structure"
|
|
75
|
+
}
|