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/pb-ui.js CHANGED
@@ -8299,6 +8299,36 @@
8299
8299
  };
8300
8300
  var ExpandableText$1 = React.memo(ExpandableText);
8301
8301
 
8302
+ /*
8303
+ * @Author: binruan@chatlabs.com
8304
+ * @Date: 2024-03-20 10:27:31
8305
+ * @LastEditors: binruan@chatlabs.com
8306
+ * @LastEditTime: 2024-04-17 20:45:55
8307
+ * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\FormatImage.tsx
8308
+ *
8309
+ */
8310
+ const FormatImage = React.forwardRef((props, ref) => {
8311
+ const { src, onLoad, style, className, loading } = props;
8312
+ const [imgSrc, setImgSrc] = React.useState(src);
8313
+ React.useImperativeHandle(ref, () => ({
8314
+ setSrc: (v) => {
8315
+ setImgSrc(v);
8316
+ }
8317
+ }));
8318
+ if (imgSrc === '' || !imgSrc)
8319
+ return null;
8320
+ return (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8321
+ React.createElement("source", { type: 'image/avif', srcSet: imgSrc }),
8322
+ React.createElement("source", { type: 'image/webp', srcSet: `${imgSrc}?imageMogr2/format/webp` }),
8323
+ React.createElement("source", { type: 'image/jpeg', srcSet: `${imgSrc}?imageMogr2/format/jpg` }),
8324
+ React.createElement("img", { className: className, src: imgSrc, style: style, loading: loading, onLoad: (e) => {
8325
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad(e.target);
8326
+ } }))) : (React.createElement("img", { className: className, src: imgSrc, style: style, loading: loading, onLoad: (e) => {
8327
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad(e.target);
8328
+ } }));
8329
+ });
8330
+ var FormatImage$1 = React.memo(FormatImage);
8331
+
8302
8332
  const CommodityDetail$1 = (_a) => {
8303
8333
  var _b, _c, _d, _e, _f, _g, _h, _j;
8304
8334
  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"]);
@@ -8376,7 +8406,7 @@
8376
8406
  width,
8377
8407
  height: width
8378
8408
  } },
8379
- React.createElement("img", { src: src, style: { height: '100%', width: '100%', objectFit: 'cover' } }))));
8409
+ React.createElement(FormatImage$1, { style: { height: '100%', width: '100%', objectFit: 'cover', display: 'block' }, src: src }))));
8380
8410
  }))),
