bhd-components 0.10.41 → 0.10.42

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # bhd-components
2
2
 
3
- **当前版本:** 0.10.13
3
+ **当前版本:** 0.10.42
4
4
 
5
5
  ## Install
6
6
 
@@ -14902,6 +14902,8 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
14902
14902
  loadMore: null,
14903
14903
  scrollTimer: null
14904
14904
  });
14905
+ var userScrolledUpRef = useRef(false);
14906
+ var isAutoScrollRef = useRef(true);
14905
14907
  var wrapperRef = useRef(null);
14906
14908
  var recordRef = useRef({
14907
14909
  page: page,
@@ -14912,8 +14914,6 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
14912
14914
  sendingId: ""
14913
14915
  });
14914
14916
  var timeRenderCache = useRef(new Map()).current;
14915
- var autoScrollBottom = useRef(true);
14916
- useRef(new Map()).current;
14917
14917
  useImperativeHandle(ref, function() {
14918
14918
  return {
14919
14919
  addMsg: addMsg,
@@ -15007,9 +15007,6 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
15007
15007
  recordRef.current.dataSource = dataSource;
15008
15008
  recordRef.current.maxPage = Math.ceil(total / pageSize);
15009
15009
  recordRef.current.sendingId = sendingId;
15010
- if (!sendingId) {
15011
- autoScrollBottom.current = true;
15012
- }
15013
15010
  }, [
15014
15011
  page,
15015
15012
  pageSize,
@@ -15045,13 +15042,15 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
15045
15042
  scrollToBottom();
15046
15043
  };
15047
15044
  var scrollToBottom = function() {
15048
- if (!virtuosoRef.current || !autoScrollBottom.current) return;
15045
+ if (!virtuosoRef.current) return;
15049
15046
  timerRef.current.scrollTimer = setTimeout(function() {
15050
- virtuosoRef.current.scrollToIndex({
15051
- index: "LAST",
15052
- align: "end",
15053
- behavior: "auto"
15054
- });
15047
+ if (isAutoScrollRef.current && !userScrolledUpRef.current) {
15048
+ virtuosoRef.current.scrollToIndex({
15049
+ index: "LAST",
15050
+ align: "end",
15051
+ behavior: "auto"
15052
+ });
15053
+ }
15055
15054
  }, 100);
15056
15055
  };
15057
15056
  var getData = function(page, pageSize) {
@@ -15496,9 +15495,20 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
15496
15495
  p[0].innerText = "复制代码";
15497
15496
  }
15498
15497
  };
15499
- var onWheel = function() {
15500
- if (recordRef.current.sendingId && recordRef.current.sendingId !== "inputing") {
15501
- autoScrollBottom.current = false;
15498
+ var handleScroll = function(event) {
15499
+ var element = event.target;
15500
+ var scrollTop = element.scrollTop;
15501
+ var scrollHeight = element.scrollHeight;
15502
+ var clientHeight = element.clientHeight;
15503
+ // 如果距离底部小于30px,认为是底部,重新启用自动滚动
15504
+ var distanceToBottom = scrollHeight - scrollTop - clientHeight;
15505
+ if (distanceToBottom < 30) {
15506
+ userScrolledUpRef.current = false;
15507
+ isAutoScrollRef.current = true;
15508
+ } else {
15509
+ // 用户向上滚动,禁用自动滚动
15510
+ userScrolledUpRef.current = true;
15511
+ isAutoScrollRef.current = false;
15502
15512
  }
15503
15513
  };
15504
15514
  return /*#__PURE__*/ jsx("div", {
@@ -15527,7 +15537,7 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
15527
15537
  },
15528
15538
  increaseViewportBy: 200,
15529
15539
  overscan: 10,
15530
- onWheel: onWheel
15540
+ onScroll: handleScroll
15531
15541
  })
15532
15542
  });
15533
15543
  });
@@ -16104,6 +16114,9 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
16104
16114
  useImperativeHandle(ref, function() {
16105
16115
  return _object_spread({
16106
16116
  setTextValue: setTextValue,
16117
+ getTextValue: function() {
16118
+ return recordRef.current.value;
16119
+ },
16107
16120
  sendMsg: sendMsg,
16108
16121
  refreshSendMsg: refreshSendMsg,
16109
16122
  sendMsgLeft: sendMsgLeft,