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.css CHANGED
@@ -1319,7 +1319,6 @@ button.swiper-pagination-bullet {
1319
1319
  bottom: 0;
1320
1320
  left: 0;
1321
1321
  right: 0;
1322
- padding: 20px 0 20px 0;
1323
1322
  }
1324
1323
  .clc-sxp-bottom-nudge {
1325
1324
  display: -webkit-box;
package/dist/index.js CHANGED
@@ -369,6 +369,7 @@ const getFeSessionId = () => {
369
369
  };
370
370
 
371
371
  const FAKE_USER_KEY = 'SXP_FAKE_USER_ID';
372
+ const FAKE_USER_STATE = 'FAKE_USER_STATE';
372
373
  const storeAndLoadFeUserId = () => {
373
374
  let fakeUserId = window.localStorage.getItem(FAKE_USER_KEY);
374
375
  if (isEmpty(fakeUserId)) {
@@ -377,6 +378,13 @@ const storeAndLoadFeUserId = () => {
377
378
  }
378
379
  return fakeUserId;
379
380
  };
381
+ const getFeUserId = () => {
382
+ const fakeUserState = window.localStorage.getItem(FAKE_USER_STATE);
383
+ if (isEmpty(fakeUserState)) {
384
+ window.localStorage.setItem(FAKE_USER_STATE, 'true');
385
+ }
386
+ return isEmpty(fakeUserState);
387
+ };
380
388
 
381
389
  /*
382
390
  * @Author: binruan@chatlabs.com
@@ -8217,7 +8225,7 @@ var Modal$1 = memo(Modal);
8217
8225
  * @Author: binruan@chatlabs.com
8218
8226
  * @Date: 2023-12-26 16:11:34
8219
8227
  * @LastEditors: binruan@chatlabs.com
8220
- * @LastEditTime: 2024-04-09 11:00:07
8228
+ * @LastEditTime: 2024-04-16 19:27:48
8221
8229
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\ExpandableText.tsx
8222
8230
  *
8223
8231
  */
@@ -8239,48 +8247,47 @@ const limitTextLastWholeWord = (originalText = '', limit) => {
8239
8247
  const _words = newWords.length > 1 && newWords.length < words.length ? newWords.slice(0, newWords.length - 1) : newWords;
8240
8248
  return _words.join(' ') + ' ';
8241
8249
  };
8242
- const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost }) => {
8243
- const [isShowMore, setIsShowMore] = useState(true);
8244
- const [isShow, setIsShow] = useState(false);
8250
+ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost, onChange }) => {
8251
+ const [isShowMore, setIsShowMore] = useState(false);
8252
+ useState(false);
8245
8253
  const lineClamp = Number((style === null || style === void 0 ? void 0 : style.lineClamp) || 2);
8246
8254
  const multiRow = useRef(null);
8247
8255
  const handleClick = useCallback(() => {
8248
8256
  setIsShowMore(!isShowMore);
8249
- }, [isShowMore]);
8257
+ onChange === null || onChange === void 0 ? void 0 : onChange(!isShowMore);
8258
+ }, [isShowMore, onChange]);
8250
8259
  useMemo(() => {
8251
8260
  return !isShowMore && text.length > maxStr ? limitTextLastWholeWord(text, maxStr) + '...' : text;
8252
8261
  }, [text, maxStr, isShowMore]);
