bhd-components 0.10.5 → 0.10.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.
Files changed (37) hide show
  1. package/dist/index.esm.es5.development.css +127 -87
  2. package/dist/index.esm.es5.development.js +453 -249
  3. package/dist/index.esm.es5.production.css +1 -1
  4. package/dist/index.esm.es5.production.js +1 -1
  5. package/dist/vendor.esm.es5.development.js +2 -2
  6. package/dist/vendor.esm.es5.production.js +2 -2
  7. package/es2017/AIMessageList/components/copyIcon/index.js +22 -7
  8. package/es2017/AIMessageList/components/copyIcon/index.module.less +2 -2
  9. package/es2017/AIMessageList/components/fileList/index.js +11 -2
  10. package/es2017/AIMessageList/components/footer/index.js +59 -48
  11. package/es2017/AIMessageList/components/referencesIcon/index.js +19 -8
  12. package/es2017/AIMessageList/components/referencesIcon/index.module.less +1 -1
  13. package/es2017/AIMessageList/components/refreshBtn/index.d.ts +4 -0
  14. package/es2017/AIMessageList/components/refreshBtn/index.js +29 -0
  15. package/es2017/AIMessageList/components/refreshBtn/index.module.less +12 -0
  16. package/es2017/AIMessageList/components/remarkBtn/index.d.ts +4 -0
  17. package/es2017/AIMessageList/components/remarkBtn/index.js +51 -0
  18. package/es2017/AIMessageList/components/remarkBtn/index.module.less +13 -0
  19. package/es2017/AIMessageList/components/virtuosoList/index.js +91 -13
  20. package/es2017/AIMessageList/components/virtuosoList/index.module.less +10 -1
  21. package/es2017/AIMessageList/type.d.ts +42 -10
  22. package/esm/AIMessageList/components/copyIcon/index.js +22 -7
  23. package/esm/AIMessageList/components/copyIcon/index.module.less +2 -2
  24. package/esm/AIMessageList/components/fileList/index.js +7 -2
  25. package/esm/AIMessageList/components/footer/index.js +63 -50
  26. package/esm/AIMessageList/components/referencesIcon/index.js +19 -8
  27. package/esm/AIMessageList/components/referencesIcon/index.module.less +1 -1
  28. package/esm/AIMessageList/components/refreshBtn/index.d.ts +4 -0
  29. package/esm/AIMessageList/components/refreshBtn/index.js +31 -0
  30. package/esm/AIMessageList/components/refreshBtn/index.module.less +12 -0
  31. package/esm/AIMessageList/components/remarkBtn/index.d.ts +4 -0
  32. package/esm/AIMessageList/components/remarkBtn/index.js +51 -0
  33. package/esm/AIMessageList/components/remarkBtn/index.module.less +13 -0
  34. package/esm/AIMessageList/components/virtuosoList/index.js +93 -13
  35. package/esm/AIMessageList/components/virtuosoList/index.module.less +10 -1
  36. package/esm/AIMessageList/type.d.ts +42 -10
  37. package/package.json +1 -1
@@ -26,11 +26,17 @@ export interface headerConfigProps {
26
26
  export interface msgActionProps {
27
27
  renderLeft?: (
28
28
  copyNode: React.ReactNode,
29
- referencesNode: React.ReactNode
29
+ referencesNode: React.ReactNode,
30
+ upVoteNode: React.ReactNode,
31
+ downVoteNode: React.ReactNode,
32
+ refreshNode:React.ReactNode,
30
33
  ) => React.ReactNode;
31
34
  renderRight?: (
32
35
  copyNode: React.ReactNode,
33
- referencesNode: React.ReactNode
36
+ referencesNode: React.ReactNode,
37
+ upVoteNode: React.ReactNode,
38
+ downVoteNode: React.ReactNode,
39
+ refreshNode:React.ReactNode,
34
40
  ) => React.ReactNode;
35
41
  }
36
42
 
@@ -54,6 +60,8 @@ export interface contentConfigProps {
54
60
  referenceNode: React.ReactNode
55
61
  ) => React.ReactNode; //覆盖引用内容
56
62
  onRecordMessage?: (item: dataItemType) => void; // 发送和接收的消息记录
63
+ onVoteChange?: (type:string,item: dataItemType) => void; // 点赞 或踩
64
+ onRefresh?: (item:dataItemType) => void;// 刷新
57
65
  }
58
66
 
59
67
  // content props
@@ -76,19 +84,25 @@ export interface footerConfigProps {
76
84
  ) => React.ReactNode; // 自定义渲染操作栏
77
85
  fileUpload?: boolean | fileUploadProps; // 默认为false
78
86
  sendMsgAjaxParams: sendMsgAjaxParams;
87
+ onClickStop?: () => void;
88
+ }
89
+
90
+ export interface onOpenProps {
91
+ retryFetch: () => void; // 重试
92
+ stopMessage: () => void;
79
93
  }
80
94
 
