pb-sxp-ui 1.7.1 → 1.7.2
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 +118 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +118 -57
- 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 +118 -57
- 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/VideoWidget/index.js +8 -5
- package/es/core/components/SxpPageRender/WaterFall/index.js +5 -2
- package/es/core/components/SxpPageRender/index.d.ts +1 -0
- package/es/core/components/SxpPageRender/index.js +10 -17
- package/es/core/context/SxpDataSourceProvider.d.ts +2 -4
- package/es/core/context/SxpDataSourceProvider.js +53 -11
- package/es/materials/sxp/popup/CommodityDetail/index.d.ts +1 -0
- package/es/materials/sxp/popup/CommodityDetail/index.js +12 -7
- 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 +15 -8
- package/es/materials/sxp/popup/CommodityList/index.js +7 -2
- package/lib/core/components/SxpPageRender/Modal/index.js +5 -2
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +8 -5
- package/lib/core/components/SxpPageRender/WaterFall/index.js +5 -2
- package/lib/core/components/SxpPageRender/index.d.ts +1 -0
- package/lib/core/components/SxpPageRender/index.js +10 -17
- package/lib/core/context/SxpDataSourceProvider.d.ts +2 -4
- package/lib/core/context/SxpDataSourceProvider.js +53 -11
- package/lib/materials/sxp/popup/CommodityDetail/index.d.ts +1 -0
- package/lib/materials/sxp/popup/CommodityDetail/index.js +12 -7
- 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 +15 -8
- package/lib/materials/sxp/popup/CommodityList/index.js +6 -1
- package/package.json +1 -1
@@ -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;
|
@@ -192,23 +192,65 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
192
192
|
type: 'beacon'
|
193
193
|
});
|
194
194
|
}, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
|
195
|
-
const bffFbReport = (0, react_1.useCallback)((
|
196
|
-
var _b, _c, _d;
|
197
|
-
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;
|
195
|
+
const bffFbReport = (0, react_1.useCallback)(({ eventName, product }) => {
|
196
|
+
var _a, _b, _c, _d;
|
198
197
|
if (!enableReportEvent || !enabledMetaConversionApi || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
|
199
198
|
return;
|
200
199
|
}
|
201
|
-
|
200
|
+
let jsonParams = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.converApi) === null || _a === void 0 ? void 0 : _a[eventName];
|
202
201
|
const urlParams = new URLSearchParams(window.location.search);
|
203
|
-
const fbclid = urlParams.get('fbclid');
|
202
|
+
const fbclid = urlParams === null || urlParams === void 0 ? void 0 : urlParams.get('fbclid');
|
203
|
+
const fix_par = {
|
204
|
+
event_source_url: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href,
|
205
|
+
external_id: (0, localStore_1.storeAndLoadFeUserId)(),
|
206
|
+
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 : '',
|
207
|
+
fbc: fbclid ? `fb.2.${new Date().getTime()}.${fbclid}` : '',
|
208
|
+
fbp: (0, tool_1.getCookie)('_fbp') ? `fb.2.${new Date().getTime()}.${(0, tool_1.getCookie)('_fbp')}` : '',
|
209
|
+
time: new Date().getTime()
|
210
|
+
};
|
211
|
+
const regex = /\{\{(.*?)\}\}/g;
|
212
|
+
const getEventParams = (obj) => {
|
213
|
+
if (!obj)
|
214
|
+
return;
|
215
|
+
if (obj instanceof Array) {
|
216
|
+
obj === null || obj === void 0 ? void 0 : obj.map((item) => getEventParams(item));
|
217
|
+
}
|
218
|
+
else {
|
219
|
+
for (const key in obj) {
|
220
|
+
if (obj.hasOwnProperty(key)) {
|
221
|
+
const value = obj === null || obj === void 0 ? void 0 : obj[key];
|
222
|
+
if (typeof value === 'object') {
|
223
|
+
getEventParams(value);
|
224
|
+
}
|
225
|
+
else if (typeof value === 'string') {
|
226
|
+
const matches = value === null || value === void 0 ? void 0 : value.match(regex);
|
227
|
+
if (matches) {
|
228
|
+
matches.forEach((match) => {
|
229
|
+
const prop = match.substring(2, match.length - 2);
|
230
|
+
try {
|
231
|
+
const replaceValue = new Function('fix_par', 'product', `return ${prop}`)(fix_par, product);
|
232
|
+
if (replaceValue) {
|
233
|
+
obj[key] = replaceValue;
|
234
|
+
}
|
235
|
+
else {
|
236
|
+
delete obj[key];
|
237
|
+
}
|
238
|
+
}
|
239
|
+
catch (error) {
|
240
|
+
delete obj[key];
|
241
|
+
console.error('An error occurred:', error === null || error === void 0 ? void 0 : error.message);
|
242
|
+
}
|
243
|
+
});
|
244
|
+
}
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
}
|
249
|
+
};
|
250
|
+
getEventParams(jsonParams);
|
204
251
|
return bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/fb/events', {
|
205
252
|
method: 'POST',
|
206
|
-
body:
|
207
|
-
eventName,
|
208
|
-
actionSource,
|
209
|
-
eventSourceUrl,
|
210
|
-
userData: Object.assign(Object.assign(Object.assign({ externalId: fakeUserId }, (fbclid && { fbc: `fb.2.${new Date().getTime()}.${fbclid}` })), ((0, tool_1.getCookie)('_fbp') && { fbp: `fb.2.${new Date().getTime()}.${(0, tool_1.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 : '' })
|
211
|
-
},
|
253
|
+
body: jsonParams,
|
212
254
|
type: 'beacon'
|
213
255
|
});
|
214
256
|
}, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
|
@@ -16,7 +16,7 @@ const CommodityGroup_1 = tslib_1.__importDefault(require("../../template/compone
|
|
16
16
|
const materials_1 = require("../../../../core/utils/materials");
|
17
17
|
const CommodityDetail = (_a) => {
|
18
18
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
19
|
-
var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio, isTel, iframeBgColor } = _a, props = tslib_1.__rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio", "isTel", "iframeBgColor"]);
|
19
|
+
var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio, isTel, iframeBgColor, isActive = true } = _a, props = tslib_1.__rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio", "isTel", "iframeBgColor", "isActive"]);
|
20
20
|
const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef, globalConfig } = (0, hooks_1.useSxpDataSource)();
|
21
21
|
const { jumpToWeb, productView } = (0, useEventReport_1.useEventReport)();
|
22
22
|
const curTimeRef = (0, react_1.useRef)(null);
|
@@ -46,12 +46,17 @@ const CommodityDetail = (_a) => {
|
|
46
46
|
}
|
47
47
|
};
|
48
48
|
(0, react_1.useEffect)(() => {
|
49
|
-
if (!
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
if (!isActive)
|
50
|
+
return;
|
51
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
52
|
+
eventName: 'ProductView',
|
53
|
+
product
|
54
|
+
});
|
55
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
56
|
+
eventName: 'PageView',
|
57
|
+
product
|
58
|
+
});
|
59
|
+
}, [isActive, bffFbReport]);
|
55
60
|
(0, react_1.useEffect)(() => {
|
56
61
|
const initTime = () => {
|
57
62
|
curTimeRef.current = new Date();
|
@@ -12,7 +12,7 @@ const useEventReport_1 = require("../../../../core/hooks/useEventReport");
|
|
12
12
|
const FormatImage_1 = tslib_1.__importDefault(require("../../../../core/components/SxpPageRender/FormatImage"));
|
13
13
|
const CommodityDetailDiro = (_a) => {
|
14
14
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
15
|
-
var { style, isDefault, rec, viewTime, isPost, bottom_image, index } = _a, props = tslib_1.__rest(_a, ["style", "isDefault", "rec", "viewTime", "isPost", "bottom_image", "index"]);
|
15
|
+
var { style, isDefault, rec, viewTime, isPost, bottom_image, index, isActive = true } = _a, props = tslib_1.__rest(_a, ["style", "isDefault", "rec", "viewTime", "isPost", "bottom_image", "index", "isActive"]);
|
16
16
|
const [spread, setSpread] = (0, react_1.useState)(true);
|
17
17
|
const { sxpParameter } = (0, hooks_1.useSxpDataSource)();
|
18
18
|
const { popupDetailData, bffEventReport, isPreview, swiperRef, bffFbReport } = (0, hooks_1.useSxpDataSource)();
|
@@ -38,14 +38,21 @@ const CommodityDetailDiro = (_a) => {
|
|
38
38
|
}
|
39
39
|
};
|
40
40
|
(0, react_1.useEffect)(() => {
|
41
|
-
if (!
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
if (!isActive)
|
42
|
+
return;
|
43
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
44
|
+
eventName: 'ProductView',
|
45
|
+
product
|
46
|
+
});
|
47
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
48
|
+
eventName: 'PageView',
|
49
|
+
product
|
50
|
+
});
|
51
|
+
}, [isActive, bffFbReport]);
|
47
52
|
(0, react_1.useEffect)(() => {
|
48
53
|
const initTime = () => {
|
54
|
+
if (!isActive)
|
55
|
+
return;
|
49
56
|
curTimeRef.current = new Date();
|
50
57
|
};
|
51
58
|
initTime();
|
@@ -53,7 +60,7 @@ const CommodityDetailDiro = (_a) => {
|
|
53
60
|
return () => {
|
54
61
|
window.removeEventListener('pageshow', initTime);
|
55
62
|
};
|
56
|
-
}, []);
|
63
|
+
}, [isActive]);
|
57
64
|
const priceText = (0, react_1.useMemo)(() => {
|
58
65
|
var _a, _b, _c, _d, _e;
|
59
66
|
if ((product === null || product === void 0 ? void 0 : product.currency) && (product === null || product === void 0 ? void 0 : product.price)) {
|
@@ -16,7 +16,7 @@ const CommodityGroup_1 = tslib_1.__importDefault(require("../../template/compone
|
|
16
16
|
const materials_1 = require("../../../../core/utils/materials");
|
17
17
|
const CommodityDetailDiroNew = (_a) => {
|
18
18
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
19
|
-
var { style, isDefault, rec, viewTime, isPost, bottom_image, tipText, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio, isTel, iframeBgColor } = _a, props = tslib_1.__rest(_a, ["style", "isDefault", "rec", "viewTime", "isPost", "bottom_image", "tipText", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio", "isTel", "iframeBgColor"]);
|
19
|
+
var { style, isDefault, rec, viewTime, isPost, bottom_image, tipText, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio, isTel, iframeBgColor, isActive = true } = _a, props = tslib_1.__rest(_a, ["style", "isDefault", "rec", "viewTime", "isPost", "bottom_image", "tipText", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio", "isTel", "iframeBgColor", "isActive"]);
|
20
20
|
const [spread, setSpread] = (0, react_1.useState)(true);
|
21
21
|
const { sxpParameter, popupCurTimeRef, popupDetailData, isPreview, bffFbReport, checkCommodityIndexRef, globalConfig } = (0, hooks_1.useSxpDataSource)();
|
22
22
|
const { jumpToWeb, productView } = (0, useEventReport_1.useEventReport)();
|
@@ -50,14 +50,21 @@ const CommodityDetailDiroNew = (_a) => {
|
|
50
50
|
}
|
51
51
|
};
|
52
52
|
(0, react_1.useEffect)(() => {
|
53
|
-
if (!
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
if (!isActive)
|
54
|
+
return;
|
55
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
56
|
+
eventName: 'ProductView',
|
57
|
+
product
|
58
|
+
});
|
59
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
60
|
+
eventName: 'PageView',
|
61
|
+
product
|
62
|
+
});
|
63
|
+
}, [isActive, bffFbReport]);
|
59
64
|
(0, react_1.useEffect)(() => {
|
60
65
|
const initTime = () => {
|
66
|
+
if (!isActive)
|
67
|
+
return;
|
61
68
|
curTimeRef.current = new Date();
|
62
69
|
};
|
63
70
|
initTime();
|
@@ -65,7 +72,7 @@ const CommodityDetailDiroNew = (_a) => {
|
|
65
72
|
return () => {
|
66
73
|
window.removeEventListener('pageshow', initTime);
|
67
74
|
};
|
68
|
-
}, []);
|
75
|
+
}, [isActive]);
|
69
76
|
const priceText = (0, materials_1.getPriceText)({
|
70
77
|
product,
|
71
78
|
enableFormattedPrice: (_t = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _t === void 0 ? void 0 : _t.enableFormattedPrice,
|
@@ -13,7 +13,7 @@ const materials_1 = require("../../../../core/utils/materials");
|
|
13
13
|
const CommodityList = (_a) => {
|
14
14
|
var _b, _c, _d;
|
15
15
|
var { style, isDefault, rec, viewTime, isPost, bottom_image, commodityStyles, buttonStyle, translateY = 0, commodityPicture, isExternalLink, onClick } = _a, props = tslib_1.__rest(_a, ["style", "isDefault", "rec", "viewTime", "isPost", "bottom_image", "commodityStyles", "buttonStyle", "translateY", "commodityPicture", "isExternalLink", "onClick"]);
|
16
|
-
const { sxpParameter, popupDetailData, setPopupDetailData, ctaEvent, globalConfig } = (0, hooks_1.useSxpDataSource)();
|
16
|
+
const { sxpParameter, popupDetailData, setPopupDetailData, ctaEvent, globalConfig, bffFbReport } = (0, hooks_1.useSxpDataSource)();
|
17
17
|
const { jumpToWeb } = (0, useEventReport_1.useEventReport)();
|
18
18
|
const { popup } = (0, hooks_1.useEditor)();
|
19
19
|
const recData = isPost ? rec : popupDetailData;
|
@@ -43,6 +43,11 @@ const CommodityList = (_a) => {
|
|
43
43
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
44
44
|
}
|
45
45
|
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
46
|
+
(0, react_1.useEffect)(() => {
|
47
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
48
|
+
eventName: 'PageView'
|
49
|
+
});
|
50
|
+
}, []);
|
46
51
|
return (react_1.default.createElement("div", { className: (0, css_1.css)(Object.assign(Object.assign({}, style), { display: 'flex', flexDirection: 'column', gap: '10px', padding: '0 20px', marginTop: '50px', boxSizing: 'border-box' })) }, product === null || product === void 0 ? void 0 : product.map((item, index) => {
|
47
52
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
48
53
|
return (react_1.default.createElement(react_1.default.Fragment, null, recData && !(item === null || item === void 0 ? void 0 : item.bindCta) ? null : (react_1.default.createElement("div", Object.assign({ key: index }, props, { className: (0, css_1.css)({
|