8253
8262
  useEffect(() => {
8254
- if (multiRow.current && isPost) {
8255
- setIsShowMore(true);
8256
- setTimeout(() => {
8257
- var _a;
8258
- setIsShow(false);
8259
- try {
8260
- const cs = (_a = window === null || window === void 0 ? void 0 : window.getComputedStyle) === null || _a === void 0 ? void 0 : _a.call(window, multiRow.current);
8261
- const height = parseFloat(cs === null || cs === void 0 ? void 0 : cs.height);
8262
- const lh = parseFloat(cs === null || cs === void 0 ? void 0 : cs.lineHeight);
8263
- const fs = parseFloat(cs === null || cs === void 0 ? void 0 : cs.fontSize) + 6;
8264
- const lineHeight = isNaN(lh) ? fs : lh;
8265
- if (text && height > lineHeight * lineClamp) {
8266
- setIsShowMore(false);
8267
- setIsShow(true);
8268
- }
8269
- }
8270
- catch (_b) { }
8271
- }, 100);
8272
- }
8263
+ // if (multiRow.current && isPost) {
8264
+ // setIsShowMore(true);
8265
+ // setTimeout(() => {
8266
+ // setIsShow(false);
8267
+ // try {
8268
+ // const cs = window?.getComputedStyle?.(multiRow.current);
8269
+ // const height = parseFloat(cs?.height);
8270
+ // const lh = parseFloat(cs?.lineHeight);
8271
+ // const fs = parseFloat(cs?.fontSize) + 6;
8272
+ // const lineHeight = isNaN(lh) ? fs : lh;
8273
+ // if (text && height > lineHeight * lineClamp) {
8274
+ // setIsShowMore(false);
8275
+ // setIsShow(true);
8276
+ // }
8277
+ // } catch {}
8278
+ // }, 100);
8279
+ // }
8273
8280
  }, [multiRow, text, lineClamp, style, isPost]);
