pb-sxp-ui 1.0.13 → 1.0.14
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 +63 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -1
- package/dist/index.js +63 -32
- 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 +63 -32
- 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/index.js +34 -5
- package/es/core/utils/localStore.d.ts +1 -0
- package/es/core/utils/localStore.js +4 -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/index.js +34 -5
- package/lib/core/utils/localStore.d.ts +1 -0
- package/lib/core/utils/localStore.js +6 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
package/dist/index.js
CHANGED
@@ -377,6 +377,10 @@ const storeAndLoadFeUserId = () => {
|
|
377
377
|
}
|
378
378
|
return fakeUserId;
|
379
379
|
};
|
380
|
+
const getFeUserId = () => {
|
381
|
+
const fakeUserId = window.localStorage.getItem(FAKE_USER_KEY);
|
382
|
+
return isEmpty(fakeUserId);
|
383
|
+
};
|
380
384
|
|
381
385
|
/*
|
382
386
|
* @Author: binruan@chatlabs.com
|
@@ -8217,7 +8221,7 @@ var Modal$1 = memo(Modal);
|
|
8217
8221
|
* @Author: binruan@chatlabs.com
|
8218
8222
|
* @Date: 2023-12-26 16:11:34
|
8219
8223
|
* @LastEditors: binruan@chatlabs.com
|
8220
|
-
* @LastEditTime: 2024-04-
|
8224
|
+
* @LastEditTime: 2024-04-16 19:27:48
|
8221
8225
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\ExpandableText.tsx
|
8222
8226
|
*
|
8223
8227
|
*/
|
@@ -8239,48 +8243,47 @@ const limitTextLastWholeWord = (originalText = '', limit) => {
|
|
8239
8243
|
const _words = newWords.length > 1 && newWords.length < words.length ? newWords.slice(0, newWords.length - 1) : newWords;
|
8240
8244
|
return _words.join(' ') + ' ';
|
8241
8245
|
};
|
8242
|
-
const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost }) => {
|
8243
|
-
const [isShowMore, setIsShowMore] = useState(
|
8244
|
-
|
8246
|
+
const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost, onChange }) => {
|
8247
|
+
const [isShowMore, setIsShowMore] = useState(false);
|
8248
|
+
useState(false);
|
8245
8249
|
const lineClamp = Number((style === null || style === void 0 ? void 0 : style.lineClamp) || 2);
|
8246
8250
|
const multiRow = useRef(null);
|
8247
8251
|
const handleClick = useCallback(() => {
|
8248
8252
|
setIsShowMore(!isShowMore);
|
8249
|
-
|
8253
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(!isShowMore);
|
8254
|
+
}, [isShowMore, onChange]);
|
8250
8255
|
useMemo(() => {
|
8251
8256
|
return !isShowMore && text.length > maxStr ? limitTextLastWholeWord(text, maxStr) + '...' : text;
|
8252
8257
|
}, [text, maxStr, isShowMore]);
|
8253
8258
|
useEffect(() => {
|
8254
|
-
if (multiRow.current && isPost) {
|
8255
|
-
|
8256
|
-
|
8257
|
-
|
8258
|
-
|
8259
|
-
|
8260
|
-
|
8261
|
-
|
8262
|
-
|
8263
|
-
|
8264
|
-
|
8265
|
-
|
8266
|
-
|
8267
|
-
|
8268
|
-
|
8269
|
-
|
8270
|
-
|
8271
|
-
}, 100);
|
8272
|
-
}
|
8259
|
+
// if (multiRow.current && isPost) {
|
8260
|
+
// setIsShowMore(true);
|
8261
|
+
// setTimeout(() => {
|
8262
|
+
// setIsShow(false);
|
8263
|
+
// try {
|
8264
|
+
// const cs = window?.getComputedStyle?.(multiRow.current);
|
8265
|
+
// const height = parseFloat(cs?.height);
|
8266
|
+
// const lh = parseFloat(cs?.lineHeight);
|
8267
|
+
// const fs = parseFloat(cs?.fontSize) + 6;
|
8268
|
+
// const lineHeight = isNaN(lh) ? fs : lh;
|
8269
|
+
// if (text && height > lineHeight * lineClamp) {
|
8270
|
+
// setIsShowMore(false);
|
8271
|
+
// setIsShow(true);
|
8272
|
+
// }
|
8273
|
+
// } catch {}
|
8274
|
+
// }, 100);
|
8275
|
+
// }
|
8273
8276
|
}, [multiRow, text, lineClamp, style, isPost]);
|
8274
8277
|
return (React.createElement("div", { className: className, style: Object.assign({}, style), hidden: !text || text === '' },
|
8275
8278
|
React.createElement("div", { ref: multiRow, style: {
|
8276
8279
|
overflow: 'hidden',
|
8277
|
-
WebkitLineClamp:
|
8280
|
+
WebkitLineClamp: isShowMore ? '' : lineClamp,
|
8278
8281
|
textOverflow: 'ellipsis',
|
8279
8282
|
display: '-webkit-box',
|
8280
8283
|
WebkitBoxOrient: 'vertical',
|
8281
8284
|
wordBreak: 'break-word'
|
8282
8285
|
}, dangerouslySetInnerHTML: { __html: text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>') } }),
|
8283
|
-
|
8286
|
+
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'))));
|
8284
8287
|
};
|
8285
8288
|
var ExpandableText$1 = memo(ExpandableText);
|
8286
8289
|
|
@@ -12474,7 +12477,7 @@ const Nudge = ({ nudge }) => {
|
|
12474
12477
|
* @Author: binruan@chatlabs.com
|
12475
12478
|
* @Date: 2024-01-15 19:03:09
|
12476
12479
|
* @LastEditors: binruan@chatlabs.com
|
12477
|
-
* @LastEditTime: 2024-04-
|
12480
|
+
* @LastEditTime: 2024-04-16 18:26:41
|
12478
12481
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
|
12479
12482
|
*
|
12480
12483
|
*/
|
@@ -12488,10 +12491,11 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
12488
12491
|
const curTime = useRef();
|
12489
12492
|
const viewTime = useRef();
|
12490
12493
|
const [isLoadMore, setIsLoadMore] = useState(false);
|
12494
|
+
const [isShowMore, setIsShowMore] = useState(false);
|
12491
12495
|
const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData } = useSxpDataSource();
|
12492
12496
|
const { productView } = useEventReport();
|
12493
12497
|
const isShowFingerTip = useMemo(() => {
|
12494
|
-
return data.length > 0 && !loading;
|
12498
|
+
return data.length > 0 && !loading && !getFeUserId;
|
12495
12499
|
}, [data, loading]);
|
12496
12500
|
const handleH5EnterLink = useCallback(() => {
|
12497
12501
|
if (data.length <= 0) {
|
@@ -12650,20 +12654,47 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
12650
12654
|
}
|
12651
12655
|
return null;
|
12652
12656
|
}, [containerWidth, data, height, isMuted, activeIndex, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost, viewTime, tipText, resolver, schema]);
|
12657
|
+
const onExpandableChange = useCallback((v) => {
|
12658
|
+
setIsShowMore(v);
|
12659
|
+
}, []);
|
12660
|
+
const lineGradStyle = useMemo(() => {
|
12661
|
+
return !isShowMore
|
12662
|
+
? {
|
12663
|
+
padding: '20px 0'
|
12664
|
+
}
|
12665
|
+
: {
|
12666
|
+
background: 'linear-gradient( 180deg, rgba(129,129,129,0) 0%, rgba(121,121,121,0.5) 5%, #616161 100%)',
|
12667
|
+
paddingTop: 20,
|
12668
|
+
paddingBottom: 20
|
12669
|
+
};
|
12670
|
+
}, [isShowMore]);
|
12653
12671
|
const renderBottom = useCallback((rec, index) => {
|
12654
12672
|
var _a, _b, _c, _d, _e, _f, _g;
|
12655
12673
|
if (rec.video) {
|
12656
12674
|
return (React.createElement(React.Fragment, null,
|
12657
|
-
((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
|
12675
|
+
((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && !isShowMore && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
|
12658
12676
|
React.createElement("div", { className: 'clc-sxp-bottom' },
|
12659
12677
|
React.createElement(Nudge, { nudge: nudge }),
|
12660
12678
|
React.createElement("div", { className: 'clc-sxp-bottom-card' },
|
12661
12679
|
React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
|
12662
|
-
React.createElement(
|
12663
|
-
|
12680
|
+
React.createElement("div", { style: lineGradStyle },
|
12681
|
+
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 }),
|
12682
|
+
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 })))));
|
12664
12683
|
}
|
12665
12684
|
return null;
|
12666
|
-
}, [
|
12685
|
+
}, [
|
12686
|
+
descStyle,
|
12687
|
+
activeIndex,
|
12688
|
+
tempMap,
|
12689
|
+
resolver,
|
12690
|
+
tipText,
|
12691
|
+
nudge,
|
12692
|
+
hashTagStyle,
|
12693
|
+
globalConfig,
|
12694
|
+
onExpandableChange,
|
12695
|
+
isShowMore,
|
12696
|
+
lineGradStyle
|
12697
|
+
]);
|
12667
12698
|
const renderLikeButton = useCallback((rec, index) => {
|
12668
12699
|
var _a, _b;
|
12669
12700
|
if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
|