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 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-09 11:00:07
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(true);
8267
- const [isShow, setIsShow] = React.useState(false);
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
- }, [isShowMore]);
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
- setIsShowMore(true);
8279
- setTimeout(() => {
8280
- var _a;
8281
- setIsShow(false);
8282
- try {
8283
- const cs = (_a = window === null || window === void 0 ? void 0 : window.getComputedStyle) === null || _a === void 0 ? void 0 : _a.call(window, multiRow.current);
8284
- const height = parseFloat(cs === null || cs === void 0 ? void 0 : cs.height);
8285
- const lh = parseFloat(cs === null || cs === void 0 ? void 0 : cs.lineHeight);
8286
- const fs = parseFloat(cs === null || cs === void 0 ? void 0 : cs.fontSize) + 6;
8287
- const lineHeight = isNaN(lh) ? fs : lh;
8288
- if (text && height > lineHeight * lineClamp) {
8289
- setIsShowMore(false);
8290
- setIsShow(true);
8291
- }
8292
- }
8293
- catch (_b) { }
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: !isShowMore ? lineClamp : '',
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
- isShow && text && (React.createElement("span", { style: { textDecoration: 'underline', cursor: 'pointer' }, onClick: onClick !== null && onClick !== void 0 ? onClick : handleClick }, isShowMore ? unfoldText || 'show less' : foldText || 'show more'))));
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-15 17:07:42
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(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' }) }),
12686
- 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 }))));
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
- }, [descStyle, activeIndex, tempMap, resolver, tipText, nudge, hashTagStyle, globalConfig]);
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))