pb-sxp-ui 1.0.23 → 1.0.24

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
@@ -8248,7 +8248,7 @@ var Modal$1 = React.memo(Modal);
8248
8248
  * @Author: binruan@chatlabs.com
8249
8249
  * @Date: 2023-12-26 16:11:34
8250
8250
  * @LastEditors: binruan@chatlabs.com
8251
- * @LastEditTime: 2024-04-17 13:49:29
8251
+ * @LastEditTime: 2024-04-18 14:33:15
8252
8252
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\ExpandableText.tsx
8253
8253
  *
8254
8254
  */
@@ -8293,7 +8293,7 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
8293
8293
  }
8294
8294
  multiRowCopy.current.style.display = 'none';
8295
8295
  }, [isPost]);
8296
- return (React.createElement("div", { className: className, style: Object.assign({}, style), hidden: !text || text === '' },
8296
+ return (React.createElement("div", { className: className, style: Object.assign(Object.assign({}, style), { transform: 'translate3d(0px, 0px, 0px)' }), hidden: !text || text === '' },
8297
8297
  React.createElement("div", { ref: multiRow, style: {
8298
8298
  overflow: 'hidden',
8299
8299
  WebkitLineClamp: !isPost || isShowMore ? '' : lineClamp,
@@ -9702,7 +9702,7 @@ var Scroll$1 = React.memo(Scroll);
9702
9702
  * @Author: binruan@chatlabs.com
9703
9703
  * @Date: 2024-01-16 14:50:13
9704
9704
  * @LastEditors: binruan@chatlabs.com
9705
- * @LastEditTime: 2024-04-17 19:03:01
9705
+ * @LastEditTime: 2024-04-18 12:32:49
9706
9706
  * @FilePath: \pb-sxp-ui\src\materials\sxp\template\components\Img.tsx
9707
9707
  *
9708
9708
  */
@@ -9718,7 +9718,7 @@ const Img = ({ src, rec, item, index }) => {
9718
9718
  }, rec, item, index);
9719
9719
  }
9720
9720
  }, [isOnScreen, src, ref, rec, ctaEvent, item, index]);
9721
- return (React.createElement("div", { ref: ref, hidden: !src },
9721
+ return (React.createElement("div", { ref: ref, hidden: !src, className: css.css({ width: '100%', height: '100%' }) },
9722
9722
  React.createElement(FormatImage$1, { className: css.css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })));
9723
9723
  };
9724
9724
  var Img$1 = React.memo(Img);
@@ -11994,7 +11994,8 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
11994
11994
  const videoRef = React.useRef(null);
11995
11995
  const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
11996
11996
  const videoStartTime = React.useRef(0);
11997
- const [isLoad, setIsLoad] = React.useState(false);
11997
+ const [isLoadFinish, setIsLoadFinish] = React.useState(false);
11998
+ const [isFirstPlay, setIsFirstPlay] = React.useState(true);
11998
11999
  const { isActive } = useSwiperSlide();
11999
12000
  React.useEffect(() => {
12000
12001
  if (!videoRef.current)
@@ -12010,11 +12011,11 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
12010
12011
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
12011
12012
  setIsPauseVideo(false);
12012
12013
  const item = data[index];
12013
- if (item && isLoad && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
12014
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
12014
12015
  videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
12015
12016
  const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
12016
12017
  const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
12017
- const playType = '1';
12018
+ const playType = isFirstPlay ? '0' : '1';
12018
12019
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
12019
12020
  eventInfo: {
12020
12021
  eventSubject: 'playVideo',
@@ -12030,72 +12031,41 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
12030
12031
  traceInfo: (_o = item.video) === null || _o === void 0 ? void 0 : _o.traceInfo
12031
12032
  }
12032
12033
  });
12034
+ setIsFirstPlay(false);
12033
12035
  }
12034
- if (!isLoad) {
12035
- setIsLoad(true);
12036
- }
12037
- }, [bffEventReport, data, index, isLoad]);
12036
+ }, [bffEventReport, data, index, isFirstPlay]);
12038
12037
  const handleLoadedMetadata = React.useCallback(() => {
12039
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
12040
- const item = data[index];
12041
- if (item && !isLoad && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
12042
- videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
12043
- const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
12044
- const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
12045
- const playType = '0';
12046
- bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
12047
- eventInfo: {
12048
- eventSubject: 'playVideo',
12049
- eventDescription: 'User played the video',
12050
- contentId: (_h = (_g = item.video) === null || _g === void 0 ? void 0 : _g.itemId) !== null && _h !== void 0 ? _h : '',
12051
- contentName: (_k = (_j = item.video) === null || _j === void 0 ? void 0 : _j.title) !== null && _k !== void 0 ? _k : '',
12052
- playType,
12053
- startTime: videoCurrentTime,
12054
- videoDuration,
12055
- contentTags: JSON.stringify((_m = (_l = item.video) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : []),
12056
- position: index + '',
12057
- contentFormat: 'video',
12058
- traceInfo: (_o = item.video) === null || _o === void 0 ? void 0 : _o.traceInfo
12059
- }
12060
- });
12061
- }
12062
- setTimeout(() => {
12063
- var _a;
12064
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
12065
- }, 0);
12066
- }, [index, bffEventReport, data, isLoad]);
12038
+ setIsLoadFinish(true);
12039
+ }, []);
12067
12040
  const handleClickVideo = React.useCallback((type) => () => {
12068
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12069
- if (!isLoad)
12041
+ var _a, _b, _c, _d, _e;
12042
+ if (!isLoadFinish)
12070
12043
  return;
12071
- data[index];
12072
- ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
12073
- ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
12074
- const isPause = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.paused;
12044
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
12075
12045
  switch (type) {
12076
12046
  case 'start':
12077
12047
  if (!isPause)
12078
12048
  return;
12079
- (_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.play();
12049
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
12080
12050
  setIsPauseVideo(false);
12081
12051
  break;
12082
12052
  case 'pause':
12083
12053
  if (isPause)
12084
12054
  return;
12085
- (_g = videoRef.current) === null || _g === void 0 ? void 0 : _g.pause();
12055
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
12086
12056
  setIsPauseVideo(true);
12087
12057
  break;
12088
12058
  default:
12089
12059
  if (isPause) {
12090
- (_h = videoRef.current) === null || _h === void 0 ? void 0 : _h.play();
12060
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
12091
12061
  }
12092
12062
  else {
12093
- (_j = videoRef.current) === null || _j === void 0 ? void 0 : _j.pause();
12063
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
12094
12064
  }
12095
12065
  setIsPauseVideo(!isPause);
12096
12066
  break;
12097
12067
  }
12098
- }, [data, index, isLoad]);
12068
+ }, [isLoadFinish]);
12099
12069
  const onPause = React.useCallback(() => {
12100
12070
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
12101
12071
  const item = data[index];
@@ -12121,16 +12091,10 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
12121
12091
  }
12122
12092
  }, [data, index, bffEventReport]);
