pb-sxp-ui 1.0.21 → 1.0.22

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 (37) hide show
  1. package/dist/index.cjs +60 -29
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +60 -29
  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 +60 -29
  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/FormatImage.d.ts +13 -0
  14. package/es/core/components/SxpPageRender/FormatImage.js +22 -0
  15. package/es/core/components/SxpPageRender/PictureGroup/Picture.js +10 -10
  16. package/es/core/components/SxpPageRender/WaterFall/List.js +9 -7
  17. package/es/materials/sxp/popup/CommodityDetail/index.js +2 -1
  18. package/es/materials/sxp/popup/CommodityDetailDiro/index.js +2 -1
  19. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -1
  20. package/es/materials/sxp/template/Commodity/index.js +2 -1
  21. package/es/materials/sxp/template/CommodityDiro/index.js +2 -1
  22. package/es/materials/sxp/template/CommodityDiroNew/index.js +2 -1
  23. package/es/materials/sxp/template/Link/index.js +2 -1
  24. package/es/materials/sxp/template/components/Img.js +3 -1
  25. package/lib/core/components/SxpPageRender/FormatImage.d.ts +13 -0
  26. package/lib/core/components/SxpPageRender/FormatImage.js +25 -0
  27. package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +10 -10
  28. package/lib/core/components/SxpPageRender/WaterFall/List.js +9 -7
  29. package/lib/materials/sxp/popup/CommodityDetail/index.js +2 -1
  30. package/lib/materials/sxp/popup/CommodityDetailDiro/index.js +2 -1
  31. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -1
  32. package/lib/materials/sxp/template/Commodity/index.js +2 -1
  33. package/lib/materials/sxp/template/CommodityDiro/index.js +2 -1
  34. package/lib/materials/sxp/template/CommodityDiroNew/index.js +2 -1
  35. package/lib/materials/sxp/template/Link/index.js +2 -1
  36. package/lib/materials/sxp/template/components/Img.js +3 -1
  37. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8284,6 +8284,36 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
8284
8284
  };
8285
8285
  var ExpandableText$1 = memo(ExpandableText);
8286
8286
 
8287
+ /*
8288
+ * @Author: binruan@chatlabs.com
8289
+ * @Date: 2024-03-20 10:27:31
8290
+ * @LastEditors: binruan@chatlabs.com
8291
+ * @LastEditTime: 2024-04-17 20:45:55
8292
+ * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\FormatImage.tsx
8293
+ *
8294
+ */
8295
+ const FormatImage = forwardRef((props, ref) => {
8296
+ const { src, onLoad, style, className, loading } = props;
8297
+ const [imgSrc, setImgSrc] = useState(src);
8298
+ useImperativeHandle(ref, () => ({
8299
+ setSrc: (v) => {
8300
+ setImgSrc(v);
8301
+ }
8302
+ }));
8303
+ if (imgSrc === '' || !imgSrc)
8304
+ return null;
8305
+ return (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8306
+ React.createElement("source", { type: 'image/avif', srcSet: imgSrc }),
8307
+ React.createElement("source", { type: 'image/webp', srcSet: `${imgSrc}?imageMogr2/format/webp` }),
8308
+ React.createElement("source", { type: 'image/jpeg', srcSet: `${imgSrc}?imageMogr2/format/jpg` }),
8309
+ React.createElement("img", { className: className, src: imgSrc, style: style, loading: loading, onLoad: (e) => {
8310
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad(e.target);
8311
+ } }))) : (React.createElement("img", { className: className, src: imgSrc, style: style, loading: loading, onLoad: (e) => {
8312
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad(e.target);
8313
+ } }));
8314
+ });
8315
+ var FormatImage$1 = memo(FormatImage);
8316
+
8287
8317
  const CommodityDetail$1 = (_a) => {
8288
8318
  var _b, _c, _d, _e, _f, _g, _h, _j;
8289
8319
  var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index } = _a, props = __rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index"]);
@@ -8361,7 +8391,7 @@ const CommodityDetail$1 = (_a) => {
8361
8391
  width,
8362
8392
  height: width
8363
8393
  } },
8364
- React.createElement("img", { src: src, style: { height: '100%', width: '100%', objectFit: 'cover' } }))));
8394
+ React.createElement(FormatImage$1, { style: { height: '100%', width: '100%', objectFit: 'cover', display: 'block' }, src: src }))));
8365
8395
  }))),
