bhd-components 0.10.1 → 0.10.3
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 +88 -88
- package/dist/index.esm.es5.development.js +32 -9
- 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 +1589 -3476
- package/dist/vendor.esm.es5.production.js +99 -99
- package/es2017/AIMessageList/components/footer/index.js +20 -4
- package/es2017/AIMessageList/components/virtuosoList/index.js +9 -2
- package/es2017/AIMessageList/components/virtuosoList/index.module.less +12 -12
- package/es2017/AIMessageList/type.d.ts +3 -0
- package/esm/AIMessageList/components/footer/index.js +20 -4
- package/esm/AIMessageList/components/virtuosoList/index.js +9 -2
- package/esm/AIMessageList/components/virtuosoList/index.module.less +12 -12
- package/esm/AIMessageList/type.d.ts +3 -0
- package/package.json +2 -2
|
@@ -35,6 +35,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
35
35
|
const [textValue, setTextValue] = useState("");
|
|
36
36
|
const [sending, setSending] = useState(false);
|
|
37
37
|
const [fileCanSending, setFileCanSending] = useState(true); // 是否允许发送 关联文件
|
|
38
|
+
const updateMsgRef = useRef(null);
|
|
38
39
|
// const [referencesSource, setReferencesSource] = useState<referenceType>({
|
|
39
40
|
// type: "file",
|
|
40
41
|
// value: {
|
|
@@ -70,6 +71,11 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
70
71
|
}
|
|
71
72
|
}, fileListRef.current);
|
|
72
73
|
});
|
|
74
|
+
useEffect(()=>{
|
|
75
|
+
return ()=>{
|
|
76
|
+
clearTimeout(updateMsgRef.current);
|
|
77
|
+
};
|
|
78
|
+
}, []);
|
|
73
79
|
useEffect(()=>{
|
|
74
80
|
recordRef.current.value = textValue;
|
|
75
81
|
recordRef.current.referencesSource = referencesSource;
|
|
@@ -196,6 +202,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
196
202
|
setSending(true);
|
|
197
203
|
setTextValue("");
|
|
198
204
|
setReferencesSource(null);
|
|
205
|
+
let recordMsgObj = {};
|
|
199
206
|
let arg = [
|
|
200
207
|
recordRef.current.value,
|
|
201
208
|
recordRef.current.referencesSource,
|
|
@@ -219,22 +226,31 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
219
226
|
let data = onMessage(ev);
|
|
220
227
|
msgContent += data.content;
|
|
221
228
|
delete data.content;
|
|
222
|
-
|
|
229
|
+
recordMsgObj = _object_spread({
|
|
223
230
|
createTime: createTime,
|
|
224
231
|
content: msgContent,
|
|
225
232
|
location: "left",
|
|
226
233
|
reference: null,
|
|
227
234
|
source: null
|
|
228
|
-
}, data)
|
|
229
|
-
|
|
235
|
+
}, data);
|
|
236
|
+
updateMsgRef.current = setTimeout(()=>{
|
|
237
|
+
apiRef.contentApi.updateMsg(msgId, recordMsgObj);
|
|
238
|
+
msgId = data.id;
|
|
239
|
+
}, 100);
|
|
230
240
|
},
|
|
231
241
|
onclose: ()=>{
|
|
232
242
|
onClose();
|
|
233
243
|
setSending(false);
|
|
234
|
-
|
|
244
|
+
if (recordMsgObj.id) {
|
|
245
|
+
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
246
|
+
}
|
|
247
|
+
console.log("onclose: ", recordMsgObj);
|
|
235
248
|
},
|
|
236
249
|
onerror: (err)=>{
|
|
237
250
|
onError(err);
|
|
251
|
+
if (recordMsgObj.id) {
|
|
252
|
+
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
253
|
+
}
|
|
238
254
|
console.log("onerror: ", err);
|
|
239
255
|
}
|
|
240
256
|
}, coverProps));
|
|
@@ -43,14 +43,14 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
43
43
|
const { getList, coverRenderText, msgAction = [
|
|
44
44
|
"copy",
|
|
45
45
|
"references"
|
|
46
|
-
], coverRenderReferences } = contentConfig;
|
|
46
|
+
], coverRenderReferences, onRecordMessage = ()=>{} } = contentConfig;
|
|
47
47
|
const loadMoreProps = contentConfig.loadMore || true;
|
|
48
48
|
const virtuosoRef = useRef(null);
|
|
49
49
|
const [loading, setLoading] = useState(false); // 是否加载中
|
|
50
50
|
const [dataSource, setDataSource] = useState([]);
|
|
51
51
|
const [firstItemIndex, setFirstItemIndex] = useState(0);
|
|
52
52
|
const [page, setPage] = useState(1);
|
|
53
|
-
const [pageSize, setPageSize] = useState(30);
|
|
53
|
+
const [pageSize, setPageSize] = useState(contentConfig.pageSize || 30);
|
|
54
54
|
const [total, setTotal] = useState(0);
|
|
55
55
|
const timerRef = useRef({
|
|
56
56
|
loadMore: null,
|
|
@@ -68,6 +68,10 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
68
68
|
useImperativeHandle(ref, ()=>{
|
|
69
69
|
return {
|
|
70
70
|
addMsg: (msg)=>{
|
|
71
|
+
if (msg.id !== "inputing") {
|
|
72
|
+
// 不记录"正在输入..."的消息
|
|
73
|
+
onRecordMessage(msg);
|
|
74
|
+
}
|
|
71
75
|
setDataSource((data)=>{
|
|
72
76
|
return [
|
|
73
77
|
...data,
|
|
@@ -89,6 +93,9 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
89
93
|
setDataSource((data)=>{
|
|
90
94
|
return data.filter((item)=>item.id !== "inputing");
|
|
91
95
|
});
|
|
96
|
+
},
|
|
97
|
+
recordMsg: (msg)=>{
|
|
98
|
+
onRecordMessage(msg);
|
|
92
99
|
}
|
|
93
100
|
};
|
|
94
101
|
});
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
background: rgba(0, 0, 0, 0.02);
|
|
71
71
|
text-align: right;
|
|
72
72
|
height: 37px;
|
|
73
|
-
line-height: 37px
|
|
74
|
-
padding: 0
|
|
75
|
-
padding-right: 16px
|
|
73
|
+
line-height: 37px;
|
|
74
|
+
padding: 0 ;
|
|
75
|
+
padding-right: 16px ;
|
|
76
76
|
position: relative;
|
|
77
77
|
cursor: pointer;
|
|
78
|
-
font-weight: 400
|
|
78
|
+
font-weight: 400 ;
|
|
79
79
|
top: 6px;
|
|
80
80
|
&.copyCodeFun {
|
|
81
81
|
display: flex;
|
|
@@ -167,20 +167,20 @@
|
|
|
167
167
|
list-style: inside;
|
|
168
168
|
color: rgba(0, 0, 0, 0.85);
|
|
169
169
|
&::marker {
|
|
170
|
-
color: #d9d9d9
|
|
170
|
+
color: #d9d9d9;
|
|
171
171
|
}
|
|
172
172
|
&:first-child {
|
|
173
|
-
padding-top: 8px
|
|
173
|
+
padding-top: 8px;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
li > ol li {
|
|
177
177
|
// padding-bottom: 8px;
|
|
178
178
|
&::marker {
|
|
179
|
-
color: rgba(0, 0, 0, 0.45)
|
|
179
|
+
color: rgba(0, 0, 0, 0.45);
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
&:first-child {
|
|
183
|
-
padding-top: 8px
|
|
183
|
+
padding-top: 8px;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
> li:last-of-type {
|
|
@@ -202,10 +202,10 @@
|
|
|
202
202
|
padding-top: 8px;
|
|
203
203
|
padding-bottom: 8px;
|
|
204
204
|
&:first-child {
|
|
205
|
-
padding-top: 0
|
|
205
|
+
padding-top: 0;
|
|
206
206
|
}
|
|
207
207
|
&:last-child {
|
|
208
|
-
padding-bottom: 0
|
|
208
|
+
padding-bottom: 0;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
> h3,
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
}
|
|
234
234
|
table {
|
|
235
235
|
width: 100%;
|
|
236
|
-
padding: 0
|
|
236
|
+
padding: 0;
|
|
237
237
|
margin: 8px 0;
|
|
238
238
|
border-collapse: separate;
|
|
239
239
|
border-top: 1px solid #dfe6ec;
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
.msgItem-action-popover {
|
|
290
290
|
position: absolute;
|
|
291
291
|
width: max-content;
|
|
292
|
-
border-radius: 4px
|
|
292
|
+
border-radius: 4px;
|
|
293
293
|
background: #fff;
|
|
294
294
|
line-height: 1;
|
|
295
295
|
z-index: 9;
|
|
@@ -47,8 +47,10 @@ export interface contentConfigProps {
|
|
|
47
47
|
}>; // 列表数据
|
|
48
48
|
loadMore?: boolean; // 是否开启加载更多 // 默认为true
|
|
49
49
|
helloMsg?: string; //欢迎语
|
|
50
|
+
pageSize?: number;//每页数量 默认为30
|
|
50
51
|
coverRenderText?: (item, html) => React.ReactNode; // 覆盖文本内容
|
|
51
52
|
coverRenderReferences?: (item:dataItemType,referenceNode:React.ReactNode) => React.ReactNode;//覆盖引用内容
|
|
53
|
+
onRecordMessage?: (item: dataItemType,) => void;// 发送和接收的消息记录
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
// content props
|
|
@@ -221,6 +223,7 @@ export interface VirtuosoListRefProps {
|
|
|
221
223
|
addMsg: (msg: dataItemType) => void;
|
|
222
224
|
updateMsg: (id: string, obj: any) => void;
|
|
223
225
|
clearInputing: () => void;//清楚正在输入的inputing
|
|
226
|
+
recordMsg:(item: dataItemType) => void;
|
|
224
227
|
}
|
|
225
228
|
|
|
226
229
|
export interface contentRefProps extends VirtuosoListRefProps {}
|
|
@@ -37,6 +37,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
37
37
|
var _useState = _sliced_to_array(useState(""), 2), textValue = _useState[0], setTextValue = _useState[1];
|
|
38
38
|
var _useState1 = _sliced_to_array(useState(false), 2), sending = _useState1[0], setSending = _useState1[1];
|
|
39
39
|
var _useState2 = _sliced_to_array(useState(true), 2), fileCanSending = _useState2[0], setFileCanSending = _useState2[1]; // 是否允许发送 关联文件
|
|
40
|
+
var updateMsgRef = useRef(null);
|
|
40
41
|
// const [referencesSource, setReferencesSource] = useState<referenceType>({
|
|
41
42
|
// type: "file",
|
|
42
43
|
// value: {
|
|
@@ -72,6 +73,11 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
72
73
|
}
|
|
73
74
|
}, fileListRef.current);
|
|
74
75
|
});
|
|
76
|
+
useEffect(function() {
|
|
77
|
+
return function() {
|
|
78
|
+
clearTimeout(updateMsgRef.current);
|
|
79
|
+
};
|
|
80
|
+
}, []);
|
|
75
81
|
useEffect(function() {
|
|
76
82
|
recordRef.current.value = textValue;
|
|
77
83
|
recordRef.current.referencesSource = referencesSource;
|
|
@@ -202,6 +208,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
202
208
|
setSending(true);
|
|
203
209
|
setTextValue("");
|
|
204
210
|
setReferencesSource(null);
|
|
211
|
+
var recordMsgObj = {};
|
|
205
212
|
var arg = [
|
|
206
213
|
recordRef.current.value,
|
|
207
214
|
recordRef.current.referencesSource,
|
|
@@ -225,22 +232,31 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
225
232
|
var data = onMessage(ev);
|
|
226
233
|
msgContent += data.content;
|
|
227
234
|
delete data.content;
|
|
228
|
-
|
|
235
|
+
recordMsgObj = _object_spread({
|
|
229
236
|
createTime: createTime,
|
|
230
237
|
content: msgContent,
|
|
231
238
|
location: "left",
|
|
232
239
|
reference: null,
|
|
233
240
|
source: null
|
|
234
|
-
}, data)
|
|
235
|
-
|
|
241
|
+
}, data);
|
|
242
|
+
updateMsgRef.current = setTimeout(function() {
|
|
243
|
+
apiRef.contentApi.updateMsg(msgId, recordMsgObj);
|
|
244
|
+
msgId = data.id;
|
|
245
|
+
}, 100);
|
|
236
246
|
},
|
|
237
247
|
onclose: function() {
|
|
238
248
|
onClose();
|
|
239
249
|
setSending(false);
|
|
240
|
-
|
|
250
|
+
if (recordMsgObj.id) {
|
|
251
|
+
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
252
|
+
}
|
|
253
|
+
console.log("onclose: ", recordMsgObj);
|
|
241
254
|
},
|
|
242
255
|
onerror: function(err) {
|
|
243
256
|
onError(err);
|
|
257
|
+
if (recordMsgObj.id) {
|
|
258
|
+
apiRef.contentApi.recordMsg(recordMsgObj);
|
|
259
|
+
}
|
|
244
260
|
console.log("onerror: ", err);
|
|
245
261
|
}
|
|
246
262
|
}, coverProps));
|
|
@@ -47,14 +47,14 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
47
47
|
var getList = contentConfig.getList, coverRenderText = contentConfig.coverRenderText, _contentConfig_msgAction = contentConfig.msgAction, msgAction = _contentConfig_msgAction === void 0 ? [
|
|
48
48
|
"copy",
|
|
49
49
|
"references"
|
|
50
|
-
] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences;
|
|
50
|
+
] : _contentConfig_msgAction, coverRenderReferences = contentConfig.coverRenderReferences, _contentConfig_onRecordMessage = contentConfig.onRecordMessage, onRecordMessage = _contentConfig_onRecordMessage === void 0 ? function() {} : _contentConfig_onRecordMessage;
|
|
51
51
|
var loadMoreProps = contentConfig.loadMore || true;
|
|
52
52
|
var virtuosoRef = useRef(null);
|
|
53
53
|
var _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1]; // 是否加载中
|
|
54
54
|
var _useState1 = _sliced_to_array(useState([]), 2), dataSource = _useState1[0], setDataSource = _useState1[1];
|
|
55
55
|
var _useState2 = _sliced_to_array(useState(0), 2), firstItemIndex = _useState2[0], setFirstItemIndex = _useState2[1];
|
|
56
56
|
var _useState3 = _sliced_to_array(useState(1), 2), page = _useState3[0], setPage = _useState3[1];
|
|
57
|
-
var _useState4 = _sliced_to_array(useState(30), 2), pageSize = _useState4[0], setPageSize = _useState4[1];
|
|
57
|
+
var _useState4 = _sliced_to_array(useState(contentConfig.pageSize || 30), 2), pageSize = _useState4[0], setPageSize = _useState4[1];
|
|
58
58
|
var _useState5 = _sliced_to_array(useState(0), 2), total = _useState5[0], setTotal = _useState5[1];
|
|
59
59
|
var timerRef = useRef({
|
|
60
60
|
loadMore: null,
|
|
@@ -72,6 +72,10 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
72
72
|
useImperativeHandle(ref, function() {
|
|
73
73
|
return {
|
|
74
74
|
addMsg: function(msg) {
|
|
75
|
+
if (msg.id !== "inputing") {
|
|
76
|
+
// 不记录"正在输入..."的消息
|
|
77
|
+
onRecordMessage(msg);
|
|
78
|
+
}
|
|
75
79
|
setDataSource(function(data) {
|
|
76
80
|
return _to_consumable_array(data).concat([
|
|
77
81
|
msg
|
|
@@ -94,6 +98,9 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
94
98
|
return item.id !== "inputing";
|
|
95
99
|
});
|
|
96
100
|
});
|
|
101
|
+
},
|
|
102
|
+
recordMsg: function(msg) {
|
|
103
|
+
onRecordMessage(msg);
|
|
97
104
|
}
|
|
98
105
|
};
|
|
99
106
|
});
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
background: rgba(0, 0, 0, 0.02);
|
|
71
71
|
text-align: right;
|
|
72
72
|
height: 37px;
|
|
73
|
-
line-height: 37px
|
|
74
|
-
padding: 0
|
|
75
|
-
padding-right: 16px
|
|
73
|
+
line-height: 37px;
|
|
74
|
+
padding: 0 ;
|
|
75
|
+
padding-right: 16px ;
|
|
76
76
|
position: relative;
|
|
77
77
|
cursor: pointer;
|
|
78
|
-
font-weight: 400
|
|
78
|
+
font-weight: 400 ;
|
|
79
79
|
top: 6px;
|
|
80
80
|
&.copyCodeFun {
|
|
81
81
|
display: flex;
|
|
@@ -167,20 +167,20 @@
|
|
|
167
167
|
list-style: inside;
|
|
168
168
|
color: rgba(0, 0, 0, 0.85);
|
|
169
169
|
&::marker {
|
|
170
|
-
color: #d9d9d9
|
|
170
|
+
color: #d9d9d9;
|
|
171
171
|
}
|
|
172
172
|
&:first-child {
|
|
173
|
-
padding-top: 8px
|
|
173
|
+
padding-top: 8px;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
li > ol li {
|
|
177
177
|
// padding-bottom: 8px;
|
|
178
178
|
&::marker {
|
|
179
|
-
color: rgba(0, 0, 0, 0.45)
|
|
179
|
+
color: rgba(0, 0, 0, 0.45);
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
&:first-child {
|
|
183
|
-
padding-top: 8px
|
|
183
|
+
padding-top: 8px;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
> li:last-of-type {
|
|
@@ -202,10 +202,10 @@
|
|
|
202
202
|
padding-top: 8px;
|
|
203
203
|
padding-bottom: 8px;
|
|
204
204
|
&:first-child {
|
|
205
|
-
padding-top: 0
|
|
205
|
+
padding-top: 0;
|
|
206
206
|
}
|
|
207
207
|
&:last-child {
|
|
208
|
-
padding-bottom: 0
|
|
208
|
+
padding-bottom: 0;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
> h3,
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
}
|
|
234
234
|
table {
|
|
235
235
|
width: 100%;
|
|
236
|
-
padding: 0
|
|
236
|
+
padding: 0;
|
|
237
237
|
margin: 8px 0;
|
|
238
238
|
border-collapse: separate;
|
|
239
239
|
border-top: 1px solid #dfe6ec;
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
.msgItem-action-popover {
|
|
290
290
|
position: absolute;
|
|
291
291
|
width: max-content;
|
|
292
|
-
border-radius: 4px
|
|
292
|
+
border-radius: 4px;
|
|
293
293
|
background: #fff;
|
|
294
294
|
line-height: 1;
|
|
295
295
|
z-index: 9;
|
|
@@ -47,8 +47,10 @@ export interface contentConfigProps {
|
|
|
47
47
|
}>; // 列表数据
|
|
48
48
|
loadMore?: boolean; // 是否开启加载更多 // 默认为true
|
|
49
49
|
helloMsg?: string; //欢迎语
|
|
50
|
+
pageSize?: number;//每页数量 默认为30
|
|
50
51
|
coverRenderText?: (item, html) => React.ReactNode; // 覆盖文本内容
|
|
51
52
|
coverRenderReferences?: (item:dataItemType,referenceNode:React.ReactNode) => React.ReactNode;//覆盖引用内容
|
|
53
|
+
onRecordMessage?: (item: dataItemType,) => void;// 发送和接收的消息记录
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
// content props
|
|
@@ -221,6 +223,7 @@ export interface VirtuosoListRefProps {
|
|
|
221
223
|
addMsg: (msg: dataItemType) => void;
|
|
222
224
|
updateMsg: (id: string, obj: any) => void;
|
|
223
225
|
clearInputing: () => void;//清楚正在输入的inputing
|
|
226
|
+
recordMsg:(item: dataItemType) => void;
|
|
224
227
|
}
|
|
225
228
|
|
|
226
229
|
export interface contentRefProps extends VirtuosoListRefProps {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bhd-components",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "组件功能描述",
|
|
5
5
|
"config": {
|
|
6
6
|
"commitizen": {
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"raw-loader": "^4.0.2",
|
|
80
80
|
"react-cropper": "^2.3.3",
|
|
81
81
|
"react-image-crop": "^11.0.5",
|
|
82
|
-
"react-virtuoso": "^
|
|
82
|
+
"react-virtuoso": "^3.1.5",
|
|
83
83
|
"remarkable": "^2.0.1"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|