pb-sxp-ui 1.19.8 → 1.19.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.cjs +90 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +6 -2
- package/dist/index.js +90 -4
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +90 -4
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/index.js +25 -4
- package/es/core/hooks/useVisibleHeight.d.ts +1 -0
- package/es/core/hooks/useVisibleHeight.js +52 -0
- package/lib/core/components/SxpPageRender/index.js +25 -4
- package/lib/core/hooks/useVisibleHeight.d.ts +1 -0
- package/lib/core/hooks/useVisibleHeight.js +56 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -19000,6 +19000,70 @@ const NavBack = ({ data, minusHeight, tagHeight, onClick }) => {
|
|
|
19000
19000
|
};
|
|
19001
19001
|
var NavBack$1 = React.memo(NavBack);
|
|
19002
19002
|
|
|
19003
|
+
const useVisibleHeight = () => {
|
|
19004
|
+
const [visibleHeight, setVisibleHeight] = React.useState(0);
|
|
19005
|
+
const getVisibleContentHeight = () => {
|
|
19006
|
+
// 方法优先级:
|
|
19007
|
+
// 1. visualViewport.height (最准确)
|
|
19008
|
+
// 2. window.innerHeight (次之)
|
|
19009
|
+
// 3. document.documentElement.clientHeight (fallback)
|
|
19010
|
+
if (typeof window === 'undefined')
|
|
19011
|
+
return 0;
|
|
19012
|
+
let height = window.innerHeight;
|
|
19013
|
+
// 优先使用 visualViewport
|
|
19014
|
+
if (window.visualViewport) {
|
|
19015
|
+
height = window.visualViewport.height;
|
|
19016
|
+
}
|
|
19017
|
+
// 验证高度合理性
|
|
19018
|
+
if (height <= 0 || height > window.screen.height) {
|
|
19019
|
+
height = window.innerHeight;
|
|
19020
|
+
}
|
|
19021
|
+
// 最终 fallback
|
|
19022
|
+
if (height <= 0) {
|
|
19023
|
+
height = document.documentElement.clientHeight;
|
|
19024
|
+
}
|
|
19025
|
+
return height;
|
|
19026
|
+
};
|
|
19027
|
+
const updateHeight = React.useCallback(() => {
|
|
19028
|
+
const height = getVisibleContentHeight();
|
|
19029
|
+
setVisibleHeight(height);
|
|
19030
|
+
}, []);
|
|
19031
|
+
React.useEffect(() => {
|
|
19032
|
+
// 初始计算
|
|
19033
|
+
updateHeight();
|
|
19034
|
+
// 事件监听
|
|
19035
|
+
const events = ['resize', 'orientationchange', 'load', 'DOMContentLoaded'];
|
|
19036
|
+
events.forEach((event) => {
|
|
19037
|
+
window.addEventListener(event, updateHeight);
|
|
19038
|
+
});
|
|
19039
|
+
// visualViewport 监听(最重要)
|
|
19040
|
+
if (window.visualViewport) {
|
|
19041
|
+
window.visualViewport.addEventListener('resize', updateHeight);
|
|
19042
|
+
window.visualViewport.addEventListener('scroll', updateHeight);
|
|
19043
|
+
}
|
|
19044
|
+
// 键盘弹出/收起监听(移动端重要)
|
|
19045
|
+
if ('virtualKeyboard' in navigator) {
|
|
19046
|
+
navigator.virtualKeyboard.addEventListener('geometrychange', updateHeight);
|
|
19047
|
+
}
|
|
19048
|
+
// 定期检查(应对某些特殊情况)
|
|
19049
|
+
const interval = setInterval(updateHeight, 1000);
|
|
19050
|
+
return () => {
|
|
19051
|
+
events.forEach((event) => {
|
|
19052
|
+
window.removeEventListener(event, updateHeight);
|
|
19053
|
+
});
|
|
19054
|
+
if (window.visualViewport) {
|
|
19055
|
+
window.visualViewport.removeEventListener('resize', updateHeight);
|
|
19056
|
+
window.visualViewport.removeEventListener('scroll', updateHeight);
|
|
19057
|
+
}
|
|
19058
|
+
if ('virtualKeyboard' in navigator) {
|
|
19059
|
+
navigator.virtualKeyboard.removeEventListener('geometrychange', updateHeight);
|
|
19060
|
+
}
|
|
19061
|
+
clearInterval(interval);
|
|
19062
|
+
};
|
|
19063
|
+
}, [updateHeight]);
|
|
19064
|
+
return visibleHeight;
|
|
19065
|
+
};
|
|
19066
|
+
|
|
19003
19067
|
/*
|
|
19004
19068
|
* @Author: binruan@chatlabs.com
|
|
19005
19069
|
* @Date: 2024-03-20 10:27:31
|
|
@@ -19028,6 +19092,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
|
19028
19092
|
const fbcRef = React.useRef('');
|
|
19029
19093
|
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();
|
|
19030
19094
|
const { backMainFeed, productView, jumpToWeb } = useEventReport();
|
|
19095
|
+
const visibleHeight = useVisibleHeight();
|
|
19031
19096
|
const isShowFingerTip = React.useMemo(() => {
|
|
19032
19097
|
return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
|
|
19033
19098
|
}, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
|
|
@@ -19196,9 +19261,24 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
|
19196
19261
|
}
|
|
19197
19262
|
return minusHeight;
|
|
19198
19263
|
}, [globalConfig]);
|
|
19264
|
+
const getHeightWithSafeArea = () => {
|
|
19265
|
+
// 获取窗口高度
|
|
19266
|
+
// 动态检测安全区域
|
|
19267
|
+
const detector = document.createElement('div');
|
|
19268
|
+
detector.style.position = 'fixed';
|
|
19269
|
+
detector.style.bottom = '0';
|
|
19270
|
+
detector.style.left = '0';
|
|
19271
|
+
detector.style.paddingBottom = 'env(safe-area-inset-bottom)';
|
|
19272
|
+
detector.style.visibility = 'hidden';
|
|
19273
|
+
document.body.appendChild(detector);
|
|
19274
|
+
const computedStyle = window.getComputedStyle(detector);
|
|
19275
|
+
const safeAreaBottom = parseFloat(computedStyle.paddingBottom) || 0;
|
|
19276
|
+
document.body.removeChild(detector);
|
|
19277
|
+
return safeAreaBottom;
|
|
19278
|
+
};
|
|
19199
19279
|
const height = React.useMemo(() => {
|
|
19200
|
-
return
|
|
19201
|
-
}, [minusHeight,
|
|
19280
|
+
return visibleHeight - minusHeight - tagHeight;
|
|
19281
|
+
}, [minusHeight, visibleHeight, tagHeight]);
|
|
19202
19282
|
const visList = React.useMemo(() => {
|
|
19203
19283
|
var _a;
|
|
19204
19284
|
const list = activeIndex === 0 && !waterFallData && !isEditor && !isDiyH5
|
|
@@ -19339,6 +19419,9 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
|
19339
19419
|
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconYPosit) === 'top') {
|
|
19340
19420
|
top += minusHeight;
|
|
19341
19421
|
}
|
|
19422
|
+
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconFixed) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconYPosit) !== 'top') {
|
|
19423
|
+
top += getHeightWithSafeArea();
|
|
19424
|
+
}
|
|
19342
19425
|
if (rec === null || rec === void 0 ? void 0 : rec.video) {
|
|
19343
19426
|
return (React.createElement(LikeButton$1, { key: rec.position, activeIcon: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIcon, unActicveIcon: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unlikeIcon, active: rec.isCollected, recData: rec, className: 'clc-sxp-like-button', style: {
|
|
19344
19427
|
position: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconFixed) ? 'fixed' : 'absolute',
|
|
@@ -19573,6 +19656,9 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
|
19573
19656
|
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) === 'top') {
|
|
19574
19657
|
top += minusHeight;
|
|
19575
19658
|
}
|
|
19659
|
+
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) !== 'top') {
|
|
19660
|
+
top += getHeightWithSafeArea();
|
|
19661
|
+
}
|
|
19576
19662
|
return (((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === true) && (React.createElement(ToggleButton$1, { style: {
|
|
19577
19663
|
position: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed) ? 'fixed' : 'absolute',
|
|
19578
19664
|
visibility: ((_c = (_b = visList === null || visList === void 0 ? void 0 : visList[activeIndex]) === null || _b === void 0 ? void 0 : _b.video) === null || _c === void 0 ? void 0 : _c.url) ? 'visible' : 'hidden',
|
|
@@ -19675,10 +19761,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
|
19675
19761
|
renderToggleButton(!!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed))),
|
|
19676
19762
|
React.createElement(WaterFall$1, Object.assign({}, (_u = (_t = (_s = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.item) === null || _u === void 0 ? void 0 : _u.props)),
|
|
19677
19763
|
React.createElement(ConsentPopup, { resolver: resolver, globalConfig: globalConfig }),
|
|
19678
|
-
openMultiPosts && (React.createElement(MultiPosts$2, Object.assign({}, (_x = (_w = (_v = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _v === void 0 ? void 0 : _v[0]) === null || _w === void 0 ? void 0 : _w.item) === null || _x === void 0 ? void 0 : _x.props, (_0 = (_z = (_y = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _y === void 0 ? void 0 : _y[0]) === null || _z === void 0 ? void 0 : _z.item) === null || _0 === void 0 ? void 0 : _0.event, { style: { position: 'fixed', top: 0, left: 0, right: 0 } }))))),
|
|
19764
|
+
openMultiPosts && (React.createElement(MultiPosts$2, Object.assign({}, (_x = (_w = (_v = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _v === void 0 ? void 0 : _v[0]) === null || _w === void 0 ? void 0 : _w.item) === null || _x === void 0 ? void 0 : _x.props, (_0 = (_z = (_y = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.multiPosts) === null || _y === void 0 ? void 0 : _y[0]) === null || _z === void 0 ? void 0 : _z.item) === null || _0 === void 0 ? void 0 : _0.event, { style: { position: 'fixed', top: 0, left: 0, right: 0, bottom: 'env(safe-area-inset-bottom)' } }))))),
|
|
19679
19765
|
(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableCookieSetting) && (React.createElement("div", { style: {
|
|
19680
19766
|
position: 'fixed',
|
|
19681
|
-
bottom:
|
|
19767
|
+
bottom: 'env(safe-area-inset-bottom)',
|
|
19682
19768
|
left: 0,
|
|
19683
19769
|
right: 0,
|
|
19684
19770
|
width: '100%',
|