pb-sxp-ui 1.0.24 → 1.0.25

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.
Files changed (29) hide show
  1. package/dist/index.cjs +61 -23
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +61 -23
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +3 -3
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +3 -3
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +61 -23
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +3 -3
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/SxpPageRender/PictureGroup/Picture.d.ts +3 -2
  14. package/es/core/components/SxpPageRender/PictureGroup/Picture.js +13 -13
  15. package/es/core/components/SxpPageRender/PictureGroup/index.d.ts +2 -0
  16. package/es/core/components/SxpPageRender/PictureGroup/index.js +4 -3
  17. package/es/core/components/SxpPageRender/VideoWidget/index.d.ts +2 -0
  18. package/es/core/components/SxpPageRender/VideoWidget/index.js +41 -3
  19. package/es/core/components/SxpPageRender/index.d.ts +8 -1
  20. package/es/core/components/SxpPageRender/index.js +2 -2
  21. package/lib/core/components/SxpPageRender/PictureGroup/Picture.d.ts +3 -2
  22. package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +12 -12
  23. package/lib/core/components/SxpPageRender/PictureGroup/index.d.ts +2 -0
  24. package/lib/core/components/SxpPageRender/PictureGroup/index.js +4 -3
  25. package/lib/core/components/SxpPageRender/VideoWidget/index.d.ts +2 -0
  26. package/lib/core/components/SxpPageRender/VideoWidget/index.js +41 -3
  27. package/lib/core/components/SxpPageRender/index.d.ts +8 -1
  28. package/lib/core/components/SxpPageRender/index.js +2 -2
  29. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11966,7 +11966,7 @@ var SXP_EVENT_TYPE;
11966
11966
  SXP_EVENT_TYPE["PAGE_DID_HIDE"] = "pageDidHide";
11967
11967
  })(SXP_EVENT_TYPE || (SXP_EVENT_TYPE = {}));
11968
11968
 
11969
- const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
11969
+ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig }) => {
11970
11970
  const [isPauseVideo, setIsPauseVideo] = useState(false);
11971
11971
  const videoRef = useRef(null);
11972
11972
  const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
@@ -12155,17 +12155,54 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
12155
12155
  window.removeEventListener('beforeunload', handleBeforeUnload);
12156
12156
  };
12157
12157
  }, [activeIndex, index, rec, videoRef, handleClickVideo, isPauseVideo]);
