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/pb-ui.js CHANGED
@@ -384,6 +384,7 @@
384
384
  };
385
385
 
386
386
  const FAKE_USER_KEY = 'SXP_FAKE_USER_ID';
387
+ const FAKE_USER_STATE = 'FAKE_USER_STATE';
387
388
  const storeAndLoadFeUserId = () => {
388
389
  let fakeUserId = window.localStorage.getItem(FAKE_USER_KEY);
389
390
  if (lodash.isEmpty(fakeUserId)) {
@@ -392,6 +393,13 @@
392
393
  }
393
394
  return fakeUserId;
394
395
  };
396
+ const getFeUserId = () => {
397
+ const fakeUserState = window.localStorage.getItem(FAKE_USER_STATE);
398
+ if (lodash.isEmpty(fakeUserState)) {
399
+ window.localStorage.setItem(FAKE_USER_STATE, 'true');
400
+ }
401
+ return lodash.isEmpty(fakeUserState);
402
+ };
395
403
 
396
404
  /*
397
405
  * @Author: binruan@chatlabs.com
@@ -8232,7 +8240,7 @@
8232
8240
  * @Author: binruan@chatlabs.com
8233
8241
  * @Date: 2023-12-26 16:11:34
8234
8242
  * @LastEditors: binruan@chatlabs.com
8235
- * @LastEditTime: 2024-04-09 11:00:07
8243
+ * @LastEditTime: 2024-04-16 19:27:48
8236
8244
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\ExpandableText.tsx
8237
8245
  *
8238
8246
  */
@@ -8254,48 +8262,47 @@
8254
8262
  const _words = newWords.length > 1 && newWords.length < words.length ? newWords.slice(0, newWords.length - 1) : newWords;
8255
8263
  return _words.join(' ') + ' ';
8256
8264
  };
8257
- const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost }) => {
8258
- const [isShowMore, setIsShowMore] = React.useState(true);
8259
- const [isShow, setIsShow] = React.useState(false);
8265
+ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldText, unfoldText, isPost, onChange }) => {
8266
+ const [isShowMore, setIsShowMore] = React.useState(false);
8267
+ React.useState(false);
8260
8268
  const lineClamp = Number((style === null || style === void 0 ? void 0 : style.lineClamp) || 2);
8261
8269
  const multiRow = React.useRef(null);
8262
8270
  const handleClick = React.useCallback(() => {
8263
8271
  setIsShowMore(!isShowMore);
8264
- }, [isShowMore]);
8272
+ onChange === null || onChange === void 0 ? void 0 : onChange(!isShowMore);
8273
+ }, [isShowMore, onChange]);
8265
8274
  React.useMemo(() => {
8266
8275
  return !isShowMore && text.length > maxStr ? limitTextLastWholeWord(text, maxStr) + '...' : text;
8267
8276
  }, [text, maxStr, isShowMore]);
8268
8277
  React.useEffect(() => {
8269
- if (multiRow.current && isPost) {
8270
- setIsShowMore(true);
8271
- setTimeout(() => {
8272
- var _a;
8273
- setIsShow(false);
8274
- try {
8275
- const cs = (_a = window === null || window === void 0 ? void 0 : window.getComputedStyle) === null || _a === void 0 ? void 0 : _a.call(window, multiRow.current);
8276
- const height = parseFloat(cs === null || cs === void 0 ? void 0 : cs.height);
8277
- const lh = parseFloat(cs === null || cs === void 0 ? void 0 : cs.lineHeight);
8278
- const fs = parseFloat(cs === null || cs === void 0 ? void 0 : cs.fontSize) + 6;
8279
- const lineHeight = isNaN(lh) ? fs : lh;
8280
- if (text && height > lineHeight * lineClamp) {
8281
- setIsShowMore(false);
8282
- setIsShow(true);
8283
- }
8284
- }
8285
- catch (_b) { }
8286
- }, 100);
8287
- }
8278
+ // if (multiRow.current && isPost) {
8279
+ // setIsShowMore(true);
8280
+ // setTimeout(() => {
8281
+ // setIsShow(false);
8282
+ // try {
8283
+ // const cs = window?.getComputedStyle?.(multiRow.current);
8284
+ // const height = parseFloat(cs?.height);
8285
+ // const lh = parseFloat(cs?.lineHeight);
8286
+ // const fs = parseFloat(cs?.fontSize) + 6;
8287
+ // const lineHeight = isNaN(lh) ? fs : lh;
8288
+ // if (text && height > lineHeight * lineClamp) {
8289
+ // setIsShowMore(false);
8290
+ // setIsShow(true);
8291
+ // }
8292
+ // } catch {}
8293
+ // }, 100);
8294
+ // }
8288
8295
  }, [multiRow, text, lineClamp, style, isPost]);
