pb-sxp-ui 1.0.20 → 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.
- package/dist/index.cjs +75 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +75 -45
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +75 -45
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/FormatImage.d.ts +13 -0
- package/es/core/components/SxpPageRender/FormatImage.js +22 -0
- package/es/core/components/SxpPageRender/PictureGroup/Picture.js +25 -27
- package/es/core/components/SxpPageRender/VideoWidget/index.js +2 -1
- package/es/core/components/SxpPageRender/WaterFall/List.js +9 -7
- package/es/materials/sxp/popup/CommodityDetail/index.js +2 -1
- package/es/materials/sxp/popup/CommodityDetailDiro/index.js +2 -1
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -1
- package/es/materials/sxp/template/Commodity/index.js +2 -1
- package/es/materials/sxp/template/CommodityDiro/index.js +2 -1
- package/es/materials/sxp/template/CommodityDiroNew/index.js +2 -1
- package/es/materials/sxp/template/Link/index.js +2 -1
- package/es/materials/sxp/template/components/Img.js +3 -1
- package/lib/core/components/SxpPageRender/FormatImage.d.ts +13 -0
- package/lib/core/components/SxpPageRender/FormatImage.js +25 -0
- package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +24 -26
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +2 -1
- package/lib/core/components/SxpPageRender/WaterFall/List.js +9 -7
- package/lib/materials/sxp/popup/CommodityDetail/index.js +2 -1
- package/lib/materials/sxp/popup/CommodityDetailDiro/index.js +2 -1
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -1
- package/lib/materials/sxp/template/Commodity/index.js +2 -1
- package/lib/materials/sxp/template/CommodityDiro/index.js +2 -1
- package/lib/materials/sxp/template/CommodityDiroNew/index.js +2 -1
- package/lib/materials/sxp/template/Link/index.js +2 -1
- package/lib/materials/sxp/template/components/Img.js +3 -1
- 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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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-
|
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("
|
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 (
|
11572
|
+
if (ref.current === null || src === '') {
|
11541
11573
|
return;
|
11542
11574
|
}
|
11543
11575
|
if (showVideo && firstFrameSrc) {
|
11544
|
-
imgDom.current.
|
11576
|
+
imgDom.current.setSrc(firstFrameSrc);
|
11545
11577
|
}
|
11546
11578
|
else {
|
11547
|
-
imgDom.current.src
|
11579
|
+
imgDom.current.setSrc(src);
|
11548
11580
|
}
|
11549
|
-
observer.unobserve(
|
11581
|
+
observer.unobserve(ref.current);
|
11550
11582
|
}
|
11551
11583
|
});
|
11552
11584
|
});
|
11553
|
-
observer.observe(
|
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(
|
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,36 +12261,34 @@ 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
|
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
|
-
|
12240
|
-
|
12241
|
-
|
12242
|
-
|
12243
|
-
const
|
12244
|
-
|
12245
|
-
|
12246
|
-
|
12247
|
-
|
12248
|
-
|
12249
|
-
if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
|
12250
|
-
setBlur(true);
|
12251
|
-
}
|
12252
|
-
};
|
12253
|
-
}, [src]);
|
12254
|
-
const getImg = React.useCallback((src, style) => {
|
12271
|
+
useSxpDataSource();
|
12272
|
+
const onLoad = (img) => {
|
12273
|
+
const aspectRatio = img.height / img.width;
|
12274
|
+
const targetAspectRatio = 16 / 9;
|
12275
|
+
const tolerance = 0.05; // 允许的宽高比误差范围
|
12276
|
+
if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
|
12277
|
+
setBlur(true);
|
12278
|
+
}
|
12279
|
+
};
|
12280
|
+
React.useCallback((src, style) => {
|
12255
12281
|
if (src === '' || !src)
|
12256
12282
|
return;
|
12257
|
-
return (src === null || src === void 0 ? void 0 : src.
|
12283
|
+
return (src === null || src === void 0 ? void 0 : src.includes('.avif')) ? (React.createElement("picture", null,
|
12258
12284
|
React.createElement("source", { type: 'image/avif', srcSet: src }),
|
12259
12285
|
React.createElement("source", { type: 'image/webp', srcSet: `${src}?imageMogr2/format/webp` }),
|
12260
12286
|
React.createElement("source", { type: 'image/jpeg', srcSet: `${src}?imageMogr2/format/jpg` }),
|
12261
|
-
React.createElement("img", {
|
12287
|
+
React.createElement("img", { src: src, style: style, onLoad: (e) => {
|
12288
|
+
onLoad(e.target);
|
12289
|
+
} }))) : (React.createElement("img", { src: src, style: style, onLoad: (e) => {
|
12290
|
+
onLoad(e.target);
|
12291
|
+
} }));
|
12262
12292
|
}, []);
|
12263
12293
|
return (React.createElement("div", { style: {
|
12264
12294
|
overflow: 'hidden',
|
@@ -12266,15 +12296,14 @@ Made in Italy` })));
|
|
12266
12296
|
width: '100%',
|
12267
12297
|
position: 'relative'
|
12268
12298
|
} },
|
12269
|
-
|
12270
|
-
|
12271
|
-
|
12272
|
-
|
12273
|
-
|
12274
|
-
|
12275
|
-
|
12276
|
-
blur &&
|
12277
|
-
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: {
|
12278
12307
|
width: '100%',
|
12279
12308
|
objectFit: 'contain',
|
12280
12309
|
position: 'absolute',
|
@@ -12282,14 +12311,14 @@ Made in Italy` })));
|
|
12282
12311
|
transform: 'translateY(-50%)',
|
12283
12312
|
left: 0,
|
12284
12313
|
right: 0
|
12285
|
-
})));
|
12314
|
+
} }))));
|
12286
12315
|
};
|
12287
12316
|
|
12288
12317
|
/*
|
12289
12318
|
* @Author: lewinlu@chatlabs.com
|
12290
12319
|
* @Date: 2024-01-03 14:39:09
|
12291
12320
|
* @LastEditors: binruan@chatlabs.com
|
12292
|
-
* @LastEditTime: 2024-04-17
|
12321
|
+
* @LastEditTime: 2024-04-17 18:52:45
|
12293
12322
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\index.tsx
|
12294
12323
|
*/
|
12295
12324
|
const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {
|
@@ -13058,3 +13087,4 @@ Made in Italy` })));
|
|
13058
13087
|
Object.defineProperty(exports, '__esModule', { value: true });
|
13059
13088
|
|
13060
13089
|
}));
|
13090
|
+
//# sourceMappingURL=pb-ui.js.map
|