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 CHANGED
@@ -19409,34 +19409,43 @@ const baseStyles = {
19409
19409
  carouselSection: {
19410
19410
  width: '100%',
19411
19411
  position: 'relative',
19412
- padding: '20px 16px'
19412
+ padding: '20px'
19413
19413
  },
19414
19414
  carouselImageContainer: {
19415
19415
  width: '100%',
19416
- height: 'auto',
19416
+ maxWidth: '100%',
19417
+ margin: '0 auto',
19417
19418
  position: 'relative',
19418
- overflow: 'hidden'
19419
+ overflow: 'hidden',
19420
+ aspectRatio: '9 / 16',
19421
+ touchAction: 'pan-y pinch-zoom'
19419
19422
  },
19420
19423
  carouselContainer: {
19421
19424
  display: 'flex',
19422
- transition: 'transform 0.5s ease-in-out',
19423
- width: '100%'
19425
+ transition: 'transform 0.3s ease-out',
19426
+ width: '100%',
19427
+ height: '100%'
19424
19428
  },
19425
19429
  carouselSlide: {
19426
19430
  minWidth: '100%',
19431
+ height: '100%',
19427
19432
  position: 'relative'
19428
19433
  },
19429
19434
  carouselImage: {
19430
19435
  width: '100%',
19431
- height: 'auto',
19436
+ height: '100%',
19432
19437
  display: 'block',
19433
- objectFit: 'cover'
19438
+ objectFit: 'cover',
19439
+ userSelect: 'none',
19440
+ WebkitUserDrag: 'none'
19434
19441
  },
19435
19442
  carouselVideo: {
19436
19443
  width: '100%',
19437
- height: 'auto',
19444
+ height: '100%',
19438
19445
  display: 'block',
19439
- objectFit: 'cover'
19446
+ objectFit: 'cover',
19447
+ userSelect: 'none',
19448
+ WebkitUserDrag: 'none'
19440
19449
  },
19441
19450
  carouselInfoSection: {
19442
19451
  width: '100%',
@@ -19636,12 +19645,14 @@ const baseStyles = {
19636
19645
  }
19637
19646
  };
19638
19647
  const StructurePage = (_a) => {
19639
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
19648
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
19640
19649
  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"]);
19641
19650
  const [data, setData] = React.useState(null);
19642
19651
  const [loading, setLoading] = React.useState(true);
19643
19652
  const [error, setError] = React.useState(null);
19644
19653
  const [carouselIndex, setCarouselIndex] = React.useState(0);
19654
+ const [touchStart, setTouchStart] = React.useState(null);
19655
+ const [touchEnd, setTouchEnd] = React.useState(null);
19645
19656
  const heroVideoRef = React.useRef(null);
19646
19657
  const carouselVideoRefs = React.useRef([]);
19647
19658
  // 视频暂停状态管理
@@ -20017,6 +20028,39 @@ const StructurePage = (_a) => {
20017
20028
  setCarouselIndex((prev) => (prev === data.carouselSection.length - 1 ? 0 : prev + 1));
20018
20029
  }
20019
20030
  };
20031
+ // 触摸滑动处理
20032
+ const handleTouchStart = (e) => {
20033
+ setTouchEnd(null);
20034
+ setTouchStart(e.targetTouches[0].clientX);
20035
+ };
20036
+ const handleTouchMove = (e) => {
20037
+ if (!touchStart)
20038
+ return;
20039
+ const currentTouch = e.targetTouches[0].clientX;
20040
+ setTouchEnd(currentTouch);
20041
+ // 如果移动距离大于阈值,阻止默认行为(防止拖拽图片)
20042
+ const distance = Math.abs(touchStart - currentTouch);
20043
+ if (distance > 10) {
20044
+ e.preventDefault();
20045
+ }
20046
+ };
20047
+ const handleTouchEnd = () => {
20048
+ if (!touchStart || !touchEnd)
20049
+ return;
20050
+ const distance = touchStart - touchEnd;
20051
+ const minSwipeDistance = 50;
20052
+ if (distance > minSwipeDistance) {
20053
+ // 向左滑动,下一张
20054
+ handleCarouselNext();
20055
+ }
20056
+ else if (distance < -minSwipeDistance) {
20057
+ // 向右滑动,上一张
20058
+ handleCarouselPrev();
20059
+ }
20060
+ // 重置状态
20061
+ setTouchStart(null);
20062
+ setTouchEnd(null);
20063
+ };
20020
20064
  if (loading) {
20021
20065
  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..."));
20022
20066
  }
@@ -20036,21 +20080,21 @@ const StructurePage = (_a) => {
20036
20080
  React.createElement("video", { ref: heroVideoRef, src: data.heroSection.url, style: baseStyles.heroVideo, autoPlay: true, muted: true, loop: true, playsInline: true, controls: false }),
20037
20081
  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,
20038
20082
  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))))),