8289
8296
  return (React.createElement("div", { className: className, style: Object.assign({}, style), hidden: !text || text === '' },
8290
8297
  React.createElement("div", { ref: multiRow, style: {
8291
8298
  overflow: 'hidden',
8292
- WebkitLineClamp: !isShowMore ? lineClamp : '',
8299
+ WebkitLineClamp: isShowMore ? '' : lineClamp,
8293
8300
  textOverflow: 'ellipsis',
8294
8301
  display: '-webkit-box',
8295
8302
  WebkitBoxOrient: 'vertical',
8296
8303
  wordBreak: 'break-word'
8297
8304
  }, dangerouslySetInnerHTML: { __html: text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>') } }),
8298
- 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'))));
8305
+ 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'))));
8299
8306
  };
8300
8307
  var ExpandableText$1 = React.memo(ExpandableText);
8301
8308
 
@@ -12229,7 +12236,7 @@ Made in Italy` })));
12229
12236
  * @Author: binruan@chatlabs.com
12230
12237
  * @Date: 2024-03-20 10:27:31
12231
12238
  * @LastEditors: binruan@chatlabs.com
12232
- * @LastEditTime: 2024-04-15 18:10:26
12239
+ * @LastEditTime: 2024-04-16 20:49:51
12233
12240
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\Picture.tsx
12234
12241
  *
12235
12242
  */
@@ -12238,6 +12245,9 @@ Made in Italy` })));
12238
12245
  const [blur, setBlur] = React.useState(false);
12239
12246
  const imgDom = React.useRef(null);
12240
12247
  const { sxpParameter } = useSxpDataSource();
12248
+ const getAvifToPng = React.useCallback((src) => {
12249
+ return src.indexOf('avif') !== -1 ? `${src}?imageMogr2/format/png` : src;
12250
+ }, []);
12241
12251
  React.useEffect(() => {
12242
12252
  if (imgDom.current === null || src === '') {
12243
12253
  return;
@@ -12252,22 +12262,22 @@ Made in Italy` })));
12252
12262
  setBlur(true);
12253
12263
  }
12254
12264
  };
12255
- imgDom.current.src = src;
12256
- }, [src]);
12265
+ imgDom.current.src = getAvifToPng(src);
12266
+ }, [src, getAvifToPng]);
12257
12267
  return (React.createElement("div", { style: {
12258
12268
  overflow: 'hidden',
12259
12269
  height,
12260
12270
  width: '100%',
12261
12271
  position: 'relative'
12262
12272
  } },
12263
- 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: {
12273
+ React.createElement("img", { ref: imgDom, loading: 'lazy', src: src ? getAvifToPng(src) : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, style: {
12264
12274
  height: '100%',
12265
12275
  width: '100%',
12266
12276
  objectFit: 'cover',
12267
12277
  filter: blur ? 'blur(10px)' : 'none',
12268
12278
  transform: blur ? 'scale(1.2)' : 'none'
12269
12279
  } }),
12270
- blur && (React.createElement("img", { ref: imgDom, src: src, loading: 'lazy', style: {
12280
+ blur && (React.createElement("img", { ref: imgDom, src: getAvifToPng(src), loading: 'lazy', style: {
12271
12281
  width: '100%',
12272
12282
  objectFit: 'contain',
12273
12283
  position: 'absolute',
@@ -12282,7 +12292,7 @@ Made in Italy` })));
12282
12292
  * @Author: lewinlu@chatlabs.com
