bhd-components 0.9.28 → 0.10.1

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.
Files changed (113) hide show
  1. package/dist/index.esm.es5.development.css +970 -0
  2. package/dist/index.esm.es5.development.js +2831 -153
  3. package/dist/index.esm.es5.production.css +10 -1
  4. package/dist/index.esm.es5.production.js +1 -1
  5. package/dist/vendor.esm.es5.development.js +8138 -1570
  6. package/dist/vendor.esm.es5.production.js +157 -149
  7. package/es2017/AIMessageList/components/content/index.d.ts +4 -0
  8. package/es2017/AIMessageList/components/content/index.js +29 -0
  9. package/es2017/AIMessageList/components/content/index.module.less +8 -0
  10. package/es2017/AIMessageList/components/copyIcon/index.d.ts +7 -0
  11. package/es2017/AIMessageList/components/copyIcon/index.js +58 -0
  12. package/es2017/AIMessageList/components/copyIcon/index.module.less +22 -0
  13. package/es2017/AIMessageList/components/errorCallback/index.d.ts +3 -0
  14. package/es2017/AIMessageList/components/errorCallback/index.js +6 -0
  15. package/es2017/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
  16. package/es2017/AIMessageList/components/fileList/fileIcon.js +970 -0
  17. package/es2017/AIMessageList/components/fileList/index.d.ts +4 -0
  18. package/es2017/AIMessageList/components/fileList/index.js +299 -0
  19. package/es2017/AIMessageList/components/fileList/index.module.less +95 -0
  20. package/es2017/AIMessageList/components/footer/index.d.ts +10 -0
  21. package/es2017/AIMessageList/components/footer/index.js +296 -0
  22. package/es2017/AIMessageList/components/footer/index.module.less +51 -0
  23. package/es2017/AIMessageList/components/header/index.d.ts +9 -0
  24. package/es2017/AIMessageList/components/header/index.js +94 -0
  25. package/es2017/AIMessageList/components/header/index.module.less +31 -0
  26. package/es2017/AIMessageList/components/referencesIcon/index.d.ts +9 -0
  27. package/es2017/AIMessageList/components/referencesIcon/index.js +37 -0
  28. package/es2017/AIMessageList/components/referencesIcon/index.module.less +13 -0
  29. package/es2017/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
  30. package/es2017/AIMessageList/components/renderReferrnce/index.js +68 -0
  31. package/es2017/AIMessageList/components/renderReferrnce/index.module.less +64 -0
  32. package/es2017/AIMessageList/components/sendBtn/index.d.ts +4 -0
  33. package/es2017/AIMessageList/components/sendBtn/index.js +46 -0
  34. package/es2017/AIMessageList/components/sendBtn/index.module.less +25 -0
  35. package/es2017/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
  36. package/es2017/AIMessageList/components/uplodaFileBtn/index.js +33 -0
  37. package/es2017/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
  38. package/es2017/AIMessageList/components/virtuosoList/index.d.ts +5 -0
  39. package/es2017/AIMessageList/components/virtuosoList/index.js +507 -0
  40. package/es2017/AIMessageList/components/virtuosoList/index.module.less +381 -0
  41. package/es2017/AIMessageList/index.d.ts +4 -0
  42. package/es2017/AIMessageList/index.js +58 -0
  43. package/es2017/AIMessageList/index.module.less +20 -0
  44. package/es2017/AIMessageList/type.d.ts +242 -0
  45. package/es2017/bhdEditor/index.d.ts +2 -0
  46. package/es2017/bhdEditor/index.js +3 -0
  47. package/es2017/bhdModalCropper/index.d.ts +10 -0
  48. package/es2017/bhdModalCropper/index.js +144 -0
  49. package/es2017/bhdModalCropper/index.module.less +362 -0
  50. package/es2017/customerService/index.js +1 -0
  51. package/es2017/images/loading2.js +2 -0
  52. package/es2017/index.d.ts +2 -0
  53. package/es2017/index.js +2 -0
  54. package/es2017/utils/Date.d.ts +2 -1
  55. package/es2017/utils/Date.js +2 -1
  56. package/es2017/utils/dom.d.ts +4 -1
  57. package/es2017/utils/dom.js +44 -1
  58. package/es2017/utils/number.d.ts +1 -0
  59. package/es2017/utils/number.js +9 -0
  60. package/esm/AIMessageList/components/content/index.d.ts +4 -0
  61. package/esm/AIMessageList/components/content/index.js +29 -0
  62. package/esm/AIMessageList/components/content/index.module.less +8 -0
  63. package/esm/AIMessageList/components/copyIcon/index.d.ts +7 -0
  64. package/esm/AIMessageList/components/copyIcon/index.js +61 -0
  65. package/esm/AIMessageList/components/copyIcon/index.module.less +22 -0
  66. package/esm/AIMessageList/components/errorCallback/index.d.ts +3 -0
  67. package/esm/AIMessageList/components/errorCallback/index.js +6 -0
  68. package/esm/AIMessageList/components/fileList/fileIcon.d.ts +3 -0
  69. package/esm/AIMessageList/components/fileList/fileIcon.js +970 -0
  70. package/esm/AIMessageList/components/fileList/index.d.ts +4 -0
  71. package/esm/AIMessageList/components/fileList/index.js +325 -0
  72. package/esm/AIMessageList/components/fileList/index.module.less +95 -0
  73. package/esm/AIMessageList/components/footer/index.d.ts +10 -0
  74. package/esm/AIMessageList/components/footer/index.js +304 -0
  75. package/esm/AIMessageList/components/footer/index.module.less +51 -0
  76. package/esm/AIMessageList/components/header/index.d.ts +9 -0
  77. package/esm/AIMessageList/components/header/index.js +96 -0
  78. package/esm/AIMessageList/components/header/index.module.less +31 -0
  79. package/esm/AIMessageList/components/referencesIcon/index.d.ts +9 -0
  80. package/esm/AIMessageList/components/referencesIcon/index.js +39 -0
  81. package/esm/AIMessageList/components/referencesIcon/index.module.less +13 -0
  82. package/esm/AIMessageList/components/renderReferrnce/index.d.ts +10 -0
  83. package/esm/AIMessageList/components/renderReferrnce/index.js +72 -0
  84. package/esm/AIMessageList/components/renderReferrnce/index.module.less +64 -0
  85. package/esm/AIMessageList/components/sendBtn/index.d.ts +4 -0
  86. package/esm/AIMessageList/components/sendBtn/index.js +48 -0
  87. package/esm/AIMessageList/components/sendBtn/index.module.less +25 -0
  88. package/esm/AIMessageList/components/uplodaFileBtn/index.d.ts +4 -0
  89. package/esm/AIMessageList/components/uplodaFileBtn/index.js +33 -0
  90. package/esm/AIMessageList/components/uplodaFileBtn/index.module.less +5 -0
  91. package/esm/AIMessageList/components/virtuosoList/index.d.ts +5 -0
  92. package/esm/AIMessageList/components/virtuosoList/index.js +484 -0
  93. package/esm/AIMessageList/components/virtuosoList/index.module.less +381 -0
  94. package/esm/AIMessageList/index.d.ts +4 -0
  95. package/esm/AIMessageList/index.js +58 -0
  96. package/esm/AIMessageList/index.module.less +20 -0
  97. package/esm/AIMessageList/type.d.ts +242 -0
  98. package/esm/bhdEditor/index.d.ts +2 -0
  99. package/esm/bhdEditor/index.js +3 -0
  100. package/esm/bhdModalCropper/index.d.ts +10 -0
  101. package/esm/bhdModalCropper/index.js +151 -0
  102. package/esm/bhdModalCropper/index.module.less +362 -0
  103. package/esm/customerService/index.js +1 -0
  104. package/esm/images/loading2.js +2 -0
  105. package/esm/index.d.ts +2 -0
  106. package/esm/index.js +2 -0
  107. package/esm/utils/Date.d.ts +2 -1
  108. package/esm/utils/Date.js +2 -1
  109. package/esm/utils/dom.d.ts +4 -1
  110. package/esm/utils/dom.js +45 -1
  111. package/esm/utils/number.d.ts +1 -0
  112. package/esm/utils/number.js +9 -0
  113. package/package.json +7 -2
