pb-sxp-ui 1.20.67 → 1.20.69
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 +53 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -37
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +6 -6
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +53 -37
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +6 -6
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/Popup/index.js +16 -9
- package/es/core/components/SxpPageRender/VideoWidget/index.js +6 -2
- package/es/core/components/SxpPageRender/index.js +2 -5
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +24 -18
- package/lib/core/components/SxpPageRender/Popup/index.js +16 -9
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +6 -2
- package/lib/core/components/SxpPageRender/index.js +2 -5
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +24 -18
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12754,7 +12754,7 @@ const CommodityDetailDiroNew$1 = (_a) => {
|
|
|
12754
12754
|
var { style, rec, viewTime, isPost, bottom_image, tipText, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio, iframeBgColor, isActive = true } = _a, props = __rest(_a, ["style", "rec", "viewTime", "isPost", "bottom_image", "tipText", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio", "iframeBgColor", "isActive"]);
|
|
12755
12755
|
const { sxpParameter, popupCurTimeRef, popupDetailData, setPopupDetailData, isPreview, bffFbReport, checkCommodityIndexRef, globalConfig, ctaEvent } = useSxpDataSource();
|
|
12756
12756
|
useEditor();
|
|
12757
|
-
const { productView } = useEventReport();
|
|
12757
|
+
const { productView, jumpToWeb } = useEventReport();
|
|
12758
12758
|
const [showModal, setShowModal] = React.useState(false);
|
|
12759
12759
|
const curTimeRef = React.useRef(null);
|
|
12760
12760
|
const [show3DModal, setShow3DModal] = React.useState(false);
|
|
@@ -12777,21 +12777,20 @@ const CommodityDetailDiroNew$1 = (_a) => {
|
|
|
12777
12777
|
}
|
|
12778
12778
|
// 是否为 SKU 层绑定(variantId 和 variantOption 同时存在时)
|
|
12779
12779
|
const isSkuLevel = !!(product === null || product === void 0 ? void 0 : product.variantId) && !!(product === null || product === void 0 ? void 0 : product.variantOption);
|
|
12780
|
-
const handleOpenAddToCart = (variantId) => {
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
productView(data, product, cta, viewTime || curTimeRef.current, position);
|
|
12780
|
+
const handleOpenAddToCart = (variantId, isUserClick = false) => {
|
|
12781
|
+
if (isUserClick) {
|
|
12782
|
+
ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({ eventSubject: 'clickCta', eventDescription: 'User clicked the CTA' }, data, product, position);
|
|
12783
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
|
12784
|
+
eventName: 'ClickCTA',
|
|
12785
|
+
product: product ? [product] : undefined,
|
|
12786
|
+
contentType: 'product',
|
|
12787
|
+
data,
|
|
12788
|
+
position,
|
|
12789
|
+
cta_text: cta === null || cta === void 0 ? void 0 : cta.enTitle,
|
|
12790
|
+
cta_action_type: 'open_internal_popup',
|
|
12791
|
+
target_content_id: product === null || product === void 0 ? void 0 : product.itemId,
|
|
12792
|
+
target_url: product === null || product === void 0 ? void 0 : product.link
|
|
12793
|
+
});
|
|
12795
12794
|
}
|
|
12796
12795
|
ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({ eventSubject: 'clickShopifyPopup', eventDescription: 'User clicked to open Shopify popup' }, data, product, position);
|
|
12797
12796
|
setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, data), { video: Object.assign(Object.assign({}, data === null || data === void 0 ? void 0 : data.video), { bindProduct: product }), index: position }));
|
|
@@ -12815,12 +12814,13 @@ const CommodityDetailDiroNew$1 = (_a) => {
|
|
|
12815
12814
|
});
|
|
12816
12815
|
productView(data, product, cta, viewTime || curTimeRef.current, position);
|
|
12817
12816
|
if (product === null || product === void 0 ? void 0 : product.link) {
|
|
12817
|
+
jumpToWeb(e, data, product, cta, position);
|
|
12818
12818
|
window.location.href = window.getJointUtmLink(product.link);
|
|
12819
12819
|
}
|
|
12820
12820
|
return;
|
|
12821
12821
|
}
|
|
12822
12822
|
// SKU 层绑定:直接传入 variantId 预选该 SKU
|
|
12823
|
-
handleOpenAddToCart(isSkuLevel ? product === null || product === void 0 ? void 0 : product.variantId : undefined);
|
|
12823
|
+
handleOpenAddToCart(isSkuLevel ? product === null || product === void 0 ? void 0 : product.variantId : undefined, true);
|
|
12824
12824
|
};
|
|
12825
12825
|
// popup 模式下,若为 SKU 层绑定,直接自动打开加购弹窗
|
|
12826
12826
|
React.useEffect(() => {
|
|
@@ -13107,7 +13107,14 @@ Made in Italy` })));
|
|
|
13107
13107
|
marginTop: '50px',
|
|
13108
13108
|
border: 'none'
|
|
13109
13109
|
} }))),
|
|
13110
|
-
showAddToCart && (React.createElement(Modal$1, { visible: showAddToCart, padding: 0, isFullScreen: false, onClose: () =>
|
|
13110
|
+
showAddToCart && (React.createElement(Modal$1, { visible: showAddToCart, padding: 0, isFullScreen: false, onClose: () => {
|
|
13111
|
+
setShowAddToCart(false);
|
|
13112
|
+
// SKU 场景:关闭加购弹窗时直接回到 feed,不再停留在商品弹窗
|
|
13113
|
+
if (addToCartVariantId && typeof window !== 'undefined' && window.sxpPopup) {
|
|
13114
|
+
window.sxpPopup('');
|
|
13115
|
+
setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(null);
|
|
13116
|
+
}
|
|
13117
|
+
} },
|
|
13111
13118
|
React.createElement(AddToCartPopup$1, { isActive: true, defaultVariantId: addToCartVariantId })))));
|
|
13112
13119
|
};
|
|
13113
13120
|
var CommodityDetailDiroNewComponent = React.memo(CommodityDetailDiroNew$1);
|
|
@@ -23323,6 +23330,7 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
|
23323
23330
|
const initTimeRef = React.useRef();
|
|
23324
23331
|
const loadedTimeRef = React.useRef();
|
|
23325
23332
|
const isFirstPlayRef = React.useRef(true);
|
|
23333
|
+
const lastPlayReportTimeRef = React.useRef(0);
|
|
23326
23334
|
const loopPlayRef = React.useRef(loopPlay);
|
|
23327
23335
|
const scene = rec.video.scene;
|
|
23328
23336
|
const videoUrl = (scene === null || scene === void 0 ? void 0 : scene.mediaUrl) || ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url);
|
|
@@ -23401,6 +23409,9 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
|
23401
23409
|
return;
|
|
23402
23410
|
setIsPauseVideo(false);
|
|
23403
23411
|
const item = data[index];
|
|
23412
|
+
const now = Date.now();
|
|
23413
|
+
if (now - lastPlayReportTimeRef.current < 500)
|
|
23414
|
+
return;
|
|
23404
23415
|
if (item && ((_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration)) {
|
|
23405
23416
|
videoStartTime.current = ((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) || 0;
|
|
23406
23417
|
const videoDuration = ((_f = (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) !== null && _f !== void 0 ? _f : 0).toFixed(2);
|
|
@@ -23409,6 +23420,7 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
|
23409
23420
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
|
23410
23421
|
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (_k = (_j = item === null || item === void 0 ? void 0 : item.video) === null || _j === void 0 ? void 0 : _j.itemId) !== null && _k !== void 0 ? _k : '', sceneId: (_o = (_m = (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.scene) === null || _m === void 0 ? void 0 : _m.sceneId) !== null && _o !== void 0 ? _o : '', contentName: (_q = (_p = item === null || item === void 0 ? void 0 : item.video) === null || _p === void 0 ? void 0 : _p.title) !== null && _q !== void 0 ? _q : '', playType, startTime: videoCurrentTime, videoDuration, contentTags: JSON.stringify((_s = (_r = item === null || item === void 0 ? void 0 : item.video) === null || _r === void 0 ? void 0 : _r.tags) !== null && _s !== void 0 ? _s : []), position: index + '', contentFormat: 'video', traceInfo: (_t = item === null || item === void 0 ? void 0 : item.video) === null || _t === void 0 ? void 0 : _t.traceInfo }, ((isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) && { loadTime: (loadedTimeRef === null || loadedTimeRef === void 0 ? void 0 : loadedTimeRef.current) - (initTimeRef === null || initTimeRef === void 0 ? void 0 : initTimeRef.current) + '' }))
|
|
23411
23422
|
});
|
|
23423
|
+
lastPlayReportTimeRef.current = Date.now();
|
|
23412
23424
|
isFirstPlayRef.current = false;
|
|
23413
23425
|
}
|
|
23414
23426
|
}), [bffEventReport, data, index, isFirstPlayRef, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
|
@@ -23437,9 +23449,8 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
|
23437
23449
|
if (!videoRef.current)
|
|
23438
23450
|
return;
|
|
23439
23451
|
loadedTimeRef.current = new Date();
|
|
23440
|
-
handleStartPlay();
|
|
23441
23452
|
handLoadeddata();
|
|
23442
|
-
}, [videoRef.current, handLoadeddata
|
|
23453
|
+
}, [videoRef.current, handLoadeddata]);
|
|
23443
23454
|
const handleClickVideo = React.useCallback((type) => () => {
|
|
23444
23455
|
var _a, _b, _c, _d, _e;
|
|
23445
23456
|
if (!videoRef.current)
|
|
@@ -24694,13 +24705,9 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight, containerWidt
|
|
|
24694
24705
|
viewTime.current = new Date();
|
|
24695
24706
|
};
|
|
24696
24707
|
const handleReportProductView = (item, position) => {
|
|
24697
|
-
var _a, _b, _c
|
|
24708
|
+
var _a, _b, _c;
|
|
24698
24709
|
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) && (item === null || item === void 0 ? void 0 : item.product)) {
|
|
24699
|
-
|
|
24700
|
-
const isEnableAddToCart = (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _c === void 0 ? void 0 : _c.some((v) => { var _a, _b; return (_b = (_a = v === null || v === void 0 ? void 0 : v.item) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.enableAddToCart; });
|
|
24701
|
-
if (isEnableAddToCart)
|
|
24702
|
-
return;
|
|
24703
|
-
productView(item, item.product, (_d = item === null || item === void 0 ? void 0 : item.product) === null || _d === void 0 ? void 0 : _d.bindCta, viewTime.current, position !== null && position !== void 0 ? position : activeIndex);
|
|
24710
|
+
productView(item, item.product, (_c = item === null || item === void 0 ? void 0 : item.product) === null || _c === void 0 ? void 0 : _c.bindCta, viewTime.current, position !== null && position !== void 0 ? position : activeIndex);
|
|
24704
24711
|
}
|
|
24705
24712
|
};
|
|
24706
24713
|
React.useEffect(() => {
|
|
@@ -25829,12 +25836,12 @@ const Popup = () => {
|
|
|
25829
25836
|
};
|
|
25830
25837
|
}, []);
|
|
25831
25838
|
React.useEffect(() => {
|
|
25832
|
-
var _a, _b, _c, _d;
|
|
25839
|
+
var _a, _b, _c, _d, _e;
|
|
25833
25840
|
if (popup && (popup === null || popup === void 0 ? void 0 : popup.id) && (popup === null || popup === void 0 ? void 0 : popup.id) !== '') {
|
|
25834
25841
|
popupCurTimeRef.current = new Date();
|
|
25835
25842
|
setVisible(popup);
|
|
25836
25843
|
const currentValue = (_c = (_b = (_a = schema === null || schema === void 0 ? void 0 : schema.sxpPageConf) === null || _a === void 0 ? void 0 : _a.globalConfig) === null || _b === void 0 ? void 0 : _b.popupList) === null || _c === void 0 ? void 0 : _c.find((item) => (item === null || item === void 0 ? void 0 : item.id) === (popup === null || popup === void 0 ? void 0 : popup.id));
|
|
25837
|
-
const isAddToCart = ((_d = currentValue === null || currentValue === void 0 ? void 0 : currentValue.item) === null || _d === void 0 ? void 0 : _d.type) === 'AddToCart';
|
|
25844
|
+
const isAddToCart = ((_d = currentValue === null || currentValue === void 0 ? void 0 : currentValue.item) === null || _d === void 0 ? void 0 : _d.type) === 'AddToCart' || ((_e = currentValue === null || currentValue === void 0 ? void 0 : currentValue.item) === null || _e === void 0 ? void 0 : _e.type) === 'AddToCartPopup';
|
|
25838
25845
|
isAddToCartPopupRef.current = isAddToCart;
|
|
25839
25846
|
if (!isAddToCart) {
|
|
25840
25847
|
// 记录非加购弹窗(商品弹窗等),供加购弹窗关闭后恢复
|
|
@@ -25842,7 +25849,8 @@ const Popup = () => {
|
|
|
25842
25849
|
}
|
|
25843
25850
|
}
|
|
25844
25851
|
else if ((popup === null || popup === void 0 ? void 0 : popup.id) === '') {
|
|
25845
|
-
// popup
|
|
25852
|
+
// popup 被清空时,同步 visible 状态以便 Modal 正确关闭,避免白屏且关不掉
|
|
25853
|
+
setVisible(Object.assign(Object.assign({}, popup), { id: '' }));
|
|
25846
25854
|
isAddToCartPopupRef.current = false;
|
|
25847
25855
|
}
|
|
25848
25856
|
}, [popup, schema]);
|
|
@@ -25861,11 +25869,16 @@ const Popup = () => {
|
|
|
25861
25869
|
}
|
|
25862
25870
|
}, [popup, schema]);
|
|
25863
25871
|
const handleClose = () => {
|
|
25864
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
25865
|
-
|
|
25866
|
-
|
|
25867
|
-
|
|
25868
|
-
|
|
25872
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
25873
|
+
// popup 已被清空时(如 CommodityDetailDiroNew SKU 场景直接调用 sxpPopup('')),确保能关闭 Modal,避免白屏关不掉
|
|
25874
|
+
if ((popup === null || popup === void 0 ? void 0 : popup.id) === '') {
|
|
25875
|
+
setVisible({ id: '' });
|
|
25876
|
+
setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(null);
|
|
25877
|
+
checkCommodityIndexRef.current = -1;
|
|
25878
|
+
prevCommodityPopupRef.current = null;
|
|
25879
|
+
return;
|
|
25880
|
+
}
|
|
25881
|
+
if (!popup || !visible || new Date() - popupCurTimeRef.current < ((_a = popup === null || popup === void 0 ? void 0 : popup.duration) !== null && _a !== void 0 ? _a : 0)) {
|
|
25869
25882
|
return;
|
|
25870
25883
|
}
|
|
25871
25884
|
setVisible(Object.assign(Object.assign({}, popup), { id: '' }));
|
|
@@ -25886,11 +25899,14 @@ const Popup = () => {
|
|
|
25886
25899
|
}
|
|
25887
25900
|
}
|
|
25888
25901
|
// 加购弹窗关闭时,判断是否需要恢复商品弹窗
|
|
25889
|
-
if (((_u = value === null || value === void 0 ? void 0 : value.item) === null || _u === void 0 ? void 0 : _u.type) === 'AddToCart') {
|
|
25902
|
+
if (((_u = value === null || value === void 0 ? void 0 : value.item) === null || _u === void 0 ? void 0 : _u.type) === 'AddToCart' || ((_v = value === null || value === void 0 ? void 0 : value.item) === null || _v === void 0 ? void 0 : _v.type) === 'AddToCartPopup') {
|
|
25890
25903
|
const prevPopup = prevCommodityPopupRef.current;
|
|
25891
25904
|
prevCommodityPopupRef.current = null;
|
|
25892
25905
|
isAddToCartPopupRef.current = false;
|
|
25893
|
-
|
|
25906
|
+
// SKU 场景:加购弹窗带有 _defaultVariantId 表示从 SKU CTA 直接进入(CommodityDetail 注入),关闭后不应恢复商品弹窗
|
|
25907
|
+
const popupData = popupDetailData;
|
|
25908
|
+
const isSkuFlow = !!(popupData === null || popupData === void 0 ? void 0 : popupData._defaultVariantId);
|
|
25909
|
+
if ((prevPopup === null || prevPopup === void 0 ? void 0 : prevPopup.id) && !isSkuFlow) {
|
|
25894
25910
|
// SPU 场景:加购弹窗之前有商品弹窗,关闭后恢复商品弹窗
|
|
25895
25911
|
const { id: commodityId } = prevPopup, commodityAni = __rest(prevPopup, ["id"]);
|
|
25896
25912
|
setTimeout(() => {
|
|
@@ -25898,7 +25914,7 @@ const Popup = () => {
|
|
|
25898
25914
|
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
|
25899
25915
|
return;
|
|
25900
25916
|
}
|
|
25901
|
-
// SKU
|
|
25917
|
+
// SKU 场景:直接回到 feed,不恢复商品弹窗
|
|
25902
25918
|
}
|
|
25903
25919
|
setTimeout(() => {
|
|
25904
25920
|
window === null || window === void 0 ? void 0 : window.sxpPopup('');
|