pb-sxp-ui 1.0.13 → 1.0.15
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 +76 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -1
- package/dist/index.js +76 -38
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +76 -38
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/ExpandableText.d.ts +1 -0
- package/es/core/components/SxpPageRender/ExpandableText.js +6 -24
- package/es/core/components/SxpPageRender/PictureGroup/Picture.js +8 -5
- package/es/core/components/SxpPageRender/index.js +34 -5
- package/es/core/utils/localStore.d.ts +2 -0
- package/es/core/utils/localStore.js +8 -0
- package/lib/core/components/SxpPageRender/ExpandableText.d.ts +1 -0
- package/lib/core/components/SxpPageRender/ExpandableText.js +6 -24
- package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +7 -4
- package/lib/core/components/SxpPageRender/index.js +34 -5
- package/lib/core/utils/localStore.d.ts +2 -0
- package/lib/core/utils/localStore.js +10 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -392,6 +392,7 @@ const getFeSessionId = () => {
|
|
392
392
|
};
|
393
393
|
|
394
394
|
const FAKE_USER_KEY = 'SXP_FAKE_USER_ID';
|
395
|
+
const FAKE_USER_STATE = 'FAKE_USER_STATE';
|
395
396
|
const storeAndLoadFeUserId = () => {
|
396
397
|
let fakeUserId = window.localStorage.getItem(FAKE_USER_KEY);
|
397
398
|
if (lodash.isEmpty(fakeUserId)) {
|
@@ -400,6 +401,13 @@ const storeAndLoadFeUserId = () => {
|
|
400
401
|
}
|
401
402
|
return fakeUserId;
|
402
403
|
};
|
404
|
+
const getFeUserId = () => {
|
405
|
+
const fakeUserState = window.localStorage.getItem(FAKE_USER_STATE);
|
406
|
+
if (lodash.isEmpty(fakeUserState)) {
|
407
|
+
window.localStorage.setItem(FAKE_USER_STATE, 'true');
|
408
|
+
}
|
409
|
+
return lodash.isEmpty(fakeUserState);
|
410
|
+
};
|
403
411
|
|
404
412
|
/*
|
405
413
|
* @Author: binruan@chatlabs.com
|
@@ -8240,7 +8248,7 @@ var Modal$1 = React.memo(Modal);
|
|
8240
8248
|
* @Author: binruan@chatlabs.com
|
8241
8249
|
* @Date: 2023-12-26 16:11:34
|
8242
8250
|
* @LastEditors: binruan@chatlabs.com
|
8243
|
-
* @LastEditTime: 2024-04-
|
8251
|
+
* @LastEditTime: 2024-04-16 19:27:48
|
8244
8252
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\ExpandableText.tsx
|
8245
8253
|
*
|
8246
8254
|
*/
|
@@ -8262,48 +8270,47 @@ const limitTextLastWholeWord = (originalText = '', limit) => {
|
|
8262
8270
|
const _words = newWords.length > 1 && newWords.length < words.length ? newWords.slice(0, newWords.length - 1) : newWords;
|
8263
8271
|
return _words.join(' ') + ' ';
|
8264
8272
|
};
|
8265
|
-
const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost }) => {
|
8266
|
-
const [isShowMore, setIsShowMore] = React.useState(
|
8267
|
-
|
8273
|
+
const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost, onChange }) => {
|
8274
|
+
const [isShowMore, setIsShowMore] = React.useState(false);
|
8275
|
+
React.useState(false);
|
8268
8276
|
const lineClamp = Number((style === null || style === void 0 ? void 0 : style.lineClamp) || 2);
|
8269
8277
|
const multiRow = React.useRef(null);
|
8270
8278
|
const handleClick = React.useCallback(() => {
|
8271
8279
|
setIsShowMore(!isShowMore);
|
8272
|
-
|
8280
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(!isShowMore);
|
8281
|
+
}, [isShowMore, onChange]);
|
8273
8282
|
React.useMemo(() => {
|
8274
8283
|
return !isShowMore && text.length > maxStr ? limitTextLastWholeWord(text, maxStr) + '...' : text;
|
8275
8284
|
}, [text, maxStr, isShowMore]);
|
8276
8285
|
React.useEffect(() => {
|
8277
|
-
if (multiRow.current && isPost) {
|
8278
|
-
|
8279
|
-
|
8280
|
-
|
8281
|
-
|
8282
|
-
|
8283
|
-
|
8284
|
-
|
8285
|
-
|
8286
|
-
|
8287
|
-
|
8288
|
-
|
8289
|
-
|
8290
|
-
|
8291
|
-
|
8292
|
-
|
8293
|
-
|
8294
|
-
}, 100);
|
8295
|
-
}
|
8286
|
+
// if (multiRow.current && isPost) {
|
8287
|
+
// setIsShowMore(true);
|
8288
|
+
// setTimeout(() => {
|
8289
|
+
// setIsShow(false);
|
8290
|
+
// try {
|
8291
|
+
// const cs = window?.getComputedStyle?.(multiRow.current);
|
8292
|
+
// const height = parseFloat(cs?.height);
|
8293
|
+
// const lh = parseFloat(cs?.lineHeight);
|
8294
|
+
// const fs = parseFloat(cs?.fontSize) + 6;
|
8295
|
+
// const lineHeight = isNaN(lh) ? fs : lh;
|
8296
|
+
// if (text && height > lineHeight * lineClamp) {
|
8297
|
+
// setIsShowMore(false);
|
8298
|
+
// setIsShow(true);
|
8299
|
+
// }
|
8300
|
+
// } catch {}
|
8301
|
+
// }, 100);
|
8302
|
+
// }
|
8296
8303
|
}, [multiRow, text, lineClamp, style, isPost]);
|
8297
8304
|
return (React.createElement("div", { className: className, style: Object.assign({}, style), hidden: !text || text === '' },
|
8298
8305
|
React.createElement("div", { ref: multiRow, style: {
|
8299
8306
|
overflow: 'hidden',
|
8300
|
-
WebkitLineClamp:
|
8307
|
+
WebkitLineClamp: isShowMore ? '' : lineClamp,
|
8301
8308
|
textOverflow: 'ellipsis',
|
8302
8309
|
display: '-webkit-box',
|
8303
8310
|
WebkitBoxOrient: 'vertical',
|
8304
8311
|
wordBreak: 'break-word'
|
8305
8312
|
}, dangerouslySetInnerHTML: { __html: text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>') } }),
|
8306
|
-
|
8313
|
+
text && isPost && (React.createElement("span", { style: { textDecoration: 'underline', cursor: 'pointer' }, onClick: onClick !== null && onClick !== void 0 ? onClick : handleClick }, isShowMore ? unfoldText || 'show less' : foldText || 'show more'))));
|
8307
8314
|
};
|
8308
8315
|
var ExpandableText$1 = React.memo(ExpandableText);
|
8309
8316
|
|
@@ -12237,7 +12244,7 @@ const FingerSwipeTip = ({ imageUrl }) => {
|
|
12237
12244
|
* @Author: binruan@chatlabs.com
|
12238
12245
|
* @Date: 2024-03-20 10:27:31
|
12239
12246
|
* @LastEditors: binruan@chatlabs.com
|
12240
|
-
* @LastEditTime: 2024-04-
|
12247
|
+
* @LastEditTime: 2024-04-16 20:49:51
|
12241
12248
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\Picture.tsx
|
12242
12249
|
*
|
12243
12250
|
*/
|
@@ -12246,6 +12253,9 @@ const Picture = (props) => {
|
|
12246
12253
|
const [blur, setBlur] = React.useState(false);
|
12247
12254
|
const imgDom = React.useRef(null);
|
12248
12255
|
const { sxpParameter } = useSxpDataSource();
|
12256
|
+
const getAvifToPng = React.useCallback((src) => {
|
12257
|
+
return src.indexOf('avif') !== -1 ? `${src}?imageMogr2/format/png` : src;
|
12258
|
+
}, []);
|
12249
12259
|
React.useEffect(() => {
|
12250
12260
|
if (imgDom.current === null || src === '') {
|
12251
12261
|
return;
|
@@ -12260,22 +12270,22 @@ const Picture = (props) => {
|
|
12260
12270
|
setBlur(true);
|
12261
12271
|
}
|
12262
12272
|
};
|
12263
|
-
imgDom.current.src = src;
|
12264
|
-
}, [src]);
|
12273
|
+
imgDom.current.src = getAvifToPng(src);
|
12274
|
+
}, [src, getAvifToPng]);
|
12265
12275
|
return (React.createElement("div", { style: {
|
12266
12276
|
overflow: 'hidden',
|
12267
12277
|
height,
|
12268
12278
|
width: '100%',
|
12269
12279
|
position: 'relative'
|
12270
12280
|
} },
|
12271
|
-
React.createElement("img", { ref: imgDom, loading: 'lazy', src: src
|
12281
|
+
React.createElement("img", { ref: imgDom, loading: 'lazy', src: src ? getAvifToPng(src) : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, style: {
|
12272
12282
|
height: '100%',
|
12273
12283
|
width: '100%',
|
12274
12284
|
objectFit: 'cover',
|
12275
12285
|
filter: blur ? 'blur(10px)' : 'none',
|
12276
12286
|
transform: blur ? 'scale(1.2)' : 'none'
|
12277
12287
|
} }),
|
12278
|
-
blur && (React.createElement("img", { ref: imgDom, src: src, loading: 'lazy', style: {
|
12288
|
+
blur && (React.createElement("img", { ref: imgDom, src: getAvifToPng(src), loading: 'lazy', style: {
|
12279
12289
|
width: '100%',
|
12280
12290
|
objectFit: 'contain',
|
12281
12291
|
position: 'absolute',
|
@@ -12290,7 +12300,7 @@ const Picture = (props) => {
|
|
12290
12300
|
* @Author: lewinlu@chatlabs.com
|
12291
12301
|
* @Date: 2024-01-03 14:39:09
|
12292
12302
|
* @LastEditors: binruan@chatlabs.com
|
12293
|
-
* @LastEditTime: 2024-04-
|
12303
|
+
* @LastEditTime: 2024-04-16 22:06:11
|
12294
12304
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\index.tsx
|
12295
12305
|
*/
|
12296
12306
|
const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {
|
@@ -12497,7 +12507,7 @@ const Nudge = ({ nudge }) => {
|
|
12497
12507
|
* @Author: binruan@chatlabs.com
|
12498
12508
|
* @Date: 2024-01-15 19:03:09
|
12499
12509
|
* @LastEditors: binruan@chatlabs.com
|
12500
|
-
* @LastEditTime: 2024-04-
|
12510
|
+
* @LastEditTime: 2024-04-16 19:50:16
|
12501
12511
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
|
12502
12512
|
*
|
12503
12513
|
*/
|
@@ -12511,10 +12521,11 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
12511
12521
|
const curTime = React.useRef();
|
12512
12522
|
const viewTime = React.useRef();
|
12513
12523
|
const [isLoadMore, setIsLoadMore] = React.useState(false);
|
12524
|
+
const [isShowMore, setIsShowMore] = React.useState(false);
|
12514
12525
|
const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData } = useSxpDataSource();
|
12515
12526
|
const { productView } = useEventReport();
|
12516
12527
|
const isShowFingerTip = React.useMemo(() => {
|
12517
|
-
return data.length > 0 && !loading;
|
12528
|
+
return data.length > 0 && !loading && getFeUserId();
|
12518
12529
|
}, [data, loading]);
|
12519
12530
|
const handleH5EnterLink = React.useCallback(() => {
|
12520
12531
|
if (data.length <= 0) {
|
@@ -12673,20 +12684,47 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
12673
12684
|
}
|
12674
12685
|
return null;
|
12675
12686
|
}, [containerWidth, data, height, isMuted, activeIndex, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost, viewTime, tipText, resolver, schema]);
|
12687
|
+
const onExpandableChange = React.useCallback((v) => {
|
12688
|
+
setIsShowMore(v);
|
12689
|
+
}, []);
|
12690
|
+
const lineGradStyle = React.useMemo(() => {
|
12691
|
+
return !isShowMore
|
12692
|
+
? {
|
12693
|
+
padding: '20px 0'
|
12694
|
+
}
|
12695
|
+
: {
|
12696
|
+
background: 'linear-gradient( 180deg, rgba(129,129,129,0) 0%, rgba(121,121,121,0.5) 5%, #616161 100%)',
|
12697
|
+
paddingTop: 20,
|
12698
|
+
paddingBottom: 20
|
12699
|
+
};
|
12700
|
+
}, [isShowMore]);
|
12676
12701
|
const renderBottom = React.useCallback((rec, index) => {
|
12677
12702
|
var _a, _b, _c, _d, _e, _f, _g;
|
12678
12703
|
if (rec.video) {
|
12679
12704
|
return (React.createElement(React.Fragment, null,
|
12680
|
-
((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
|
12705
|
+
((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && !isShowMore && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
|
12681
12706
|
React.createElement("div", { className: 'clc-sxp-bottom' },
|
12682
12707
|
React.createElement(Nudge, { nudge: nudge }),
|
12683
12708
|
React.createElement("div", { className: 'clc-sxp-bottom-card' },
|
12684
12709
|
React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
|
12685
|
-
React.createElement(
|
12686
|
-
|
12710
|
+
React.createElement("div", { style: lineGradStyle },
|
12711
|
+
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(Object.assign({}, descStyle), { textShadow: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isOpenTextShadow) ? '2px 2px 4px rgba(0, 0, 0, 0.5)' : 'none' }), onChange: onExpandableChange }),
|
12712
|
+
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 })))));
|
12687
12713
|
}
|
12688
12714
|
return null;
|
12689
|
-
}, [
|
12715
|
+
}, [
|
12716
|
+
descStyle,
|
12717
|
+
activeIndex,
|
12718
|
+
tempMap,
|
12719
|
+
resolver,
|
12720
|
+
tipText,
|
12721
|
+
nudge,
|
12722
|
+
hashTagStyle,
|
12723
|
+
globalConfig,
|
12724
|
+
onExpandableChange,
|
12725
|
+
isShowMore,
|
12726
|
+
lineGradStyle
|
12727
|
+
]);
|
12690
12728
|
const renderLikeButton = React.useCallback((rec, index) => {
|
12691
12729
|
var _a, _b;
|
12692
12730
|
if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
|