pb-sxp-ui 1.19.9 → 1.19.11

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.css CHANGED
@@ -62,6 +62,10 @@ a:active {
62
62
  .swiper-button-next,.swiper-button-prev{
63
63
  color: #000;
64
64
  outline: none;
65
+ }
66
+
67
+ :root {
68
+ --safe-area-inset-bottom: env(safe-area-inset-bottom);
65
69
  }
66
70
  .pb-appoint-form {
67
71
  position: relative;
package/dist/index.js CHANGED
@@ -18978,6 +18978,70 @@ const NavBack = ({ data, minusHeight, tagHeight, onClick }) => {
18978
18978
  };
18979
18979
  var NavBack$1 = memo(NavBack);
18980
18980
 
18981
+ const useVisibleHeight = () => {
18982
+ const [visibleHeight, setVisibleHeight] = useState(0);
18983
+ const getVisibleContentHeight = () => {
18984
+ // 方法优先级:
18985
+ // 1. visualViewport.height (最准确)
18986
+ // 2. window.innerHeight (次之)
18987
+ // 3. document.documentElement.clientHeight (fallback)
18988
+ if (typeof window === 'undefined')
18989
+ return 0;
18990
+ let height = window.innerHeight;
18991
+ // 优先使用 visualViewport
18992
+ if (window.visualViewport) {
18993
+ height = window.visualViewport.height;
18994
+ }
18995
+ // 验证高度合理性
18996
+ if (height <= 0 || height > window.screen.height) {
18997
+ height = window.innerHeight;
18998
+ }
18999
+ // 最终 fallback
19000
+ if (height <= 0) {
19001
+ height = document.documentElement.clientHeight;
19002
+ }
19003
+ return height;
19004
+ };
19005
+ const updateHeight = useCallback(() => {
19006
+ const height = getVisibleContentHeight();
19007
+ setVisibleHeight(height);
19008
+ }, []);
19009
+ useEffect(() => {
19010
+ // 初始计算
19011
+ updateHeight();
19012
+ // 事件监听
19013
+ const events = ['resize', 'orientationchange', 'load', 'DOMContentLoaded'];
19014
+ events.forEach((event) => {
19015
+ window.addEventListener(event, updateHeight);
19016
+ });
19017
+ // visualViewport 监听(最重要)
19018
+ if (window.visualViewport) {
19019
+ window.visualViewport.addEventListener('resize', updateHeight);
19020
+ window.visualViewport.addEventListener('scroll', updateHeight);
19021
+ }
19022
+ // 键盘弹出/收起监听(移动端重要)
19023
+ if ('virtualKeyboard' in navigator) {
19024
+ navigator.virtualKeyboard.addEventListener('geometrychange', updateHeight);
19025
+ }
19026
+ // 定期检查(应对某些特殊情况)
19027
+ const interval = setInterval(updateHeight, 1000);
19028
+ return () => {
19029
+ events.forEach((event) => {
19030
+ window.removeEventListener(event, updateHeight);
19031
+ });
19032
+ if (window.visualViewport) {
19033
+ window.visualViewport.removeEventListener('resize', updateHeight);
19034
+ window.visualViewport.removeEventListener('scroll', updateHeight);
19035
+ }
19036
+ if ('virtualKeyboard' in navigator) {
19037
+ navigator.virtualKeyboard.removeEventListener('geometrychange', updateHeight);
19038
+ }
19039
+ clearInterval(interval);
19040
+ };
19041
+ }, [updateHeight]);
19042
+ return visibleHeight;
19043
+ };
19044
+
18981
19045
  /*
18982
19046
  * @Author: binruan@chatlabs.com
18983
19047
  * @Date: 2024-03-20 10:27:31
@@ -19006,6 +19070,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19006
19070
  const fbcRef = useRef('');
19007
19071
  const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData, bffFbReport, curTime, h5EnterLink, isShowConsent, selectTag, isPreview, isEditor, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, isNoMoreData, channel, refreshFeSession, isDiyH5, pixelPvStatusRef } = useSxpDataSource();
19008
19072
  const { backMainFeed, productView, jumpToWeb } = useEventReport();
19073
+ useVisibleHeight();
19009
19074
  const isShowFingerTip = useMemo(() => {
19010
19075
  return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
19011
19076
  }, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
@@ -19175,6 +19240,13 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19175
19240
  return minusHeight;
19176
19241
  }, [globalConfig]);
19177
19242
  const getHeightWithSafeArea = () => {
19243
+ const root = document.documentElement;
19244
+ const value = getComputedStyle(root).getPropertyValue('--safe-area-inset-bottom');
19245
+ // 处理可能的值(可能是 '0px', '34px' 等)
19246
+ const numericValue = parseInt(value) || 0;
19247
+ return numericValue;
19248
+ };
19249
+ const getHeightWithSafeArea2 = () => {
19178
19250
  // 获取窗口高度
19179
19251
  // 动态检测安全区域
19180
19252
  const detector = document.createElement('div');
@@ -19190,8 +19262,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
19190
19262
  return safeAreaBottom;
19191
19263
  };
19192
19264
  const height = useMemo(() => {
19193
- return containerHeight - minusHeight - tagHeight - getHeightWithSafeArea();
19194
- }, [minusHeight, containerHeight, tagHeight]);
19265
+ return containerHeight - minusHeight - tagHeight - getHeightWithSafeArea2();
19266
+ }, [minusHeight, containerHeight, tagHeight, getHeightWithSafeArea2]);
19195
19267
  const visList = useMemo(() => {
19196
19268
  var _a;
19197
19269
  const list = activeIndex === 0 && !waterFallData && !isEditor && !isDiyH5