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.
- package/dist/index.esm.es5.development.css +127 -87
- package/dist/index.esm.es5.development.js +453 -249
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/dist/vendor.esm.es5.development.js +2 -2
- package/dist/vendor.esm.es5.production.js +2 -2
- package/es2017/AIMessageList/components/copyIcon/index.js +22 -7
- package/es2017/AIMessageList/components/copyIcon/index.module.less +2 -2
- package/es2017/AIMessageList/components/fileList/index.js +11 -2
- package/es2017/AIMessageList/components/footer/index.js +59 -48
- package/es2017/AIMessageList/components/referencesIcon/index.js +19 -8
- package/es2017/AIMessageList/components/referencesIcon/index.module.less +1 -1
- package/es2017/AIMessageList/components/refreshBtn/index.d.ts +4 -0
- package/es2017/AIMessageList/components/refreshBtn/index.js +29 -0
- package/es2017/AIMessageList/components/refreshBtn/index.module.less +12 -0
- package/es2017/AIMessageList/components/remarkBtn/index.d.ts +4 -0
- package/es2017/AIMessageList/components/remarkBtn/index.js +51 -0
- package/es2017/AIMessageList/components/remarkBtn/index.module.less +13 -0
- package/es2017/AIMessageList/components/virtuosoList/index.js +91 -13
- package/es2017/AIMessageList/components/virtuosoList/index.module.less +10 -1
- package/es2017/AIMessageList/type.d.ts +42 -10
- package/esm/AIMessageList/components/copyIcon/index.js +22 -7
- package/esm/AIMessageList/components/copyIcon/index.module.less +2 -2
- package/esm/AIMessageList/components/fileList/index.js +7 -2
- package/esm/AIMessageList/components/footer/index.js +63 -50
- package/esm/AIMessageList/components/referencesIcon/index.js +19 -8
- package/esm/AIMessageList/components/referencesIcon/index.module.less +1 -1
- package/esm/AIMessageList/components/refreshBtn/index.d.ts +4 -0
- package/esm/AIMessageList/components/refreshBtn/index.js +31 -0
- package/esm/AIMessageList/components/refreshBtn/index.module.less +12 -0
- package/esm/AIMessageList/components/remarkBtn/index.d.ts +4 -0
- package/esm/AIMessageList/components/remarkBtn/index.js +51 -0
- package/esm/AIMessageList/components/remarkBtn/index.module.less +13 -0
- package/esm/AIMessageList/components/virtuosoList/index.js +93 -13
- package/esm/AIMessageList/components/virtuosoList/index.module.less +10 -1
- package/esm/AIMessageList/type.d.ts +42 -10
- package/package.json +1 -1
|
@@ -14,6 +14,8 @@ import hljs from "highlight.js";
|
|
|
14
14
|
import "highlight.js/styles/github.css";
|
|
15
15
|
import CopyIcon from "../copyIcon";
|
|
16
16
|
import ReferencesIcon from "../referencesIcon";
|
|
17
|
+
import { UpVoteBtn, DownVoteBtn } from "../remarkBtn";
|
|
18
|
+
import RefreshBtn from "../refreshBtn";
|
|
17
19
|
var Header = function(param) {
|
|
18
20
|
var context = param.context;
|
|
19
21
|
var prefix = context.prefix, loading = context.loading;
|
|
@@ -47,7 +49,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
47
49
|
var getList = contentConfig.getList, coverRenderText = contentConfig.coverRenderText, _contentConfig_msgAction = contentConfig.msgAction, msgAction = _contentConfig_msgAction === void 0 ? [
|
|
48
50
|
"copy",
|
|
49
51
|
"references"
|
|
50
|
-
] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences, _contentConfig_onRecordMessage = contentConfig.onRecordMessage, onRecordMessage = _contentConfig_onRecordMessage === void 0 ? function() {} : _contentConfig_onRecordMessage;
|
|
52
|
+
] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences, _contentConfig_onRecordMessage = contentConfig.onRecordMessage, onRecordMessage = _contentConfig_onRecordMessage === void 0 ? function() {} : _contentConfig_onRecordMessage, _contentConfig_onVoteChange = contentConfig.onVoteChange, onVoteChange = _contentConfig_onVoteChange === void 0 ? function() {} : _contentConfig_onVoteChange, _contentConfig_onRefresh = contentConfig.onRefresh, onRefresh = _contentConfig_onRefresh === void 0 ? function() {} : _contentConfig_onRefresh;
|
|
51
53
|
var loadMoreProps = contentConfig.loadMore || true;
|
|
52
54
|
var virtuosoRef = useRef(null);
|
|
53
55
|
var _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1]; // 是否加载中
|
|
@@ -69,6 +71,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
69
71
|
maxPage: Math.ceil(total / pageSize)
|
|
70
72
|
});
|
|
71
73
|
var timeRenderCache = useRef(new Map()).current;
|
|
74
|
+
var htmlRenderCache = useRef(new Map()).current;
|
|
72
75
|
useImperativeHandle(ref, function() {
|
|
73
76
|
return {
|
|
74
77
|
addMsg: function(msg) {
|
|
@@ -101,6 +104,22 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
101
104
|
},
|
|
102
105
|
recordMsg: function(msg) {
|
|
103
106
|
onRecordMessage(msg);
|
|
107
|
+
},
|
|
108
|
+
getDataSource: function() {
|
|
109
|
+
return recordRef.current.dataSource;
|
|
110
|
+
},
|
|
111
|
+
upateDataSource: function(id, obj) {
|
|
112
|
+
setDataSource(function(list) {
|
|
113
|
+
return list.map(function(item) {
|
|
114
|
+
if (item.id === id) {
|
|
115
|
+
return _object_spread({}, item, obj);
|
|
116
|
+
}
|
|
117
|
+
return item;
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
changeDataSource: function(data) {
|
|
122
|
+
setDataSource(data);
|
|
104
123
|
}
|
|
105
124
|
};
|
|
106
125
|
});
|
|
@@ -175,14 +194,21 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
175
194
|
]);
|
|
176
195
|
var itemContent = function(index, item) {
|
|
177
196
|
var timeNode = renderTime(item);
|
|
178
|
-
var
|
|
179
|
-
var contentNode =
|
|
180
|
-
|
|
181
|
-
|
|
197
|
+
var cahceKey = item.id + "-" + item.content;
|
|
198
|
+
var contentNode = null;
|
|
199
|
+
if (htmlRenderCache.has(cahceKey)) {
|
|
200
|
+
contentNode = htmlRenderCache.get(cahceKey);
|
|
201
|
+
} else {
|
|
202
|
+
var html = markToHtml(item.content, item.id);
|
|
203
|
+
contentNode = /*#__PURE__*/ _jsx("div", {
|
|
204
|
+
dangerouslySetInnerHTML: {
|
|
205
|
+
__html: html
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
if (coverRenderText) {
|
|
209
|
+
contentNode = coverRenderText(item, html);
|
|
182
210
|
}
|
|
183
|
-
|
|
184
|
-
if (coverRenderText) {
|
|
185
|
-
contentNode = coverRenderText(item, html);
|
|
211
|
+
htmlRenderCache.set(cahceKey, contentNode);
|
|
186
212
|
}
|
|
187
213
|
// 是否显示时间
|
|
188
214
|
var itemNode = /*#__PURE__*/ _jsx("div", {
|
|
@@ -292,11 +318,53 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
292
318
|
apiRef: apiRef,
|
|
293
319
|
item: item
|
|
294
320
|
});
|
|
321
|
+
var UpVoteNode = /*#__PURE__*/ _jsx(UpVoteBtn, {
|
|
322
|
+
prefix: prefix,
|
|
323
|
+
isActive: item.vote === "up",
|
|
324
|
+
clickFn: function() {
|
|
325
|
+
setDataSource(function(data) {
|
|
326
|
+
return data.map(function(ite) {
|
|
327
|
+
if (item.id === ite.id) {
|
|
328
|
+
ite.vote = item.vote === "up" ? "" : "up";
|
|
329
|
+
}
|
|
330
|
+
return ite;
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
onVoteChange(item.vote === "up" ? "" : "up", item);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
var DownVoteNode = /*#__PURE__*/ _jsx(DownVoteBtn, {
|
|
337
|
+
prefix: prefix,
|
|
338
|
+
isActive: item.vote === "down",
|
|
339
|
+
clickFn: function() {
|
|
340
|
+
setDataSource(function(data) {
|
|
341
|
+
return data.map(function(ite) {
|
|
342
|
+
if (item.id === ite.id) {
|
|
343
|
+
ite.vote = ite.vote === "down" ? "" : "down";
|
|
344
|
+
}
|
|
345
|
+
return ite;
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
onVoteChange(item.vote === "down" ? "" : "down", item);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
var RefreshNode = /*#__PURE__*/ _jsx(RefreshBtn, {
|
|
352
|
+
prefix: prefix,
|
|
353
|
+
clickFn: function() {
|
|
354
|
+
return onRefresh(item);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
if (item.location === "right") {
|
|
358
|
+
UpVoteNode = null;
|
|
359
|
+
DownVoteNode = null;
|
|
360
|
+
}
|
|
295
361
|
var leftNodes = null;
|
|
296
362
|
var rightNodes = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
297
363
|
children: [
|
|
298
364
|
copyNode,
|
|
299
|
-
referencesNode
|
|
365
|
+
referencesNode,
|
|
366
|
+
UpVoteNode,
|
|
367
|
+
DownVoteNode
|
|
300
368
|
]
|
|
301
369
|
});
|
|
302
370
|
if (_instanceof(msgAction, Array)) {
|
|
@@ -308,12 +376,21 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
308
376
|
if (!msgAction.includes("references")) {
|
|
309
377
|
referencesNode = null;
|
|
310
378
|
}
|
|
379
|
+
if (!msgAction.includes("upVite")) {
|
|
380
|
+
UpVoteNode = null;
|
|
381
|
+
}
|
|
382
|
+
if (!msgAction.includes("downVote")) {
|
|
383
|
+
DownVoteNode = null;
|
|
384
|
+
}
|
|
385
|
+
if (!msgAction.includes("refresh")) {
|
|
386
|
+
RefreshNode = null;
|
|
387
|
+
}
|
|
311
388
|
} else if (typeof msgAction === "object") {
|
|
312
389
|
if (msgAction.renderLeft) {
|
|
313
|
-
leftNodes = msgAction.renderLeft(copyNode, referencesNode);
|
|
390
|
+
leftNodes = msgAction.renderLeft(copyNode, referencesNode, UpVoteNode, DownVoteNode, RefreshNode);
|
|
314
391
|
}
|
|
315
392
|
if (msgAction.renderRight) {
|
|
316
|
-
rightNodes = msgAction.renderRight(copyNode, referencesNode);
|
|
393
|
+
rightNodes = msgAction.renderRight(copyNode, referencesNode, UpVoteNode, DownVoteNode, RefreshNode);
|
|
317
394
|
}
|
|
318
395
|
}
|
|
319
396
|
var index = recordRef.current.dataSource.findIndex(function(ite) {
|
|
@@ -329,9 +406,12 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
329
406
|
className: "".concat(getCls("msgItem-action-left")),
|
|
330
407
|
children: leftNodes
|
|
331
408
|
}),
|
|
332
|
-
/*#__PURE__*/
|
|
409
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
333
410
|
className: "".concat(getCls("msgItem-action-right")),
|
|
334
|
-
children:
|
|
411
|
+
children: [
|
|
412
|
+
RefreshNode,
|
|
413
|
+
rightNodes
|
|
414
|
+
]
|
|
335
415
|
})
|
|
336
416
|
]
|
|
337
417
|
});
|
|
@@ -274,7 +274,10 @@
|
|
|
274
274
|
display: flex;
|
|
275
275
|
align-items: center;
|
|
276
276
|
justify-content: space-between;
|
|
277
|
-
.msgItem-action-
|
|
277
|
+
.msgItem-action-left {
|
|
278
|
+
display: flex;
|
|
279
|
+
align-items: center;
|
|
280
|
+
gap: 8px;
|
|
278
281
|
}
|
|
279
282
|
.msgItem-action-right {
|
|
280
283
|
display: flex;
|
|
@@ -294,8 +297,14 @@
|
|
|
294
297
|
line-height: 1;
|
|
295
298
|
z-index: 9;
|
|
296
299
|
padding: 4px 8px;
|
|
300
|
+
.msgItem-action-left {
|
|
301
|
+
display: flex;
|
|
302
|
+
align-items: center;
|
|
303
|
+
gap: 8px;
|
|
304
|
+
}
|
|
297
305
|
.msgItem-action-right {
|
|
298
306
|
display: flex;
|
|
307
|
+
align-items: center;
|
|
299
308
|
gap: 8px;
|
|
300
309
|
}
|
|
301
310
|
&.msgItem-action-popover-floatTop {
|
|
@@ -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?: (
|
|
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
|
}
|