pb-sxp-ui 1.7.1 → 1.7.3
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 +222 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +222 -102
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +222 -102
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/Modal/index.js +6 -3
- package/es/core/components/SxpPageRender/PictureGroup/Picture.d.ts +1 -1
- package/es/core/components/SxpPageRender/PictureGroup/index.d.ts +4 -1
- package/es/core/components/SxpPageRender/PictureGroup/index.js +24 -4
- package/es/core/components/SxpPageRender/RenderCard.js +6 -1
- package/es/core/components/SxpPageRender/VideoWidget/index.js +22 -12
- package/es/core/components/SxpPageRender/WaterFall/List.js +3 -2
- package/es/core/components/SxpPageRender/WaterFall/WaterfallList.js +3 -2
- package/es/core/components/SxpPageRender/WaterFall/index.js +5 -2
- package/es/core/components/SxpPageRender/index.d.ts +2 -0
- package/es/core/components/SxpPageRender/index.js +20 -25
- package/es/core/context/SxpDataSourceProvider.d.ts +2 -4
- package/es/core/context/SxpDataSourceProvider.js +53 -11
- package/es/core/utils/materials.d.ts +7 -1
- package/es/core/utils/materials.js +5 -2
- package/es/core/utils/tool.d.ts +2 -1
- package/es/core/utils/tool.js +11 -1
- package/es/materials/sxp/cta/AniLink/settingRender.d.ts +11 -0
- package/es/materials/sxp/cta/AniLink/settingRender.js +6 -0
- package/es/materials/sxp/cta/AniLinkPopup/settingRender.d.ts +1 -1
- package/es/materials/sxp/cta/AniLinkPopup/settingRender.js +6 -0
- package/es/materials/sxp/popup/CommodityDetail/index.d.ts +1 -0
- package/es/materials/sxp/popup/CommodityDetail/index.js +15 -9
- package/es/materials/sxp/popup/CommodityDetailDiro/index.d.ts +1 -0
- package/es/materials/sxp/popup/CommodityDetailDiro/index.js +15 -8
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.d.ts +1 -0
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +18 -10
- package/es/materials/sxp/popup/CommodityList/index.js +12 -6
- package/es/materials/sxp/template/components/settingRender.d.ts +1 -1
- package/es/materials/sxp/template/components/settingRender.js +6 -0
- package/lib/core/components/SxpPageRender/Modal/index.js +5 -2
- package/lib/core/components/SxpPageRender/PictureGroup/Picture.d.ts +1 -1
- package/lib/core/components/SxpPageRender/PictureGroup/index.d.ts +4 -1
- package/lib/core/components/SxpPageRender/PictureGroup/index.js +23 -4
- package/lib/core/components/SxpPageRender/RenderCard.js +6 -1
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +21 -12
- package/lib/core/components/SxpPageRender/WaterFall/List.js +3 -2
- package/lib/core/components/SxpPageRender/WaterFall/WaterfallList.js +3 -2
- package/lib/core/components/SxpPageRender/WaterFall/index.js +5 -2
- package/lib/core/components/SxpPageRender/index.d.ts +2 -0
- package/lib/core/components/SxpPageRender/index.js +20 -25
- package/lib/core/context/SxpDataSourceProvider.d.ts +2 -4
- package/lib/core/context/SxpDataSourceProvider.js +53 -11
- package/lib/core/utils/materials.d.ts +7 -1
- package/lib/core/utils/materials.js +5 -2
- package/lib/core/utils/tool.d.ts +2 -1
- package/lib/core/utils/tool.js +12 -1
- package/lib/materials/sxp/cta/AniLink/settingRender.d.ts +11 -0
- package/lib/materials/sxp/cta/AniLink/settingRender.js +6 -0
- package/lib/materials/sxp/cta/AniLinkPopup/settingRender.d.ts +1 -1
- package/lib/materials/sxp/cta/AniLinkPopup/settingRender.js +6 -0
- package/lib/materials/sxp/popup/CommodityDetail/index.d.ts +1 -0
- package/lib/materials/sxp/popup/CommodityDetail/index.js +15 -9
- package/lib/materials/sxp/popup/CommodityDetailDiro/index.d.ts +1 -0
- package/lib/materials/sxp/popup/CommodityDetailDiro/index.js +15 -8
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.d.ts +1 -0
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +18 -10
- package/lib/materials/sxp/popup/CommodityList/index.js +11 -5
- package/lib/materials/sxp/template/components/settingRender.d.ts +1 -1
- package/lib/materials/sxp/template/components/settingRender.js +6 -0
- package/package.json +1 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
import { debounce } from 'lodash';
|
2
|
-
import React, { memo, useEffect, useMemo, useRef, useState } from 'react';
|
2
|
+
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
3
3
|
import * as ReactDOM from 'react-dom';
|
4
4
|
import { useEditor, useSxpDataSource } from '../../../../core/hooks';
|
5
5
|
const closeIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAjhJREFUWEfFlztOw0AQhmeWiJ4CCmpQ5DiRQsIJyAWg5A0lR0AIChDiCJS8ER0cADgBeRSxt4CCDgkaKiq8i+zYeWx2413HEWmiJJv9v535Z2aN8M8vFPT9z3zETD0aAUChUJjwvPFHAJhBhB3Hqd6OAsK2yyucwykAvP38eJX398Z3AJDLlVYR8ToU9Rhj25TWr9KEsKy5dULIGQCMtfZly45TvwsAstm56UwG6wA4FUFwzrdctxZBDcWSy5XWEPG8I84/GcMipdWPtgcsaz5PCHtKG0IuTiqUvjT9U/WYMG2IOPE+AP+LtCB0xKUAAyA2Xbd2o2OG0NQXvTnvhL17D7EPtH9TRCIWwkRcGYGIQgYBABuqPuHXOQBc6pw80lBGwBQiiXhsBHQhkoprA6iM6acjhDQKu5YJZW6XeOI3XJdpvfsdTu52VfXEekD8owQiXGIubpSCbhDbLu8DwKEAd+A41SOdPpE4BS0viFOtvV2iKWqUgn5x/tmS70xR01GuDSCKc86/OCcLgTyyZ0ScDGNhFAktAJV4NFJ9YyaFiAWIE+9uVkkgBgLoig8DMWAa9ro9ynkUdlW5maZDCmB6clmz0k1HH4Cs1Ezbq2p2yEpUuBOKTSZZex00RUWIrltxuuK6EOGDSbGIOPZicpMx6fny650377qNRgBgWeVFQuA+6UjVgREhGIMlSqsPUQqIbZdOOIdZQmCv2axRnU1N1+TzJYsxOEaEV8ep7frPZ7Gd0FTEdP0ft0/kMNdg0eoAAAAASUVORK5CYII=';
|
@@ -15,7 +15,7 @@ const Modal = ({ visible, onClose, children, modalStyle, padding, popup, schema,
|
|
15
15
|
const [isShow, setIsShow] = useState(false);
|
16
16
|
const modalEleRef = useRef(null);
|
17
17
|
const { globalConfig, popupDetailData } = useSxpDataSource();
|
18
|
-
const { schema: _schema } = useEditor();
|
18
|
+
const { schema: _schema, popup: _popup } = useEditor();
|
19
19
|
const [scrollTop, setScrollTop] = useState(15);
|
20
20
|
useEffect(() => {
|
21
21
|
const parentNode = document.getElementById('sxp-render');
|
@@ -53,6 +53,9 @@ const Modal = ({ visible, onClose, children, modalStyle, padding, popup, schema,
|
|
53
53
|
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
54
54
|
}
|
55
55
|
}, [isOpen, popup]);
|
56
|
+
const child = useCallback(() => {
|
57
|
+
return children;
|
58
|
+
}, [_popup]);
|
56
59
|
if (!modalEleRef.current)
|
57
60
|
return null;
|
58
61
|
const handleClose = debounce(() => {
|
@@ -135,6 +138,6 @@ const Modal = ({ visible, onClose, children, modalStyle, padding, popup, schema,
|
|
135
138
|
var _a;
|
136
139
|
setScrollTop(15 - ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.scrollTop));
|
137
140
|
}
|
138
|
-
})),
|
141
|
+
})), child())))))), modalEleRef.current);
|
139
142
|
};
|
140
143
|
export default memo(Modal);
|
@@ -4,7 +4,7 @@ interface IPictureProps {
|
|
4
4
|
src: string;
|
5
5
|
height?: number;
|
6
6
|
imgUrlsPostConfig?: postConfigType;
|
7
|
-
onShowFirstImage?: () => void;
|
7
|
+
onShowFirstImage?: (e: any) => void;
|
8
8
|
}
|
9
9
|
declare const Picture: (props: IPictureProps) => React.JSX.Element;
|
10
10
|
export default Picture;
|
@@ -8,7 +8,10 @@ interface IPictureGroupProps {
|
|
8
8
|
rec: RecItemType;
|
9
9
|
index: number;
|
10
10
|
onReportViewImageEnd: (rec: RecItemType) => void;
|
11
|
-
onViewImageStartEvent: (index: number
|
11
|
+
onViewImageStartEvent: (index: number, imgInfo?: {
|
12
|
+
contentSize: string;
|
13
|
+
loadTime: string;
|
14
|
+
}) => void;
|
12
15
|
imgUrlsPostConfig?: postConfigType;
|
13
16
|
}
|
14
17
|
declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
|
@@ -1,15 +1,20 @@
|
|
1
|
+
import { __awaiter } from "tslib";
|
1
2
|
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
|
2
3
|
import { Autoplay, Pagination } from 'swiper/modules';
|
3
4
|
import { Swiper, SwiperSlide, useSwiperSlide } from 'swiper/react';
|
4
5
|
import Picture from './Picture';
|
5
6
|
import { useSxpDataSource } from '../../../../core/hooks';
|
6
7
|
import { css } from '@emotion/css';
|
8
|
+
import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
|
9
|
+
import { getResFileSizeFromSrc } from '../../../../core/utils/tool';
|
7
10
|
const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent, imgUrlsPostConfig }) => {
|
8
11
|
var _a, _b;
|
9
12
|
const ref = useRef();
|
10
13
|
const { isActive } = useSwiperSlide();
|
11
14
|
const { sxpParameter, openHashtag } = useSxpDataSource();
|
12
15
|
const [isLoad, setIsLoad] = useState(false);
|
16
|
+
const [imgInfo, setImgInfo] = useState();
|
17
|
+
const initTime = new Date();
|
13
18
|
useEffect(() => {
|
14
19
|
if (isLoad && isActive) {
|
15
20
|
(ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.start();
|
@@ -17,18 +22,33 @@ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd
|
|
17
22
|
onReportViewImageEnd(rec);
|
18
23
|
}
|
19
24
|
else {
|
20
|
-
onViewImageStartEvent(index);
|
25
|
+
onViewImageStartEvent(index, imgInfo);
|
21
26
|
}
|
22
27
|
}
|
23
28
|
else {
|
24
29
|
(ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.stop();
|
25
30
|
}
|
26
|
-
}, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad]);
|
27
|
-
const showFirstImageFn = useCallback(() => {
|
31
|
+
}, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad, imgInfo]);
|
32
|
+
const showFirstImageFn = useCallback((e) => __awaiter(void 0, void 0, void 0, function* () {
|
28
33
|
if (!isLoad) {
|
34
|
+
const contentSize = yield getResFileSizeFromSrc(e.src);
|
35
|
+
setImgInfo({
|
36
|
+
contentSize,
|
37
|
+
loadTime: (new Date() - initTime).toFixed(2) + ''
|
38
|
+
});
|
29
39
|
setIsLoad(true);
|
30
40
|
}
|
31
|
-
}, [isLoad]);
|
41
|
+
}), [isLoad]);
|
42
|
+
useEffect(() => {
|
43
|
+
const onShow = () => onViewImageStartEvent(index, imgInfo);
|
44
|
+
const onHide = () => onReportViewImageEnd(rec);
|
45
|
+
SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
|
46
|
+
SXP_EVENT_BUS.on(SXP_EVENT_TYPE.PAGE_DID_HIDE, onHide);
|
47
|
+
return () => {
|
48
|
+
SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_SHOW, onShow);
|
49
|
+
SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE, onHide);
|
50
|
+
};
|
51
|
+
}, [imgInfo]);
|
32
52
|
return (React.createElement(Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
|
33
53
|
clickable: true,
|
34
54
|
bulletActiveClass: 'swipe-item-active-bullet',
|
@@ -49,7 +49,12 @@ const RenderCard = ({ rec, index, tempMap, resolver, includesCtaType, isActive }
|
|
49
49
|
const Component = withBindDataSource(t);
|
50
50
|
const defaulSetting = (_z = t === null || t === void 0 ? void 0 : t.extend) === null || _z === void 0 ? void 0 : _z.defaulSetting;
|
51
51
|
const isExternalLink = ((_2 = (_1 = (_0 = value === null || value === void 0 ? void 0 : value.item) === null || _0 === void 0 ? void 0 : _0.event) === null || _1 === void 0 ? void 0 : _1.onClick) === null || _2 === void 0 ? void 0 : _2.linkType) === 'externalLink';
|
52
|
-
|
52
|
+
let style = (_3 = value === null || value === void 0 ? void 0 : value.item) === null || _3 === void 0 ? void 0 : _3.style;
|
53
|
+
if (style.hasOwnProperty('backdropFilter')) {
|
54
|
+
let sbf = style['backdropFilter'];
|
55
|
+
style['backdropFilter'] = `blur(${sbf !== null && sbf !== void 0 ? sbf : 0}px)`;
|
56
|
+
}
|
57
|
+
return (React.createElement(Component, Object.assign({ style: Object.assign(Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.style), style), { zIndex: 50, marginLeft: '20px', boxSizing: 'border-box', transform: 'translate3d(0px, 0px, 0px)' }), textStyle: Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.textStyle), (_4 = value === null || value === void 0 ? void 0 : value.item) === null || _4 === void 0 ? void 0 : _4.textStyle), bindDatas: (_6 = (_5 = value === null || value === void 0 ? void 0 : value.item) === null || _5 === void 0 ? void 0 : _5.bindDatas) !== null && _6 !== void 0 ? _6 : [] }, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.props, (_7 = value === null || value === void 0 ? void 0 : value.item) === null || _7 === void 0 ? void 0 : _7.props, { event: ((_8 = value === null || value === void 0 ? void 0 : value.item) === null || _8 === void 0 ? void 0 : _8.event) || {}, schema: schema, id: value === null || value === void 0 ? void 0 : value.id, key: value === null || value === void 0 ? void 0 : value.id, recData: rec, isExternalLink: isExternalLink, index: index, isActive: isActive })));
|
53
58
|
}
|
54
59
|
else {
|
55
60
|
return null;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { __awaiter } from "tslib";
|
1
2
|
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
2
3
|
import { useSwiperSlide } from 'swiper/react';
|
3
4
|
import { useIconLink } from '../useIconLink';
|
@@ -6,6 +7,7 @@ import { useSxpDataSource } from '../../../../core/hooks';
|
|
6
7
|
import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
|
7
8
|
import loading_gif from './loading.gif';
|
8
9
|
import { mountVideoPlayerAtNode } from './VideoPlayer';
|
10
|
+
import { getResFileSizeFromSrc } from '../../../../core/utils/tool';
|
9
11
|
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
|
10
12
|
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
11
13
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = useSxpDataSource();
|
@@ -20,6 +22,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
20
22
|
const videoId = `pb-cache-video-${index}`;
|
21
23
|
const videoEleRef = useRef(null);
|
22
24
|
const hlsRef = useRef(null);
|
25
|
+
const initTimeRef = useRef();
|
23
26
|
const blur = useMemo(() => {
|
24
27
|
return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
|
25
28
|
}, [videoPostConfig]);
|
@@ -65,8 +68,8 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
65
68
|
setWaiting(false);
|
66
69
|
setIsLoadFinish(true);
|
67
70
|
}, []);
|
68
|
-
const handleStartPlay = useCallback(() => {
|
69
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
71
|
+
const handleStartPlay = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
70
73
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
71
74
|
return;
|
72
75
|
setIsPauseVideo(false);
|
@@ -76,24 +79,27 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
76
79
|
const videoDuration = ((_d = (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
|
77
80
|
const videoCurrentTime = ((_f = (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
|
78
81
|
const playType = isFirstPlay ? '0' : '1';
|
82
|
+
const contentSize = yield getResFileSizeFromSrc((_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.url);
|
79
83
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
80
84
|
eventInfo: {
|
81
85
|
eventSubject: 'playVideo',
|
82
86
|
eventDescription: 'User played the video',
|
83
|
-
contentId: (
|
84
|
-
contentName: (
|
87
|
+
contentId: (_j = (_h = item === null || item === void 0 ? void 0 : item.video) === null || _h === void 0 ? void 0 : _h.itemId) !== null && _j !== void 0 ? _j : '',
|
88
|
+
contentName: (_l = (_k = item === null || item === void 0 ? void 0 : item.video) === null || _k === void 0 ? void 0 : _k.title) !== null && _l !== void 0 ? _l : '',
|
85
89
|
playType,
|
86
90
|
startTime: videoCurrentTime,
|
87
91
|
videoDuration,
|
88
|
-
contentTags: JSON.stringify((
|
92
|
+
contentTags: JSON.stringify((_o = (_m = item === null || item === void 0 ? void 0 : item.video) === null || _m === void 0 ? void 0 : _m.tags) !== null && _o !== void 0 ? _o : []),
|
89
93
|
position: index + '',
|
90
94
|
contentFormat: 'video',
|
91
|
-
traceInfo: (
|
95
|
+
traceInfo: (_p = item === null || item === void 0 ? void 0 : item.video) === null || _p === void 0 ? void 0 : _p.traceInfo,
|
96
|
+
contentSize,
|
97
|
+
loadTime: (new Date() - (initTimeRef === null || initTimeRef === void 0 ? void 0 : initTimeRef.current)).toFixed(2) + ''
|
92
98
|
}
|
93
99
|
});
|
94
100
|
setIsFirstPlay(false);
|
95
101
|
}
|
96
|
-
}, [bffEventReport, data, index, isFirstPlay, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
102
|
+
}), [bffEventReport, data, index, isFirstPlay, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
97
103
|
const handLoadeddata = useCallback(() => {
|
98
104
|
var _a;
|
99
105
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
@@ -197,6 +203,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
197
203
|
videoRef.current = mountVideoPlayerAtNode === null || mountVideoPlayerAtNode === void 0 ? void 0 : mountVideoPlayerAtNode(videoPlayerWrapperNode);
|
198
204
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
199
205
|
return;
|
206
|
+
initTimeRef.current = new Date();
|
200
207
|
const Hls = window === null || window === void 0 ? void 0 : window.Hls;
|
201
208
|
let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
|
202
209
|
if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
|
@@ -240,17 +247,18 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
240
247
|
};
|
241
248
|
}, [isActive]);
|
242
249
|
useEffect(() => {
|
243
|
-
var _a, _b;
|
250
|
+
var _a, _b, _c, _d;
|
244
251
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
|
245
252
|
return;
|
246
253
|
if (isActive) {
|
247
254
|
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
248
|
-
eventName: 'ViewContent'
|
255
|
+
eventName: 'ViewContent',
|
256
|
+
product: (_b = (_a = data === null || data === void 0 ? void 0 : data[index]) === null || _a === void 0 ? void 0 : _a.video) === null || _b === void 0 ? void 0 : _b.bindProduct
|
249
257
|
});
|
250
|
-
(
|
258
|
+
(_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.play();
|
251
259
|
}
|
252
260
|
else {
|
253
|
-
(
|
261
|
+
(_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.pause();
|
254
262
|
}
|
255
263
|
}, [isActive, isLoadFinish, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
256
264
|
useEffect(() => {
|
@@ -269,9 +277,11 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
269
277
|
if (!isActive)
|
270
278
|
return;
|
271
279
|
const onShow = () => {
|
280
|
+
var _a, _b;
|
272
281
|
handleClickVideo('start')();
|
273
282
|
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
274
|
-
eventName: 'ViewContent'
|
283
|
+
eventName: 'ViewContent',
|
284
|
+
product: (_b = (_a = data === null || data === void 0 ? void 0 : data[index]) === null || _a === void 0 ? void 0 : _a.video) === null || _b === void 0 ? void 0 : _b.bindProduct
|
275
285
|
});
|
276
286
|
};
|
277
287
|
const onHide = handleClickVideo('pause');
|
@@ -41,7 +41,8 @@ const WaterfallFlowItem = (props) => {
|
|
41
41
|
product: rec === null || rec === void 0 ? void 0 : rec.product,
|
42
42
|
enableFormattedPrice: (_a = textStyles === null || textStyles === void 0 ? void 0 : textStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice,
|
43
43
|
globalConfig,
|
44
|
-
isHiddenDef: true
|
44
|
+
isHiddenDef: true,
|
45
|
+
style: textStyles === null || textStyles === void 0 ? void 0 : textStyles.price
|
45
46
|
});
|
46
47
|
useEffect(() => {
|
47
48
|
const observer = new IntersectionObserver((entries) => {
|
@@ -113,7 +114,7 @@ const WaterfallFlowItem = (props) => {
|
|
113
114
|
__html: setFontForText(title, textStyles === null || textStyles === void 0 ? void 0 : textStyles.title)
|
114
115
|
} }),
|
115
116
|
React.createElement("div", { className: 'list-content-listItem-info-price', style: textStyles === null || textStyles === void 0 ? void 0 : textStyles.price, hidden: !priceText, dangerouslySetInnerHTML: {
|
116
|
-
__html:
|
117
|
+
__html: priceText !== null && priceText !== void 0 ? priceText : ''
|
117
118
|
} }))));
|
118
119
|
};
|
119
120
|
export default function WaterfallList(_a) {
|
@@ -64,7 +64,8 @@ const WaterfallFlowItem = (props) => {
|
|
64
64
|
product: rec === null || rec === void 0 ? void 0 : rec.product,
|
65
65
|
enableFormattedPrice: (_a = textStyles === null || textStyles === void 0 ? void 0 : textStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice,
|
66
66
|
globalConfig,
|
67
|
-
isHiddenDef: true
|
67
|
+
isHiddenDef: true,
|
68
|
+
style: textStyles === null || textStyles === void 0 ? void 0 : textStyles.price
|
68
69
|
});
|
69
70
|
useEffect(() => {
|
70
71
|
if (imgDom.current === null || src === '') {
|
@@ -105,7 +106,7 @@ const WaterfallFlowItem = (props) => {
|
|
105
106
|
__html: setFontForText(title, textStyles === null || textStyles === void 0 ? void 0 : textStyles.title)
|
106
107
|
} }),
|
107
108
|
React.createElement("div", { className: 'waterFallList-content-listItem-info-price', hidden: !priceText, style: textStyles.price, dangerouslySetInnerHTML: {
|
108
|
-
__html:
|
109
|
+
__html: priceText !== null && priceText !== void 0 ? priceText : ''
|
109
110
|
} }))));
|
110
111
|
};
|
111
112
|
export default function WaterfallList(_a) {
|
@@ -9,7 +9,7 @@ import { useSxpDataSource } from '../../../../core/hooks';
|
|
9
9
|
import { useEventReport } from '../../../../core/hooks/useEventReport';
|
10
10
|
const WaterFall = (props) => {
|
11
11
|
var _a;
|
12
|
-
const { waterFallData, setOpenHashtag, openHashtag, swiperRef, setWaterFallData, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, setCacheRtcList, setIsFromHashtag, isFromHashtag, bffEventReport, themeTag, selectTag } = useSxpDataSource();
|
12
|
+
const { waterFallData, setOpenHashtag, openHashtag, swiperRef, setWaterFallData, cacheRtcList, setRtcList, cacheActiveIndex, rtcList, setCacheRtcList, setIsFromHashtag, isFromHashtag, bffEventReport, themeTag, selectTag, bffFbReport } = useSxpDataSource();
|
13
13
|
const { backMainFeed } = useEventReport();
|
14
14
|
const ref = useRef(null);
|
15
15
|
const modalEleRef = useRef(null);
|
@@ -78,8 +78,11 @@ const WaterFall = (props) => {
|
|
78
78
|
useEffect(() => {
|
79
79
|
if (openHashtag) {
|
80
80
|
setViewTime(new Date());
|
81
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
82
|
+
eventName: 'PageView'
|
83
|
+
});
|
81
84
|
}
|
82
|
-
}, [openHashtag]);
|
85
|
+
}, [openHashtag, bffFbReport]);
|
83
86
|
useEffect(() => {
|
84
87
|
const initTime = () => {
|
85
88
|
setViewTime(new Date());
|
@@ -56,6 +56,7 @@ export interface ISxpPageRenderProps {
|
|
56
56
|
decimalPoint?: string;
|
57
57
|
currencyPosition?: string;
|
58
58
|
showTwoDecimalPoint?: boolean;
|
59
|
+
fontFamily?: string;
|
59
60
|
};
|
60
61
|
backButton?: {
|
61
62
|
enable: boolean;
|
@@ -65,6 +66,7 @@ export interface ISxpPageRenderProps {
|
|
65
66
|
yPosit: string;
|
66
67
|
y: number;
|
67
68
|
};
|
69
|
+
converApi?: any;
|
68
70
|
};
|
69
71
|
descStyle?: CSSProperties;
|
70
72
|
tipText?: {
|
@@ -48,9 +48,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
48
48
|
if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
|
49
49
|
const now = new Date();
|
50
50
|
viewTime.current = now;
|
51
|
-
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
52
|
-
eventName: 'PageView'
|
53
|
-
});
|
54
51
|
}
|
55
52
|
}, [data === null || data === void 0 ? void 0 : data.length]);
|
56
53
|
const handleH5EnterLink = useCallback(() => {
|
@@ -59,11 +56,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
59
56
|
if (data.length > 0) {
|
60
57
|
const now = new Date();
|
61
58
|
viewTime.current = now;
|
62
|
-
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
63
|
-
eventName: 'PageView'
|
64
|
-
});
|
65
59
|
}
|
66
|
-
}, [data.length,
|
60
|
+
}, [data.length, h5EnterLink]);
|
67
61
|
useEffect(() => {
|
68
62
|
var _a;
|
69
63
|
if (!ctaType || (ctaType === null || ctaType === void 0 ? void 0 : ctaType.length) < 1)
|
@@ -92,7 +86,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
92
86
|
if (document.visibilityState === 'hidden') {
|
93
87
|
if (repCond) {
|
94
88
|
SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_HIDE, item);
|
95
|
-
handleReportViewImageEnd(item);
|
96
89
|
handleReportProductView(item);
|
97
90
|
}
|
98
91
|
let fromKName = '';
|
@@ -136,7 +129,6 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
136
129
|
}
|
137
130
|
handleH5EnterLink();
|
138
131
|
if (repCond) {
|
139
|
-
handleViewImageStartEvent(activeIndex);
|
140
132
|
SXP_EVENT_BUS.emit(SXP_EVENT_TYPE.PAGE_DID_SHOW, item);
|
141
133
|
backMainFeed('external', selectTag);
|
142
134
|
}
|
@@ -229,7 +221,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
229
221
|
const t = resolver[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
|
230
222
|
const Component = withBindDataSource(t);
|
231
223
|
const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
|
232
|
-
return (React.createElement(Component, Object.assign({ key: `${index}${idx}`, textStyle: Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.textStyle), (_c = value === null || value === void 0 ? void 0 : value.item) === null || _c === void 0 ? void 0 : _c.textStyle), bindDatas: (_e = (_d = value === null || value === void 0 ? void 0 : value.item) === null || _d === void 0 ? void 0 : _d.bindDatas) !== null && _e !== void 0 ? _e : [] }, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.props, (_f = value === null || value === void 0 ? void 0 : value.item) === null || _f === void 0 ? void 0 : _f.props, { event: ((_g = value === null || value === void 0 ? void 0 : value.item) === null || _g === void 0 ? void 0 : _g.event) || {}, schema: schema, id: value === null || value === void 0 ? void 0 : value.id, viewTime: viewTime.current, rec: rec, isPost: true, tipText: tipText, style: Object.assign(Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.style), (_h = value === null || value === void 0 ? void 0 : value.item) === null || _h === void 0 ? void 0 : _h.style), { height: '100%', overflow: 'auto' }), index: index })));
|
224
|
+
return (React.createElement(Component, Object.assign({ key: `${index}${idx}`, textStyle: Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.textStyle), (_c = value === null || value === void 0 ? void 0 : value.item) === null || _c === void 0 ? void 0 : _c.textStyle), bindDatas: (_e = (_d = value === null || value === void 0 ? void 0 : value.item) === null || _d === void 0 ? void 0 : _d.bindDatas) !== null && _e !== void 0 ? _e : [] }, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.props, (_f = value === null || value === void 0 ? void 0 : value.item) === null || _f === void 0 ? void 0 : _f.props, { event: ((_g = value === null || value === void 0 ? void 0 : value.item) === null || _g === void 0 ? void 0 : _g.event) || {}, schema: schema, id: value === null || value === void 0 ? void 0 : value.id, viewTime: viewTime.current, rec: rec, isPost: true, tipText: tipText, style: Object.assign(Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.style), (_h = value === null || value === void 0 ? void 0 : value.item) === null || _h === void 0 ? void 0 : _h.style), { height: '100%', overflow: 'auto' }), index: index, isActive: activeIndex === index })));
|
233
225
|
});
|
234
226
|
}
|
235
227
|
return null;
|
@@ -386,7 +378,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
386
378
|
productId: (_g = (_f = item === null || item === void 0 ? void 0 : item.product) === null || _f === void 0 ? void 0 : _f.itemId) !== null && _g !== void 0 ? _g : '',
|
387
379
|
requestId: null,
|
388
380
|
traceInfo: (_j = (_h = item === null || item === void 0 ? void 0 : item.video) === null || _h === void 0 ? void 0 : _h.traceInfo) !== null && _j !== void 0 ? _j : '',
|
389
|
-
contentFormat
|
381
|
+
contentFormat,
|
382
|
+
position: ((_k = swiper.previousIndex) !== null && _k !== void 0 ? _k : 0) + ''
|
390
383
|
}
|
391
384
|
});
|
392
385
|
handleReportViewImageEnd(item);
|
@@ -397,22 +390,17 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
397
390
|
eventInfo: {
|
398
391
|
eventSubject: 'scrollUp',
|
399
392
|
eventDescription: 'User scroll up',
|
400
|
-
contentId: (
|
401
|
-
productId: (
|
393
|
+
contentId: (_m = (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.itemId) !== null && _m !== void 0 ? _m : '',
|
394
|
+
productId: (_p = (_o = item.product) === null || _o === void 0 ? void 0 : _o.itemId) !== null && _p !== void 0 ? _p : '',
|
402
395
|
requestId: null,
|
403
|
-
traceInfo: (
|
404
|
-
contentFormat
|
396
|
+
traceInfo: (_r = (_q = item === null || item === void 0 ? void 0 : item.video) === null || _q === void 0 ? void 0 : _q.traceInfo) !== null && _r !== void 0 ? _r : '',
|
397
|
+
contentFormat,
|
398
|
+
position: ((_s = swiper.previousIndex) !== null && _s !== void 0 ? _s : 0) + ''
|
405
399
|
}
|
406
400
|
});
|
407
401
|
handleReportViewImageEnd(item);
|
408
402
|
}
|
409
403
|
handleReportProductView(item);
|
410
|
-
const curItem = data[swiper.activeIndex];
|
411
|
-
if (!((_r = curItem === null || curItem === void 0 ? void 0 : curItem.video) === null || _r === void 0 ? void 0 : _r.url) && !((_s = curItem === null || curItem === void 0 ? void 0 : curItem.video) === null || _s === void 0 ? void 0 : _s.imgUrls) && (curItem === null || curItem === void 0 ? void 0 : curItem.product)) {
|
412
|
-
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
413
|
-
eventName: 'ProductView'
|
414
|
-
});
|
415
|
-
}
|
416
404
|
viewTime.current = new Date();
|
417
405
|
};
|
418
406
|
const handleReportProductView = (item) => {
|
@@ -430,8 +418,8 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
430
418
|
viewTime.current = new Date();
|
431
419
|
}
|
432
420
|
}, [openHashtag, data, activeIndex]);
|
433
|
-
const handleViewImageStartEvent = (activeIndex) => {
|
434
|
-
var _a, _b, _c, _d, _e, _f;
|
421
|
+
const handleViewImageStartEvent = (activeIndex, imgInfo) => {
|
422
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
435
423
|
const item = data[activeIndex];
|
436
424
|
if (!((_a = item === null || item === void 0 ? void 0 : item.video) === null || _a === void 0 ? void 0 : _a.url) && ((_b = item === null || item === void 0 ? void 0 : item.video) === null || _b === void 0 ? void 0 : _b.imgUrls)) {
|
437
425
|
const startTime = Date.now();
|
@@ -446,11 +434,18 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
446
434
|
contentTags: JSON.stringify((_f = item === null || item === void 0 ? void 0 : item.video.tags) !== null && _f !== void 0 ? _f : []),
|
447
435
|
position: activeIndex + '',
|
448
436
|
contentFormat: 'image',
|
449
|
-
traceInfo: item === null || item === void 0 ? void 0 : item.video.traceInfo
|
437
|
+
traceInfo: item === null || item === void 0 ? void 0 : item.video.traceInfo,
|
438
|
+
contentSize: imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.contentSize,
|
439
|
+
loadTime: imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.loadTime
|
450
440
|
}
|
451
441
|
});
|
452
442
|
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
453
|
-
eventName: 'ViewContent'
|
443
|
+
eventName: 'ViewContent',
|
444
|
+
product: (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.bindProduct
|
445
|
+
});
|
446
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
447
|
+
eventName: 'PageView',
|
448
|
+
product: (_h = item === null || item === void 0 ? void 0 : item.video) === null || _h === void 0 ? void 0 : _h.bindProduct
|
454
449
|
});
|
455
450
|
}
|
456
451
|
};
|
@@ -67,10 +67,8 @@ export interface ISxpDataSourceContext {
|
|
67
67
|
videoRef?: any;
|
68
68
|
setVideoRef?: React.Dispatch<React.SetStateAction<any>>;
|
69
69
|
bffFbReport?: (body: {
|
70
|
-
eventName:
|
71
|
-
|
72
|
-
eventSourceUrl?: string;
|
73
|
-
externalId?: string;
|
70
|
+
eventName: 'PageView' | 'ProductView' | 'ViewContent';
|
71
|
+
product?: any;
|
74
72
|
}) => Promise<any> | undefined | boolean;
|
75
73
|
curTime?: any;
|
76
74
|
h5EnterLink?: () => void;
|
@@ -189,23 +189,65 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
189
189
|
type: 'beacon'
|
190
190
|
});
|
191
191
|
}, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
|
192
|
-
const bffFbReport = useCallback((
|
193
|
-
var _b, _c, _d;
|
194
|
-
var { eventName, actionSource = 'website', eventSourceUrl = (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href, externalId } = _a;
|
192
|
+
const bffFbReport = useCallback(({ eventName, product }) => {
|
193
|
+
var _a, _b, _c, _d;
|
195
194
|
if (!enableReportEvent || !enabledMetaConversionApi || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
|
196
195
|
return;
|
197
196
|
}
|
198
|
-
|
197
|
+
let jsonParams = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName];
|
199
198
|
const urlParams = new URLSearchParams(window.location.search);
|
200
|
-
const fbclid = urlParams.get('fbclid');
|
199
|
+
const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
|
200
|
+
const fix_par = {
|
201
|
+
event_source_url: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href,
|
202
|
+
external_id: storeAndLoadFeUserId(),
|
203
|
+
client_user_agent: (_d = (_c = window === null || window === void 0 ? void 0 : window.navigator) === null || _c === void 0 ? void 0 : _c.userAgent) !== null && _d !== void 0 ? _d : '',
|
204
|
+
fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
|
205
|
+
fbp: getCookie('_fbp') ? `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` : '',
|
206
|
+
time: new Date().getTime()
|
207
|
+
};
|
208
|
+
const regex = /\{\{(.*?)\}\}/g;
|
209
|
+
const getEventParams = (obj) => {
|
210
|
+
if (!obj)
|
211
|
+
return;
|
212
|
+
if (obj instanceof Array) {
|
213
|
+
obj === null || obj === void 0 ? void 0 : obj.map((item) => getEventParams(item));
|
214
|
+
}
|
215
|
+
else {
|
216
|
+
for (const key in obj) {
|
217
|
+
if (obj.hasOwnProperty(key)) {
|
218
|
+
const value = obj === null || obj === void 0 ? void 0 : obj[key];
|
219
|
+
if (typeof value === 'object') {
|
220
|
+
getEventParams(value);
|
221
|
+
}
|
222
|
+
else if (typeof value === 'string') {
|
223
|
+
const matches = value === null || value === void 0 ? void 0 : value.match(regex);
|
224
|
+
if (matches) {
|
225
|
+
matches.forEach((match) => {
|
226
|
+
const prop = match.substring(2, match.length - 2);
|
227
|
+
try {
|
228
|
+
const replaceValue = new Function('fix_par', 'product', `return ${prop}`)(fix_par, product);
|
229
|
+
if (replaceValue) {
|
230
|
+
obj[key] = replaceValue;
|
231
|
+
}
|
232
|
+
else {
|
233
|
+
delete obj[key];
|
234
|
+
}
|
235
|
+
}
|
236
|
+
catch (error) {
|
237
|
+
delete obj[key];
|
238
|
+
console.error('An error occurred:', error === null || error === void 0 ? void 0 : error.message);
|
239
|
+
}
|
240
|
+
});
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
246
|
+
};
|
247
|
+
getEventParams(jsonParams);
|
201
248
|
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/fb/events', {
|
202
249
|
method: 'POST',
|
203
|
-
body:
|
204
|
-
eventName,
|
205
|
-
actionSource,
|
206
|
-
eventSourceUrl,
|
207
|
-
userData: Object.assign(Object.assign(Object.assign({ externalId: fakeUserId }, (fbclid && { fbc: `fb.2.${new Date().getTime()}.${fbclid}` })), (getCookie('_fbp') && { fbp: `fb.2.${new Date().getTime()}.${getCookie('_fbp')}` })), { clientUserAgent: (_d = (_c = window === null || window === void 0 ? void 0 : window.navigator) === null || _c === void 0 ? void 0 : _c.userAgent) !== null && _d !== void 0 ? _d : '' })
|
208
|
-
},
|
250
|
+
body: jsonParams,
|
209
251
|
type: 'beacon'
|
210
252
|
});
|
211
253
|
}, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
|
@@ -11,9 +11,15 @@ export declare const getBgStyleByImg: (data: any) => "" | {
|
|
11
11
|
backgroundRepeat: string;
|
12
12
|
backgroundSize: string;
|
13
13
|
};
|
14
|
-
|
14
|
+
interface IfontType {
|
15
|
+
'fontFamily-cn': string;
|
16
|
+
'fontFamily-en': string;
|
17
|
+
}
|
18
|
+
export declare const getPriceText: ({ product, enableFormattedPrice, globalConfig, isHiddenDef, style }: {
|
15
19
|
product: ProductInfoType | undefined | null;
|
16
20
|
enableFormattedPrice: boolean | undefined;
|
17
21
|
globalConfig: ISxpPageRenderProps['globalConfig'];
|
18
22
|
isHiddenDef?: boolean;
|
23
|
+
style?: IfontType | any;
|
19
24
|
}) => string | null;
|
25
|
+
export {};
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { setFontForText } from './tool';
|
1
2
|
export const getMediaValueByMode = (obj) => {
|
2
3
|
var _a;
|
3
4
|
if (!obj || typeof obj !== 'object') {
|
@@ -29,8 +30,8 @@ export const getBgStyleByImg = (data) => {
|
|
29
30
|
const imgSrc = typeof bgImg === 'string' ? bgImg : getMediaValueByMode(bgImg);
|
30
31
|
return getBgStyle(imgSrc);
|
31
32
|
};
|
32
|
-
export const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef }) => {
|
33
|
-
var _a, _b, _c, _d, _e;
|
33
|
+
export const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef, style }) => {
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
34
35
|
if ((!(product === null || product === void 0 ? void 0 : product.currency) || !(product === null || product === void 0 ? void 0 : product.price)) && isHiddenDef)
|
35
36
|
return null;
|
36
37
|
let price = (product === null || product === void 0 ? void 0 : product.currency) && (product === null || product === void 0 ? void 0 : product.price) ? product === null || product === void 0 ? void 0 : product.price : 7000;
|
@@ -77,6 +78,8 @@ export const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHi
|
|
77
78
|
}
|
78
79
|
});
|
79
80
|
}
|
81
|
+
currency = `<span style="font-family:${(_h = (_g = (_f = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.priceSymbol) === null || _f === void 0 ? void 0 : _f.fontFamily) !== null && _g !== void 0 ? _g : style === null || style === void 0 ? void 0 : style['fontFamily-en']) !== null && _h !== void 0 ? _h : 'inherit'}">${currency}</span>`;
|
82
|
+
text = setFontForText(text, style);
|
80
83
|
if ((priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) && (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) !== 'none') {
|
81
84
|
text = (priceSymbol === null || priceSymbol === void 0 ? void 0 : priceSymbol.currencyPosition) === 'left' ? currency + text : text + currency;
|
82
85
|
}
|
package/es/core/utils/tool.d.ts
CHANGED
@@ -11,4 +11,5 @@ declare function getBrowserInfo(): string | null;
|
|
11
11
|
declare function getSystem(): string | null;
|
12
12
|
declare function getDevice(): string | null;
|
13
13
|
declare function getCookie(val: string): string;
|
14
|
-
|
14
|
+
declare const getResFileSizeFromSrc: (imageSrc?: string) => "" | Promise<string>;
|
15
|
+
export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie, getResFileSizeFromSrc };
|
package/es/core/utils/tool.js
CHANGED
@@ -156,4 +156,14 @@ function getCookie(val) {
|
|
156
156
|
});
|
157
157
|
return value !== null && value !== void 0 ? value : '';
|
158
158
|
}
|
159
|
-
|
159
|
+
const getResFileSizeFromSrc = (imageSrc) => {
|
160
|
+
if (!imageSrc)
|
161
|
+
return '';
|
162
|
+
return fetch(imageSrc)
|
163
|
+
.then((response) => response.blob())
|
164
|
+
.then((blob) => {
|
165
|
+
const fileSizeInMB = blob.size / (1024 * 1024);
|
166
|
+
return fileSizeInMB.toFixed(2) + '';
|
167
|
+
});
|
168
|
+
};
|
169
|
+
export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie, getResFileSizeFromSrc };
|