8274
8281
  return (React.createElement("div", { className: className, style: Object.assign({}, style), hidden: !text || text === '' },
8275
8282
  React.createElement("div", { ref: multiRow, style: {
8276
8283
  overflow: 'hidden',
8277
- WebkitLineClamp: !isShowMore ? lineClamp : '',
8284
+ WebkitLineClamp: isShowMore ? '' : lineClamp,
8278
8285
  textOverflow: 'ellipsis',
8279
8286
  display: '-webkit-box',
8280
8287
  WebkitBoxOrient: 'vertical',
8281
8288
  wordBreak: 'break-word'
8282
8289
  }, dangerouslySetInnerHTML: { __html: text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>') } }),
8283
- 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'))));
8290
+ 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
8291
  };
8285
8292
  var ExpandableText$1 = memo(ExpandableText);
8286
8293
 
@@ -12214,7 +12221,7 @@ const FingerSwipeTip = ({ imageUrl }) => {
12214
12221
  * @Author: binruan@chatlabs.com
12215
12222
  * @Date: 2024-03-20 10:27:31
12216
12223
  * @LastEditors: binruan@chatlabs.com
12217
- * @LastEditTime: 2024-04-15 18:10:26
12224
+ * @LastEditTime: 2024-04-16 20:49:51
12218
12225
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\Picture.tsx
12219
12226
  *
12220
12227
  */
@@ -12223,6 +12230,9 @@ const Picture = (props) => {
12223
12230
  const [blur, setBlur] = useState(false);
12224
12231
  const imgDom = useRef(null);
12225
12232
  const { sxpParameter } = useSxpDataSource();
12233
+ const getAvifToPng = useCallback((src) => {
12234
+ return src.indexOf('avif') !== -1 ? `${src}?imageMogr2/format/png` : src;
12235
+ }, []);
12226
12236
  useEffect(() => {
12227
12237
  if (imgDom.current === null || src === '') {
12228
12238
  return;
@@ -12237,22 +12247,22 @@ const Picture = (props) => {
12237
12247
  setBlur(true);
12238
12248
  }
12239
12249
  };
12240
- imgDom.current.src = src;
12241
- }, [src]);
12250
+ imgDom.current.src = getAvifToPng(src);
12251
+ }, [src, getAvifToPng]);
12242
12252
  return (React.createElement("div", { style: {
12243
12253
  overflow: 'hidden',
12244
12254
  height,
12245
12255
  width: '100%',
12246
12256
  position: 'relative'
12247
12257
  } },
12248
- React.createElement("img", { ref: imgDom, loading: 'lazy', src: src !== null && src !== void 0 ? src : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, style: {
12258
+ React.createElement("img", { ref: imgDom, loading: 'lazy', src: src ? getAvifToPng(src) : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, style: {
12249
12259
  height: '100%',
12250
12260
  width: '100%',
12251
12261
  objectFit: 'cover',
12252
12262
  filter: blur ? 'blur(10px)' : 'none',
12253
12263
  transform: blur ? 'scale(1.2)' : 'none'
12254
12264
  } }),
12255
- blur && (React.createElement("img", { ref: imgDom, src: src, loading: 'lazy', style: {
12265
+ blur && (React.createElement("img", { ref: imgDom, src: getAvifToPng(src), loading: 'lazy', style: {
12256
12266
  width: '100%',
12257
12267
  objectFit: 'contain',
12258
12268
  position: 'absolute',
@@ -12267,7 +12277,7 @@ const Picture = (props) => {
12267
12277
  * @Author: lewinlu@chatlabs.com
12268
12278
  * @Date: 2024-01-03 14:39:09
12269
12279
  * @LastEditors: binruan@chatlabs.com
12270
- * @LastEditTime: 2024-04-15 18:08:25
12280
+ * @LastEditTime: 2024-04-16 22:06:11
12271
12281
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\index.tsx
12272
12282
  */
12273
12283
  const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {
@@ -12474,7 +12484,7 @@ const Nudge = ({ nudge }) => {
12474
12484
  * @Author: binruan@chatlabs.com
12475
12485
  * @Date: 2024-01-15 19:03:09
12476
12486
  * @LastEditors: binruan@chatlabs.com
12477
- * @LastEditTime: 2024-04-15 17:07:42
12487
+ * @LastEditTime: 2024-04-16 19:50:16
12478
12488
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
12479
12489
  *
12480
12490
  */
@@ -12488,10 +12498,11 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
12488
12498
  const curTime = useRef();
12489
12499
  const viewTime = useRef();
12490
12500
  const [isLoadMore, setIsLoadMore] = useState(false);
12501
+ const [isShowMore, setIsShowMore] = useState(false);
12491
12502
  const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData } = useSxpDataSource();
12492
12503
  const { productView } = useEventReport();
12493
12504
  const isShowFingerTip = useMemo(() => {
12494
- return data.length > 0 && !loading;
12505
+ return data.length > 0 && !loading && getFeUserId();
12495
12506
  }, [data, loading]);
12496
12507
  const handleH5EnterLink = useCallback(() => {
12497
12508
  if (data.length <= 0) {
@@ -12650,20 +12661,47 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
12650
12661
  }
12651
12662
  return null;
12652
12663
  }, [containerWidth, data, height, isMuted, activeIndex, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost, viewTime, tipText, resolver, schema]);
12664
+ const onExpandableChange = useCallback((v) => {
12665
+ setIsShowMore(v);
12666
+ }, []);
12667
+ const lineGradStyle = useMemo(() => {
12668
+ return !isShowMore
12669
+ ? {
12670
+ padding: '20px 0'
12671
+ }
12672
+ : {
12673
+ background: 'linear-gradient( 180deg, rgba(129,129,129,0) 0%, rgba(121,121,121,0.5) 5%, #616161 100%)',
12674
+ paddingTop: 20,
12675
+ paddingBottom: 20
12676
+ };
12677
+ }, [isShowMore]);
12653
12678
  const renderBottom = useCallback((rec, index) => {
12654
12679
  var _a, _b, _c, _d, _e, _f, _g;
12655
12680
  if (rec.video) {
12656
12681
  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' }),
12682
+ ((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && !isShowMore && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
12658
12683
  React.createElement("div", { className: 'clc-sxp-bottom' },
12659
12684
  React.createElement(Nudge, { nudge: nudge }),
12660
12685
  React.createElement("div", { className: 'clc-sxp-bottom-card' },
12661
12686
  React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
12662
- 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' }) }),
12663
- 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
+ React.createElement("div", { style: lineGradStyle },
12688
+ 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 }),
12689
+ 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
12690
  }
12665
12691
  return null;
12666
- }, [descStyle, activeIndex, tempMap, resolver, tipText, nudge, hashTagStyle, globalConfig]);
12692
+ }, [
12693
+ descStyle,
12694
+ activeIndex,
12695
+ tempMap,
12696
+ resolver,
12697
+ tipText,
12698
+ nudge,
12699
+ hashTagStyle,
12700
+ globalConfig,
12701
+ onExpandableChange,
12702
+ isShowMore,
12703
+ lineGradStyle
12704
+ ]);
12667
12705
  const renderLikeButton = useCallback((rec, index) => {
12668
12706
  var _a, _b;
12669
12707
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))