81
95
  export interface sendMsgAjaxParams {
82
96
  url: string;
83
97
  method?: string;
84
- headers?: object;
98
+ headers?: () => object;
85
99
  params: (
86
100
  value: string,
87
101
  refereces: referenceType,
88
102
  fileList: fileCustomProps[],
89
- beforeInfo:any,
103
+ beforeInfo: any
90
104
  ) => string;
91
- onOpen?: (res: Response) => void;
105
+ onOpen?: (res: Response, onOpenProps: onOpenProps) => void;
92
106
  onMessage?: (ev: EventSourceMessage) => { id: string; content: string };
93
107
  onClose?: () => void;
94
108
  onError?: (err: any) => void;
@@ -107,16 +121,17 @@ export interface fileUploadProps {
107
121
  maxCount?: number; // 上传文件数量限制 -1为不限制 默认为10
108
122
  maxSize?: number; // 默认为50Mb 目前不考虑切片上传 业务上不要设置太大
109
123
  multiple?: boolean; // 是否允许多选
110
- customRequest: (
111
- file: File
112
- ) => Promise<{
124
+ customRequest: (file: File) => Promise<{
113
125
  url: string;
114
126
  fileId: string;
115
127
  source: File;
116
128
  status: fileStatus;
117
129
  }>; // 自定义上传方法
118
130
  mapUploadCount?: number; // 并发上传的数量 默认为1
119
- deleteFileAjax?: (fileId: string) => Promise<{ fileId: string }>; // 删除文件的ajax 返回删除文件的fileId
131
+ deleteFileAjax?: (
132
+ fileId: string,
133
+ file: fileCustomProps
134
+ ) => Promise<{ fileId: string }>; // 删除文件的ajax 返回删除文件的fileId
120
135
  statusText?: (status: fileStatus) => React.ReactNode; // 自定义状态显示
121
136
  parseFileAjax?: (fileId: string) => { status: fileStatus; fileId; string }; //文件解析的 ajax 请求 如不存在解析过程,可在此函数内直接返回上传成功的状态
122
137
  iconFileRender?: (suffix: string) => React.ReactNode; // 文件上传的 icon。参数 文件对象file 返回值为图标
@@ -161,6 +176,17 @@ export interface uploadFileBtnProps {
161
176
  customRequest: (options: any) => void;
162
177
  }
163
178
 
179
+ export interface VoteBtnProps {
180
+ prefix: string;
181
+ clickFn: () => void;
182
+ isActive: boolean;
183
+ }
184
+
185
+ export interface refreshBtnProps{
186
+ prefix:string;
187
+ clickFn:()=>void;
188
+ }
189
+
164
190
  // fileList Props
165
191
 
166
192
  export interface fileListProps {
@@ -190,7 +216,7 @@ export interface FileListRefProps {
190
216
  updateFile: (fileId: string, status: fileStatus) => void;
191
217
  getFileList: () => fileCustomProps[];
192
218
  vaildFile: (file: File, fileId?: string) => boolean; // 校验文件是否合规
193
- fileToCustomFile: (file: File) => fileCustomProps;
219
+ fileToCustomFile: (file: File, params: any) => fileCustomProps;
194
220
  }
195
221
 
196
222
  // error Message
@@ -220,11 +246,13 @@ export type referenceType = referenceTypeText | referenceTypeFile;
220
246
  export type referenceTypeText = {
221
247
  type: "text";
222
248
  value: string;
249
+ source:any;
223
250
  };
224
251
 
225
252
  export type referenceTypeFile = {
226
253
  type: "file";
227
254
  value: fileCustomProps;
255
+ source:any;
228
256
  };
229
257
 
230
258
  export interface VirtuosoListProps {
@@ -238,6 +266,9 @@ export interface VirtuosoListRefProps {
238
266
  updateMsg: (id: string, obj: any) => void;
239
267
  clearInputing: () => void; //清楚正在输入的inputing
240
268
  recordMsg: (item: dataItemType) => void;
269
+ getDataSource: () => dataItemType[];
270
+ upateDataSource:(id:string,obj:dataItemType)=>void;
271
+ changeDataSource:(list:dataItemType[])=>void
241
272
  }
242
273
 
243
274
  export interface contentRefProps extends VirtuosoListRefProps {}
@@ -256,4 +287,5 @@ export interface dataItemType {
256
287
  location: "left" | "right"; // 消息显示在左边还是右边
257
288
  reference: referenceType | null; // 引用数据
258
289
  source: any; //原消息对象
290
+ vote?:string;// "up":点赞。"down":踩
259
291
  }
@@ -1,18 +1,33 @@
1
1
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
2
- import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
3
3
  import React, { useEffect, useState, useRef } from "react";
4
4
  import styles from "./index.module.less";
5
5
  import { copyText } from "../../../utils/dom";
6
6
  var copyIconSvg = /*#__PURE__*/ _jsx("i", {
7
- children: /*#__PURE__*/ _jsx("svg", {
8
- xmlns: "http://www.w3.org/2000/svg",
7
+ children: /*#__PURE__*/ _jsxs("svg", {
9
8
  width: "1em",
10
9
  height: "1em",
11
- viewBox: "0 0 20 20",
10
+ viewBox: "0 0 14 14",
11
+ "shape-rendering": "geometricPrecision",
12
12
  fill: "currentColor",
13
- children: /*#__PURE__*/ _jsx("path", {
14
- d: "M7.97375 3H15.7106C16.0526 3 16.3806 3.13585 16.6224 3.37768C16.8642 3.6195 17.0001 3.94748 17.0001 4.28947V12.0263C17.0001 12.3683 16.8642 12.6963 16.6224 12.9381C16.3806 13.1799 16.0526 13.3158 15.7106 13.3158H7.97375C7.63176 13.3158 7.30377 13.1799 7.06195 12.9381C6.82013 12.6963 6.68427 12.3683 6.68427 12.0263V4.28947C6.68427 3.94748 6.82013 3.6195 7.06195 3.37768C7.30377 3.13585 7.63176 3 7.97375 3ZM7.97375 4.10526C7.92489 4.10526 7.87804 4.12467 7.84349 4.15922C7.80894 4.19376 7.78954 4.24062 7.78954 4.28947V12.0263C7.78954 12.0505 7.7943 12.0745 7.80356 12.0968C7.81281 12.1192 7.82638 12.1395 7.84349 12.1566C7.86059 12.1737 7.8809 12.1872 7.90325 12.1965C7.9256 12.2058 7.94955 12.2105 7.97375 12.2105H15.7106C15.7594 12.2105 15.8063 12.1911 15.8408 12.1566C15.8754 12.122 15.8948 12.0752 15.8948 12.0263V4.28947C15.8948 4.24062 15.8754 4.19376 15.8408 4.15922C15.8063 4.12467 15.7594 4.10526 15.7106 4.10526H7.97375ZM12.2106 14.4211C12.2106 14.2745 12.2688 14.1339 12.3724 14.0303C12.4761 13.9266 12.6167 13.8684 12.7632 13.8684C12.9098 13.8684 13.0504 13.9266 13.154 14.0303C13.2576 14.1339 13.3159 14.2745 13.3159 14.4211V15.7105C13.3159 16.0525 13.18 16.3805 12.9382 16.6223C12.6963 16.8641 12.3684 17 12.0264 17H4.28953C3.94755 17 3.61956 16.8641 3.37774 16.6223C3.13592 16.3805 3.00006 16.0525 3.00006 15.7105V7.97368C3.00006 7.63169 3.13592 7.30371 3.37774 7.06189C3.61956 6.82007 3.94755 6.68421 4.28953 6.68421H5.57901C5.72558 6.68421 5.86614 6.74243 5.96978 6.84607C6.07342 6.94971 6.13164 7.09028 6.13164 7.23684C6.13164 7.38341 6.07342 7.52397 5.96978 7.62761C5.86614 7.73125 5.72558 7.78947 5.57901 7.78947H4.28953C4.24068 7.78947 4.19382 7.80888 4.15928 7.84343C4.12473 7.87797 4.10532 7.92483 4.10532 7.97368V15.7105C4.10532 15.7594 4.12473 15.8062 4.15928 15.8408C4.19382 15.8753 4.24068 15.8947 4.28953 15.8947H12.0264C12.0752 15.8947 12.1221 15.8753 12.1566 15.8408C12.1912 15.8062 12.2106 15.7594 12.2106 15.7105V14.4211Z"
15
- })
13
+ xmlns: "http://www.w3.org/2000/svg",
14
+ children: [
15
+ /*#__PURE__*/ _jsx("g", {
16
+ "clip-path": "url(#clip0_518_8403)",
17
+ children: /*#__PURE__*/ _jsx("path", {
18
+ d: "M6.16666 1.66666H13.1667C13.4761 1.66666 13.7728 1.78957 13.9916 2.00837C14.2104 2.22716 14.3333 2.5239 14.3333 2.83332V9.83332C14.3333 10.1427 14.2104 10.4395 13.9916 10.6583C13.7728 10.8771 13.4761 11 13.1667 11H6.16666C5.85724 11 5.5605 10.8771 5.34171 10.6583C5.12291 10.4395 5 10.1427 5 9.83332V2.83332C5 2.5239 5.12291 2.22716 5.34171 2.00837C5.5605 1.78957 5.85724 1.66666 6.16666 1.66666ZM6.16666 2.66666C6.12246 2.66666 6.08007 2.68422 6.04881 2.71547C6.01756 2.74673 6 2.78912 6 2.83332V9.83332C6 9.85521 6.00431 9.87688 6.01268 9.8971C6.02106 9.91732 6.03334 9.9357 6.04881 9.95117C6.06429 9.96665 6.08266 9.97893 6.10288 9.9873C6.1231 9.99568 6.14478 9.99999 6.16666 9.99999H13.1667C13.2109 9.99999 13.2533 9.98243 13.2845 9.95117C13.3158 9.91992 13.3333 9.87753 13.3333 9.83332V2.83332C13.3333 2.78912 13.3158 2.74673 13.2845 2.71547C13.2533 2.68422 13.2109 2.66666 13.1667 2.66666H6.16666ZM10 12C10 11.8674 10.0527 11.7402 10.1464 11.6464C10.2402 11.5527 10.3674 11.5 10.5 11.5C10.6326 11.5 10.7598 11.5527 10.8536 11.6464C10.9473 11.7402 11 11.8674 11 12V13.1667C11 13.4761 10.8771 13.7728 10.6583 13.9916C10.4395 14.2104 10.1427 14.3333 9.83333 14.3333H2.83333C2.52391 14.3333 2.22717 14.2104 2.00837 13.9916C1.78958 13.7728 1.66666 13.4761 1.66666 13.1667V6.16666C1.66666 5.85724 1.78958 5.56049 2.00837 5.3417C2.22717 5.12291 2.52391 4.99999 2.83333 4.99999H4C4.13261 4.99999 4.25978 5.05267 4.35355 5.14644C4.44732 5.2402 4.5 5.36738 4.5 5.49999C4.5 5.6326 4.44732 5.75978 4.35355 5.85354C4.25978 5.94731 4.13261 5.99999 4 5.99999H2.83333C2.78913 5.99999 2.74674 6.01755 2.71548 6.04881C2.68422 6.08006 2.66666 6.12245 2.66666 6.16666V13.1667C2.66666 13.2109 2.68422 13.2533 2.71548 13.2845C2.74674 13.3158 2.78913 13.3333 2.83333 13.3333H9.83333C9.87753 13.3333 9.91993 13.3158 9.95118 13.2845C9.98244 13.2533 10 13.2109 10 13.1667V12Z"
19
+ })
20
+ }),
21
+ /*#__PURE__*/ _jsx("defs", {
22
+ children: /*#__PURE__*/ _jsx("clipPath", {
23
+ id: "clip0_518_8403",
24
+ children: /*#__PURE__*/ _jsx("rect", {
25
+ width: "16",
26
+ height: "16"
27
+ })
28
+ })
29
+ })
30
+ ]
16
31
  })
17
32
  });
18
33
  var copySuccessSvg = /*#__PURE__*/ _jsx("i", {
@@ -8,13 +8,13 @@
8
8
  background-color: transparent;
9
9
  &>i{
10
10
  color: #f4523b;
11
- font-size: 20px;
11
+ font-size: 16px;
12
12
  transform:scale(0.8);
13
13
  }
14
14
  }
15
15
  & > i {
16
16
  color: rgba(140, 140, 140, 1);
17
- font-size: 20px;
17
+ font-size: 16px;
18
18
  }
19
19
  &:hover {
20
20
  background-color: rgba(0, 0, 0, 0.04);
@@ -202,9 +202,14 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
202
202
  };
203
203
  // 删除文件
204
204
  var deleteFile = function(fileId) {
205
+ var fileObj = null;
205
206
  setFileList(function(fileList) {
206
207
  return fileList.filter(function(item) {
207
- return item.fileId !== fileId;
208
+ if (item.fileId === fileId) {
209
+ fileObj = item;
210
+ return true;
211
+ }
212
+ return false;
208
213
  });
209
214
  });
210
215
  // 删除文件时如果删除的是最后一条 则page-1
@@ -216,7 +221,7 @@ var FileList = /*#__PURE__*/ forwardRef(function(props, ref) {
216
221
  if (list.length === 0 && page > 1) {
217
222
  changePage(page - 1);
218
223
  }
219
- fileUpload.deleteFileAjax && fileUpload.deleteFileAjax(fileId);
224
+ fileUpload.deleteFileAjax && fileUpload.deleteFileAjax(fileId, fileObj);
220
225
  };
221
226
  // 更新文件状态
222
227
  var updateFile = function(fileId, status) {
@@ -28,7 +28,7 @@ var defaultFileUploadProps = {
28
28
  };
29
29
  var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
30
30
  var footerConfig = props.footerConfig, prefix = props.prefix, errorCallback = props.errorCallback, apiRef = props.apiRef;
31
- var _footerConfig_placeholder = footerConfig.placeholder, placeholder = _footerConfig_placeholder === void 0 ? defaultProps.placeholder : _footerConfig_placeholder, _footerConfig_className = footerConfig.className, className = _footerConfig_className === void 0 ? defaultProps.className : _footerConfig_className, _footerConfig_maxLength = footerConfig.maxLength, maxLength = _footerConfig_maxLength === void 0 ? defaultProps.maxLength : _footerConfig_maxLength, renderAction = footerConfig.renderAction, fileUpload = footerConfig.fileUpload, sendMsgAjaxParams = footerConfig.sendMsgAjaxParams;
31
+ var _footerConfig_placeholder = footerConfig.placeholder, placeholder = _footerConfig_placeholder === void 0 ? defaultProps.placeholder : _footerConfig_placeholder, _footerConfig_className = footerConfig.className, className = _footerConfig_className === void 0 ? defaultProps.className : _footerConfig_className, _footerConfig_maxLength = footerConfig.maxLength, maxLength = _footerConfig_maxLength === void 0 ? defaultProps.maxLength : _footerConfig_maxLength, renderAction = footerConfig.renderAction, fileUpload = footerConfig.fileUpload, sendMsgAjaxParams = footerConfig.sendMsgAjaxParams, _footerConfig_onClickStop = footerConfig.onClickStop, onClickStop = _footerConfig_onClickStop === void 0 ? function() {} : _footerConfig_onClickStop;
32
32
  if (fileUpload) {
33
33
  fileUpload = _object_spread({}, defaultFileUploadProps, fileUpload);
34
34
  }
@@ -116,7 +116,10 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
116
116
  prefix: prefix,
117
117
  canSendMsg: canSendMsg,
118
118
  sending: sending,
119
- stopMessage: stopMessage,
119
+ stopMessage: function() {
120
+ onClickStop();
121
+ stopMessage();
122
+ },
120
123
  clickFn: function() {
121
124
  if (textValue.trim().length === 0) return;
122
125
  sendMsg(textValue);
@@ -190,7 +193,9 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
190
193
  sendMsgAjax();
191
194
  };
192
195
  var sendMsgAjax = function() {
193
- var url = sendMsgAjaxParams.url, _sendMsgAjaxParams_method = sendMsgAjaxParams.method, method = _sendMsgAjaxParams_method === void 0 ? "POST" : _sendMsgAjaxParams_method, _sendMsgAjaxParams_headers = sendMsgAjaxParams.headers, headers = _sendMsgAjaxParams_headers === void 0 ? {} : _sendMsgAjaxParams_headers, _sendMsgAjaxParams_params = sendMsgAjaxParams.params, params = _sendMsgAjaxParams_params === void 0 ? function() {
196
+ var url = sendMsgAjaxParams.url, _sendMsgAjaxParams_method = sendMsgAjaxParams.method, method = _sendMsgAjaxParams_method === void 0 ? "POST" : _sendMsgAjaxParams_method, _sendMsgAjaxParams_headers = sendMsgAjaxParams.headers, headers = _sendMsgAjaxParams_headers === void 0 ? function() {
197
+ return {};
198
+ } : _sendMsgAjaxParams_headers, _sendMsgAjaxParams_params = sendMsgAjaxParams.params, params = _sendMsgAjaxParams_params === void 0 ? function() {
194
199
  return "";
195
200
  } : _sendMsgAjaxParams_params, _sendMsgAjaxParams_onOpen = sendMsgAjaxParams.onOpen, onOpen = _sendMsgAjaxParams_onOpen === void 0 ? function() {} : _sendMsgAjaxParams_onOpen, _sendMsgAjaxParams_onMessage = sendMsgAjaxParams.onMessage, onMessage = _sendMsgAjaxParams_onMessage === void 0 ? function(ev) {
196
201
  return ev;
@@ -221,54 +226,62 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
221
226
  fileListRef.current ? fileListRef.current.getFileList() : []
222
227
  ];
223
228
  beforeSendMsg.apply(void 0, _to_consumable_array(arg)).then(function(beforeInfo) {
224
- fetchEventSource(url, _object_spread({
225
- method: method,
226
- headers: _object_spread({
227
- "Content-Type": "application/json",
228
- Accept: "text/event-stream,application/json"
229
- }, headers),
230
- body: params.apply(void 0, _to_consumable_array(arg).concat([
231
- beforeInfo
232
- ])),
233
- openWhenHidden: true,
234
- signal: ctrl.current.signal,
235
- onopen: function(res) {
236
- onOpen(res);
237
- if (res.status === 200) {}
238
- return null;
239
- },
240
- onmessage: function(ev) {
241
- var data = onMessage(ev);
242
- msgContent += data.content;
243
- delete data.content;
244
- recordMsgObj = _object_spread({
245
- createTime: createTime,
246
- content: msgContent,
247
- location: "left",
248
- reference: null,
249
- source: null
250
- }, data);
251
- updateMsgRef.current = setTimeout(function() {
252
- apiRef.contentApi.updateMsg(msgId, recordMsgObj);
253
- msgId = data.id;
254
- }, 100);
255
- },
256
- onclose: function() {
257
- onClose();
258
- setSending(false);
259
- if (recordMsgObj.id) {
260
- apiRef.contentApi.recordMsg(recordMsgObj);
229
+ var callback = function() {
230
+ fetchEventSource(url, _object_spread({
231
+ method: method,
232
+ headers: _object_spread({
233
+ "Content-Type": "application/json",
234
+ "Accept": "text/event-stream,application/json"
235
+ }, headers()),
236
+ body: params.apply(void 0, _to_consumable_array(arg).concat([
237
+ beforeInfo
238
+ ])),
239
+ openWhenHidden: true,
240
+ signal: ctrl.current.signal,
241
+ onopen: function(res) {
242
+ var retryFetch = function() {
243
+ callback();
244
+ };
245
+ onOpen(res, {
246
+ retryFetch: retryFetch,
247
+ stopMessage: stopMessage
248
+ });
249
+ return null;
250
+ },
251
+ onmessage: function(ev) {
252
+ var data = onMessage(ev);
253
+ msgContent += data.content;
254
+ delete data.content;
255
+ recordMsgObj = _object_spread({
256
+ createTime: createTime,
257
+ content: msgContent,
258
+ location: "left",
259
+ reference: null,
260
+ source: null
261
+ }, data);
262
+ updateMsgRef.current = setTimeout(function() {
263
+ apiRef.contentApi.updateMsg(msgId, recordMsgObj);
264
+ msgId = data.id;
265
+ }, 100);
266
+ },
267
+ onclose: function() {
268
+ onClose();
269
+ setSending(false);
270
+ if (recordMsgObj.id) {
271
+ apiRef.contentApi.recordMsg(recordMsgObj);
272
+ }
273
+ console.log("onclose: ", recordMsgObj);
274
+ },
275
+ onerror: function(err) {
276
+ onError(err);
277
+ if (recordMsgObj.id) {
278
+ apiRef.contentApi.recordMsg(recordMsgObj);
279
+ }
280
+ console.log("onerror: ", err);
261
281
  }
262
- console.log("onclose: ", recordMsgObj);
263
- },
264
- onerror: function(err) {
265
- onError(err);
266
- if (recordMsgObj.id) {
267
- apiRef.contentApi.recordMsg(recordMsgObj);
268
- }
269
- console.log("onerror: ", err);
270
- }
271
- }, coverProps));
282
+ }, coverProps));
283
+ };
284
+ callback();
272
285
  }).catch(function() {
273
286
  stopMessage();
274
287
  });
@@ -1,16 +1,26 @@
1
- import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
2
2
  import React from "react";
3
3
  import styles from "./index.module.less";
4
4
  var referencesIcon = /*#__PURE__*/ _jsx("i", {
5
- children: /*#__PURE__*/ _jsx("svg", {
6
- xmlns: "http://www.w3.org/2000/svg",
5
+ children: /*#__PURE__*/ _jsxs("svg", {
7
6
  width: "1em",
8
7
  height: "1em",
9
- viewBox: "0 0 20 20",
8
+ "shape-rendering": "geometricPrecision",
10
9
  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
- })
10
+ viewBox: "0 0 14 14",
11
+ xmlns: "http://www.w3.org/2000/svg",
12
+ children: [
13
+ /*#__PURE__*/ _jsx("path", {
14
+ "fill-rule": "evenodd",
15
+ "clip-rule": "evenodd",
16
+ d: "M6.28443 3.03861C3.77423 4.65069 2.37971 6.52702 2.10085 8.66759C1.66674 12 4.6468 13.6311 6.15677 12.1655C7.66673 10.7 6.7616 8.83982 5.66823 8.33136C4.57487 7.82286 3.90623 7.99996 4.02287 7.32046C4.1395 6.64099 5.69503 4.75706 7.06163 3.87969C7.1523 3.80259 7.1868 3.65299 7.0995 3.53949C7.04207 3.46486 6.92943 3.31847 6.7616 3.10033C6.61483 2.90957 6.47423 2.91671 6.28443 3.03861Z"
17
+ }),
18
+ /*#__PURE__*/ _jsx("path", {
19
+ "fill-rule": "evenodd",
20
+ "clip-rule": "evenodd",
21
+ d: "M12.893 3.03861C10.3828 4.65069 8.98827 6.52702 8.7094 8.66759C8.2753 12 11.2554 13.6311 12.7653 12.1655C14.2753 10.7 13.3702 8.83982 12.2768 8.33136C11.1834 7.82286 10.5148 7.99996 10.6314 7.32046C10.7481 6.64099 12.3036 4.75706 13.6702 3.87969C13.7609 3.80259 13.7954 3.65299 13.708 3.53949C13.6506 3.46486 13.538 3.31847 13.3702 3.10033C13.2234 2.90957 13.0828 2.91671 12.893 3.03861Z"
22
+ })
23
+ ]
14
24
  })
15
25
  });
16
26
  var ReferencesIcon = function(props) {
@@ -24,7 +34,8 @@ var ReferencesIcon = function(props) {
24
34
  console.log("itemitem", item);
25
35
  apiRef.footerApi.setReferences({
26
36
  type: "text",
27
- value: item.content
37
+ value: item.content,
38
+ source: item
28
39
  });
29
40
  }
30
41
  };
@@ -5,7 +5,7 @@
5
5
  line-height: 1;
6
6
  & > i {
7
7
  color: rgba(140, 140, 140, 1);
8
- font-size: 20px;
8
+ font-size: 16px;
9
9
  }
10
10
  &:hover {
11
11
  background-color: rgba(0, 0, 0, 0.04);
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { refreshBtnProps } from "../../type";
3
+ declare const RefreshBtn: (props: refreshBtnProps) => React.JSX.Element;
4
+ export default RefreshBtn;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
2
+ import React from "react";
3
+ import styles from "./index.module.less";
4
+ var refreshSvg = /*#__PURE__*/ _jsx("svg", {
5
+ viewBox: "0 0 14 14",
6
+ version: "1.1",
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ "p-id": "8340",
9
+ width: "1em",
10
+ height: "1em",
11
+ fill: "currentColor",
12
+ "shape-rendering": "geometricPrecision",
13
+ "aria-hidden": "true",
14
+ children: /*#__PURE__*/ _jsx("path", {
15
+ d: "M8 3.80001C7.27938 3.80001 6.60141 3.97512 6.00464 4.2846C5.71048 4.43715 5.34834 4.32235 5.19579 4.02818C5.04324 3.73401 5.15804 3.37187 5.4522 3.21932C6.21563 2.82342 7.0826 2.60001 8 2.60001C11.0603 2.60001 13.5412 5.08088 13.5412 8.14118C13.5412 8.40936 13.5221 8.67343 13.4851 8.93202C13.4737 9.01141 13.4607 9.09026 13.446 9.16853L13.7175 9.02364C14.0098 8.86759 14.3733 8.97808 14.5293 9.27041C14.6854 9.56274 14.5749 9.92622 14.2825 10.0823L12.6718 10.9421C12.3819 11.0968 12.0215 10.9896 11.8633 10.7016L11.0035 9.13588C10.844 8.84542 10.9501 8.48065 11.2406 8.32115C11.5311 8.16164 11.8958 8.2678 12.0553 8.55825L12.2672 8.94405C12.2784 8.88383 12.2885 8.82318 12.2972 8.76211C12.3261 8.55962 12.3412 8.35233 12.3412 8.14118C12.3412 5.74362 10.3976 3.80001 8 3.80001ZM3.32824 5.34029C3.61811 5.18556 3.97853 5.29278 4.13669 5.58079L4.99651 7.14649C5.15601 7.43694 5.04986 7.80171 4.7594 7.96122C4.46895 8.12072 4.10418 8.01457 3.94467 7.72411L3.73281 7.33832C3.72156 7.39853 3.71155 7.45919 3.70282 7.52026C3.67386 7.72275 3.65883 7.93003 3.65883 8.14118C3.65883 10.5387 5.60244 12.4824 8 12.4824C8.72063 12.4824 9.39859 12.3072 9.99536 11.9978C10.2895 11.8452 10.6517 11.96 10.8042 12.2542C10.9568 12.5484 10.842 12.9105 10.5478 13.063C9.78437 13.4589 8.9174 13.6824 8 13.6824C4.93969 13.6824 2.45883 11.2015 2.45883 8.14118C2.45883 7.87301 2.47792 7.60894 2.51491 7.35034C2.52627 7.27095 2.5393 7.19211 2.55399 7.11384L2.28254 7.25873C1.99021 7.41477 1.62673 7.30429 1.47069 7.01196C1.31465 6.71963 1.42513 6.35615 1.71746 6.20011L3.32824 5.34029Z"
16
+ })
17
+ });
18
+ var RefreshBtn = function(props) {
19
+ var prefix = props.prefix, clickFn = props.clickFn;
20
+ var getCls = function(clsName) {
21
+ return styles[clsName] + " " + prefix + "-" + clsName;
22
+ };
23
+ return /*#__PURE__*/ _jsx("i", {
24
+ className: "".concat(getCls("refreshBtn")),
25
+ onClick: function() {
26
+ return clickFn();
27
+ },
28
+ children: refreshSvg
29
+ });
30
+ };
31
+ export default RefreshBtn;
@@ -0,0 +1,12 @@
1
+ .refreshBtn {
2
+ font-size: 16px;
3
+ cursor: pointer;
4
+ color: rgba(0, 0, 0, 0.65);
5
+ display: flex;
6
+ &:hover {
7
+ color: #f4523b;
8
+ }
9
+ &.active {
10
+ color: #f4523b;
11
+ }
12
+ }
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { VoteBtnProps } from "../../type";
3
+ export declare const UpVoteBtn: (props: VoteBtnProps) => React.JSX.Element;
4
+ export declare const DownVoteBtn: (props: VoteBtnProps) => React.JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
2
+ import React from "react";
3
+ import styles from "./index.module.less";
4
+ var upvoteBtnSvg = /*#__PURE__*/ _jsx("svg", {
5
+ width: "1em",
6
+ height: "1em",
7
+ viewBox: "0 0 16 16",
8
+ "shape-rendering": "geometricPrecision",
9
+ fill: "currentColor",
10
+ xmlns: "http://www.w3.org/2000/svg",
11
+ children: /*#__PURE__*/ _jsx("path", {
12
+ d: "M14.9948 7.82355C14.999 7.88679 14.9948 7.95002 14.978 8.01326L13.7172 13.4046C13.7003 13.4699 13.6709 13.527 13.633 13.58C13.4983 13.8411 13.292 14.0716 13.0205 14.2409C12.7321 14.4184 12.4122 14.5 12.0944 14.5V14.4959L4.00144 14.4918C3.97408 14.4959 3.94461 14.498 3.91514 14.498C3.88568 14.498 3.85621 14.4959 3.82885 14.4918H1.67564C1.64617 14.4959 1.6146 14.5 1.58303 14.5C1.26099 14.5 1 14.2471 1 13.935L1.00631 7.1504C1.00631 6.8383 1.26731 6.58536 1.58934 6.58536C1.6125 6.58536 1.63775 6.5874 1.66091 6.58944L3.59522 6.58536V6.57516C5.37587 6.45073 6.78609 5.03711 6.8366 3.29303C6.83239 3.24408 6.82818 3.19512 6.82818 3.14412C6.82818 2.23639 7.58802 1.5 8.52465 1.5C9.32868 1.5 10.0022 2.04464 10.1769 2.77287L10.1853 2.77083C10.2801 3.18696 10.3327 3.61941 10.3327 4.06206C10.3327 4.74745 10.2127 5.40428 9.99169 6.0142L13.2457 6.01828C13.2752 6.01828 13.3046 6.02032 13.3341 6.02644C13.8898 6.04684 14.4244 6.32426 14.7401 6.8179C14.9422 7.13204 15.0222 7.4829 14.9948 7.82355ZM2.16816 13.3618H3.33422L3.33843 7.71544L2.17448 7.71748L2.16816 13.3618ZM13.7572 7.40946C13.6456 7.23403 13.4478 7.14224 13.2478 7.15244V7.1504H13.2457L9.13294 7.14632C8.8109 7.14632 8.54991 6.89338 8.54991 6.58128C8.54991 6.49153 8.57306 6.40585 8.61095 6.33038L8.60463 6.3263C8.83827 5.90609 9.00665 5.44712 9.10347 4.96367H9.10979C9.10979 4.96367 9.18766 4.6577 9.18556 4.0743C9.18556 3.61125 9.09716 3.18696 9.09716 3.18696H9.09295C9.09295 3.1788 9.09505 3.17064 9.09505 3.16248C9.09505 2.87078 8.85089 2.63416 8.54991 2.63416C8.24892 2.63416 8.00477 2.87078 8.00477 3.16248C8.00477 3.17472 8.00687 3.18696 8.00687 3.1992H7.99845C7.99845 3.1992 8.00687 3.63981 7.91636 4.09878C7.87848 4.29256 7.82375 4.47411 7.77324 4.6169C7.77324 4.6169 7.77113 4.6169 7.77113 4.61486C7.28072 6.06928 6.0473 7.19528 4.50449 7.57673L4.49817 13.3638L12.0965 13.3658C12.1217 13.3658 12.147 13.3679 12.1723 13.372C12.248 13.3618 12.3238 13.3373 12.3912 13.2944C12.488 13.2353 12.5595 13.1496 12.6016 13.0517H12.6037L13.8161 7.86231L13.8119 7.86027C13.8624 7.71544 13.8477 7.55021 13.7572 7.40946Z"
13
+ })
14
+ });
15
+ var downvoteBtnSvg = /*#__PURE__*/ _jsx("svg", {
16
+ width: "1em",
17
+ height: "1em",
18
+ "shape-rendering": "geometricPrecision",
19
+ fill: "currentColor",
20
+ viewBox: "0 0 16 16",
21
+ xmlns: "http://www.w3.org/2000/svg",
22
+ children: /*#__PURE__*/ _jsx("path", {
23
+ d: "M1.0052 8.17645C1.00099 8.11321 1.0052 8.04998 1.02204 7.98674L2.28281 2.5954C2.29965 2.53013 2.32912 2.47301 2.36701 2.41998C2.50171 2.15887 2.70798 1.92837 2.9795 1.75906C3.26786 1.58159 3.58779 1.5 3.90561 1.5V1.50408L11.9986 1.50816C12.0259 1.50408 12.0554 1.50204 12.0849 1.50204C12.1143 1.50204 12.1438 1.50408 12.1712 1.50816H14.3244C14.3538 1.50408 14.3854 1.5 14.417 1.5C14.739 1.5 15 1.75294 15 2.06504L14.9937 8.8496C14.9937 9.1617 14.7327 9.41464 14.4107 9.41464C14.3875 9.41464 14.3622 9.4126 14.3391 9.41056L12.4048 9.41464V9.42484C10.6241 9.54927 9.21391 10.9629 9.1634 12.707C9.16761 12.7559 9.17182 12.8049 9.17182 12.8559C9.17182 13.7636 8.41198 14.5 7.47535 14.5C6.67132 14.5 5.99778 13.9554 5.82308 13.2271L5.81466 13.2292C5.71995 12.813 5.66733 12.3806 5.66733 11.9379C5.66733 11.2526 5.7873 10.5957 6.00831 9.9858L2.75429 9.98172C2.72482 9.98172 2.69535 9.97968 2.66589 9.97356C2.11022 9.95316 1.5756 9.67574 1.25988 9.1821C1.05782 8.86796 0.977839 8.5171 1.0052 8.17645ZM13.8318 2.63824H12.6658L12.6616 8.28456L13.8255 8.28252L13.8318 2.63824ZM2.24282 8.59054C2.35438 8.76597 2.55223 8.85776 2.75218 8.84756V8.8496H2.75429L6.86706 8.85368C7.1891 8.85368 7.45009 9.10662 7.45009 9.41872C7.45009 9.50847 7.42694 9.59415 7.38905 9.66962L7.39537 9.6737C7.16173 10.0939 6.99335 10.5529 6.89653 11.0363H6.89021C6.89021 11.0363 6.81234 11.3423 6.81444 11.9257C6.81444 12.3887 6.90284 12.813 6.90284 12.813H6.90705C6.90705 12.8212 6.90495 12.8294 6.90495 12.8375C6.90495 13.1292 7.14911 13.3658 7.45009 13.3658C7.75108 13.3658 7.99523 13.1292 7.99523 12.8375C7.99523 12.8253 7.99313 12.813 7.99313 12.8008H8.00155C8.00155 12.8008 7.99313 12.3602 8.08364 11.9012C8.12152 11.7074 8.17625 11.5259 8.22676 11.3831C8.22676 11.3831 8.22887 11.3831 8.22887 11.3851C8.71928 9.93072 9.9527 8.80472 11.4955 8.42327L11.5018 2.6362L3.90351 2.63416C3.87825 2.63416 3.85299 2.63212 3.82773 2.62804C3.75196 2.63824 3.67619 2.66272 3.60884 2.70555C3.51201 2.76471 3.44045 2.85038 3.39836 2.9483H3.39625L2.18389 8.13769L2.1881 8.13973C2.13758 8.28456 2.15232 8.44979 2.24282 8.59054Z"
24
+ })
25
+ });
26
+ export var UpVoteBtn = function(props) {
27
+ var prefix = props.prefix, isActive = props.isActive, clickFn = props.clickFn;
28
+ var getCls = function(clsName) {
29
+ return styles[clsName] + " " + prefix + "-" + clsName;
30
+ };
31
+ return /*#__PURE__*/ _jsx("i", {
32
+ onClick: function() {
33
+ clickFn();
34
+ },
35
+ className: "".concat(getCls("upVoteBtn"), " ").concat(isActive ? getCls("active") : ""),
36
+ children: upvoteBtnSvg
37
+ });
38
+ };
39
+ export var DownVoteBtn = function(props) {
40
+ var prefix = props.prefix, isActive = props.isActive, clickFn = props.clickFn;
41
+ var getCls = function(clsName) {
42
+ return styles[clsName] + " " + prefix + "-" + clsName;
43
+ };
44
+ return /*#__PURE__*/ _jsx("i", {
45
+ onClick: function() {
46
+ clickFn();
47
+ },
48
+ className: "".concat(getCls("downVoteBtn"), " ").concat(isActive ? getCls("active") : ""),
49
+ children: downvoteBtnSvg
50
+ });
51
+ };
@@ -0,0 +1,13 @@
1
+ .upVoteBtn,
2
+ .downVoteBtn {
3
+ font-size: 16px;
4
+ cursor: pointer;
5
+ color: rgba(0, 0, 0, 0.65);
6
+ display: flex;
7
+ &:hover {
8
+ color: #f4523b;
9
+ }
10
+ &.active {
11
+ color: #f4523b;
12
+ }
13
+ }