20039
- data.carouselSection && data.carouselSection.length > 0 && (React.createElement("div", { style: Object.assign(Object.assign({}, mergeStyles(baseStyles.carouselSection, 'carouselSection')), (((_j = multiCTAConfig === null || multiCTAConfig === void 0 ? void 0 : multiCTAConfig.carouselContainerStyle) === null || _j === void 0 ? void 0 : _j.padding) && { padding: multiCTAConfig.carouselContainerStyle.padding })) },
20040
- React.createElement("div", { style: Object.assign(Object.assign({}, baseStyles.carouselImageContainer), (((_k = multiCTAConfig === null || multiCTAConfig === void 0 ? void 0 : multiCTAConfig.carouselContainerStyle) === null || _k === void 0 ? void 0 : _k.aspectRatio) && { aspectRatio: multiCTAConfig.carouselContainerStyle.aspectRatio })) },
20083
+ data.carouselSection && data.carouselSection.length > 0 && (React.createElement("div", { style: mergeStyles(baseStyles.carouselSection, 'carouselSection') },
20084
+ React.createElement("div", { style: baseStyles.carouselImageContainer, onTouchStart: handleTouchStart, onTouchMove: handleTouchMove, onTouchEnd: handleTouchEnd },
20041
20085
  React.createElement("div", { style: Object.assign(Object.assign({}, baseStyles.carouselContainer), { transform: `translateX(-${carouselIndex * 100}%)` }) }, data.carouselSection.map((item, index) => {
20042
20086
  var _a;
20043
20087
  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) },
20044
20088
  React.createElement("video", { ref: (el) => {
20045
20089
  carouselVideoRefs.current[index] = el;
20046
- }, src: item.url, style: baseStyles.carouselVideo, muted: true, loop: true, playsInline: true, controls: false }),
20047
- 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));
20090
+ }, src: item.url, style: baseStyles.carouselVideo, muted: true, loop: true, playsInline: true, controls: false, draggable: false, onDragStart: (e) => e.preventDefault() }),
20091
+ 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));
20048
20092
  })),
20049
20093
  React.createElement("button", { style: Object.assign(Object.assign({}, baseStyles.arrowButton), { left: '10px' }), onClick: handleCarouselPrev }, "\u2039"),
20050
20094
  React.createElement("button", { style: Object.assign(Object.assign({}, baseStyles.arrowButton), { right: '10px' }), onClick: handleCarouselNext }, "\u203A")),
20051
20095
  React.createElement("div", { style: mergeStyles(baseStyles.carouselInfoSection, 'carouselSection') },
20052
- ((_l = data.carouselSection[carouselIndex]) === null || _l === void 0 ? void 0 : _l.text) && (React.createElement("div", { style: mergeStyles(baseStyles.carouselText, 'carouselSection') }, (_m = data.carouselSection[carouselIndex]) === null || _m === void 0 ? void 0 : _m.text)),
20053
- renderCTA('carouselButton', (_q = (_p = (_o = data.carouselSection[carouselIndex]) === null || _o === void 0 ? void 0 : _o.bindProducts) === null || _p === void 0 ? void 0 : _p[0]) === null || _q === void 0 ? void 0 : _q.bindCta, (_s = (_r = data.carouselSection[carouselIndex]) === null || _r === void 0 ? void 0 : _r.bindProducts) === null || _s === void 0 ? void 0 : _s[0], baseStyles.carouselButton)))),
20096
+ ((_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)),
20097
+ 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)))),
20054
20098
  data.highlightRevealSection && (React.createElement("div", { style: mergeStyles(baseStyles.highlightSection, 'highlightSection') },
20055
20099
  React.createElement("div", { style: baseStyles.highlightImageContainer },
20056
20100
  React.createElement("img", { src: data.highlightRevealSection.landingImageUrl || data.highlightRevealSection.cover, alt: data.highlightRevealSection.title, style: baseStyles.highlightImage })),