8366
8396
  !((_h = product === null || product === void 0 ? void 0 : product.homePage) === null || _h === void 0 ? void 0 : _h.length) && (React.createElement("div", { className: css({
8367
8397
  position: 'relative',
@@ -8808,7 +8838,7 @@ Made in Italy` })));
8808
8838
  width,
8809
8839
  height: width
8810
8840
  } },
8811
- React.createElement("img", { src: src, style: { height: '100%', width: '100%', objectFit: 'cover' } }))));
8841
+ React.createElement(FormatImage$1, { style: { height: '100%', width: '100%', objectFit: 'cover', display: 'block' }, src: src }))));
8812
8842
  }))),
8813
8843
  !((_h = product === null || product === void 0 ? void 0 : product.homePage) === null || _h === void 0 ? void 0 : _h.length) && (React.createElement("div", { className: css({
8814
8844
  position: 'relative',
@@ -9222,7 +9252,7 @@ const Commodity$1 = (_a) => {
9222
9252
  const src = (_e = (_d = (_c = product === null || product === void 0 ? void 0 : product.homePage) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.bottom_image) !== null && _e !== void 0 ? _e : bottom_image;
9223
9253
  return (React.createElement(EventProvider$1, Object.assign({ isExternalLink: isExternalLink, rec: recData, className: css(Object.assign({}, style)), style: { display: 'flex' } }, props),
9224
9254
  React.createElement("div", { className: css(Object.assign({ overflow: 'hidden', flexShrink: 0, backgroundColor: '#f2f2f2' }, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img)) },
9225
- React.createElement("img", { className: css({ width: '100%', objectFit: 'cover', height: '100%' }), src: src, hidden: !src, alt: '' })),
9255
+ React.createElement(FormatImage$1, { className: css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })),
9226
9256
  React.createElement("div", { className: css({
9227
9257
  color: '#fff',
9228
9258
  display: 'flex',
@@ -9383,7 +9413,7 @@ const Link$1 = (_a) => {
9383
9413
  };
9384
9414
  return (React.createElement(EventProvider$1, Object.assign({ index: index, rec: recData, className: css(Object.assign({ alignItems: 'center' }, style)), style: { display: 'flex' } }, props, { onClick: handleTo }),
9385
9415
  React.createElement("div", { className: css(Object.assign({ backgroundColor: '#f2f2f2', overflow: 'hidden', flexShrink: 0 }, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img)) },
9386
- React.createElement("img", { className: css({ width: '100%', objectFit: 'cover', height: '100%' }), src: (_e = (_d = cta === null || cta === void 0 ? void 0 : cta.icon) !== null && _d !== void 0 ? _d : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.bottom_image) !== null && _e !== void 0 ? _e : bottom_image, alt: '' })),
9416
+ React.createElement(FormatImage$1, { className: css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: (_e = (_d = cta === null || cta === void 0 ? void 0 : cta.icon) !== null && _d !== void 0 ? _d : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.bottom_image) !== null && _e !== void 0 ? _e : bottom_image })),
9387
9417
  React.createElement("div", { className: css({
9388
9418
  display: 'flex',
9389
9419
  alignItems: 'center',
@@ -9465,7 +9495,7 @@ const CommodityDiro$1 = (_a) => {
9465
9495
  const src = (_e = (_d = (_c = product === null || product === void 0 ? void 0 : product.homePage) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.bottom_image) !== null && _e !== void 0 ? _e : bottom_image;
9466
9496
  return (React.createElement(EventProvider$1, Object.assign({ isExternalLink: isExternalLink, rec: recData, className: css(Object.assign({}, style)), style: { display: 'flex' } }, props),
9467
9497
  React.createElement("div", { className: css(Object.assign({ overflow: 'hidden', flexShrink: 0, backgroundColor: '#f2f2f2' }, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img)) },
9468
- React.createElement("img", { className: css({ width: '100%', objectFit: 'cover', height: '100%' }), src: src, hidden: !src, alt: '' })),
9498
+ React.createElement(FormatImage$1, { className: css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })),
9469
9499
  React.createElement("div", { className: css({
9470
9500
  color: '#fff',
9471
9501
  display: 'flex',
@@ -9557,7 +9587,7 @@ const CommodityDiroNew$1 = (_a) => {
9557
9587
  const src = (_e = (_d = (_c = product === null || product === void 0 ? void 0 : product.homePage) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.bottom_image) !== null && _e !== void 0 ? _e : bottom_image;
9558
9588
  return (React.createElement(EventProvider$1, Object.assign({ isExternalLink: isExternalLink, rec: recData, className: css(Object.assign({}, style)), style: { display: 'flex' } }, props),
9559
9589
  React.createElement("div", { className: css(Object.assign({ overflow: 'hidden', flexShrink: 0, backgroundColor: '#f2f2f2' }, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img)) },
9560
- React.createElement("img", { className: css({ width: '100%', objectFit: 'cover', height: '100%' }), src: src, hidden: !src, alt: '' })),
9590
+ React.createElement(FormatImage$1, { className: css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })),
9561
9591
  React.createElement("div", { className: css({
9562
9592
  color: '#fff',
9563
9593
  display: 'flex',
@@ -9649,7 +9679,7 @@ var Scroll$1 = memo(Scroll);
9649
9679
  * @Author: binruan@chatlabs.com
9650
9680
  * @Date: 2024-01-16 14:50:13
9651
9681
  * @LastEditors: binruan@chatlabs.com
9652
- * @LastEditTime: 2024-04-11 18:24:15
9682
+ * @LastEditTime: 2024-04-17 19:03:01
9653
9683
  * @FilePath: \pb-sxp-ui\src\materials\sxp\template\components\Img.tsx
9654
9684
  *
9655
9685
  */
@@ -9665,7 +9695,8 @@ const Img = ({ src, rec, item, index }) => {
9665
9695
  }, rec, item, index);
9666
9696
  }
9667
9697
  }, [isOnScreen, src, ref, rec, ctaEvent, item, index]);
9668
- return (React.createElement("img", { ref: ref, hidden: !src, className: css({ width: '100%', objectFit: 'cover', height: '100%' }), src: src, alt: '' }));
9698
+ return (React.createElement("div", { ref: ref, hidden: !src },
9699
+ React.createElement(FormatImage$1, { className: css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })));
9669
9700
  };
9670
9701
  var Img$1 = memo(Img);
9671
9702
 
@@ -11466,6 +11497,7 @@ const WaterfallFlowItem = (props) => {
11466
11497
  const { swiperRef, setRtcList, setOpenHashtag, bffEventReport, sxpParameter } = useSxpDataSource();
11467
11498
  const [showVideo, setShowVideo] = useState(false);
11468
11499
  const imgDom = useRef(null);
11500
+ const ref = useRef(null);
11469
11501
  const videoDom = useRef(null);
11470
11502
  const canvasRef = useRef(null);
11471
11503
  const [firstFrameSrc, setFirstFrameSrc] = useState('');
@@ -11522,20 +11554,20 @@ const WaterfallFlowItem = (props) => {
11522
11554
  const observer = new IntersectionObserver((entries) => {
11523
11555
  entries.forEach((entry) => {
11524
11556
  if (entry.isIntersecting) {
11525
- if (imgDom.current === null || src === '') {
11557
+ if (ref.current === null || src === '') {
11526
11558
  return;
11527
11559
  }
11528
11560
  if (showVideo && firstFrameSrc) {
11529
- imgDom.current.src = firstFrameSrc;
11561
+ imgDom.current.setSrc(firstFrameSrc);
11530
11562
  }
11531
11563
  else {
11532
- imgDom.current.src = src;
11564
+ imgDom.current.setSrc(src);
11533
11565
  }
11534
- observer.unobserve(imgDom.current);
11566
+ observer.unobserve(ref.current);
11535
11567
  }
11536
11568
  });
11537
11569
  });
11538
- observer.observe(imgDom.current);
11570
+ observer.observe(ref.current);
11539
11571
  return () => {
11540
11572
  observer.disconnect();
11541
11573
  };
@@ -11577,12 +11609,12 @@ const WaterfallFlowItem = (props) => {
11577
11609
  setOpenHashtag === null || setOpenHashtag === void 0 ? void 0 : setOpenHashtag(false);
11578
11610
  }, 0);
11579
11611
  };
11580
- return (React.createElement("div", { className: 'list-content-listItem', key: index, onClick: handleClickToDetail, style: { marginBottom: space } },
11612
+ return (React.createElement("div", { ref: ref, className: 'list-content-listItem', key: index, onClick: handleClickToDetail, style: { marginBottom: space } },
11581
11613
  React.createElement("div", { className: 'list-content-listItem-picture' },
11582
11614
  showVideo && (React.createElement("div", { style: { display: 'none' } },
11583
11615
  React.createElement("video", { ref: videoDom, crossOrigin: 'anonymous', className: 'list-content-listItem-picture-img' }),
11584
11616
  React.createElement("canvas", { ref: canvasRef }))),
11585
- React.createElement("img", { className: 'list-content-listItem-picture-img', loading: 'lazy', ref: imgDom })),
11617
+ React.createElement(FormatImage$1, { loading: 'lazy', className: 'list-content-listItem-picture-img', ref: imgDom })),
11586
11618
  React.createElement("div", { className: 'list-content-listItem-info' },
11587
11619
  React.createElement("div", { className: `${'list-content-listItem-info-title'} ${priceText ? 'list-content-listItem-info-nowrap' : ''}`, style: textStyles === null || textStyles === void 0 ? void 0 : textStyles.title }, title && title),
11588
11620
  React.createElement("div", { className: 'list-content-listItem-info-price', style: textStyles === null || textStyles === void 0 ? void 0 : textStyles.price, hidden: !priceText }, priceText))));
@@ -12214,14 +12246,14 @@ const FingerSwipeTip = ({ imageUrl }) => {
12214
12246
  * @Author: binruan@chatlabs.com
12215
12247
  * @Date: 2024-03-20 10:27:31
12216
12248
  * @LastEditors: binruan@chatlabs.com
12217
- * @LastEditTime: 2024-04-17 18:09:29
12249
+ * @LastEditTime: 2024-04-17 18:59:40
12218
12250
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\Picture.tsx
12219
12251
  *
12220
12252
  */
12221
12253
  const Picture = (props) => {
12222
12254
  const { src, height, width } = props;
12223
12255
  const [blur, setBlur] = useState(false);
12224
- const { sxpParameter } = useSxpDataSource();
12256
+ useSxpDataSource();
12225
12257
  const onLoad = (img) => {
12226
12258
  const aspectRatio = img.height / img.width;
12227
12259
  const targetAspectRatio = 16 / 9;
@@ -12230,7 +12262,7 @@ const Picture = (props) => {
12230
12262
  setBlur(true);
12231
12263
  }
12232
12264
  };
12233
- const getImg = useCallback((src, style) => {
12265
+ useCallback((src, style) => {
12234
12266
  if (src === '' || !src)
12235
12267
  return;
12236
12268
  return (src === null || src === void 0 ? void 0 : src.includes('.avif')) ? (React.createElement("picture", null,
@@ -12249,15 +12281,14 @@ const Picture = (props) => {
12249
12281
  width: '100%',
12250
12282
  position: 'relative'
12251
12283
  } },
12252
- getImg(src !== null && src !== void 0 ? src : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, {
12253
- height: '100%',
12254
- width: '100%',
12255
- objectFit: 'cover',
12256
- filter: blur ? 'blur(10px)' : 'none',
12257
- transform: blur ? 'scale(1.2)' : 'none'
12258
- }),
12259
- blur &&
12260
- getImg(src, {
12284
+ React.createElement(FormatImage$1, { src: src, style: {
12285
+ height: '100%',
12286
+ width: '100%',
12287
+ objectFit: 'cover',
12288
+ filter: blur ? 'blur(10px)' : 'none',
12289
+ transform: blur ? 'scale(1.2)' : 'none'
12290
+ }, onLoad: onLoad }),
12291
+ blur && (React.createElement(FormatImage$1, { src: src, style: {
12261
12292
  width: '100%',
12262
12293
  objectFit: 'contain',
12263
12294
  position: 'absolute',
@@ -12265,14 +12296,14 @@ const Picture = (props) => {
12265
12296
  transform: 'translateY(-50%)',
12266
12297
  left: 0,
12267
12298
  right: 0
12268
- })));
12299
+ } }))));
12269
12300
  };
12270
12301
 
12271
12302
  /*
12272
12303
  * @Author: lewinlu@chatlabs.com
12273
12304
  * @Date: 2024-01-03 14:39:09
12274
12305
  * @LastEditors: binruan@chatlabs.com
12275
- * @LastEditTime: 2024-04-17 15:15:33
12306
+ * @LastEditTime: 2024-04-17 18:52:45
12276
12307
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\index.tsx
12277
12308
  */
12278
12309
  const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {