pb-sxp-ui 1.0.23 → 1.0.25

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.
Files changed (35) hide show
  1. package/dist/index.cjs +104 -96
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +104 -96
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +3 -3
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +3 -3
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +104 -96
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +3 -3
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/SxpPageRender/ExpandableText.js +1 -1
  14. package/es/core/components/SxpPageRender/PictureGroup/Picture.d.ts +3 -2
  15. package/es/core/components/SxpPageRender/PictureGroup/Picture.js +13 -13
  16. package/es/core/components/SxpPageRender/PictureGroup/index.d.ts +2 -0
  17. package/es/core/components/SxpPageRender/PictureGroup/index.js +4 -3
  18. package/es/core/components/SxpPageRender/RenderCard.js +1 -1
  19. package/es/core/components/SxpPageRender/VideoWidget/index.d.ts +2 -0
  20. package/es/core/components/SxpPageRender/VideoWidget/index.js +77 -67
  21. package/es/core/components/SxpPageRender/index.d.ts +8 -1
  22. package/es/core/components/SxpPageRender/index.js +3 -3
  23. package/es/materials/sxp/template/components/Img.js +1 -1
  24. package/lib/core/components/SxpPageRender/ExpandableText.js +1 -1
  25. package/lib/core/components/SxpPageRender/PictureGroup/Picture.d.ts +3 -2
  26. package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +12 -12
  27. package/lib/core/components/SxpPageRender/PictureGroup/index.d.ts +2 -0
  28. package/lib/core/components/SxpPageRender/PictureGroup/index.js +4 -3
  29. package/lib/core/components/SxpPageRender/RenderCard.js +1 -1
  30. package/lib/core/components/SxpPageRender/VideoWidget/index.d.ts +2 -0
  31. package/lib/core/components/SxpPageRender/VideoWidget/index.js +77 -67
  32. package/lib/core/components/SxpPageRender/index.d.ts +8 -1
  33. package/lib/core/components/SxpPageRender/index.js +3 -3
  34. package/lib/materials/sxp/template/components/Img.js +1 -1
  35. package/package.json +1 -1
@@ -37,7 +37,7 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
37
37
  }
38
38
  multiRowCopy.current.style.display = 'none';
39
39
  }, [isPost]);
40
- return (React.createElement("div", { className: className, style: Object.assign({}, style), hidden: !text || text === '' },
40
+ return (React.createElement("div", { className: className, style: Object.assign(Object.assign({}, style), { transform: 'translate3d(0px, 0px, 0px)' }), hidden: !text || text === '' },
41
41
  React.createElement("div", { ref: multiRow, style: {
42
42
  overflow: 'hidden',
43
43
  WebkitLineClamp: !isPost || isShowMore ? '' : lineClamp,
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
+ import { postConfigType } from '..';
2
3
  interface IPictureProps {
3
4
  src: string;
4
- height: number;
5
- width: number;
5
+ height?: number;
6
+ imgUrlsPostConfig?: postConfigType;
6
7
  }
7
8
  declare const Picture: (props: IPictureProps) => React.JSX.Element;
8
9
  export default Picture;
@@ -1,16 +1,16 @@
1
- import React, { useState } from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import FormatImage from '../FormatImage';
3
3
  const Picture = (props) => {
4
- const { src, height, width } = props;
5
- const [blur, setBlur] = useState(false);
6
- const onLoad = (img) => {
7
- const aspectRatio = img.naturalHeight / img.naturalWidth;
8
- const targetAspectRatio = 16 / 9;
9
- const tolerance = 0.05;
10
- if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
11
- setBlur(true);
12
- }
13
- };
4
+ const { src, height, imgUrlsPostConfig } = props;
5
+ const blur = useMemo(() => {
6
+ return (imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.mode) === '2';
7
+ }, [imgUrlsPostConfig]);
8
+ const translateY = useMemo(() => {
9
+ var _a;
10
+ return (imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.mode) === '2'
11
+ ? `translateY(-${50 + ((_a = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%)`
12
+ : 'translateY(-50%)';
13
+ }, [imgUrlsPostConfig]);
14
14
  return (React.createElement("div", { style: {
15
15
  overflow: 'hidden',
16
16
  height,
@@ -23,13 +23,13 @@ const Picture = (props) => {
23
23
  objectFit: 'cover',
24
24
  filter: blur ? 'blur(10px)' : 'none',
25
25
  transform: blur ? 'scale(1.2)' : 'none'
26
- }, onLoad: onLoad }),
26
+ } }),
27
27
  blur && (React.createElement(FormatImage, { src: src, style: {
28
28
  width: '100%',
29
29
  objectFit: 'contain',
30
30
  position: 'absolute',
31
31
  top: '50%',
32
- transform: 'translateY(-50%)',
32
+ transform: translateY,
33
33
  left: 0,
34
34
  right: 0
35
35
  } }))));
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { RecItemType } from '../typing';
3
+ import { postConfigType } from '..';
3
4
  interface IPictureGroupProps {
4
5
  imgUrls?: string[];
5
6
  width: number;
@@ -8,6 +9,7 @@ interface IPictureGroupProps {
8
9
  index: number;
9
10
  onReportViewImageEnd: (rec: RecItemType) => void;
10
11
  onViewImageStartEvent: (index: number) => void;
12
+ imgUrlsPostConfig?: postConfigType;
11
13
  }
12
14
  declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
13
15
  export default _default;
@@ -3,7 +3,8 @@ import { Autoplay, Pagination } from 'swiper/modules';
3
3
  import { Swiper, SwiperSlide, useSwiperSlide } from 'swiper/react';
4
4
  import Picture from './Picture';
5
5
  import { useSxpDataSource } from '../../../../core/hooks';
6
- const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {
6
+ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent, imgUrlsPostConfig }) => {
7
+ var _a;
7
8
  const ref = useRef();
8
9
  const { isActive } = useSwiperSlide();
9
10
  const { sxpParameter, openHashtag } = useSxpDataSource();
@@ -23,9 +24,9 @@ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd
23
24
  (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.stop();
24
25
  }
25
26
  }, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad]);
26
- return (React.createElement(Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: { clickable: true, bulletActiveClass: 'swipe-item-active-bullet' }, height: height, loop: true, autoplay: { delay: 3000 } }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
27
+ return (React.createElement(Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: { clickable: true, bulletActiveClass: 'swipe-item-active-bullet' }, height: height, loop: true, autoplay: { delay: ((_a = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.delay) !== null && _a !== void 0 ? _a : 3) * 1000 } }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
27
28
  return (React.createElement(SwiperSlide, { key: url },
28
- React.createElement(Picture, { src: url, width: width, height: height })));
29
+ React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
29
30
  })));
30
31
  };
31
32
  export default memo(PictureGroup);
@@ -32,7 +32,7 @@ const RenderCard = ({ rec, index, tempMap, resolver }) => {
32
32
  const Component = withBindDataSource(t);
33
33
  const defaulSetting = (_x = t === null || t === void 0 ? void 0 : t.extend) === null || _x === void 0 ? void 0 : _x.defaulSetting;
34
34
  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';
35
- 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 })));
35
+ 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 })));
36
36
  }
37
37
  else {
38
38
  return null;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { RecItemType } from '../typing';
3
+ import { postConfigType } from '..';
3
4
  interface IVideoWidgetProps {
4
5
  rec: RecItemType;
5
6
  index: number;
@@ -7,6 +8,7 @@ interface IVideoWidgetProps {
7
8
  data: RecItemType[];
8
9
  muted: boolean;
9
10
  activeIndex?: number;
11
+ videoPostConfig?: postConfigType;
10
12
  }
11
13
  declare const _default: React.NamedExoticComponent<IVideoWidgetProps>;
12
14
  export default _default;
@@ -1,14 +1,16 @@
1
1
  import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { useSwiperSlide } from 'swiper/react';
3
3
  import { useIconLink } from '../useIconLink';
4
+ import FormatImage from '../FormatImage';
4
5
  import { useSxpDataSource } from '../../../../core/hooks';
5
6
  import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
6
- const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
7
+ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig }) => {
7
8
  const [isPauseVideo, setIsPauseVideo] = useState(false);
8
9
  const videoRef = useRef(null);
9
10
  const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
10
11
  const videoStartTime = useRef(0);
11
- const [isLoad, setIsLoad] = useState(false);
12
+ const [isLoadFinish, setIsLoadFinish] = useState(false);
13
+ const [isFirstPlay, setIsFirstPlay] = useState(true);
12
14
  const { isActive } = useSwiperSlide();
13
15
  useEffect(() => {
14
16
  if (!videoRef.current)
@@ -24,11 +26,11 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
24
26
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
25
27
  setIsPauseVideo(false);
26
28
  const item = data[index];
27
- if (item && isLoad && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
29
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
28
30
  videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
29
31
  const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
30
32
  const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
31
- const playType = '1';
33
+ const playType = isFirstPlay ? '0' : '1';
32
34
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
33
35
  eventInfo: {
34
36
  eventSubject: 'playVideo',
@@ -44,72 +46,41 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
44
46
  traceInfo: (_o = item.video) === null || _o === void 0 ? void 0 : _o.traceInfo
45
47
  }
46
48
  });
49
+ setIsFirstPlay(false);
47
50
  }
48
- if (!isLoad) {
49
- setIsLoad(true);
50
- }
51
- }, [bffEventReport, data, index, isLoad]);
51
+ }, [bffEventReport, data, index, isFirstPlay]);
52
52
  const handleLoadedMetadata = useCallback(() => {
53
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
54
- const item = data[index];
55
- if (item && !isLoad && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
56
- videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
57
- const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
58
- const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
59
- const playType = '0';
60
- bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
61
- eventInfo: {
62
- eventSubject: 'playVideo',
63
- eventDescription: 'User played the video',
64
- contentId: (_h = (_g = item.video) === null || _g === void 0 ? void 0 : _g.itemId) !== null && _h !== void 0 ? _h : '',
65
- contentName: (_k = (_j = item.video) === null || _j === void 0 ? void 0 : _j.title) !== null && _k !== void 0 ? _k : '',
66
- playType,
67
- startTime: videoCurrentTime,
68
- videoDuration,
69
- contentTags: JSON.stringify((_m = (_l = item.video) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : []),
70
- position: index + '',
71
- contentFormat: 'video',
72
- traceInfo: (_o = item.video) === null || _o === void 0 ? void 0 : _o.traceInfo
73
- }
74
- });
75
- }
76
- setTimeout(() => {
77
- var _a;
78
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
79
- }, 0);
80
- }, [index, bffEventReport, data, isLoad]);
53
+ setIsLoadFinish(true);
54
+ }, []);
81
55
  const handleClickVideo = useCallback((type) => () => {
82
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
83
- if (!isLoad)
56
+ var _a, _b, _c, _d, _e;
57
+ if (!isLoadFinish)
84
58
  return;
85
- const item = data[index];
86
- const videoDuration = ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
87
- const videoCurrentTime = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
88
- const isPause = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.paused;
59
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
89
60
  switch (type) {
90
61
  case 'start':
91
62
  if (!isPause)
92
63
  return;
93
- (_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.play();
64
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
94
65
  setIsPauseVideo(false);
95
66
  break;
96
67
  case 'pause':
97
68
  if (isPause)
98
69
  return;
99
- (_g = videoRef.current) === null || _g === void 0 ? void 0 : _g.pause();
70
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
100
71
  setIsPauseVideo(true);
101
72
  break;
102
73
  default:
103
74
  if (isPause) {
104
- (_h = videoRef.current) === null || _h === void 0 ? void 0 : _h.play();
75
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
105
76
  }
106
77
  else {
107
- (_j = videoRef.current) === null || _j === void 0 ? void 0 : _j.pause();
78
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
108
79
  }
109
80
  setIsPauseVideo(!isPause);
110
81
  break;
111
82
  }
112
- }, [data, index, isLoad]);
83
+ }, [isLoadFinish]);
113
84
  const onPause = useCallback(() => {
114
85
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
115
86
  const item = data[index];
@@ -135,38 +106,40 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
135
106
  }
136
107
  }, [data, index, bffEventReport]);
137
108
  useEffect(() => {
138
- var _a, _b, _c;
139
- if (data.length <= 0)
140
- return;
109
+ var _a, _b;
141
110
  if (!videoRef.current)
142
111
  return;
143
112
  setIsPauseVideo(false);
144
- if (!isActive) {
145
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
146
- return;
147
- }
148
113
  if (!videoRef.current.src) {
149
114
  const videoSrc = rec.video.url;
150
115
  videoRef.current.src = videoSrc;
151
116
  videoRef.current.setAttribute('x5-playsinline', 'true');
152
117
  videoRef.current.setAttribute('webkit-playsinline', 'true');
153
118
  }
154
- else {
155
- videoRef.current.play();
156
- }
157
- (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('canplay', handleLoadedMetadata);
158
- (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('playing', handlePlaying);
119
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', handleLoadedMetadata);
120
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('playing', handlePlaying);
159
121
  return () => {
160
122
  var _a, _b;
161
123
  (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', handleLoadedMetadata);
162
124
  (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('playing', handlePlaying);
163
125
  };
164
- }, [data, handleLoadedMetadata, handlePlaying, isActive, isLoad, rec.video]);
126
+ }, [handleLoadedMetadata, handlePlaying, rec.video]);
127
+ useEffect(() => {
128
+ var _a;
129
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
130
+ return;
131
+ if (isActive) {
132
+ videoRef.current.play();
133
+ }
134
+ else {
135
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.pause();
136
+ }
137
+ }, [isActive, isLoadFinish]);
165
138
  useEffect(() => {
166
139
  var _a, _b, _c;
167
- const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
168
- if (!isActive)
140
+ if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
169
141
  return;
142
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
170
143
  if (!isPause && openHashtag) {
171
144
  (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.pause();
172
145
  }
@@ -187,11 +160,11 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
187
160
  };
188
161
  }, [handleClickVideo, isActive]);
189
162
  const renderPoster = useMemo(() => {
190
- if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image)) {
163
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
191
164
  return null;
192
165
  }
193
- 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 }));
194
- }, [isLoad, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
166
+ 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 }));
167
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
195
168
  useEffect(() => {
196
169
  const handleBeforeUnload = () => {
197
170
  var _a, _b;
@@ -204,16 +177,53 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex }) => {
204
177
  window.removeEventListener('beforeunload', handleBeforeUnload);
205
178
  };
206
179
  }, [activeIndex, index, rec, videoRef, handleClickVideo, isPauseVideo]);