12283
12293
  * @Date: 2024-01-03 14:39:09
12284
12294
  * @LastEditors: binruan@chatlabs.com
12285
- * @LastEditTime: 2024-04-15 18:08:25
12295
+ * @LastEditTime: 2024-04-16 22:06:11
12286
12296
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\index.tsx
12287
12297
  */
12288
12298
  const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {
@@ -12489,7 +12499,7 @@ Made in Italy` })));
12489
12499
  * @Author: binruan@chatlabs.com
12490
12500
  * @Date: 2024-01-15 19:03:09
12491
12501
  * @LastEditors: binruan@chatlabs.com
12492
- * @LastEditTime: 2024-04-15 17:07:42
12502
+ * @LastEditTime: 2024-04-16 19:50:16
12493
12503
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
12494
12504
  *
12495
12505
  */
@@ -12503,10 +12513,11 @@ Made in Italy` })));
12503
12513
  const curTime = React.useRef();
12504
12514
  const viewTime = React.useRef();
12505
12515
  const [isLoadMore, setIsLoadMore] = React.useState(false);
12516
+ const [isShowMore, setIsShowMore] = React.useState(false);
12506
12517
  const { loadVideos, bffEventReport, loading, setPopupDetailData, ctaEvent, swiperRef, waterFallData, setOpenHashtag, appDomain, openHashtag, loadingImage, isFromHashtag, popupDetailData } = useSxpDataSource();
12507
12518
  const { productView } = useEventReport();
12508
12519
  const isShowFingerTip = React.useMemo(() => {
12509
- return data.length > 0 && !loading;
12520
+ return data.length > 0 && !loading && getFeUserId();
12510
12521
  }, [data, loading]);
12511
12522
  const handleH5EnterLink = React.useCallback(() => {
12512
12523
  if (data.length <= 0) {
@@ -12665,20 +12676,47 @@ Made in Italy` })));
12665
12676
  }
12666
12677
  return null;
12667
12678
  }, [containerWidth, data, height, isMuted, activeIndex, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost, viewTime, tipText, resolver, schema]);
12679
+ const onExpandableChange = React.useCallback((v) => {
12680
+ setIsShowMore(v);
12681
+ }, []);
12682
+ const lineGradStyle = React.useMemo(() => {
12683
+ return !isShowMore
12684
+ ? {
12685
+ padding: '20px 0'
12686
+ }
12687
+ : {
12688
+ background: 'linear-gradient( 180deg, rgba(129,129,129,0) 0%, rgba(121,121,121,0.5) 5%, #616161 100%)',
12689
+ paddingTop: 20,
12690
+ paddingBottom: 20
12691
+ };
12692
+ }, [isShowMore]);
12668
12693
  const renderBottom = React.useCallback((rec, index) => {
12669
12694
  var _a, _b, _c, _d, _e, _f, _g;
12670
12695
  if (rec.video) {
12671
12696
  return (React.createElement(React.Fragment, null,
12672
- ((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
12697
+ ((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && !isShowMore && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
12673
12698
  React.createElement("div", { className: 'clc-sxp-bottom' },
12674
12699
  React.createElement(Nudge, { nudge: nudge }),
12675
12700
  React.createElement("div", { className: 'clc-sxp-bottom-card' },
12676
12701
  React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
12677
- 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' }) }),
12678
- 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 }))));
12702
+ React.createElement("div", { style: lineGradStyle },
12703
+ 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 }),
12704
+ 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 })))));
12679
12705
  }
12680
12706
  return null;
12681
- }, [descStyle, activeIndex, tempMap, resolver, tipText, nudge, hashTagStyle, globalConfig]);
12707
+ }, [
12708
+ descStyle,
12709
+ activeIndex,
12710
+ tempMap,
12711
+ resolver,
12712
+ tipText,
12713
+ nudge,
12714
+ hashTagStyle,
12715
+ globalConfig,
12716
+ onExpandableChange,
12717
+ isShowMore,
12718
+ lineGradStyle
12719
+ ]);
12682
12720
  const renderLikeButton = React.useCallback((rec, index) => {
12683
12721
  var _a, _b;
12684
12722
  if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))