12158
+ const blur = useMemo(() => {
12159
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
12160
+ }, [videoPostConfig]);
12161
+ const translateY = useMemo(() => {
12162
+ var _a;
12163
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
12164
+ ? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%)`
12165
+ : 'translateY(-50%)';
12166
+ }, [videoPostConfig]);
12158
12167
  if (!rec.video) {
12159
12168
  return null;
12160
12169
  }
12161
- return (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
12170
+ return (React.createElement(React.Fragment, null, blur ? (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
12171
+ position: 'relative',
12172
+ width: '100%',
12173
+ height
12174
+ } },
12175
+ React.createElement(FormatImage$1, { src: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, style: {
12176
+ height: '100%',
12177
+ width: '100%',
12178
+ objectFit: 'cover',
12179
+ filter: blur ? 'blur(10px)' : 'none',
12180
+ transform: blur ? 'scale(1.2)' : 'none'
12181
+ } }),
12182
+ React.createElement("div", { style: {
12183
+ position: 'absolute',
12184
+ width: '100%',
12185
+ height: 'auto',
12186
+ top: '50%',
12187
+ transform: translateY,
12188
+ left: 0,
12189
+ right: 0
12190
+ } },
12191
+ React.createElement("div", { style: { position: 'relative' } },
12192
+ React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart, style: {
12193
+ width: '100%',
12194
+ height: 'auto',
12195
+ objectFit: 'contain'
12196
+ } }),
12197
+ renderPoster,
12198
+ React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON }))))) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
12162
12199
  position: 'relative',
12163
12200
  width: '100%',
12164
12201
  height
12165
12202
  } },
12166
12203
  React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart }),
12167
12204
  renderPoster,
12168
- React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })));
12205
+ React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })))));
12169
12206
  };
12170
12207
  var VideoWidget$1 = memo(VideoWidget);
12171
12208
 
@@ -12218,21 +12255,21 @@ const FingerSwipeTip = ({ imageUrl }) => {
12218
12255
  * @Author: binruan@chatlabs.com
12219
12256
  * @Date: 2024-03-20 10:27:31
12220
12257
  * @LastEditors: binruan@chatlabs.com
12221
- * @LastEditTime: 2024-04-18 10:30:17
12258
+ * @LastEditTime: 2024-04-18 19:27:35
12222
12259
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\Picture.tsx
12223
12260
  *
12224
12261
  */
12225
12262
  const Picture = (props) => {
12226
- const { src, height, width } = props;
12227
- const [blur, setBlur] = useState(false);
12228
- const onLoad = (img) => {
12229
- const aspectRatio = img.naturalHeight / img.naturalWidth;
12230
- const targetAspectRatio = 16 / 9;
12231
- const tolerance = 0.05; // 允许的宽高比误差范围
12232
- if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
12233
- setBlur(true);
12234
- }
12235
- };
12263
+ const { src, height, imgUrlsPostConfig } = props;
12264
+ const blur = useMemo(() => {
12265
+ return (imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.mode) === '2';
12266
+ }, [imgUrlsPostConfig]);
12267
+ const translateY = useMemo(() => {
12268
+ var _a;
12269
+ return (imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.mode) === '2'
12270
+ ? `translateY(-${50 + ((_a = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%)`
12271
+ : 'translateY(-50%)';
12272
+ }, [imgUrlsPostConfig]);
12236
12273
  return (React.createElement("div", { style: {
12237
12274
  overflow: 'hidden',
12238
12275
  height,
@@ -12245,13 +12282,13 @@ const Picture = (props) => {
12245
12282
  objectFit: 'cover',
12246
12283
  filter: blur ? 'blur(10px)' : 'none',
12247
12284
  transform: blur ? 'scale(1.2)' : 'none'
12248
- }, onLoad: onLoad }),
12285
+ } }),
12249
12286
  blur && (React.createElement(FormatImage$1, { src: src, style: {
12250
12287
  width: '100%',
12251
12288
  objectFit: 'contain',
12252
12289
  position: 'absolute',
12253
12290
  top: '50%',
12254
- transform: 'translateY(-50%)',
12291
+ transform: translateY,
12255
12292
  left: 0,
12256
12293
  right: 0
12257
12294
  } }))));
@@ -12261,10 +12298,11 @@ const Picture = (props) => {
12261
12298
  * @Author: lewinlu@chatlabs.com
12262
12299
  * @Date: 2024-01-03 14:39:09
12263
12300
  * @LastEditors: binruan@chatlabs.com
12264
- * @LastEditTime: 2024-04-17 18:52:45
12301
+ * @LastEditTime: 2024-04-18 19:56:22
12265
12302
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\index.tsx
12266
12303
  */
12267
- const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {
12304
+ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent, imgUrlsPostConfig }) => {
12305
+ var _a;
12268
12306
  const ref = useRef();
12269
12307
  const { isActive } = useSwiperSlide();
12270
12308
  const { sxpParameter, openHashtag } = useSxpDataSource();
@@ -12287,9 +12325,9 @@ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd
12287
12325
  // if (!isActive) {
12288
12326
  // return <img src={sxpParameter?.placeholder_image} style={{ width, height, objectFit: 'cover' }} />;
12289
12327
  // }
12290
- return (React.createElement(Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: { clickable: true, bulletActiveClass: 'swipe-item-active-bullet' }, height: height, loop: true, autoplay: { delay: 3000 } }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
12328
+ return (React.createElement(Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: { clickable: true, bulletActiveClass: 'swipe-item-active-bullet' }, height: height, loop: true, autoplay: { delay: ((_a = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.delay) !== null && _a !== void 0 ? _a : 3) * 1000 } }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
12291
12329
  return (React.createElement(SwiperSlide, { key: url },
12292
- React.createElement(Picture, { src: url, width: width, height: height })));
12330
+ React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
12293
12331
  })));
12294
12332
  };
12295
12333
  var PictureGroup$1 = memo(PictureGroup);
@@ -12471,7 +12509,7 @@ const Nudge = ({ nudge }) => {
12471
12509
  * @Author: binruan@chatlabs.com
12472
12510
  * @Date: 2024-01-15 19:03:09
12473
12511
  * @LastEditors: binruan@chatlabs.com
12474
- * @LastEditTime: 2024-04-18 16:49:34
12512
+ * @LastEditTime: 2024-04-18 19:27:03
12475
12513
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
12476
12514
  *
12477
12515
  */
@@ -12632,10 +12670,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
12632
12670
  const renderContent = useCallback((rec, index) => {
12633
12671
  var _a, _b, _c, _d;
12634
12672
  if ((_a = rec.video) === null || _a === void 0 ? void 0 : _a.url) {
12635
- return (React.createElement(VideoWidget$1, { rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex }));
12673
+ return (React.createElement(VideoWidget$1, { rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost }));
12636
12674
  }
12637
12675
  if ((_b = rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
12638
- return (React.createElement(PictureGroup$1, { key: rec.video.itemId, imgUrls: rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onReportViewImageEnd: handleReportViewImageEnd, onViewImageStartEvent: handleViewImageStartEvent }));
12676
+ return (React.createElement(PictureGroup$1, { key: rec.video.itemId, imgUrls: rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onReportViewImageEnd: handleReportViewImageEnd, onViewImageStartEvent: handleViewImageStartEvent, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
12639
12677
  }
12640
12678
  if (rec.product && Array.isArray(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) && ((_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _c === void 0 ? void 0 : _c.length) > 0) {
12641
12679
  return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {