pb-sxp-ui 1.19.9 → 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.
@@ -27,6 +27,7 @@ import MultiPosts from '../../../materials/sxp/MultiPosts';
27
27
  import { useEditorDataProvider } from '../../../core/context/EditorDataProvider';
28
28
  import NavBack from './NavBack';
29
29
  import { deleteCookie, getCookie } from '../../../core/utils/tool';
30
+ import { useVisibleHeight } from '../../../core/hooks/useVisibleHeight';
30
31
  const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, hashTagRightMargin, tagList = [], defaultData }) => {
31
32
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
32
33
  const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png');
@@ -47,6 +48,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
47
48
  const fbcRef = useRef('');
48
49
  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();
49
50
  const { backMainFeed, productView, jumpToWeb } = useEventReport();
51
+ const visibleHeight = useVisibleHeight();
50
52
  const isShowFingerTip = useMemo(() => {
51
53
  return data.length > 0 && !loading && (getFeUserState() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
52
54
  }, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
@@ -226,8 +228,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
226
228
  return safeAreaBottom;
227
229
  };
228
230
  const height = useMemo(() => {
229
- return containerHeight - minusHeight - tagHeight - getHeightWithSafeArea();
230
- }, [minusHeight, containerHeight, tagHeight]);
231
+ return visibleHeight - minusHeight - tagHeight;
232
+ }, [minusHeight, visibleHeight, tagHeight]);
231
233
  const visList = useMemo(() => {
232
234
  var _a;
233
235
  const list = activeIndex === 0 && !waterFallData && !isEditor && !isDiyH5
@@ -0,0 +1 @@
1
+ export declare const useVisibleHeight: () => number;
@@ -0,0 +1,52 @@
1
+ import { useState, useEffect, useCallback } from 'react';
2
+ export const useVisibleHeight = () => {
3
+ const [visibleHeight, setVisibleHeight] = useState(0);
4
+ const getVisibleContentHeight = () => {
5
+ if (typeof window === 'undefined')
6
+ return 0;
7
+ let height = window.innerHeight;
8
+ if (window.visualViewport) {
9
+ height = window.visualViewport.height;
10
+ }
11
+ if (height <= 0 || height > window.screen.height) {
12
+ height = window.innerHeight;
13
+ }
14
+ if (height <= 0) {
15
+ height = document.documentElement.clientHeight;
16
+ }
17
+ return height;
18
+ };
19
+ const updateHeight = useCallback(() => {
20
+ const height = getVisibleContentHeight();
21
+ setVisibleHeight(height);
22
+ }, []);
23
+ useEffect(() => {
24
+ updateHeight();
25
+ const events = ['resize', 'orientationchange', 'load', 'DOMContentLoaded'];
26
+ events.forEach((event) => {
27
+ window.addEventListener(event, updateHeight);
28
+ });
29
+ if (window.visualViewport) {
30
+ window.visualViewport.addEventListener('resize', updateHeight);
31
+ window.visualViewport.addEventListener('scroll', updateHeight);
32
+ }
33
+ if ('virtualKeyboard' in navigator) {
34
+ navigator.virtualKeyboard.addEventListener('geometrychange', updateHeight);
35
+ }
36
+ const interval = setInterval(updateHeight, 1000);
37
+ return () => {
38
+ events.forEach((event) => {
39
+ window.removeEventListener(event, updateHeight);
40
+ });
41
+ if (window.visualViewport) {
42
+ window.visualViewport.removeEventListener('resize', updateHeight);
43
+ window.visualViewport.removeEventListener('scroll', updateHeight);
44
+ }
45
+ if ('virtualKeyboard' in navigator) {
46
+ navigator.virtualKeyboard.removeEventListener('geometrychange', updateHeight);
47
+ }
48
+ clearInterval(interval);
49
+ };
50
+ }, [updateHeight]);
51
+ return visibleHeight;
52
+ };
@@ -30,6 +30,7 @@ const MultiPosts_1 = tslib_1.__importDefault(require("../../../materials/sxp/Mul
30
30
  const EditorDataProvider_1 = require("../../../core/context/EditorDataProvider");
31
31
  const NavBack_1 = tslib_1.__importDefault(require("./NavBack"));
32
32
  const tool_1 = require("../../../core/utils/tool");
33
+ const useVisibleHeight_1 = require("../../../core/hooks/useVisibleHeight");
33
34
  const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.innerHeight, containerWidth = window.innerWidth, tempMap, resolver, data = [], ctaType, tipText, nudge, _schema, hashTagStyle, hashTagRightMargin, tagList = [], defaultData }) => {
34
35
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
35
36
  const mutedIcon = (0, useIconLink_1.useIconLink)('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png');
@@ -50,6 +51,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
50
51
  const fbcRef = (0, react_1.useRef)('');
51
52
  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 } = (0, hooks_1.useSxpDataSource)();
52
53
  const { backMainFeed, productView, jumpToWeb } = (0, useEventReport_1.useEventReport)();
54
+ const visibleHeight = (0, useVisibleHeight_1.useVisibleHeight)();
53
55
  const isShowFingerTip = (0, react_1.useMemo)(() => {
54
56
  return data.length > 0 && !loading && ((0, localStore_1.getFeUserState)() || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip));
55
57
  }, [data, loading, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enableSwiperTip]);
@@ -229,8 +231,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
229
231
  return safeAreaBottom;
230
232
  };