8381
8411
  !((_h = product === null || product === void 0 ? void 0 : product.homePage) === null || _h === void 0 ? void 0 : _h.length) && (React.createElement("div", { className: css.css({
8382
8412
  position: 'relative',
@@ -8823,7 +8853,7 @@ Made in Italy` })));
8823
8853
  width,
8824
8854
  height: width
8825
8855
  } },
8826
- React.createElement("img", { src: src, style: { height: '100%', width: '100%', objectFit: 'cover' } }))));
8856
+ React.createElement(FormatImage$1, { style: { height: '100%', width: '100%', objectFit: 'cover', display: 'block' }, src: src }))));
8827
8857
  }))),
8828
8858
  !((_h = product === null || product === void 0 ? void 0 : product.homePage) === null || _h === void 0 ? void 0 : _h.length) && (React.createElement("div", { className: css.css({
8829
8859
  position: 'relative',
@@ -9237,7 +9267,7 @@ Made in Italy` })));
9237
9267
  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;
9238
9268
  return (React.createElement(EventProvider$1, Object.assign({ isExternalLink: isExternalLink, rec: recData, className: css.css(Object.assign({}, style)), style: { display: 'flex' } }, props),
9239
9269
  React.createElement("div", { className: css.css(Object.assign({ overflow: 'hidden', flexShrink: 0, backgroundColor: '#f2f2f2' }, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img)) },
9240
- React.createElement("img", { className: css.css({ width: '100%', objectFit: 'cover', height: '100%' }), src: src, hidden: !src, alt: '' })),
9270
+ React.createElement(FormatImage$1, { className: css.css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })),
9241
9271
  React.createElement("div", { className: css.css({
9242
9272
  color: '#fff',
9243
9273
  display: 'flex',
@@ -9398,7 +9428,7 @@ Made in Italy` })));
9398
9428
  };
9399
9429
  return (React.createElement(EventProvider$1, Object.assign({ index: index, rec: recData, className: css.css(Object.assign({ alignItems: 'center' }, style)), style: { display: 'flex' } }, props, { onClick: handleTo }),
9400
9430
  React.createElement("div", { className: css.css(Object.assign({ backgroundColor: '#f2f2f2', overflow: 'hidden', flexShrink: 0 }, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img)) },
9401
- React.createElement("img", { className: css.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: '' })),
9431
+ React.createElement(FormatImage$1, { className: css.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 })),
9402
9432
  React.createElement("div", { className: css.css({
9403
9433
  display: 'flex',
9404
9434
  alignItems: 'center',
@@ -9480,7 +9510,7 @@ Made in Italy` })));
9480
9510
  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;
9481
9511
  return (React.createElement(EventProvider$1, Object.assign({ isExternalLink: isExternalLink, rec: recData, className: css.css(Object.assign({}, style)), style: { display: 'flex' } }, props),
9482
9512
  React.createElement("div", { className: css.css(Object.assign({ overflow: 'hidden', flexShrink: 0, backgroundColor: '#f2f2f2' }, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img)) },
9483
- React.createElement("img", { className: css.css({ width: '100%', objectFit: 'cover', height: '100%' }), src: src, hidden: !src, alt: '' })),
9513
+ React.createElement(FormatImage$1, { className: css.css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })),
9484
9514
  React.createElement("div", { className: css.css({
9485
9515
  color: '#fff',
9486
9516
  display: 'flex',
@@ -9572,7 +9602,7 @@ Made in Italy` })));
9572
9602
  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;
9573
9603
  return (React.createElement(EventProvider$1, Object.assign({ isExternalLink: isExternalLink, rec: recData, className: css.css(Object.assign({}, style)), style: { display: 'flex' } }, props),
9574
9604
  React.createElement("div", { className: css.css(Object.assign({ overflow: 'hidden', flexShrink: 0, backgroundColor: '#f2f2f2' }, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img)) },
9575
- React.createElement("img", { className: css.css({ width: '100%', objectFit: 'cover', height: '100%' }), src: src, hidden: !src, alt: '' })),
9605
+ React.createElement(FormatImage$1, { className: css.css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })),
9576
9606
  React.createElement("div", { className: css.css({
9577
9607
  color: '#fff',
9578
9608
  display: 'flex',
@@ -9664,7 +9694,7 @@ Made in Italy` })));
9664
9694
  * @Author: binruan@chatlabs.com
9665
9695
  * @Date: 2024-01-16 14:50:13
9666
9696
  * @LastEditors: binruan@chatlabs.com
9667
- * @LastEditTime: 2024-04-11 18:24:15
9697
+ * @LastEditTime: 2024-04-17 19:03:01
9668
9698
  * @FilePath: \pb-sxp-ui\src\materials\sxp\template\components\Img.tsx
9669
9699
  *
9670
9700
  */
@@ -9680,7 +9710,8 @@ Made in Italy` })));
9680
9710
  }, rec, item, index);
9681
9711
  }
9682
9712
  }, [isOnScreen, src, ref, rec, ctaEvent, item, index]);
9683
- return (React.createElement("img", { ref: ref, hidden: !src, className: css.css({ width: '100%', objectFit: 'cover', height: '100%' }), src: src, alt: '' }));
9713
+ return (React.createElement("div", { ref: ref, hidden: !src },
9714
+ React.createElement(FormatImage$1, { className: css.css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })));
9684
9715
  };
9685
9716
  var Img$1 = React.memo(Img);
9686
9717
 
@@ -11481,6 +11512,7 @@ Made in Italy` })));
11481
11512
  const { swiperRef, setRtcList, setOpenHashtag, bffEventReport, sxpParameter } = useSxpDataSource();
11482
11513
  const [showVideo, setShowVideo] = React.useState(false);
11483
11514
  const imgDom = React.useRef(null);
11515
+ const ref = React.useRef(null);
11484
11516
  const videoDom = React.useRef(null);
11485
11517
  const canvasRef = React.useRef(null);
11486
11518
  const [firstFrameSrc, setFirstFrameSrc] = React.useState('');
@@ -11537,20 +11569,20 @@ Made in Italy` })));
11537
11569
  const observer = new IntersectionObserver((entries) => {
11538
11570
  entries.forEach((entry) => {
11539
11571
  if (entry.isIntersecting) {
11540
- if (imgDom.current === null || src === '') {
11572
+ if (ref.current === null || src === '') {
11541
11573
  return;
11542
11574
  }
11543
11575
  if (showVideo && firstFrameSrc) {
11544
- imgDom.current.src = firstFrameSrc;
11576
+ imgDom.current.setSrc(firstFrameSrc);
11545
11577
  }
11546
11578
  else {
11547
- imgDom.current.src = src;
11579
+ imgDom.current.setSrc(src);
11548
11580
  }
11549
- observer.unobserve(imgDom.current);
11581
+ observer.unobserve(ref.current);
11550
11582
  }
11551
11583
  });
11552
11584
  });
11553
- observer.observe(imgDom.current);
11585
+ observer.observe(ref.current);
11554
11586
  return () => {
11555
11587
  observer.disconnect();
11556
11588
  };
@@ -11592,12 +11624,12 @@ Made in Italy` })));
11592
11624
  setOpenHashtag === null || setOpenHashtag === void 0 ? void 0 : setOpenHashtag(false);
