pb-sxp-ui 1.0.21 → 1.0.23

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 (39) hide show
  1. package/dist/index.cjs +61 -44
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +61 -44
  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 -44
  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 +12 -27
  16. package/es/core/components/SxpPageRender/WaterFall/List.js +9 -7
  17. package/es/core/components/SxpPageRender/index.js +1 -1
  18. package/es/materials/sxp/popup/CommodityDetail/index.js +2 -1
  19. package/es/materials/sxp/popup/CommodityDetailDiro/index.js +2 -1
  20. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -1
  21. package/es/materials/sxp/template/Commodity/index.js +2 -1
  22. package/es/materials/sxp/template/CommodityDiro/index.js +2 -1
  23. package/es/materials/sxp/template/CommodityDiroNew/index.js +2 -1
  24. package/es/materials/sxp/template/Link/index.js +2 -1
  25. package/es/materials/sxp/template/components/Img.js +3 -1
  26. package/lib/core/components/SxpPageRender/FormatImage.d.ts +13 -0
  27. package/lib/core/components/SxpPageRender/FormatImage.js +25 -0
  28. package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +11 -26
  29. package/lib/core/components/SxpPageRender/WaterFall/List.js +9 -7
  30. package/lib/core/components/SxpPageRender/index.js +1 -1
  31. package/lib/materials/sxp/popup/CommodityDetail/index.js +2 -1
  32. package/lib/materials/sxp/popup/CommodityDetailDiro/index.js +2 -1
  33. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -1
  34. package/lib/materials/sxp/template/Commodity/index.js +2 -1
  35. package/lib/materials/sxp/template/CommodityDiro/index.js +2 -1
  36. package/lib/materials/sxp/template/CommodityDiroNew/index.js +2 -1
  37. package/lib/materials/sxp/template/Link/index.js +2 -1
  38. package/lib/materials/sxp/template/components/Img.js +3 -1
  39. 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,50 +12261,35 @@ 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-18 10:30:17
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();
12240
12271
  const onLoad = (img) => {
12241
- const aspectRatio = img.height / img.width;
12272
+ const aspectRatio = img.naturalHeight / img.naturalWidth;
12242
12273
  const targetAspectRatio = 16 / 9;
12243
12274
  const tolerance = 0.05; // 允许的宽高比误差范围
12244
12275
  if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
12245
12276
  setBlur(true);
12246
12277
  }
12247
12278
  };
12248
- const getImg = React.useCallback((src, style) => {
12249
- if (src === '' || !src)
12250
- return;
12251
- return (src === null || src === void 0 ? void 0 : src.includes('.avif')) ? (React.createElement("picture", null,
12252
- React.createElement("source", { type: 'image/avif', srcSet: src }),
12253
- React.createElement("source", { type: 'image/webp', srcSet: `${src}?imageMogr2/format/webp` }),
12254
- React.createElement("source", { type: 'image/jpeg', srcSet: `${src}?imageMogr2/format/jpg` }),
12255
- React.createElement("img", { src: src, style: style, onLoad: (e) => {
12256
- onLoad(e.target);
12257
- } }))) : (React.createElement("img", { src: src, style: style, onLoad: (e) => {
12258
- onLoad(e.target);
12259
- } }));
12260
- }, []);
12261
12279
  return (React.createElement("div", { style: {
12262
12280
  overflow: 'hidden',
12263
12281
  height,
12264
12282
  width: '100%',
12265
12283
  position: 'relative'
12266
12284
  } },
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, {
12285
+ React.createElement(FormatImage$1, { src: src, style: {
12286
+ height: '100%',
12287
+ width: '100%',
12288
+ objectFit: 'cover',
12289
+ filter: blur ? 'blur(10px)' : 'none',
12290
+ transform: blur ? 'scale(1.2)' : 'none'
12291
+ }, onLoad: onLoad }),
12292
+ blur && (React.createElement(FormatImage$1, { src: src, style: {
12276
12293
  width: '100%',
12277
12294
  objectFit: 'contain',
12278
12295
  position: 'absolute',
@@ -12280,14 +12297,14 @@ Made in Italy` })));
12280
12297
  transform: 'translateY(-50%)',
12281
12298
  left: 0,
12282
12299
  right: 0
12283
- })));
12300
+ } }))));
12284
12301
  };
12285
12302
 
12286
12303
  /*
12287
12304
  * @Author: lewinlu@chatlabs.com
12288
12305
  * @Date: 2024-01-03 14:39:09
12289
12306
  * @LastEditors: binruan@chatlabs.com
12290
- * @LastEditTime: 2024-04-17 15:15:33
12307
+ * @LastEditTime: 2024-04-17 18:52:45
12291
12308
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\index.tsx
12292
12309
  */
12293
12310
  const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {
@@ -12497,7 +12514,7 @@ Made in Italy` })));
12497
12514
  * @Author: binruan@chatlabs.com
12498
12515
  * @Date: 2024-01-15 19:03:09
12499
12516
  * @LastEditors: binruan@chatlabs.com
12500
- * @LastEditTime: 2024-04-17 10:30:08
12517
+ * @LastEditTime: 2024-04-18 09:43:19
12501
12518
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
12502
12519
  *
12503
12520
  */
@@ -12701,7 +12718,7 @@ Made in Italy` })));
12701
12718
  React.createElement(ExpandableText$1, { className: 'clc-sxp-bottom-text', isPost: true, foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, text: (_c = (_b = rec.video) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : '', style: Object.assign({}, descStyle
12702
12719
  // textShadow: globalConfig?.isOpenTextShadow ? '2px 2px 4px rgba(0, 0, 0, 0.5)' : 'none'
12703
12720
  ), onChange: onExpandableChange }),
12704
- React.createElement(Hashtag$1, { index: activeIndex, tags: (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.hashTags) !== null && _e !== void 0 ? _e : [], itemId: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.itemId, itemType: ((_g = rec.video) === null || _g === void 0 ? void 0 : _g.url) ? 'VIDEO' : null, rec: rec, hashTagStyle: hashTagStyle })))));
12721
+ React.createElement(Hashtag$1, { index: activeIndex, tags: (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.hashTags) !== null && _e !== void 0 ? _e : [], itemId: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.itemId, itemType: ((_g = rec.video) === null || _g === void 0 ? void 0 : _g.itemId) ? 'VIDEO' : null, rec: rec, hashTagStyle: hashTagStyle })))));
12705
12722
  }
12706
12723
  return null;
12707
12724
  }, [