231
233
  const height = (0, react_1.useMemo)(() => {
232
- return containerHeight - minusHeight - tagHeight - getHeightWithSafeArea();
233
- }, [minusHeight, containerHeight, tagHeight]);
234
+ return visibleHeight - minusHeight - tagHeight;
235
+ }, [minusHeight, visibleHeight, tagHeight]);
234
236
  const visList = (0, react_1.useMemo)(() => {
235
237
  var _a;
236
238
  const list = activeIndex === 0 && !waterFallData && !isEditor && !isDiyH5
@@ -0,0 +1 @@
1
+ export declare const useVisibleHeight: () => number;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useVisibleHeight = void 0;
4
+ const react_1 = require("react");
5
+ const useVisibleHeight = () => {
6
+ const [visibleHeight, setVisibleHeight] = (0, react_1.useState)(0);
7
+ const getVisibleContentHeight = () => {
8
+ if (typeof window === 'undefined')
9
+ return 0;
10
+ let height = window.innerHeight;
11
+ if (window.visualViewport) {
12
+ height = window.visualViewport.height;
13
+ }
14
+ if (height <= 0 || height > window.screen.height) {
15
+ height = window.innerHeight;
16
+ }
17
+ if (height <= 0) {
18
+ height = document.documentElement.clientHeight;
19
+ }
20
+ return height;
21
+ };
22
+ const updateHeight = (0, react_1.useCallback)(() => {
23
+ const height = getVisibleContentHeight();
24
+ setVisibleHeight(height);
25
+ }, []);
26
+ (0, react_1.useEffect)(() => {
27
+ updateHeight();
28
+ const events = ['resize', 'orientationchange', 'load', 'DOMContentLoaded'];
29
+ events.forEach((event) => {
30
+ window.addEventListener(event, updateHeight);
31
+ });
32
+ if (window.visualViewport) {
33
+ window.visualViewport.addEventListener('resize', updateHeight);
34
+ window.visualViewport.addEventListener('scroll', updateHeight);
35
+ }
36
+ if ('virtualKeyboard' in navigator) {
37
+ navigator.virtualKeyboard.addEventListener('geometrychange', updateHeight);
38
+ }
39
+ const interval = setInterval(updateHeight, 1000);
40
+ return () => {
41
+ events.forEach((event) => {
42
+ window.removeEventListener(event, updateHeight);
43
+ });
44
+ if (window.visualViewport) {
45
+ window.visualViewport.removeEventListener('resize', updateHeight);
46
+ window.visualViewport.removeEventListener('scroll', updateHeight);
47
+ }
48
+ if ('virtualKeyboard' in navigator) {
49
+ navigator.virtualKeyboard.removeEventListener('geometrychange', updateHeight);
50
+ }
51
+ clearInterval(interval);
52
+ };
53
+ }, [updateHeight]);
54
+ return visibleHeight;
55
+ };
56
+ exports.useVisibleHeight = useVisibleHeight;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.19.9",
3
+ "version": "1.19.10",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",