bhd-components 0.10.8 → 0.10.10
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 +123 -92
- package/dist/index.esm.es5.development.js +115 -58
- 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 +1 -1
- package/dist/vendor.esm.es5.production.js +1 -1
- package/es2017/AIMessageList/components/fileList/index.js +6 -3
- package/es2017/AIMessageList/components/referencesIcon/index.js +1 -1
- package/es2017/AIMessageList/components/referencesIcon/index.module.less +1 -1
- package/es2017/AIMessageList/components/virtuosoList/index.js +112 -56
- package/es2017/AIMessageList/components/virtuosoList/index.module.less +53 -11
- package/es2017/AIMessageList/type.d.ts +8 -2
- package/esm/AIMessageList/components/fileList/index.js +6 -3
- package/esm/AIMessageList/components/referencesIcon/index.js +1 -1
- package/esm/AIMessageList/components/referencesIcon/index.module.less +1 -1
- package/esm/AIMessageList/components/virtuosoList/index.js +106 -52
- package/esm/AIMessageList/components/virtuosoList/index.module.less +53 -11
- package/esm/AIMessageList/type.d.ts +8 -2
- package/package.json +1 -1
|
@@ -49,8 +49,8 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
49
49
|
var prefix = props.prefix, contentConfig = props.contentConfig, apiRef = props.apiRef;
|
|
50
50
|
var getList = contentConfig.getList, coverRenderText = contentConfig.coverRenderText, _contentConfig_msgAction = contentConfig.msgAction, msgAction = _contentConfig_msgAction === void 0 ? [
|
|
51
51
|
"copy",
|
|
52
|
-
"
|
|
53
|
-
] : _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,
|
|
52
|
+
"reference"
|
|
53
|
+
] : _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, helloMsg = contentConfig.helloMsg, _contentConfig_fileCustomRender = contentConfig.fileCustomRender, fileCustomRender = _contentConfig_fileCustomRender === void 0 ? {} : _contentConfig_fileCustomRender;
|
|
54
54
|
var loadMoreProps = contentConfig.loadMore || true;
|
|
55
55
|
var virtuosoRef = useRef(null);
|
|
56
56
|
var _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1]; // 是否加载中
|
|
@@ -77,20 +77,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
77
77
|
var htmlRenderCache = useRef(new Map()).current;
|
|
78
78
|
useImperativeHandle(ref, function() {
|
|
79
79
|
return {
|
|
80
|
-
addMsg:
|
|
81
|
-
if (msg.id !== "inputing") {
|
|
82
|
-
// 不记录"正在输入..."的消息
|
|
83
|
-
onRecordMessage(msg);
|
|
84
|
-
}
|
|
85
|
-
setDataSource(function(data) {
|
|
86
|
-
return _to_consumable_array(data).concat([
|
|
87
|
-
msg
|
|
88
|
-
]);
|
|
89
|
-
});
|
|
90
|
-
timerRef.current.scrollTimer = setTimeout(function() {
|
|
91
|
-
scrollToBottom();
|
|
92
|
-
}, 100);
|
|
93
|
-
},
|
|
80
|
+
addMsg: addMsg,
|
|
94
81
|
updateMsg: function(id, obj) {
|
|
95
82
|
setDataSource(function(data) {
|
|
96
83
|
return data.map(function(item) {
|
|
@@ -134,7 +121,19 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
134
121
|
};
|
|
135
122
|
});
|
|
136
123
|
useEffect(function() {
|
|
137
|
-
getData(page, pageSize)
|
|
124
|
+
getData(page, pageSize).then(function() {
|
|
125
|
+
if (helloMsg) {
|
|
126
|
+
addMsg({
|
|
127
|
+
id: "helloMsg",
|
|
128
|
+
createTime: new Date().getTime(),
|
|
129
|
+
content: helloMsg,
|
|
130
|
+
location: "left",
|
|
131
|
+
reference: null,
|
|
132
|
+
source: null,
|
|
133
|
+
fileList: []
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
138
137
|
var removeFn = delegate(wrapperRef.current, "click", ".".concat(styles.copyCode), function(event, target) {
|
|
139
138
|
findCopyContent(event);
|
|
140
139
|
});
|
|
@@ -175,6 +174,37 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
175
174
|
dataSource,
|
|
176
175
|
sendingId
|
|
177
176
|
]);
|
|
177
|
+
var addMsg = function(msg) {
|
|
178
|
+
if (msg.id !== "inputing" && msg.id !== "helloMsg") {
|
|
179
|
+
// 不记录"正在输入..."的消息
|
|
180
|
+
onRecordMessage(msg);
|
|
181
|
+
}
|
|
182
|
+
var list = [];
|
|
183
|
+
if (msg.location === "right" && msg.fileList && msg.fileList.length > 0) {
|
|
184
|
+
console.log("fileList", msg, msg.fileList);
|
|
185
|
+
msg.fileList.map(function(item) {
|
|
186
|
+
list.push({
|
|
187
|
+
type: "file",
|
|
188
|
+
id: item.fileId,
|
|
189
|
+
createTime: msg.createTime,
|
|
190
|
+
content: "",
|
|
191
|
+
location: "right",
|
|
192
|
+
reference: null,
|
|
193
|
+
source: null,
|
|
194
|
+
suffix: item.suffix,
|
|
195
|
+
fileSize: item.size || 0,
|
|
196
|
+
fileTitle: item.name
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
list.push(msg);
|
|
201
|
+
setDataSource(function(data) {
|
|
202
|
+
return _to_consumable_array(data).concat(_to_consumable_array(list));
|
|
203
|
+
});
|
|
204
|
+
timerRef.current.scrollTimer = setTimeout(function() {
|
|
205
|
+
scrollToBottom();
|
|
206
|
+
}, 100);
|
|
207
|
+
};
|
|
178
208
|
var scrollToBottom = function() {
|
|
179
209
|
if (!virtuosoRef.current) return;
|
|
180
210
|
virtuosoRef.current.scrollToIndex({
|
|
@@ -184,21 +214,17 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
184
214
|
};
|
|
185
215
|
var getData = function(page, pageSize) {
|
|
186
216
|
setLoading(true);
|
|
187
|
-
|
|
188
|
-
timerRef.current.loadMore = setTimeout(function() {
|
|
217
|
+
return getList(page, pageSize).then(function(listObj) {
|
|
189
218
|
setLoading(false);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
setDataSource(function(data) {
|
|
194
|
-
return _to_consumable_array(data).concat(_to_consumable_array(listObj.dataSource));
|
|
195
|
-
});
|
|
196
|
-
setTotal(listObj.total);
|
|
197
|
-
setPage(page);
|
|
198
|
-
setPageSize(pageSize);
|
|
199
|
-
setFirstItemIndex(listObj.total - pageSize * (page - 1));
|
|
219
|
+
console.log("listObjlistObj", listObj);
|
|
220
|
+
setDataSource(function(data) {
|
|
221
|
+
return _to_consumable_array(data).concat(_to_consumable_array(listObj.dataSource));
|
|
200
222
|
});
|
|
201
|
-
|
|
223
|
+
setTotal(listObj.total);
|
|
224
|
+
setPage(page);
|
|
225
|
+
setPageSize(pageSize);
|
|
226
|
+
setFirstItemIndex(listObj.total - pageSize * (page - 1));
|
|
227
|
+
});
|
|
202
228
|
};
|
|
203
229
|
var getCls = function(clsName) {
|
|
204
230
|
return styles[clsName] + " " + prefix + "-" + clsName;
|
|
@@ -228,26 +254,32 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
228
254
|
// item.fileTitle = "这是一个文件名称.docx";
|
|
229
255
|
// item.fileSize = "5Mb";
|
|
230
256
|
if (item.type === "file") {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
257
|
+
var renderFileObj = _object_spread({
|
|
258
|
+
fileTitleRender: function(item) {
|
|
259
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
260
|
+
children: item.fileTitle
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}, fileCustomRender);
|
|
264
|
+
if (renderFileObj.fileRender) {
|
|
265
|
+
contentNode = renderFileObj.fileRender(item);
|
|
266
|
+
} else {
|
|
267
|
+
contentNode = /*#__PURE__*/ _jsxs("div", {
|
|
268
|
+
className: "".concat(getCls("msgItem-file")),
|
|
269
|
+
children: [
|
|
270
|
+
/*#__PURE__*/ _jsx("div", {
|
|
271
|
+
className: "".concat(getCls("msgItem-file-left")),
|
|
272
|
+
children: fileIconRender(item.suffix, renderFileObj.iconFileRender)
|
|
273
|
+
}),
|
|
274
|
+
/*#__PURE__*/ _jsx("div", {
|
|
275
|
+
className: "".concat(getCls("msgItem-file-right")),
|
|
276
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
277
|
+
children: renderFileObj.fileTitleRender(item)
|
|
246
278
|
})
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
279
|
+
})
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
}
|
|
251
283
|
}
|
|
252
284
|
// 是否显示时间
|
|
253
285
|
var itemNode = /*#__PURE__*/ _jsx("div", {
|
|
@@ -291,12 +323,30 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
291
323
|
var referenceNode = null;
|
|
292
324
|
if (reference.type === "text") {
|
|
293
325
|
referenceNode = /*#__PURE__*/ _jsx("div", {
|
|
294
|
-
className: "".concat(getCls("msgItem-
|
|
326
|
+
className: "".concat(getCls("msgItem-reference-text")),
|
|
295
327
|
children: /*#__PURE__*/ _jsx("div", {
|
|
296
328
|
children: reference.value
|
|
297
329
|
})
|
|
298
330
|
});
|
|
299
331
|
}
|
|
332
|
+
if (reference.type === "file") {
|
|
333
|
+
referenceNode = /*#__PURE__*/ _jsx("div", {
|
|
334
|
+
className: "".concat(getCls("msgItem-reference-file")),
|
|
335
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
336
|
+
className: "".concat(getCls("msgItem-reference-file-box")),
|
|
337
|
+
children: [
|
|
338
|
+
/*#__PURE__*/ _jsx("div", {
|
|
339
|
+
className: "".concat(getCls("msgItem-reference-file-left")),
|
|
340
|
+
children: fileIconRender(reference.value.suffix, fileCustomRender.iconFileRender)
|
|
341
|
+
}),
|
|
342
|
+
/*#__PURE__*/ _jsx("div", {
|
|
343
|
+
className: "".concat(getCls("msgItem-reference-file-right")),
|
|
344
|
+
children: reference.value.name
|
|
345
|
+
})
|
|
346
|
+
]
|
|
347
|
+
})
|
|
348
|
+
});
|
|
349
|
+
}
|
|
300
350
|
if (coverRenderReferences) {
|
|
301
351
|
return coverRenderReferences(item, referenceNode);
|
|
302
352
|
} else {
|
|
@@ -419,7 +469,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
419
469
|
if (!msgAction.includes("copy")) {
|
|
420
470
|
copyNode = null;
|
|
421
471
|
}
|
|
422
|
-
if (!msgAction.includes("
|
|
472
|
+
if (!msgAction.includes("reference")) {
|
|
423
473
|
referencesNode = null;
|
|
424
474
|
}
|
|
425
475
|
if (!msgAction.includes("upVite")) {
|
|
@@ -586,6 +636,9 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
586
636
|
p[0].innerText = "复制代码";
|
|
587
637
|
}
|
|
588
638
|
};
|
|
639
|
+
var onScroll = function() {
|
|
640
|
+
console.log("滚动滚动");
|
|
641
|
+
};
|
|
589
642
|
return /*#__PURE__*/ _jsx("div", {
|
|
590
643
|
className: "".concat(getCls("virtuosoList-wrapper")),
|
|
591
644
|
ref: wrapperRef,
|
|
@@ -610,7 +663,8 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
610
663
|
Header: Header
|
|
611
664
|
},
|
|
612
665
|
increaseViewportBy: 200,
|
|
613
|
-
overscan: 10
|
|
666
|
+
overscan: 10,
|
|
667
|
+
onScroll: onScroll
|
|
614
668
|
})
|
|
615
669
|
});
|
|
616
670
|
});
|
|
@@ -274,30 +274,33 @@
|
|
|
274
274
|
border-radius: 8px;
|
|
275
275
|
border: 1px solid #ebebeb;
|
|
276
276
|
gap: 12px;
|
|
277
|
-
|
|
277
|
+
min-width: 216px;
|
|
278
|
+
.msgItem-file-left {
|
|
278
279
|
font-size: 24px;
|
|
279
280
|
display: flex;
|
|
280
281
|
justify-content: center;
|
|
281
282
|
align-items: center;
|
|
282
283
|
padding: 0;
|
|
283
284
|
margin: 0;
|
|
284
|
-
|
|
285
|
+
& > i {
|
|
285
286
|
display: flex;
|
|
286
287
|
font-size: 24px;
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
|
-
.msgItem-file-right{
|
|
290
|
+
.msgItem-file-right {
|
|
290
291
|
font-size: 14px;
|
|
291
292
|
font-weight: 400;
|
|
292
293
|
color: rgba(0, 0, 0, 0.65);
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
font-size: 12px;
|
|
299
|
-
color: rgba(0, 0, 0, 0.25);
|
|
294
|
+
margin: 0;
|
|
295
|
+
padding: 0;
|
|
296
|
+
& > p {
|
|
297
|
+
&:nth-child(1) {
|
|
298
|
+
// margin-bottom: 4px;
|
|
300
299
|
}
|
|
300
|
+
// &:nth-child(2) {
|
|
301
|
+
// font-size: 12px;
|
|
302
|
+
// color: rgba(0, 0, 0, 0.25);
|
|
303
|
+
// }
|
|
301
304
|
}
|
|
302
305
|
}
|
|
303
306
|
}
|
|
@@ -356,7 +359,7 @@
|
|
|
356
359
|
}
|
|
357
360
|
}
|
|
358
361
|
|
|
359
|
-
.msgItem-
|
|
362
|
+
.msgItem-reference-text {
|
|
360
363
|
padding: 8px;
|
|
361
364
|
border-radius: 2px;
|
|
362
365
|
background: #e7e7e7;
|
|
@@ -375,6 +378,45 @@
|
|
|
375
378
|
word-wrap: break-word;
|
|
376
379
|
}
|
|
377
380
|
}
|
|
381
|
+
.msgItem-reference-file {
|
|
382
|
+
padding: 8px;
|
|
383
|
+
border-radius: 2px;
|
|
384
|
+
background: #e7e7e7;
|
|
385
|
+
font-size: 12px;
|
|
386
|
+
color: rgba(0, 0, 0, 0.65);
|
|
387
|
+
margin-top: 8px;
|
|
388
|
+
|
|
389
|
+
.msgItem-reference-file-box {
|
|
390
|
+
display: flex;
|
|
391
|
+
align-items: center;
|
|
392
|
+
gap: 12px;
|
|
393
|
+
background: #fafafa;
|
|
394
|
+
border-radius: 8px;
|
|
395
|
+
border: 1px solid #ebebeb;
|
|
396
|
+
display: flex;
|
|
397
|
+
align-items: center;
|
|
398
|
+
gap: 12px;
|
|
399
|
+
padding: 8px 12px;
|
|
400
|
+
min-width: 216px;
|
|
401
|
+
.msgItem-reference-file-left {
|
|
402
|
+
font-size: 24px;
|
|
403
|
+
display: flex;
|
|
404
|
+
justify-content: center;
|
|
405
|
+
align-items: center;
|
|
406
|
+
padding: 0;
|
|
407
|
+
margin: 0;
|
|
408
|
+
& > i {
|
|
409
|
+
display: flex;
|
|
410
|
+
font-size: 24px;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
.msgItem-reference-file-right {
|
|
414
|
+
font-size: 14px;
|
|
415
|
+
font-weight: 400;
|
|
416
|
+
color: rgba(0, 0, 0, 0.65);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
378
420
|
&.msgItem-left {
|
|
379
421
|
justify-content: flex-start;
|
|
380
422
|
.msgItem-box {
|
|
@@ -62,7 +62,12 @@ export interface contentConfigProps {
|
|
|
62
62
|
onRecordMessage?: (item: dataItemType) => void; // 发送和接收的消息记录
|
|
63
63
|
onVoteChange?: (type:string,item: dataItemType) => void; // 点赞 或踩
|
|
64
64
|
onRefresh?: (item:dataItemType) => void;// 刷新
|
|
65
|
-
|
|
65
|
+
fileCustomRender?: {// 文件对象的自定义渲染
|
|
66
|
+
iconFileRender?: (suffix: string) => React.ReactNode; // 文件上传的 icon。参数 文件对象file 返回值为图标
|
|
67
|
+
fileTitleRender?: (item: dataItemType) => React.ReactNode;
|
|
68
|
+
fileBottomRender?: (item: dataItemType) => React.ReactNode;
|
|
69
|
+
fileRender?: (item: dataItemType) => React.ReactNode;
|
|
70
|
+
};
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
// content props
|
|
@@ -206,6 +211,7 @@ export interface fileCustomProps {
|
|
|
206
211
|
url: string;
|
|
207
212
|
status: fileStatus | undefined;
|
|
208
213
|
source: File | undefined;
|
|
214
|
+
size:number
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
// FileList 组件 ref props
|
|
@@ -294,7 +300,7 @@ export interface dataItemType {
|
|
|
294
300
|
vote?:string;// "up":点赞。"down":踩
|
|
295
301
|
type?:"file"|"text",
|
|
296
302
|
suffix?:string;
|
|
297
|
-
fileSize?:
|
|
303
|
+
fileSize?:number;
|
|
298
304
|
fileTitle?:string;
|
|
299
305
|
fileList?:fileCustomProps[];
|
|
300
306
|
}
|