180
+ const blur = useMemo(() => {
181
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
182
+ }, [videoPostConfig]);
183
+ const translateY = useMemo(() => {
184
+ var _a;
185
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
186
+ ? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%)`
187
+ : 'translateY(-50%)';
188
+ }, [videoPostConfig]);
207
189
  if (!rec.video) {
208
190
  return null;
209
191
  }
210
- return (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
192
+ return (React.createElement(React.Fragment, null, blur ? (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
193
+ position: 'relative',
194
+ width: '100%',
195
+ height
196
+ } },
197
+ React.createElement(FormatImage, { src: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, style: {
198
+ height: '100%',
199
+ width: '100%',
200
+ objectFit: 'cover',
201
+ filter: blur ? 'blur(10px)' : 'none',
202
+ transform: blur ? 'scale(1.2)' : 'none'
203
+ } }),
204
+ React.createElement("div", { style: {
205
+ position: 'absolute',
206
+ width: '100%',
207
+ height: 'auto',
208
+ top: '50%',
209
+ transform: translateY,
210
+ left: 0,
211
+ right: 0
212
+ } },
213
+ React.createElement("div", { style: { position: 'relative' } },
214
+ React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart, style: {
215
+ width: '100%',
216
+ height: 'auto',
217
+ objectFit: 'contain'
218
+ } }),
219
+ renderPoster,
220
+ React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON }))))) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
211
221
  position: 'relative',
212
222
  width: '100%',
213
223
  height
214
224
  } },
215
225
  React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart }),
216
226
  renderPoster,
217
- React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })));
227
+ React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })))));
218
228
  };
219
229
  export default memo(VideoWidget);
@@ -1,7 +1,12 @@
1
1
  import { CSSProperties, FC } from 'react';
2
2
  import { RecItemType } from './typing';
3
3
  import './index.less';
4
- interface ISxpPageRenderProps {
4
+ export type postConfigType = {
5
+ mode?: '1' | '2';
6
+ offsetTop?: number;
7
+ delay?: number;
8
+ };
9
+ export interface ISxpPageRenderProps {
5
10
  globalConfig?: {
6
11
  isShowLogo?: boolean;
7
12
  logoUrl?: string;
@@ -19,6 +24,8 @@ interface ISxpPageRenderProps {
19
24
  swipeTipIcon?: string;
20
25
  hashTag?: any[];
21
26
  isOpenTextShadow?: boolean;
27
+ videoPost?: postConfigType;
28
+ imgUrlsPost?: postConfigType;
22
29
  };
23
30
  descStyle?: CSSProperties;
24
31
  tipText?: {
@@ -153,10 +153,10 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
153
153
  const renderContent = useCallback((rec, index) => {
154
154
  var _a, _b, _c, _d;
155
155
  if ((_a = rec.video) === null || _a === void 0 ? void 0 : _a.url) {
156
- return (React.createElement(VideoWidget, { rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex }));
156
+ return (React.createElement(VideoWidget, { rec: rec, index: index, muted: isMuted, data: data, height: height, activeIndex: activeIndex, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost }));
157
157
  }
158
158
  if ((_b = rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
159
- return (React.createElement(PictureGroup, { key: rec.video.itemId, imgUrls: rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onReportViewImageEnd: handleReportViewImageEnd, onViewImageStartEvent: handleViewImageStartEvent }));
159
+ return (React.createElement(PictureGroup, { key: rec.video.itemId, imgUrls: rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, onReportViewImageEnd: handleReportViewImageEnd, onViewImageStartEvent: handleViewImageStartEvent, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
160
160
  }
161
161
  if (rec.product && Array.isArray(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) && ((_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _c === void 0 ? void 0 : _c.length) > 0) {
162
162
  return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
@@ -193,7 +193,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
193
193
  React.createElement("div", { className: 'clc-sxp-bottom-card' },
194
194
  React.createElement(RenderCard, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
195
195
  React.createElement("div", null,
196
- React.createElement(ExpandableText, { 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), onChange: onExpandableChange }),
196
+ React.createElement(ExpandableText, { 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 }),
197
197
  React.createElement(Hashtag, { 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 })))));
198
198
  }
199
199
  return null;
@@ -15,7 +15,7 @@ const Img = ({ src, rec, item, index }) => {
15
15
  }, rec, item, index);
16
16
  }
17
17
  }, [isOnScreen, src, ref, rec, ctaEvent, item, index]);
18
- return (React.createElement("div", { ref: ref, hidden: !src },
18
+ return (React.createElement("div", { ref: ref, hidden: !src, className: css({ width: '100%', height: '100%' }) },
19
19
  React.createElement(FormatImage, { className: css({ width: '100%', objectFit: 'cover', height: '100%', display: 'block' }), src: src })));
20
20
  };
21
21
  export default memo(Img);
@@ -40,7 +40,7 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
40
40
  }
41
41
  multiRowCopy.current.style.display = 'none';
42
42
  }, [isPost]);
43
- return (react_1.default.createElement("div", { className: className, style: Object.assign({}, style), hidden: !text || text === '' },
43
+ return (react_1.default.createElement("div", { className: className, style: Object.assign(Object.assign({}, style), { transform: 'translate3d(0px, 0px, 0px)' }), hidden: !text || text === '' },
44
44
  react_1.default.createElement("div", { ref: multiRow, style: {
45
45
  overflow: 'hidden',
46
46
  WebkitLineClamp: !isPost || isShowMore ? '' : lineClamp,
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
+ import { postConfigType } from '..';
2
3
  interface IPictureProps {
3
4
  src: string;
4
- height: number;
5
- width: number;
5
+ height?: number;
6
+ imgUrlsPostConfig?: postConfigType;
6
7
  }
7
8
  declare const Picture: (props: IPictureProps) => React.JSX.Element;
8
9
  export default Picture;
@@ -4,16 +4,16 @@ const tslib_1 = require("tslib");
4
4
  const react_1 = tslib_1.__importStar(require("react"));
5
5
  const FormatImage_1 = tslib_1.__importDefault(require("../FormatImage"));
6
6
  const Picture = (props) => {
7
- const { src, height, width } = props;
8
- const [blur, setBlur] = (0, react_1.useState)(false);
9
- const onLoad = (img) => {
10
- const aspectRatio = img.naturalHeight / img.naturalWidth;
11
- const targetAspectRatio = 16 / 9;
12
- const tolerance = 0.05;
13
- if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
14
- setBlur(true);
15
- }
16
- };
7
+ const { src, height, imgUrlsPostConfig } = props;
8
+ const blur = (0, react_1.useMemo)(() => {
9
+ return (imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.mode) === '2';
10
+ }, [imgUrlsPostConfig]);
11
+ const translateY = (0, react_1.useMemo)(() => {
12
+ var _a;
13
+ return (imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.mode) === '2'
14
+ ? `translateY(-${50 + ((_a = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%)`
15
+ : 'translateY(-50%)';
16
+ }, [imgUrlsPostConfig]);
17
17
  return (react_1.default.createElement("div", { style: {
18
18
  overflow: 'hidden',
19
19
  height,
@@ -26,13 +26,13 @@ const Picture = (props) => {
26
26
  objectFit: 'cover',
27
27
  filter: blur ? 'blur(10px)' : 'none',
28
28
  transform: blur ? 'scale(1.2)' : 'none'
29
- }, onLoad: onLoad }),
29
+ } }),
30
30
  blur && (react_1.default.createElement(FormatImage_1.default, { src: src, style: {
31
31
  width: '100%',
32
32
  objectFit: 'contain',
33
33
  position: 'absolute',
34
34
  top: '50%',
35
- transform: 'translateY(-50%)',
35
+ transform: translateY,
36
36
  left: 0,
37
37
  right: 0
38
38
  } }))));
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { RecItemType } from '../typing';
3
+ import { postConfigType } from '..';
3
4
  interface IPictureGroupProps {
4
5
  imgUrls?: string[];
5
6
  width: number;
@@ -8,6 +9,7 @@ interface IPictureGroupProps {
8
9
  index: number;
9
10
  onReportViewImageEnd: (rec: RecItemType) => void;
10
11
  onViewImageStartEvent: (index: number) => void;
12
+ imgUrlsPostConfig?: postConfigType;
11
13
  }
12
14
  declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
13
15
  export default _default;
@@ -6,7 +6,8 @@ const modules_1 = require("swiper/modules");
6
6
  const react_2 = require("swiper/react");
7
7
  const Picture_1 = tslib_1.__importDefault(require("./Picture"));
8
8
  const hooks_1 = require("../../../../core/hooks");
9
- const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {
9
+ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent, imgUrlsPostConfig }) => {
10
+ var _a;
10
11
  const ref = (0, react_1.useRef)();
11
12
  const { isActive } = (0, react_2.useSwiperSlide)();
12
13
  const { sxpParameter, openHashtag } = (0, hooks_1.useSxpDataSource)();
@@ -26,9 +27,9 @@ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd
26
27
  (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.stop();
27
28
  }
28
29
  }, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad]);
29
- return (react_1.default.createElement(react_2.Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [modules_1.Pagination, modules_1.Autoplay], pagination: { clickable: true, bulletActiveClass: 'swipe-item-active-bullet' }, height: height, loop: true, autoplay: { delay: 3000 } }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
30
+ return (react_1.default.createElement(react_2.Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [modules_1.Pagination, modules_1.Autoplay], pagination: { clickable: true, bulletActiveClass: 'swipe-item-active-bullet' }, height: height, loop: true, autoplay: { delay: ((_a = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.delay) !== null && _a !== void 0 ? _a : 3) * 1000 } }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
30
31
  return (react_1.default.createElement(react_2.SwiperSlide, { key: url },
31
- react_1.default.createElement(Picture_1.default, { src: url, width: width, height: height })));
32
+ react_1.default.createElement(Picture_1.default, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
32
33
  })));
33
34
  };
34
35
  exports.default = (0, react_1.memo)(PictureGroup);
@@ -35,7 +35,7 @@ const RenderCard = ({ rec, index, tempMap, resolver }) => {
35
35
  const Component = (0, withBindDataSource_1.default)(t);
36
36
  const defaulSetting = (_x = t === null || t === void 0 ? void 0 : t.extend) === null || _x === void 0 ? void 0 : _x.defaulSetting;
37
37
  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';
38
- return (react_1.default.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 })));
38
+ return (react_1.default.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 })));
39
39
  }
40
40
  else {
41
41
  return null;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { RecItemType } from '../typing';
3
+ import { postConfigType } from '..';
3
4
  interface IVideoWidgetProps {
4
5
  rec: RecItemType;
5
6
  index: number;
@@ -7,6 +8,7 @@ interface IVideoWidgetProps {
7
8
  data: RecItemType[];
8
9
  muted: boolean;
9
10
  activeIndex?: number;
11
+ videoPostConfig?: postConfigType;
10
12
  }
11
13
  declare const _default: React.NamedExoticComponent<IVideoWidgetProps>;
12
14
  export default _default;