12123
12093
  React.useEffect(() => {
12124
- var _a, _b, _c;
12125
- if (data.length <= 0)
12126
- return;
12094
+ var _a, _b;
12127
12095
  if (!videoRef.current)
12128
12096
  return;
12129
12097
  setIsPauseVideo(false);
12130
- if (!isActive) {
12131
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
12132
- return;
12133
- }
12134
12098
  if (!videoRef.current.src) {
12135
12099
  const videoSrc = rec.video.url;
12136
12100
  // if (videoSrc.includes('.m3u8')) {
@@ -12150,25 +12114,33 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
12150
12114
  videoRef.current.setAttribute('x5-playsinline', 'true');
12151
12115
  videoRef.current.setAttribute('webkit-playsinline', 'true');
12152
12116
  }
12153
- else {
12154
- videoRef.current.play();
12155
- }
12156
- (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('canplay', handleLoadedMetadata);
12157
- (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('playing', handlePlaying);
12117
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', handleLoadedMetadata);
12118
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('playing', handlePlaying);
12158
12119
  return () => {
12159
12120
  var _a, _b;
12160
12121
  (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', handleLoadedMetadata);
12161
12122
  (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('playing', handlePlaying);
12162
12123
  };
12163
- }, [data, handleLoadedMetadata, handlePlaying, isActive, isLoad, rec.video]);
12124
+ }, [handleLoadedMetadata, handlePlaying, rec.video]);
12125
+ React.useEffect(() => {
12126
+ var _a;
12127
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
12128
+ return;
12129
+ if (isActive) {
12130
+ videoRef.current.play();
12131
+ }
12132
+ else {
12133
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
12134
+ }
12135
+ }, [isActive, isLoadFinish]);
12164
12136
  /*
12165
12137
  打开/关闭hashtag暂停/播放视频
12166
12138
  */
12167
12139
  React.useEffect(() => {
12168
12140
  var _a, _b, _c;
12169
- const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
12170
- if (!isActive)
12141
+ if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
12171
12142
  return;
12143
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
12172
12144
  if (!isPause && openHashtag) {
12173
12145
  (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.pause();
12174
12146
  }
@@ -12189,11 +12161,11 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
12189
12161
  };
12190
12162
  }, [handleClickVideo, isActive]);
12191
12163
  const renderPoster = React.useMemo(() => {
12192
- if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image)) {
12164
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
12193
12165
  return null;
12194
12166
  }
12195
- return (React.createElement("img", { hidden: isLoad, style: { position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', objectFit: 'cover' }, src: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image }));
12196
- }, [isLoad, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
12167
+ return (React.createElement("img", { style: { position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', objectFit: 'cover' }, src: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image }));
12168
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
12197
12169
  React.useEffect(() => {
12198
12170
  const handleBeforeUnload = () => {
12199
12171
  var _a, _b;
@@ -12454,7 +12426,7 @@ function withBindDataSource(Component) {
12454
12426
  * @Author: binruan@chatlabs.com
12455
12427
  * @Date: 2023-12-26 16:11:34
12456
12428
  * @LastEditors: binruan@chatlabs.com
12457
- * @LastEditTime: 2024-04-11 18:14:05
12429
+ * @LastEditTime: 2024-04-18 14:36:53
12458
12430
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\RenderCard.tsx
12459
12431
  *
12460
12432
  */
@@ -12488,7 +12460,7 @@ const RenderCard = ({ rec, index, tempMap, resolver }) => {
12488
12460
  const Component = withBindDataSource(t);
12489
12461
  const defaulSetting = (_x = t === null || t === void 0 ? void 0 : t.extend) === null || _x === void 0 ? void 0 : _x.defaulSetting;
12490
12462
  const isExternalLink = ((_0 = (_z = (_y = value === null || value === void 0 ? void 0 : value.item) === null || _y === void 0 ? void 0 : _y.event) === null || _z === void 0 ? void 0 : _z.onClick) === null || _0 === void 0 ? void 0 : _0.linkType) === 'externalLink';
12491
- return (React.createElement(Component, Object.assign({ style: Object.assign(Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.style), (_1 = value === null || value === void 0 ? void 0 : value.item) === null || _1 === void 0 ? void 0 : _1.style), { zIndex: 50, marginLeft: '20px', boxSizing: 'border-box' }), textStyle: Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.textStyle), (_2 = value === null || value === void 0 ? void 0 : value.item) === null || _2 === void 0 ? void 0 : _2.textStyle), bindDatas: (_4 = (_3 = value === null || value === void 0 ? void 0 : value.item) === null || _3 === void 0 ? void 0 : _3.bindDatas) !== null && _4 !== void 0 ? _4 : [] }, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.props, (_5 = value === null || value === void 0 ? void 0 : value.item) === null || _5 === void 0 ? void 0 : _5.props, { event: ((_6 = value === null || value === void 0 ? void 0 : value.item) === null || _6 === void 0 ? void 0 : _6.event) || {}, schema: schema, id: value === null || value === void 0 ? void 0 : value.id, key: value === null || value === void 0 ? void 0 : value.id, recData: rec, isExternalLink: isExternalLink, index: index })));
12463
+ return (React.createElement(Component, Object.assign({ style: Object.assign(Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.style), (_1 = value === null || value === void 0 ? void 0 : value.item) === null || _1 === void 0 ? void 0 : _1.style), { zIndex: 50, marginLeft: '20px', boxSizing: 'border-box', transform: 'translate3d(0px, 0px, 0px)' }), textStyle: Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.textStyle), (_2 = value === null || value === void 0 ? void 0 : value.item) === null || _2 === void 0 ? void 0 : _2.textStyle), bindDatas: (_4 = (_3 = value === null || value === void 0 ? void 0 : value.item) === null || _3 === void 0 ? void 0 : _3.bindDatas) !== null && _4 !== void 0 ? _4 : [] }, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.props, (_5 = value === null || value === void 0 ? void 0 : value.item) === null || _5 === void 0 ? void 0 : _5.props, { event: ((_6 = value === null || value === void 0 ? void 0 : value.item) === null || _6 === void 0 ? void 0 : _6.event) || {}, schema: schema, id: value === null || value === void 0 ? void 0 : value.id, key: value === null || value === void 0 ? void 0 : value.id, recData: rec, isExternalLink: isExternalLink, index: index })));
12492
12464
  }
12493
12465
  else {
12494
12466
  return null;
@@ -12522,7 +12494,7 @@ const Nudge = ({ nudge }) => {
12522
12494
  * @Author: binruan@chatlabs.com
12523
12495
  * @Date: 2024-01-15 19:03:09
12524
12496
  * @LastEditors: binruan@chatlabs.com
12525
- * @LastEditTime: 2024-04-18 09:43:19
12497
+ * @LastEditTime: 2024-04-18 16:49:34
12526
12498
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\index.tsx
12527
12499
  *
12528
12500
  */
@@ -12723,9 +12695,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
12723
12695
  React.createElement("div", { className: 'clc-sxp-bottom-card' },
12724
12696
  React.createElement(RenderCard$1, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
12725
12697
  React.createElement("div", null,
12726
- 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({}, descStyle
12727
- // textShadow: globalConfig?.isOpenTextShadow ? '2px 2px 4px rgba(0, 0, 0, 0.5)' : 'none'
12728
- ), onChange: onExpandableChange }),
12698
+ 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 }),
12729
12699
  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.itemId) ? 'VIDEO' : null, rec: rec, hashTagStyle: hashTagStyle })))));
12730
12700
  }
12731
12701
  return null;