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.cjs
CHANGED
@@ -400,6 +400,10 @@ const storeAndLoadFeUserId = () => {
|
|
400
400
|
}
|
401
401
|
return fakeUserId;
|
402
402
|
};
|
403
|
+
const getFeUserId = () => {
|
404
|
+
const fakeUserId = window.localStorage.getItem(FAKE_USER_KEY);
|
405
|
+
return lodash.isEmpty(fakeUserId);
|
406
|
+
};
|
403
407
|
|
404
408
|
/*
|
405
409
|
* @Author: binruan@chatlabs.com
|
@@ -8240,7 +8244,7 @@ var Modal$1 = React.memo(Modal);
|
|
8240
8244
|
* @Author: binruan@chatlabs.com
|
8241
8245
|
* @Date: 2023-12-26 16:11:34
|
8242
8246
|
* @LastEditors: binruan@chatlabs.com
|
8243
|
-
* @LastEditTime: 2024-04-
|
8247
|
+
* @LastEditTime: 2024-04-16 19:27:48
|
8244
8248
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\ExpandableText.tsx
|
8245
8249
|
*
|
8246
8250
|
*/
|
@@ -8262,48 +8266,47 @@ const limitTextLastWholeWord = (originalText = '', limit) => {
|
|
8262
8266
|
const _words = newWords.length > 1 && newWords.length < words.length ? newWords.slice(0, newWords.length - 1) : newWords;
|
8263
8267
|
return _words.join(' ') + ' ';
|
8264
8268
|
};
|
8265
|
-
const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost }) => {
|
8266
|
-
const [isShowMore, setIsShowMore] = React.useState(
|
8267
|
-
|
8269
|
+
const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost, onChange }) => {
|
8270
|
+
const [isShowMore, setIsShowMore] = React.useState(false);
|
8271
|
+
React.useState(false);
|
8268
8272
|
const lineClamp = Number((style === null || style === void 0 ? void 0 : style.lineClamp) || 2);
|
8269
8273
|
const multiRow = React.useRef(null);
|
8270
8274
|
const handleClick = React.useCallback(() => {
|
8271
8275
|
setIsShowMore(!isShowMore);
|
8272
|
-
|
8276
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(!isShowMore);
|
8277
|
+
}, [isShowMore, onChange]);
|
8273
8278
|
React.useMemo(() => {
|
8274
8279
|
return !isShowMore && text.length > maxStr ? limitTextLastWholeWord(text, maxStr) + '...' : text;
|
8275
8280
|
}, [text, maxStr, isShowMore]);
|
8276
8281
|
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
|
-
}
|
8282
|
+
// if (multiRow.current && isPost) {
|
8283
|
+
// setIsShowMore(true);
|
8284
|
+
// setTimeout(() => {
|
8285
|
+
// setIsShow(false);
|
8286
|
+
// try {
|
8287
|
+
// const cs = window?.getComputedStyle?.(multiRow.current);
|
8288
|
+
// const height = parseFloat(cs?.height);
|
8289
|
+
// const lh = parseFloat(cs?.lineHeight);
|
8290
|
+
// const fs = parseFloat(cs?.fontSize) + 6;
|
8291
|
+
// const lineHeight = isNaN(lh) ? fs : lh;
|
8292
|
+
// if (text && height > lineHeight * lineClamp) {
|
8293
|
+
// setIsShowMore(false);
|
8294
|
+
// setIsShow(true);
|
8295
|
+
// }
|
8296
|
+
// } catch {}
|
8297
|
+
// }, 100);
|
8298
|
+
// }
|
8296
8299
|
}, [multiRow, text, lineClamp, style, isPost]);
|
8297
8300
|
return (React.createElement("div", { className: className, style: Object.assign({}, style), hidden: !text || text === '' },
|
8298
8301
|
React.createElement("div", { ref: multiRow, style: {
|
8299
8302
|
overflow: 'hidden',
|
8300
|
-
WebkitLineClamp:
|
8303
|
+
WebkitLineClamp: isShowMore ? '' : lineClamp,
|
8301
8304
|
textOverflow: 'ellipsis',
|
8302
8305
|
display: '-webkit-box',
|
8303
8306
|
WebkitBoxOrient: 'vertical',
|
8304
8307
|
wordBreak: 'break-word'
|
8305
8308
|
}, dangerouslySetInnerHTML: { __html: text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>') } }),
|
8306
|
-
|
8309
|
+
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
8310
|
};
|
8308
8311
|
var ExpandableText$1 = React.memo(ExpandableText);
|
8309
8312
|
|
@@ -12497,7 +12500,7 @@ const Nudge = ({ nudge }) => {
|
|
12497
12500
|
* @Author: binruan@chatlabs.com
|
12498
12501
|
* @Date: 2024-01-15 19:03:09
|
12499
12502
|
* @LastEditors: binruan@chatlabs.com
|
12500
|
-
* @LastEditTime: 2024-04-
|
12503
|
+
* @LastEditTime: 2024-04-16 18:26:41
|
12501
12504
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
|
12502
12505
|
*
|
12503
12506
|
*/
|
@@ -12511,10 +12514,11 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
12511
12514
|
const curTime = React.useRef();
|
12512
12515
|
const viewTime = React.useRef();
|
12513
12516
|
const [isLoadMore, setIsLoadMore] = React.useState(false);
|
12517
|
+
const [isShowMore, setIsShowMore] = React.useState(false);
|
12514
12518
|
const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData } = useSxpDataSource();
|
12515
12519
|
const { productView } = useEventReport();
|
12516
12520
|
const isShowFingerTip = React.useMemo(() => {
|
12517
|
-
return data.length > 0 && !loading;
|
12521
|
+
return data.length > 0 && !loading && !getFeUserId;
|
12518
12522
|
}, [data, loading]);
|
12519
12523
|
const handleH5EnterLink = React.useCallback(() => {
|
12520
12524
|
if (data.length <= 0) {
|
@@ -12673,20 +12677,47 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
12673
12677
|
}
|
12674
12678
|
return null;
|
12675
12679
|
}, [containerWidth, data, height, isMuted, activeIndex, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost, viewTime, tipText, resolver, schema]);
|
12680
|
+
const onExpandableChange = React.useCallback((v) => {
|
12681
|
+
setIsShowMore(v);
|
12682
|
+
}, []);
|
12683
|
+
const lineGradStyle = React.useMemo(() => {
|
12684
|
+
return !isShowMore
|
12685
|
+
? {
|
12686
|
+
padding: '20px 0'
|
12687
|
+
}
|
12688
|
+
: {
|
12689
|
+
background: 'linear-gradient( 180deg, rgba(129,129,129,0) 0%, rgba(121,121,121,0.5) 5%, #616161 100%)',
|
12690
|
+
paddingTop: 20,
|
12691
|
+
paddingBottom: 20
|
12692
|
+
};
|
12693
|
+
}, [isShowMore]);
|
12676
12694
|
const renderBottom = React.useCallback((rec, index) => {
|
12677
12695
|
var _a, _b, _c, _d, _e, _f, _g;
|
12678
12696
|
if (rec.video) {
|
12679
12697
|
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' }),
|
12698
|
+
((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && !isShowMore && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
|
12681
12699
|
React.createElement("div", { className: 'clc-sxp-bottom' },
|
12682
12700
|
React.createElement(Nudge, { nudge: nudge }),
|
12683
12701
|
React.createElement("div", { className: 'clc-sxp-bottom-card' },
|
12684
12702
|
React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
|
12685
|
-
React.createElement(
|
12686
|
-
|
12703
|
+
React.createElement("div", { style: lineGradStyle },
|
12704
|
+
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 }),
|
12705
|
+
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
12706
|
}
|
12688
12707
|
return null;
|
12689
|
-
}, [
|
12708
|
+
}, [
|
12709
|
+
descStyle,
|
12710
|
+
activeIndex,
|
12711
|
+
tempMap,
|
12712
|
+
resolver,
|
12713
|
+
tipText,
|
12714
|
+
nudge,
|
12715
|
+
hashTagStyle,
|
12716
|
+
globalConfig,
|
12717
|
+
onExpandableChange,
|
12718
|
+
isShowMore,
|
12719
|
+
lineGradStyle
|
12720
|
+
]);
|
12690
12721
|
const renderLikeButton = React.useCallback((rec, index) => {
|
12691
12722
|
var _a, _b;
|
12692
12723
|
if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
|