bhd-components 0.10.51 → 0.10.52
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.js +47 -18
- 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/footer/index.js +1 -0
- package/es2017/AIMessageList/components/virtuosoList/index.js +46 -18
- package/es2017/AIMessageList/type.d.ts +1 -0
- package/esm/AIMessageList/components/footer/index.js +1 -0
- package/esm/AIMessageList/components/virtuosoList/index.js +46 -18
- package/esm/AIMessageList/type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -14918,10 +14918,13 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
14918
14918
|
var _useState4 = _sliced_to_array(useState(""), 2), sendingId = _useState4[0], setSendingId = _useState4[1];
|
|
14919
14919
|
var _useState5 = _sliced_to_array(useState(contentConfig.pageSize || 30), 2), pageSize = _useState5[0], setPageSize = _useState5[1];
|
|
14920
14920
|
var _useState6 = _sliced_to_array(useState(0), 2), total = _useState6[0], setTotal = _useState6[1];
|
|
14921
|
+
var _useState7 = _sliced_to_array(useState(false), 2), isSending = _useState7[0], setIsSending = _useState7[1];
|
|
14921
14922
|
var timerRef = useRef({
|
|
14922
14923
|
loadMore: null,
|
|
14923
14924
|
scrollTimer: null
|
|
14924
14925
|
});
|
|
14926
|
+
var userScrolledUpRef = useRef(false); // 用户滚动啦滚动条
|
|
14927
|
+
var isAutoScrollRef = useRef(true); // 是否自动触底
|
|
14925
14928
|
var wrapperRef = useRef(null);
|
|
14926
14929
|
var recordRef = useRef({
|
|
14927
14930
|
page: page,
|
|
@@ -14929,10 +14932,10 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
14929
14932
|
total: total,
|
|
14930
14933
|
dataSource: dataSource,
|
|
14931
14934
|
maxPage: Math.ceil(total / pageSize),
|
|
14932
|
-
sendingId: ""
|
|
14935
|
+
sendingId: "",
|
|
14936
|
+
isSending: isSending
|
|
14933
14937
|
});
|
|
14934
14938
|
var timeRenderCache = useRef(new Map()).current;
|
|
14935
|
-
var autoScrollBottom = useRef(true);
|
|
14936
14939
|
// const htmlRenderCache = useRef(new Map<string, React.ReactNode>()).current;
|
|
14937
14940
|
useImperativeHandle(ref, function() {
|
|
14938
14941
|
return {
|
|
@@ -14976,6 +14979,13 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
14976
14979
|
scrollToBottom: scrollToBottom,
|
|
14977
14980
|
setSendingId: function(id) {
|
|
14978
14981
|
setSendingId(id);
|
|
14982
|
+
},
|
|
14983
|
+
setIsSending: function(flag) {
|
|
14984
|
+
if (!flag) {
|
|
14985
|
+
isAutoScrollRef.current = true;
|
|
14986
|
+
userScrolledUpRef.current = false;
|
|
14987
|
+
}
|
|
14988
|
+
setIsSending(flag);
|
|
14979
14989
|
}
|
|
14980
14990
|
};
|
|
14981
14991
|
});
|
|
@@ -15028,15 +15038,17 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
15028
15038
|
recordRef.current.dataSource = dataSource;
|
|
15029
15039
|
recordRef.current.maxPage = Math.ceil(total / pageSize);
|
|
15030
15040
|
recordRef.current.sendingId = sendingId;
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15041
|
+
recordRef.current.isSending = isSending;
|
|
15042
|
+
// if (!sendingId) {
|
|
15043
|
+
// autoScrollBottom.current = true;
|
|
15044
|
+
// }
|
|
15034
15045
|
}, [
|
|
15035
15046
|
page,
|
|
15036
15047
|
pageSize,
|
|
15037
15048
|
total,
|
|
15038
15049
|
dataSource,
|
|
15039
|
-
sendingId
|
|
15050
|
+
sendingId,
|
|
15051
|
+
isSending
|
|
15040
15052
|
]);
|
|
15041
15053
|
var addMsg = function(msg) {
|
|
15042
15054
|
if (msg.id !== "inputing" && msg.id !== "helloMsg") {
|
|
@@ -15066,14 +15078,16 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
15066
15078
|
scrollToBottom();
|
|
15067
15079
|
};
|
|
15068
15080
|
var scrollToBottom = function() {
|
|
15069
|
-
if (!virtuosoRef.current
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15081
|
+
if (!virtuosoRef.current) return;
|
|
15082
|
+
if (isAutoScrollRef.current && !userScrolledUpRef.current) {
|
|
15083
|
+
timerRef.current.scrollTimer = setTimeout(function() {
|
|
15084
|
+
virtuosoRef.current.scrollToIndex({
|
|
15085
|
+
index: "LAST",
|
|
15086
|
+
align: "end",
|
|
15087
|
+
behavior: "auto"
|
|
15088
|
+
});
|
|
15089
|
+
}, 100);
|
|
15090
|
+
}
|
|
15077
15091
|
};
|
|
15078
15092
|
var getData = function(page, pageSize) {
|
|
15079
15093
|
setLoading(true);
|
|
@@ -15517,9 +15531,23 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
15517
15531
|
p[0].innerText = "复制代码";
|
|
15518
15532
|
}
|
|
15519
15533
|
};
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
|
|
15534
|
+
// 滚动位置变化处理
|
|
15535
|
+
var handleScroll = function(event) {
|
|
15536
|
+
if (!recordRef.current.isSending) return;
|
|
15537
|
+
var element = event.target;
|
|
15538
|
+
var scrollTop = element.scrollTop;
|
|
15539
|
+
var scrollHeight = element.scrollHeight;
|
|
15540
|
+
var clientHeight = element.clientHeight;
|
|
15541
|
+
// 如果距离底部小于30px,认为是底部,重新启用自动滚动
|
|
15542
|
+
var distanceToBottom = scrollHeight - scrollTop - clientHeight;
|
|
15543
|
+
// console.log('handleScroll:', distanceToBottom, scrollTop, scrollHeight, clientHeight);
|
|
15544
|
+
if (distanceToBottom < 30) {
|
|
15545
|
+
userScrolledUpRef.current = false;
|
|
15546
|
+
isAutoScrollRef.current = true;
|
|
15547
|
+
} else {
|
|
15548
|
+
// 用户向上滚动,禁用自动滚动
|
|
15549
|
+
userScrolledUpRef.current = true;
|
|
15550
|
+
isAutoScrollRef.current = false;
|
|
15523
15551
|
}
|
|
15524
15552
|
};
|
|
15525
15553
|
return /*#__PURE__*/ jsx("div", {
|
|
@@ -15548,7 +15576,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
15548
15576
|
},
|
|
15549
15577
|
increaseViewportBy: 200,
|
|
15550
15578
|
overscan: 10,
|
|
15551
|
-
|
|
15579
|
+
onScroll: handleScroll
|
|
15552
15580
|
})
|
|
15553
15581
|
});
|
|
15554
15582
|
});
|
|
@@ -16156,6 +16184,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
16156
16184
|
recordRef.current.value = textValue;
|
|
16157
16185
|
recordRef.current.referencesSource = referencesSource;
|
|
16158
16186
|
recordRef.current.sending = sending;
|
|
16187
|
+
apiRef.contentApi && apiRef.contentApi.setIsSending(sending);
|
|
16159
16188
|
}, [
|
|
16160
16189
|
textValue,
|
|
16161
16190
|
referencesSource,
|