@@ -0,0 +1,296 @@
1
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
3
+ import React, { useState, useEffect, useImperativeHandle, forwardRef, useRef, useMemo } from "react";
4
+ import styles from "./index.module.less";
5
+ import { fetchEventSource } from "@microsoft/fetch-event-source";
6
+ import BhdEnterInput from "../../../bhdEnterInput";
7
+ import { Divider } from "antd";
8
+ import SendBtn from "../sendBtn";
9
+ import UploadFileBtn from "../uplodaFileBtn";
10
+ import FileList from "../fileList";
11
+ import References from "../renderReferrnce";
12
+ import { guidGenerator } from "../../../utils/number";
13
+ const { TextArea } = BhdEnterInput;
14
+ const defaultProps = {
15
+ placeholder: "请输入内容\n按Enter发送,Shift+Enter换行",
16
+ className: "",
17
+ maxLength: 500,
18
+ fileUpload: false
19
+ };
20
+ const defaultFileUploadProps = {
21
+ accept: ".pdf,.ppt,.pptx,.doc,.docx,.xls,.xlsx,.txt,.text,.png,.jpg,.jpeg,.gif,.webp",
22
+ maxCount: 10,
23
+ maxSize: 50 * 1024 * 1024,
24
+ mapUploadCount: 1,
25
+ multiple: true
26
+ };
27
+ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
28
+ let { footerConfig, prefix, errorCallback, apiRef } = props;
29
+ let { placeholder = defaultProps.placeholder, className = defaultProps.className, maxLength = defaultProps.maxLength, renderAction, fileUpload, sendMsgAjaxParams } = footerConfig;
30
+ if (fileUpload) {
31
+ fileUpload = _object_spread({}, defaultFileUploadProps, fileUpload);
32
+ }
33
+ const fileListRef = useRef(null);
34
+ const ctrl = useRef(); //停止生成ai回答时使用
35
+ const [textValue, setTextValue] = useState("");
36
+ const [sending, setSending] = useState(false);
37
+ const [fileCanSending, setFileCanSending] = useState(true); // 是否允许发送 关联文件
38
+ // const [referencesSource, setReferencesSource] = useState<referenceType>({
39
+ // type: "file",
40
+ // value: {
41
+ // name: "文件名字.doc",
42
+ // suffix: "doc",
43
+ // fileId: "",
44
+ // url: "",
45
+ // status: undefined,
46
+ // source: undefined,
47
+ // },
48
+ // });
49
+ const [referencesSource, setReferencesSource] = useState(null);
50
+ const recordRef = useRef({
51
+ value: textValue,
52
+ referencesSource: referencesSource,
53
+ sending: sending
54
+ });
55
+ useImperativeHandle(ref, ()=>{
56
+ return _object_spread({
57
+ setTextValue,
58
+ sendMsg: sendMsg,
59
+ clearText: ()=>{
60
+ setTextValue("");
61
+ },
62
+ getCanSendMsg: ()=>{
63
+ return canSendMsg;
64
+ },
65
+ stopMessage: ()=>{
66
+ stopMessage();
67
+ },
68
+ setReferences: (reference)=>{
69
+ setReferencesSource(reference);
70
+ }
71
+ }, fileListRef.current);
72
+ });
73
+ useEffect(()=>{
74
+ recordRef.current.value = textValue;
75
+ recordRef.current.referencesSource = referencesSource;
76
+ recordRef.current.sending = sending;
77
+ }, [
78
+ textValue,
79
+ referencesSource,
80
+ sending
81
+ ]);
82
+ // 是否允许发送消息
83
+ const canSendMsg = useMemo(()=>{
84
+ if (textValue.trim().length === 0) return false;
85
+ if (typeof maxLength === "function") {
86
+ if (maxLength(textValue)) return false;
87
+ }
88
+ if (textValue.trim().length > maxLength) return false;
89
+ if (sending) return false;
90
+ if (!fileCanSending) return false;
91
+ return true;
92
+ }, [
93
+ textValue,
94
+ maxLength,
95
+ sending,
96
+ fileCanSending
97
+ ]);
98
+ const stopMessage = ()=>{
99
+ ctrl.current && ctrl.current.abort();
100
+ apiRef.contentApi.clearInputing();
101
+ setSending(false);
102
+ };
103
+ const getCls = (clsName)=>{
104
+ return styles[clsName] + " " + prefix + "-" + clsName;
105
+ };
106
+ const renderBtn = ()=>{
107
+ let sendNode = /*#__PURE__*/ _jsx(SendBtn, {
108
+ prefix: prefix,
109
+ canSendMsg: canSendMsg,
110
+ sending: sending,
111
+ stopMessage: stopMessage
112
+ });
113
+ if (fileUpload) {
114
+ let fileNode = /*#__PURE__*/ _jsx(UploadFileBtn, {
115
+ prefix: prefix,
116
+ fileUpload: fileUpload,
117
+ customRequest: (options)=>{
118
+ var _fileListRef_current;
119
+ console.log("customRequestcustomRequest", options);
120
+ (_fileListRef_current = fileListRef.current) === null || _fileListRef_current === void 0 ? void 0 : _fileListRef_current.addFile(options.file);
121
+ }
122
+ });
123
+ if (renderAction) {
124
+ return renderAction(sendNode, fileNode);
125
+ } else {
126
+ return /*#__PURE__*/ _jsxs("div", {
127
+ className: `${getCls("footerActionBtn")}`,
128
+ children: [
129
+ fileNode,
130
+ /*#__PURE__*/ _jsx(Divider, {
131
+ type: "vertical"
132
+ }),
133
+ sendNode
134
+ ]
135
+ });
136
+ }
137
+ } else {
138
+ let fileNode = null;
139
+ if (renderAction) {
140
+ return renderAction(sendNode, fileNode);
141
+ } else {
142
+ return /*#__PURE__*/ _jsx("div", {
143
+ className: `${getCls("footerActionBtn")}`,
144
+ children: sendNode
145
+ });
146
+ }
147
+ }
148
+ };
149
+ const onPressEnter = (e)=>{
150
+ // 判断是否按下了 Shift 键
151
+ if (e.shiftKey) {
152
+ // 如果按下了 Shift + Enter,则允许换行(默认行为)
153
+ return;
154
+ } else {
155
+ if (textValue.length === 0) {
156
+ // 内容为空时 执行换行操作
157
+ return;
158
+ }
159
+ // 如果只按了 Enter,则阻止默认行为并发送消息
160
+ e.preventDefault();
161
+ // 在这里添加发送消息的逻辑
162
+ sendMsg(textValue);
163
+ }
164
+ };
165
+ // 发现消息
166
+ const sendMsg = (value)=>{
167
+ if (value.trim().length === 0) return;
168
+ if (!canSendMsg) return;
169
+ console.log("发送消息:", value);
170
+ apiRef.contentApi.addMsg({
171
+ id: guidGenerator(),
172
+ createTime: new Date().getTime(),
173
+ content: value,
174
+ location: "right",
175
+ reference: recordRef.current.referencesSource,
176
+ source: null
177
+ });
178
+ sendMsgAjax();
179
+ };
180
+ const sendMsgAjax = ()=>{
181
+ const { url, method = "POST", headers = {}, params = ()=>"", onOpen = ()=>{}, onMessage = (ev)=>ev, onClose = ()=>{}, onError = ()=>{}, coverProps = {} } = sendMsgAjaxParams;
182
+ ctrl.current = new AbortController();
183
+ // apiRef
184
+ console.log("apiRef", apiRef);
185
+ let msgId = "inputing";
186
+ let createTime = new Date().getTime();
187
+ apiRef.contentApi.addMsg({
188
+ id: msgId,
189
+ createTime: createTime,
190
+ content: "正在输入...",
191
+ location: "left",
192
+ reference: null,
193
+ source: null
194
+ });
195
+ let msgContent = "";
196
+ setSending(true);
197
+ setTextValue("");
198
+ setReferencesSource(null);
199
+ let arg = [
200
+ recordRef.current.value,
201
+ recordRef.current.referencesSource,
202
+ fileListRef.current ? fileListRef.current.getFileList() : []
203
+ ];
204
+ fetchEventSource(url, _object_spread({
205
+ method,
206
+ headers: _object_spread({
207
+ "Content-Type": "application/json",
208
+ Accept: "text/event-stream,application/json"
209
+ }, headers),
210
+ body: params(...arg),
211
+ openWhenHidden: true,
212
+ signal: ctrl.current.signal,
213
+ onopen: (res)=>{
214
+ onOpen(res);
215
+ if (res.status === 200) {}
216
+ return null;
217
+ },
218
+ onmessage: (ev)=>{
219
+ let data = onMessage(ev);
220
+ msgContent += data.content;
221
+ delete data.content;
222
+ apiRef.contentApi.updateMsg(msgId, _object_spread({
223
+ createTime: createTime,
224
+ content: msgContent,
225
+ location: "left",
226
+ reference: null,
227
+ source: null
228
+ }, data));
229
+ msgId = data.id;
230
+ },
231
+ onclose: ()=>{
232
+ onClose();
233
+ setSending(false);
234
+ console.log("onclose: ", event);
235
+ },
236
+ onerror: (err)=>{
237
+ onError(err);
238
+ console.log("onerror: ", err);
239
+ }
240
+ }, coverProps));
241
+ };
242
+ // 判断是否超出最大字数
243
+ const judegTextLengthWarn = ()=>{
244
+ if (typeof maxLength === "function") {
245
+ return maxLength(textValue);
246
+ } else {
247
+ return textValue.length > maxLength;
248
+ }
249
+ };
250
+ return /*#__PURE__*/ _jsx("div", {
251
+ className: `${getCls("footer")} ${className}`,
252
+ children: /*#__PURE__*/ _jsxs("div", {
253
+ className: `${getCls("footerBody")} ${judegTextLengthWarn() ? getCls("footerBodyWarn") : ""}`,
254
+ children: [
255
+ fileUpload && /*#__PURE__*/ _jsx("div", {
256
+ className: getCls("footerFile"),
257
+ children: /*#__PURE__*/ _jsx(FileList, {
258
+ prefix: prefix,
259
+ fileUpload: fileUpload,
260
+ ref: fileListRef,
261
+ errorCallback: errorCallback,
262
+ changeFileCanSending: setFileCanSending
263
+ })
264
+ }),
265
+ /*#__PURE__*/ _jsxs("div", {
266
+ className: getCls("footerInput"),
267
+ children: [
268
+ /*#__PURE__*/ _jsx(TextArea, {
269
+ value: textValue,
270
+ onChange: (e)=>{
271
+ setTextValue(e.target.value);
272
+ },
273
+ placeholder: placeholder,
274
+ autoSize: {
275
+ minRows: 2,
276
+ maxRows: 6
277
+ },
278
+ onPressEnter: onPressEnter
279
+ }),
280
+ /*#__PURE__*/ _jsx(References, {
281
+ prefix: prefix,
282
+ referencesSource: referencesSource,
283
+ fileUpload: fileUpload,
284
+ deleteReferences: ()=>setReferencesSource(null)
285
+ })
286
+ ]
287
+ }),
288
+ /*#__PURE__*/ _jsx("div", {
289
+ className: getCls("footerAction"),
290
+ children: renderBtn()
291
+ })
292
+ ]
293
+ })
294
+ });
295
+ });
296
+ export default Footer;
@@ -0,0 +1,51 @@
1
+ .footer {
2
+ width: 100%;
3
+ padding: 16px;
4
+ box-sizing: border-box;
5
+ .footerBody {
6
+ width: 100%;
7
+ border-radius: 8px;
8
+ background: #ffffff;
9
+ border: 1px solid rgba(0, 0, 0, 0.06);
10
+ padding-bottom: 12px;
11
+ &.footerBodyWarn {
12
+ border-color: #f4523b;
13
+ }
14
+
15
+ .footerFile {
16
+ width: 100%;
17
+ }
18
+ .footerInput {
19
+ :global {
20
+ .bhd-input {
21
+ border: none;
22
+ box-shadow: none;
23
+ background: transparent;
24
+ padding: 12px 16px;
25
+ }
26
+ }
27
+ }
28
+ .footerAction {
29
+ width: 100%;
30
+ padding: 0 16px;
31
+ box-sizing: border-box;
32
+ .footerActionBtn {
33
+ width: 100%;
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: flex-end;
37
+ :global {
38
+ .bhd-divider {
39
+ border-color: rgba(0, 0, 0, 0.06);
40
+ height: 16px;
41
+ top: 0;
42
+ margin: 0 16px;
43
+ }
44
+ .bhd-upload-wrapper {
45
+ display: flex;
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import type { headerConfigProps, errorMessageProps } from "../../type";
3
+ interface IProps {
4
+ headerConfig: headerConfigProps;
5
+ prefix: string;
6
+ errorCallback: (error: errorMessageProps) => void;
7
+ }
8
+ declare const Header: (props: IProps) => React.JSX.Element;
9
+ export default Header;
@@ -0,0 +1,94 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
2
+ import React from "react";
3
+ import styles from "./index.module.less";
4
+ const defaultProps = {
5
+ icon: /*#__PURE__*/ _jsx("i", {
6
+ children: /*#__PURE__*/ _jsxs("svg", {
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ width: "1em",
9
+ height: "1em",
10
+ viewBox: "0 0 16 16",
11
+ fill: "none",
12
+ children: [
13
+ /*#__PURE__*/ _jsx("path", {
14
+ d: "M12.6063 14C12.2547 13.9994 11.9095 13.9066 11.6051 13.7309C11.3006 13.5551 11.0476 13.3025 10.8714 12.9983L7.15187 6.55597L4.21122 11.6493H7.67426C7.98599 11.6493 8.28495 11.7731 8.50538 11.9935C8.7258 12.2139 8.84963 12.5129 8.84963 12.8246C8.84963 13.1364 8.7258 13.4353 8.50538 13.6557C8.28495 13.8762 7.98599 14 7.67426 14H2.17613C1.96974 14.0001 1.76696 13.9459 1.58818 13.8428C1.40939 13.7397 1.26091 13.5913 1.15766 13.4126C1.05441 13.2339 1.00003 13.0312 1 12.8248C0.999967 12.6184 1.05428 12.4157 1.15747 12.2369L6.13322 3.61754C6.23638 3.43887 6.38476 3.29051 6.56343 3.18736C6.7421 3.08421 6.94478 3.0299 7.15109 3.0299C7.3574 3.0299 7.56008 3.08421 7.73875 3.18736C7.91742 3.29051 8.0658 3.43887 8.16896 3.61754L12.2582 10.6998V4.20522C12.2582 3.8935 12.3821 3.59454 12.6025 3.37411C12.8229 3.15368 13.1219 3.02985 13.4336 3.02985C13.7453 3.02985 14.0443 3.15368 14.2647 3.37411C14.4851 3.59454 14.609 3.8935 14.609 4.20522V11.9966C14.609 12.5279 14.398 13.0373 14.0224 13.413C13.6469 13.7887 13.1375 13.9998 12.6063 14Z",
15
+ fill: "url(#paint0_linear_34_244)"
16
+ }),
17
+ /*#__PURE__*/ _jsx("path", {
18
+ d: "M13.4336 2.35075C14.0827 2.35075 14.609 1.82451 14.609 1.17537C14.609 0.526232 14.0827 0 13.4336 0C12.7845 0 12.2582 0.526232 12.2582 1.17537C12.2582 1.82451 12.7845 2.35075 13.4336 2.35075Z",
19
+ fill: "url(#paint1_linear_34_244)"
20
+ }),
21
+ /*#__PURE__*/ _jsxs("defs", {
22
+ children: [
23
+ /*#__PURE__*/ _jsxs("linearGradient", {
24
+ id: "paint0_linear_34_244",
25
+ x1: "14.609",
26
+ y1: "0",
27
+ x2: "-0.275842",
28
+ y2: "13.609",
29
+ gradientUnits: "userSpaceOnUse",
30
+ children: [
31
+ /*#__PURE__*/ _jsx("stop", {
32
+ "stop-color": "#F87AFD"
33
+ }),
34
+ /*#__PURE__*/ _jsx("stop", {
35
+ offset: "1",
36
+ "stop-color": "#41DAF8"
37
+ })
38
+ ]
39
+ }),
40
+ /*#__PURE__*/ _jsxs("linearGradient", {
41
+ id: "paint1_linear_34_244",
42
+ x1: "14.609",
43
+ y1: "0",
44
+ x2: "-0.275842",
45
+ y2: "13.609",
46
+ gradientUnits: "userSpaceOnUse",
47
+ children: [
48
+ /*#__PURE__*/ _jsx("stop", {
49
+ "stop-color": "#F87AFD"
50
+ }),
51
+ /*#__PURE__*/ _jsx("stop", {
52
+ offset: "1",
53
+ "stop-color": "#41DAF8"
54
+ })
55
+ ]
56
+ })
57
+ ]
58
+ })
59
+ ]
60
+ })
61
+ }),
62
+ className: "",
63
+ renderRightHead: ()=>null
64
+ };
65
+ const Header = (props)=>{
66
+ const { headerConfig, prefix } = props;
67
+ const { icon = defaultProps.icon, title, className = defaultProps.className, renderRightHead = defaultProps.renderRightHead } = headerConfig;
68
+ const getCls = (clsName)=>{
69
+ return styles[clsName] + " " + prefix + "-" + clsName;
70
+ };
71
+ return /*#__PURE__*/ _jsxs("div", {
72
+ className: `${getCls("header")} ${className}`,
73
+ children: [
74
+ /*#__PURE__*/ _jsxs("div", {
75
+ className: getCls("headerLeft"),
76
+ children: [
77
+ /*#__PURE__*/ _jsx("div", {
78
+ className: getCls("headerIcon"),
79
+ children: icon
80
+ }),
81
+ /*#__PURE__*/ _jsx("div", {
82
+ className: getCls("headerTitle"),
83
+ children: title
84
+ })
85
+ ]
86
+ }),
87
+ /*#__PURE__*/ _jsx("div", {
88
+ className: getCls("headerRight"),
89
+ children: renderRightHead()
90
+ })
91
+ ]
92
+ });
93
+ };
94
+ export default Header;
@@ -0,0 +1,31 @@
1
+ .header {
2
+ width: 100%;
3
+ padding: 8px 16px;
4
+ box-sizing: border-box;
5
+ display: flex;
6
+ align-items: center;
7
+ gap: 8px;
8
+ justify-content: space-between;
9
+ border-bottom: 1px solid #ebebeb;
10
+ .headerLeft {
11
+ display: flex;
12
+ align-items: center;
13
+ gap: 8px;
14
+ .headerIcon {
15
+ &>i{
16
+ line-height: 1;
17
+ font-size: 16px;
18
+ display: flex;
19
+ }
20
+ }
21
+ .headerTitle {
22
+ font-weight: 600;
23
+ color: rgba(0, 0, 0, 0.65);
24
+ font-size: 16px;
25
+ line-height: 1.5;
26
+ }
27
+ }
28
+ .headerRight {
29
+ font-size: 16px;
30
+ }
31
+ }
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import type { dataItemType, AIMessageListRefProps } from "../../type";
3
+ interface ReferencesIconProps {
4
+ prefix: string;
5
+ item: dataItemType;
6
+ apiRef: AIMessageListRefProps;
7
+ }
8
+ declare const ReferencesIcon: (props: ReferencesIconProps) => React.JSX.Element;
9
+ export default ReferencesIcon;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
2
+ import React from "react";
3
+ import styles from "./index.module.less";
4
+ const referencesIcon = /*#__PURE__*/ _jsx("i", {
5
+ children: /*#__PURE__*/ _jsx("svg", {
6
+ xmlns: "http://www.w3.org/2000/svg",
7
+ width: "1em",
8
+ height: "1em",
9
+ viewBox: "0 0 20 20",
10
+ fill: "currentColor",
11
+ children: /*#__PURE__*/ _jsx("path", {
12
+ d: "M8.28467 5.03809C8.4743 4.91639 8.61455 4.90994 8.76123 5.10059C8.92876 5.31834 9.04161 5.46433 9.09912 5.53906C9.18641 5.65254 9.15264 5.80277 9.06201 5.87988C7.69541 6.75725 6.13959 8.64084 6.02295 9.32031C5.90632 9.99981 6.57509 9.82255 7.66846 10.3311C8.76173 10.8396 9.66644 12.6996 8.15674 14.165C6.64677 15.6306 3.66696 13.9994 4.10107 10.667C4.38007 8.52662 5.77465 6.65005 8.28467 5.03809ZM14.8931 5.03809C15.0828 4.91629 15.2239 4.90989 15.3706 5.10059C15.5383 5.31849 15.6511 5.46448 15.7085 5.53906C15.7958 5.65256 15.7611 5.80278 15.6704 5.87988C14.3038 6.75727 12.748 8.64086 12.6313 9.32031C12.5147 9.99975 13.1836 9.82261 14.2769 10.3311C15.3702 10.8395 16.2751 12.6995 14.7651 14.165C13.2552 15.6306 10.2754 13.9994 10.7095 10.667C10.9885 8.52661 12.3831 6.65005 14.8931 5.03809Z"
13
+ })
14
+ })
15
+ });
16
+ const ReferencesIcon = (props)=>{
17
+ const { prefix, apiRef, item } = props;
18
+ const getCls = (clsName)=>{
19
+ return styles[clsName] + " " + prefix + "-" + clsName;
20
+ };
21
+ const clickFn = ()=>{
22
+ console.log("apiRef", apiRef);
23
+ if (apiRef && apiRef.footerApi) {
24
+ console.log("itemitem", item);
25
+ apiRef.footerApi.setReferences({
26
+ type: "text",
27
+ value: item.content
28
+ });
29
+ }
30
+ };
31
+ return /*#__PURE__*/ _jsx("div", {
32
+ className: `${getCls("msgItem-action-references")}`,
33
+ onClick: ()=>clickFn(),
34
+ children: referencesIcon
35
+ });
36
+ };
37
+ export default ReferencesIcon;
@@ -0,0 +1,13 @@
1
+ .msgItem-action-references {
2
+ cursor: pointer;
3
+ border-radius: 2px;
4
+ display: flex;
5
+ line-height: 1;
6
+ & > i {
7
+ color: rgba(140, 140, 140, 1);
8
+ font-size: 20px;
9
+ }
10
+ &:hover {
11
+ background-color: rgba(0, 0, 0, 0.04);
12
+ }
13
+ }
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import type { referenceType, fileUploadProps } from "../../type";
3
+ interface IProps {
4
+ prefix: string;
5
+ referencesSource: referenceType;
6
+ fileUpload: boolean | fileUploadProps;
7
+ deleteReferences: () => void;
8
+ }
9
+ declare const References: (props: IProps) => React.JSX.Element;
10
+ export default References;
@@ -0,0 +1,68 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
2
+ import React from "react";
3
+ import styles from "./index.module.less";
4
+ import { CloseCircleFilled } from "../../../icons";
5
+ import { fileIconRender } from "../fileList/fileIcon";
6
+ const References = (props)=>{
7
+ const { prefix, referencesSource, fileUpload, deleteReferences } = props;
8
+ const getCls = (clsName)=>{
9
+ return styles[clsName] + " " + prefix + "-" + clsName;
10
+ };
11
+ if (!referencesSource) return null;
12
+ if (referencesSource.type === "text") {
13
+ return /*#__PURE__*/ _jsxs("div", {
14
+ className: `${getCls("footerReferences")}`,
15
+ children: [
16
+ /*#__PURE__*/ _jsx("div", {
17
+ className: `${getCls("footerReferences_left")}`,
18
+ children: /*#__PURE__*/ _jsx("div", {
19
+ className: `${getCls("footerReferences_left_text")}`,
20
+ children: referencesSource.value
21
+ })
22
+ }),
23
+ /*#__PURE__*/ _jsx("div", {
24
+ className: `${getCls("footerReferences_right")}`,
25
+ children: /*#__PURE__*/ _jsx(CloseCircleFilled, {
26
+ onPointerEnterCapture: undefined,
27
+ onPointerLeaveCapture: undefined,
28
+ onClick: ()=>deleteReferences()
29
+ })
30
+ })
31
+ ]
32
+ });
33
+ }
34
+ if (referencesSource.type === "file" && fileUpload) {
35
+ return /*#__PURE__*/ _jsxs("div", {
36
+ className: `${getCls("footerReferences")}`,
37
+ children: [
38
+ /*#__PURE__*/ _jsx("div", {
39
+ className: `${getCls("footerReferences_left")}`,
40
+ children: /*#__PURE__*/ _jsxs("div", {
41
+ className: `${getCls("footerReferences_left_file")}`,
42
+ children: [
43
+ /*#__PURE__*/ _jsx("div", {
44
+ className: `${getCls("footerReferences_left_file_icon")}`,
45
+ children: fileIconRender(referencesSource.value.suffix, fileUpload.iconFileRender)
46
+ }),
47
+ /*#__PURE__*/ _jsx("div", {
48
+ className: `${getCls("footerReferences_left_file_title")}`,
49
+ title: referencesSource.value.name,
50
+ children: referencesSource.value.name
51
+ })
52
+ ]
53
+ })
54
+ }),
55
+ /*#__PURE__*/ _jsx("div", {
56
+ className: `${getCls("footerReferences_right")}`,
57
+ children: /*#__PURE__*/ _jsx(CloseCircleFilled, {
58
+ onPointerEnterCapture: undefined,
59
+ onPointerLeaveCapture: undefined,
60
+ onClick: ()=>deleteReferences()
61
+ })
62
+ })
63
+ ]
64
+ });
65
+ }
66
+ return null;
67
+ };
68
+ export default References;