pb-sxp-ui 1.20.30 → 1.20.31
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 +60 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -16
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +7 -7
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +7 -7
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +60 -16
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +7 -7
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/StructurePage/index.js +55 -16
- package/lib/core/components/StructurePage/index.js +55 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19387,34 +19387,43 @@ const baseStyles = {
|
|
|
19387
19387
|
carouselSection: {
|
|
19388
19388
|
width: '100%',
|
|
19389
19389
|
position: 'relative',
|
|
19390
|
-
padding: '20px
|
|
19390
|
+
padding: '20px'
|
|
19391
19391
|
},
|
|
19392
19392
|
carouselImageContainer: {
|
|
19393
19393
|
width: '100%',
|
|
19394
|
-
|
|
19394
|
+
maxWidth: '100%',
|
|
19395
|
+
margin: '0 auto',
|
|
19395
19396
|
position: 'relative',
|
|
19396
|
-
overflow: 'hidden'
|
|
19397
|
+
overflow: 'hidden',
|
|
19398
|
+
aspectRatio: '9 / 16',
|
|
19399
|
+
touchAction: 'pan-y pinch-zoom'
|
|
19397
19400
|
},
|
|
19398
19401
|
carouselContainer: {
|
|
19399
19402
|
display: 'flex',
|
|
19400
|
-
transition: 'transform 0.
|
|
19401
|
-
width: '100%'
|
|
19403
|
+
transition: 'transform 0.3s ease-out',
|
|
19404
|
+
width: '100%',
|
|
19405
|
+
height: '100%'
|
|
19402
19406
|
},
|
|
19403
19407
|
carouselSlide: {
|
|
19404
19408
|
minWidth: '100%',
|
|
19409
|
+
height: '100%',
|
|
19405
19410
|
position: 'relative'
|
|
19406
19411
|
},
|
|
19407
19412
|
carouselImage: {
|
|
19408
19413
|
width: '100%',
|
|
19409
|
-
height: '
|
|
19414
|
+
height: '100%',
|
|
19410
19415
|
display: 'block',
|
|
19411
|
-
objectFit: 'cover'
|
|
19416
|
+
objectFit: 'cover',
|
|
19417
|
+
userSelect: 'none',
|
|
19418
|
+
WebkitUserDrag: 'none'
|
|
19412
19419
|
},
|
|
19413
19420
|
carouselVideo: {
|
|
19414
19421
|
width: '100%',
|
|
19415
|
-
height: '
|
|
19422
|
+
height: '100%',
|
|
19416
19423
|
display: 'block',
|
|
19417
|
-
objectFit: 'cover'
|
|
19424
|
+
objectFit: 'cover',
|
|
19425
|
+
userSelect: 'none',
|
|
19426
|
+
WebkitUserDrag: 'none'
|
|
19418
19427
|
},
|
|
19419
19428
|
carouselInfoSection: {
|
|
19420
19429
|
width: '100%',
|
|
@@ -19614,12 +19623,14 @@ const baseStyles = {
|
|
|
19614
19623
|
}
|
|
19615
19624
|
};
|
|
19616
19625
|
const StructurePage = (_a) => {
|
|
19617
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
|
19626
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
19618
19627
|
var { containerStyle, containerHeight = 664, containerWidth = 375, className = '', apiUrl = 'https://bff-be-dev.chatlabs.net/api/v1/recommend/list', requestBody, editorMode = false, multiCTAConfig: propMultiCTAConfig, videoPlayIcon: propVideoPlayIcon, isCmsMode = false, storyId, customHeaders } = _a, rest = __rest(_a, ["containerStyle", "containerHeight", "containerWidth", "className", "apiUrl", "requestBody", "editorMode", "multiCTAConfig", "videoPlayIcon", "isCmsMode", "storyId", "customHeaders"]);
|
|
19619
19628
|
const [data, setData] = useState(null);
|
|
19620
19629
|
const [loading, setLoading] = useState(true);
|
|
19621
19630
|
const [error, setError] = useState(null);
|
|
19622
19631
|
const [carouselIndex, setCarouselIndex] = useState(0);
|
|
19632
|
+
const [touchStart, setTouchStart] = useState(null);
|
|
19633
|
+
const [touchEnd, setTouchEnd] = useState(null);
|
|
19623
19634
|
const heroVideoRef = useRef(null);
|
|
19624
19635
|
const carouselVideoRefs = useRef([]);
|
|
19625
19636
|
// 视频暂停状态管理
|
|
@@ -19995,6 +20006,39 @@ const StructurePage = (_a) => {
|
|
|
19995
20006
|
setCarouselIndex((prev) => (prev === data.carouselSection.length - 1 ? 0 : prev + 1));
|
|
19996
20007
|
}
|
|
19997
20008
|
};
|
|
20009
|
+
// 触摸滑动处理
|
|
20010
|
+
const handleTouchStart = (e) => {
|
|
20011
|
+
setTouchEnd(null);
|
|
20012
|
+
setTouchStart(e.targetTouches[0].clientX);
|
|
20013
|
+
};
|
|
20014
|
+
const handleTouchMove = (e) => {
|
|
20015
|
+
if (!touchStart)
|
|
20016
|
+
return;
|
|
20017
|
+
const currentTouch = e.targetTouches[0].clientX;
|
|
20018
|
+
setTouchEnd(currentTouch);
|
|
20019
|
+
// 如果移动距离大于阈值,阻止默认行为(防止拖拽图片)
|
|
20020
|
+
const distance = Math.abs(touchStart - currentTouch);
|
|
20021
|
+
if (distance > 10) {
|
|
20022
|
+
e.preventDefault();
|
|
20023
|
+
}
|
|
20024
|
+
};
|
|
20025
|
+
const handleTouchEnd = () => {
|
|
20026
|
+
if (!touchStart || !touchEnd)
|
|
20027
|
+
return;
|
|
20028
|
+
const distance = touchStart - touchEnd;
|
|
20029
|
+
const minSwipeDistance = 50;
|
|
20030
|
+
if (distance > minSwipeDistance) {
|
|
20031
|
+
// 向左滑动,下一张
|
|
20032
|
+
handleCarouselNext();
|
|
20033
|
+
}
|
|
20034
|
+
else if (distance < -minSwipeDistance) {
|
|
20035
|
+
// 向右滑动,上一张
|
|
20036
|
+
handleCarouselPrev();
|
|
20037
|
+
}
|
|
20038
|
+
// 重置状态
|
|
20039
|
+
setTouchStart(null);
|
|
20040
|
+
setTouchEnd(null);
|
|
20041
|
+
};
|
|
19998
20042
|
if (loading) {
|
|
19999
20043
|
return (React.createElement("div", { style: Object.assign(Object.assign({}, baseStyles.container), { height: containerHeight, width: containerWidth, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', fontSize: '16px' }) }, "Loading..."));
|
|
20000
20044
|
}
|
|
@@ -20014,21 +20058,21 @@ const StructurePage = (_a) => {
|
|
|
20014
20058
|
React.createElement("video", { ref: heroVideoRef, src: data.heroSection.url, style: baseStyles.heroVideo, autoPlay: true, muted: true, loop: true, playsInline: true, controls: false }),
|
|
20015
20059
|
isHeroVideoPaused && (React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon, alt: 'play' })))) : ((_e = data.heroSection.imgUrls) === null || _e === void 0 ? void 0 : _e[0]) ? (React.createElement("img", { src: data.heroSection.imgUrls[0], alt: 'Hero', style: baseStyles.heroImage })) : null,
|
|
20016
20060
|
React.createElement("div", { style: baseStyles.heroOverlay }, renderCTA('heroButton', (_g = (_f = data.heroSection.bindProducts) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.bindCta, (_h = data.heroSection.bindProducts) === null || _h === void 0 ? void 0 : _h[0], baseStyles.heroButton))))),
|
|
20017
|
-
data.carouselSection && data.carouselSection.length > 0 && (React.createElement("div", { style:
|
|
20018
|
-
React.createElement("div", { style:
|
|
20061
|
+
data.carouselSection && data.carouselSection.length > 0 && (React.createElement("div", { style: mergeStyles(baseStyles.carouselSection, 'carouselSection') },
|
|
20062
|
+
React.createElement("div", { style: baseStyles.carouselImageContainer, onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd },
|
|
20019
20063
|
React.createElement("div", { style: Object.assign(Object.assign({}, baseStyles.carouselContainer), { transform: `translateX(-${carouselIndex * 100}%)` }) }, data.carouselSection.map((item, index) => {
|
|
20020
20064
|
var _a;
|
|
20021
20065
|
return (React.createElement("div", { key: item.itemId, style: baseStyles.carouselSlide }, item.url ? (React.createElement("div", { style: { position: 'relative', width: '100%', height: '100%' }, onClick: () => handleCarouselVideoClick(index) },
|
|
20022
20066
|
React.createElement("video", { ref: (el) => {
|
|
20023
20067
|
carouselVideoRefs.current[index] = el;
|
|
20024
|
-
}, src: item.url, style: baseStyles.carouselVideo, muted: true, loop: true, playsInline: true, controls: false }),
|
|
20025
|
-
carouselVideoPausedStates[index] && (React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon, alt: 'play' })))) : ((_a = item.imgUrls) === null || _a === void 0 ? void 0 : _a[0]) ? (React.createElement("img", { src: item.imgUrls[0], alt: item.text || 'Carousel', style: baseStyles.carouselImage })) : null));
|
|
20068
|
+
}, src: item.url, style: baseStyles.carouselVideo, muted: true, loop: true, playsInline: true, controls: false, draggable: false, onDragStart: (e) => e.preventDefault() }),
|
|
20069
|
+
carouselVideoPausedStates[index] && (React.createElement(FormatImage$1, { className: 'clc-pb-video-pause', src: videoPlayIcon, alt: 'play' })))) : ((_a = item.imgUrls) === null || _a === void 0 ? void 0 : _a[0]) ? (React.createElement("img", { src: item.imgUrls[0], alt: item.text || 'Carousel', style: baseStyles.carouselImage, draggable: false, onDragStart: (e) => e.preventDefault() })) : null));
|
|
20026
20070
|
})),
|
|
20027
20071
|
React.createElement("button", { style: Object.assign(Object.assign({}, baseStyles.arrowButton), { left: '10px' }), onClick: handleCarouselPrev }, "\u2039"),
|
|
20028
20072
|
React.createElement("button", { style: Object.assign(Object.assign({}, baseStyles.arrowButton), { right: '10px' }), onClick: handleCarouselNext }, "\u203A")),
|
|
20029
20073
|
React.createElement("div", { style: mergeStyles(baseStyles.carouselInfoSection, 'carouselSection') },
|
|
20030
|
-
((
|
|
20031
|
-
renderCTA('carouselButton', (
|
|
20074
|
+
((_j = data.carouselSection[carouselIndex]) === null || _j === void 0 ? void 0 : _j.text) && (React.createElement("div", { style: mergeStyles(baseStyles.carouselText, 'carouselSection') }, (_k = data.carouselSection[carouselIndex]) === null || _k === void 0 ? void 0 : _k.text)),
|
|
20075
|
+
renderCTA('carouselButton', (_o = (_m = (_l = data.carouselSection[carouselIndex]) === null || _l === void 0 ? void 0 : _l.bindProducts) === null || _m === void 0 ? void 0 : _m[0]) === null || _o === void 0 ? void 0 : _o.bindCta, (_q = (_p = data.carouselSection[carouselIndex]) === null || _p === void 0 ? void 0 : _p.bindProducts) === null || _q === void 0 ? void 0 : _q[0], baseStyles.carouselButton)))),
|
|
20032
20076
|
data.highlightRevealSection && (React.createElement("div", { style: mergeStyles(baseStyles.highlightSection, 'highlightSection') },
|
|
20033
20077
|
React.createElement("div", { style: baseStyles.highlightImageContainer },
|
|
20034
20078
|
React.createElement("img", { src: data.highlightRevealSection.landingImageUrl || data.highlightRevealSection.cover, alt: data.highlightRevealSection.title, style: baseStyles.highlightImage })),
|