11593
11625
  }, 0);
11594
11626
  };
11595
- return (React.createElement("div", { className: 'list-content-listItem', key: index, onClick: handleClickToDetail, style: { marginBottom: space } },
11627
+ return (React.createElement("div", { ref: ref, className: 'list-content-listItem', key: index, onClick: handleClickToDetail, style: { marginBottom: space } },
11596
11628
  React.createElement("div", { className: 'list-content-listItem-picture' },
11597
11629
  showVideo && (React.createElement("div", { style: { display: 'none' } },
11598
11630
  React.createElement("video", { ref: videoDom, crossOrigin: 'anonymous', className: 'list-content-listItem-picture-img' }),
11599
11631
  React.createElement("canvas", { ref: canvasRef }))),
11600
- React.createElement("img", { className: 'list-content-listItem-picture-img', loading: 'lazy', ref: imgDom })),
11632
+ React.createElement(FormatImage$1, { loading: 'lazy', className: 'list-content-listItem-picture-img', ref: imgDom })),
11601
11633
  React.createElement("div", { className: 'list-content-listItem-info' },
11602
11634
  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),
11603
11635
  React.createElement("div", { className: 'list-content-listItem-info-price', style: textStyles === null || textStyles === void 0 ? void 0 : textStyles.price, hidden: !priceText }, priceText))));
@@ -12229,14 +12261,14 @@ Made in Italy` })));
12229
12261
  * @Author: binruan@chatlabs.com
12230
12262
  * @Date: 2024-03-20 10:27:31
12231
12263
  * @LastEditors: binruan@chatlabs.com
12232
- * @LastEditTime: 2024-04-17 18:09:29
12264
+ * @LastEditTime: 2024-04-17 18:59:40
12233
12265
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\Picture.tsx
12234
12266
  *
12235
12267
  */
12236
12268
  const Picture = (props) => {
12237
12269
  const { src, height, width } = props;
12238
12270
  const [blur, setBlur] = React.useState(false);
12239
- const { sxpParameter } = useSxpDataSource();
12271
+ useSxpDataSource();
12240
12272
  const onLoad = (img) => {
12241
12273
  const aspectRatio = img.height / img.width;
12242
12274
  const targetAspectRatio = 16 / 9;
@@ -12245,7 +12277,7 @@ Made in Italy` })));
12245
12277
  setBlur(true);
12246
12278
  }
12247
12279
  };
12248
- const getImg = React.useCallback((src, style) => {
12280
+ React.useCallback((src, style) => {
12249
12281
  if (src === '' || !src)
12250
12282
  return;
12251
12283
  return (src === null || src === void 0 ? void 0 : src.includes('.avif')) ? (React.createElement("picture", null,
@@ -12264,15 +12296,14 @@ Made in Italy` })));
12264
12296
  width: '100%',
12265
12297
  position: 'relative'
12266
12298
  } },
12267
- getImg(src !== null && src !== void 0 ? src : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, {
12268
- height: '100%',
12269
- width: '100%',
12270
- objectFit: 'cover',
12271
- filter: blur ? 'blur(10px)' : 'none',
12272
- transform: blur ? 'scale(1.2)' : 'none'
12273
- }),
12274
- blur &&
12275
- getImg(src, {
12299
+ React.createElement(FormatImage$1, { src: src, style: {
12300
+ height: '100%',
12301
+ width: '100%',
12302
+ objectFit: 'cover',
12303
+ filter: blur ? 'blur(10px)' : 'none',
12304
+ transform: blur ? 'scale(1.2)' : 'none'
12305
+ }, onLoad: onLoad }),
12306
+ blur && (React.createElement(FormatImage$1, { src: src, style: {
12276
12307
  width: '100%',
12277
12308
  objectFit: 'contain',
12278
12309
  position: 'absolute',
@@ -12280,14 +12311,14 @@ Made in Italy` })));
12280
12311
  transform: 'translateY(-50%)',
12281
12312
  left: 0,
12282
12313
  right: 0
12283
- })));
12314
+ } }))));
12284
12315
  };
12285
12316
 
12286
12317
  /*
12287
12318
  * @Author: lewinlu@chatlabs.com
12288
12319
  * @Date: 2024-01-03 14:39:09
12289
12320
  * @LastEditors: binruan@chatlabs.com
12290
- * @LastEditTime: 2024-04-17 15:15:33
12321
+ * @LastEditTime: 2024-04-17 18:52:45
12291
12322
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\index.tsx
12292
12323
  */
12293
12324
  const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {