pb-sxp-ui 1.0.40 → 1.0.42

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 (60) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +111 -111
  3. package/dist/index.cjs +560 -156
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.css +56 -4
  6. package/dist/index.js +559 -156
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.min.cjs +3 -3
  9. package/dist/index.min.cjs.map +1 -1
  10. package/dist/index.min.js +3 -3
  11. package/dist/index.min.js.map +1 -1
  12. package/dist/pb-ui.js +563 -160
  13. package/dist/pb-ui.js.map +1 -1
  14. package/dist/pb-ui.min.js +3 -3
  15. package/dist/pb-ui.min.js.map +1 -1
  16. package/es/core/components/DiyPortalPreview/PictureGroup.d.ts +13 -0
  17. package/es/core/components/DiyPortalPreview/PictureGroup.js +11 -0
  18. package/es/core/components/DiyPortalPreview/VideoWidget.d.ts +15 -0
  19. package/es/core/components/DiyPortalPreview/VideoWidget.js +236 -0
  20. package/es/core/components/DiyPortalPreview/index.d.ts +6 -0
  21. package/es/core/components/DiyPortalPreview/index.js +127 -0
  22. package/es/core/components/SxpPageCore/index.js +2 -2
  23. package/es/core/components/SxpPageRender/Nudge/index.js +6 -5
  24. package/es/core/components/SxpPageRender/PictureGroup/Picture.js +1 -0
  25. package/es/core/components/SxpPageRender/Tagbar.d.ts +7 -0
  26. package/es/core/components/SxpPageRender/Tagbar.js +37 -0
  27. package/es/core/components/SxpPageRender/VideoWidget/index.js +46 -79
  28. package/es/core/components/SxpPageRender/WaterFall/index.js +1 -1
  29. package/es/core/components/SxpPageRender/index.d.ts +2 -0
  30. package/es/core/components/SxpPageRender/index.js +22 -18
  31. package/es/core/context/SxpDataSourceProvider.d.ts +3 -0
  32. package/es/core/context/SxpDataSourceProvider.js +29 -5
  33. package/es/core/hooks/useEventReport.js +4 -4
  34. package/es/index.d.ts +1 -0
  35. package/es/index.js +1 -0
  36. package/es/materials/sxp/popup/CommodityDetail/index.js +10 -10
  37. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +10 -10
  38. package/lib/core/components/DiyPortalPreview/PictureGroup.d.ts +13 -0
  39. package/lib/core/components/DiyPortalPreview/PictureGroup.js +14 -0
  40. package/lib/core/components/DiyPortalPreview/VideoWidget.d.ts +15 -0
  41. package/lib/core/components/DiyPortalPreview/VideoWidget.js +239 -0
  42. package/lib/core/components/DiyPortalPreview/index.d.ts +6 -0
  43. package/lib/core/components/DiyPortalPreview/index.js +130 -0
  44. package/lib/core/components/SxpPageCore/index.js +2 -2
  45. package/lib/core/components/SxpPageRender/Nudge/index.js +6 -5
  46. package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +1 -0
  47. package/lib/core/components/SxpPageRender/Tagbar.d.ts +7 -0
  48. package/lib/core/components/SxpPageRender/Tagbar.js +40 -0
  49. package/lib/core/components/SxpPageRender/VideoWidget/index.js +46 -79
  50. package/lib/core/components/SxpPageRender/WaterFall/index.js +1 -1
  51. package/lib/core/components/SxpPageRender/index.d.ts +2 -0
  52. package/lib/core/components/SxpPageRender/index.js +22 -18
  53. package/lib/core/context/SxpDataSourceProvider.d.ts +3 -0
  54. package/lib/core/context/SxpDataSourceProvider.js +29 -5
  55. package/lib/core/hooks/useEventReport.js +4 -4
  56. package/lib/index.d.ts +1 -0
  57. package/lib/index.js +3 -1
  58. package/lib/materials/sxp/popup/CommodityDetail/index.js +10 -10
  59. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +10 -10
  60. package/package.json +115 -114
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { RecItemType } from '../SxpPageRender/typing';
3
+ import { postConfigType } from '../SxpPageRender';
4
+ interface IPictureGroupProps {
5
+ imgUrls?: string[];
6
+ width: number;
7
+ height: number;
8
+ rec: RecItemType;
9
+ index: number;
10
+ imgUrlsPostConfig?: postConfigType;
11
+ }
12
+ declare const _default: React.NamedExoticComponent<IPictureGroupProps>;
13
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import React, { memo } from 'react';
2
+ import { Autoplay, Pagination } from 'swiper/modules';
3
+ import { Swiper, SwiperSlide } from 'swiper/react';
4
+ import Picture from '../SxpPageRender/PictureGroup/Picture';
5
+ const PictureGroup = ({ imgUrls, width, height, imgUrlsPostConfig, rec, index }) => {
6
+ return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: { clickable: true, bulletActiveClass: 'swipe-item-active-bullet' }, height: height, style: { width }, loop: true, autoplay: false }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
7
+ return (React.createElement(SwiperSlide, { key: url },
8
+ React.createElement(Picture, { src: url, height: height, imgUrlsPostConfig: imgUrlsPostConfig })));
9
+ })));
10
+ };
11
+ export default memo(PictureGroup);
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { RecItemType } from '../SxpPageRender/typing';
3
+ import { postConfigType } from '../SxpPageRender';
4
+ interface IVideoWidgetProps {
5
+ rec: RecItemType;
6
+ index: number;
7
+ height: number;
8
+ width: number;
9
+ data: RecItemType[];
10
+ muted: boolean;
11
+ activeIndex?: number;
12
+ videoPostConfig?: postConfigType;
13
+ }
14
+ declare const _default: React.NamedExoticComponent<IVideoWidgetProps>;
15
+ export default _default;
@@ -0,0 +1,236 @@
1
+ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import Hls from 'hls.js';
3
+ import { useIconLink } from '../SxpPageRender/useIconLink';
4
+ import FormatImage from '../SxpPageRender/FormatImage';
5
+ import { useSxpDataSource } from '../../../core/hooks';
6
+ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width }) => {
7
+ const [isPauseVideo, setIsPauseVideo] = useState(false);
8
+ const videoRef = useRef(null);
9
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag } = useSxpDataSource();
10
+ const videoStartTime = useRef(0);
11
+ const [isLoadFinish, setIsLoadFinish] = useState(false);
12
+ const [isFirstPlay, setIsFirstPlay] = useState(true);
13
+ const canvasRef = useRef(null);
14
+ const [firstFrameSrc, setFirstFrameSrc] = useState('');
15
+ useEffect(() => {
16
+ if (!videoRef.current)
17
+ return;
18
+ videoRef.current.muted = muted;
19
+ }, [muted]);
20
+ const handleVideoStart = useCallback(() => {
21
+ var _a;
22
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
23
+ }, []);
24
+ const PAUSE_ICON = useIconLink('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
25
+ const handlePlaying = useCallback(() => {
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
27
+ setIsPauseVideo(false);
28
+ const item = data[index];
29
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
30
+ videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
31
+ const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
32
+ const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
33
+ const playType = isFirstPlay ? '0' : '1';
34
+ bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
35
+ eventInfo: {
36
+ eventSubject: 'playVideo',
37
+ eventDescription: 'User played the video',
38
+ contentId: (_h = (_g = item.video) === null || _g === void 0 ? void 0 : _g.itemId) !== null && _h !== void 0 ? _h : '',
39
+ contentName: (_k = (_j = item.video) === null || _j === void 0 ? void 0 : _j.title) !== null && _k !== void 0 ? _k : '',
40
+ playType,
41
+ startTime: videoCurrentTime,
42
+ videoDuration,
43
+ contentTags: JSON.stringify((_m = (_l = item.video) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : []),
44
+ position: index + '',
45
+ contentFormat: 'video',
46
+ traceInfo: (_o = item.video) === null || _o === void 0 ? void 0 : _o.traceInfo
47
+ }
48
+ });
49
+ setIsFirstPlay(false);
50
+ }
51
+ }, [bffEventReport, data, index, isFirstPlay]);
52
+ const handleLoadedMetadata = useCallback(() => {
53
+ setIsLoadFinish(true);
54
+ }, []);
55
+ const handleClickVideo = useCallback((type) => () => {
56
+ var _a, _b, _c, _d, _e;
57
+ if (!isLoadFinish)
58
+ return;
59
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
60
+ switch (type) {
61
+ case 'start':
62
+ if (!isPause)
63
+ return;
64
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
65
+ setIsPauseVideo(false);
66
+ break;
67
+ case 'pause':
68
+ if (isPause)
69
+ return;
70
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
71
+ setIsPauseVideo(true);
72
+ break;
73
+ default:
74
+ if (isPause) {
75
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
76
+ }
77
+ else {
78
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
79
+ }
80
+ setIsPauseVideo(!isPause);
81
+ break;
82
+ }
83
+ }, [isLoadFinish]);
84
+ const onPause = useCallback(() => {
85
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
86
+ const item = data[index];
87
+ const videoDuration = ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
88
+ const videoCurrentTime = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
89
+ if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
90
+ const playDuration = (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
91
+ bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
92
+ eventInfo: {
93
+ eventSubject: 'playOverVideo',
94
+ eventDescription: 'User finished playing the video',
95
+ contentId: (_h = (_g = item.video) === null || _g === void 0 ? void 0 : _g.itemId) !== null && _h !== void 0 ? _h : '',
96
+ contentName: (_k = (_j = item.video) === null || _j === void 0 ? void 0 : _j.title) !== null && _k !== void 0 ? _k : '',
97
+ endTime: videoCurrentTime,
98
+ videoDuration,
99
+ playDuration,
100
+ contentTags: JSON.stringify((_m = (_l = item.video) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : []),
101
+ position: index + '',
102
+ contentFormat: 'video',
103
+ traceInfo: (_o = item.video) === null || _o === void 0 ? void 0 : _o.traceInfo
104
+ }
105
+ });
106
+ }
107
+ }, [data, index, bffEventReport]);
108
+ const blur = useMemo(() => {
109
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
110
+ }, [videoPostConfig]);
111
+ const translateY = useMemo(() => {
112
+ var _a;
113
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
114
+ ? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
115
+ : 'translateY(-50%)';
116
+ }, [videoPostConfig]);
117
+ const blurBgSrc = useMemo(() => {
118
+ var _a;
119
+ return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
120
+ }, [firstFrameSrc, rec]);
121
+ const handLoadeddata = useCallback(() => {
122
+ if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
123
+ return;
124
+ const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
125
+ const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
126
+ const ctx = canvas.getContext('2d');
127
+ const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
128
+ const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
129
+ canvas.height = targetHeight;
130
+ canvas.width = targetWidth;
131
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
132
+ setFirstFrameSrc(canvas.toDataURL());
133
+ }, []);
134
+ useEffect(() => {
135
+ var _a, _b, _c, _d;
136
+ if (!videoRef.current)
137
+ return;
138
+ setIsPauseVideo(false);
139
+ if (!videoRef.current.src) {
140
+ const videoSrc = rec.video.url;
141
+ if (videoSrc.includes('.m3u8')) {
142
+ if (Hls.isSupported()) {
143
+ const hls = new Hls();
144
+ hls.loadSource(videoSrc);
145
+ hls.attachMedia(videoRef.current);
146
+ }
147
+ else if (videoRef.current.canPlayType('application/vnd.apple.mpegurl')) {
148
+ videoRef.current.src = videoSrc;
149
+ }
150
+ else {
151
+ videoRef.current.src = videoSrc;
152
+ }
153
+ }
154
+ else {
155
+ videoRef.current.src = videoSrc;
156
+ }
157
+ videoRef.current.setAttribute('x5-playsinline', 'true');
158
+ videoRef.current.setAttribute('webkit-playsinline', 'true');
159
+ }
160
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
161
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('canplay', handleLoadedMetadata);
162
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('playing', handlePlaying);
163
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('loadeddata', handLoadeddata);
164
+ return () => {
165
+ var _a, _b, _c, _d;
166
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('loadedmetadata', handleLoadedMetadata);
167
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('canplay', handleLoadedMetadata);
168
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('playing', handlePlaying);
169
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('loadeddata', handLoadeddata);
170
+ };
171
+ }, [handleLoadedMetadata, handlePlaying, rec.video, handLoadeddata]);
172
+ const renderPoster = useMemo(() => {
173
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
174
+ return null;
175
+ }
176
+ 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 }));
177
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
178
+ useEffect(() => {
179
+ const handleBeforeUnload = () => {
180
+ var _a, _b;
181
+ if (activeIndex === index && ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) && ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.src) && !isPauseVideo) {
182
+ handleClickVideo('pause')();
183
+ }
184
+ };
185
+ window.addEventListener('beforeunload', handleBeforeUnload);
186
+ return () => {
187
+ window.removeEventListener('beforeunload', handleBeforeUnload);
188
+ };
189
+ }, [activeIndex, index, rec, videoRef, handleClickVideo, isPauseVideo]);
190
+ const blurStyle = useMemo(() => {
191
+ return blur
192
+ ? {
193
+ filter: 'blur(10px)',
194
+ transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
195
+ }
196
+ : {};
197
+ }, [blur]);
198
+ if (!rec.video) {
199
+ return null;
200
+ }
201
+ return (React.createElement(React.Fragment, null, blur ? (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
202
+ position: 'relative',
203
+ width,
204
+ height,
205
+ overflow: 'hidden'
206
+ } },
207
+ React.createElement(FormatImage, { src: blurBgSrc, style: Object.assign({ height,
208
+ width, objectFit: 'cover' }, blurStyle) }),
209
+ React.createElement("canvas", { ref: canvasRef, style: { display: 'none' } }),
210
+ React.createElement("div", { style: {
211
+ position: 'absolute',
212
+ width,
213
+ height,
214
+ top: '50%',
215
+ transform: translateY,
216
+ left: 0,
217
+ right: 0
218
+ } },
219
+ React.createElement("div", { style: { position: 'relative', width, height: '100%' } },
220
+ React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, crossOrigin: 'anonymous', muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart, style: {
221
+ width: '100%',
222
+ height,
223
+ objectFit: 'contain'
224
+ } }),
225
+ React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON }))),
226
+ renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
227
+ position: 'relative',
228
+ width,
229
+ height,
230
+ overflow: 'hidden'
231
+ } },
232
+ React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, crossOrigin: 'anonymous', muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart }),
233
+ renderPoster,
234
+ React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })))));
235
+ };
236
+ export default memo(VideoWidget);
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { ISxpPageRenderProps } from '../SxpPageRender';
3
+ declare const _default: React.NamedExoticComponent<ISxpPageRenderProps & {
4
+ appDomain?: string | undefined;
5
+ }>;
6
+ export default _default;
@@ -0,0 +1,127 @@
1
+ import React, { memo, useMemo } from 'react';
2
+ import Nudge from '../SxpPageRender/Nudge';
3
+ import RenderCard from '../SxpPageRender/RenderCard';
4
+ import ExpandableText from '../SxpPageRender/ExpandableText';
5
+ import Hashtag from '../SxpPageRender/Hashtag';
6
+ import LikeButton from '../SxpPageRender/LikeButton';
7
+ import ToggleButton from '../SxpPageRender/ToggleButton';
8
+ import { useIconLink } from '../SxpPageRender/useIconLink';
9
+ import Tagbar from '../SxpPageRender/Tagbar';
10
+ import PictureGroup from './PictureGroup';
11
+ import VideoWidget from './VideoWidget';
12
+ import * as _materials_ from '../../../materials';
13
+ import withBindDataSource from '../../../core/hoc/withBindDataSource';
14
+ const RESOLVER = {};
15
+ Object.values(_materials_).forEach((v) => {
16
+ RESOLVER[v.extend.type] = v;
17
+ });
18
+ const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
19
+ const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
20
+ const DiyPortalPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [] }) => {
21
+ const height = useMemo(() => {
22
+ let minusHeight = 0;
23
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
24
+ minusHeight += 45;
25
+ }
26
+ if (tagList.length > 0) {
27
+ minusHeight += 45;
28
+ }
29
+ return containerHeight - minusHeight;
30
+ }, [globalConfig, containerHeight, tagList]);
31
+ const renderContent = (rec, index) => {
32
+ var _a, _b, _c, _d;
33
+ if ((_a = rec.video) === null || _a === void 0 ? void 0 : _a.url) {
34
+ return (React.createElement(VideoWidget, { rec: rec, index: index, muted: true, width: containerWidth, data: data !== null && data !== void 0 ? data : [], height: height, activeIndex: index, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost }));
35
+ }
36
+ if ((_b = rec.video) === null || _b === void 0 ? void 0 : _b.imgUrls) {
37
+ return (React.createElement(PictureGroup, { key: rec.video.itemId, imgUrls: rec.video.imgUrls, width: containerWidth, height: height, rec: rec, index: index, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost }));
38
+ }
39
+ if (rec.product) {
40
+ 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) {
41
+ return (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.productPost) === null || _d === void 0 ? void 0 : _d.map((value, idx) => {
42
+ var _a, _b, _c, _d, _e, _f, _g, _h;
43
+ const t = RESOLVER[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
44
+ const Component = withBindDataSource(t);
45
+ const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
46
+ return (React.createElement(Component, Object.assign({ key: `${index}${idx}`, textStyle: Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.textStyle), (_c = value === null || value === void 0 ? void 0 : value.item) === null || _c === void 0 ? void 0 : _c.textStyle), bindDatas: (_e = (_d = value === null || value === void 0 ? void 0 : value.item) === null || _d === void 0 ? void 0 : _d.bindDatas) !== null && _e !== void 0 ? _e : [] }, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.props, (_f = value === null || value === void 0 ? void 0 : value.item) === null || _f === void 0 ? void 0 : _f.props, { event: ((_g = value === null || value === void 0 ? void 0 : value.item) === null || _g === void 0 ? void 0 : _g.event) || {}, id: value === null || value === void 0 ? void 0 : value.id, rec: rec, isPost: true, tipText: tipText, style: Object.assign(Object.assign(Object.assign({}, defaulSetting === null || defaulSetting === void 0 ? void 0 : defaulSetting.style), (_h = value === null || value === void 0 ? void 0 : value.item) === null || _h === void 0 ? void 0 : _h.style), { width: containerWidth, height, overflow: 'auto' }), index: index })));
47
+ });
48
+ }
49
+ }
50
+ };
51
+ const renderLogo = useMemo(() => {
52
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
53
+ return (React.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
54
+ React.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
55
+ }
56
+ return null;
57
+ }, [globalConfig]);
58
+ const CTA = (rec, index) => {
59
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
60
+ return (React.createElement("div", { className: 'clc-sxp-bottom-card' },
61
+ React.createElement(RenderCard, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER })));
62
+ }
63
+ return null;
64
+ };
65
+ const renderBottom = (rec, index) => {
66
+ var _a, _b, _c, _d, _e, _f, _g;
67
+ if (rec.video) {
68
+ return (React.createElement(React.Fragment, null,
69
+ ((_a = rec.video) === null || _a === void 0 ? void 0 : _a.title) && React.createElement("div", { className: 'clc-sxp-bottom-shadow' }),
70
+ React.createElement("div", { className: 'clc-sxp-bottom' },
71
+ React.createElement(Nudge, { nudge: nudge }),
72
+ CTA(rec, index),
73
+ React.createElement("div", null,
74
+ 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' }) })),
75
+ React.createElement(Hashtag, { index: index, 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 }))));
76
+ }
77
+ return null;
78
+ };
79
+ const likeIcon = useIconLink(defaultLikeIconPath, appDomain);
80
+ const unlikeIcon = useIconLink(defaultUnLikeIconPath, appDomain);
81
+ const renderLikeButton = (rec, index) => {
82
+ var _a, _b, _c, _d;
83
+ if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
84
+ return;
85
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconY) !== null && _a !== void 0 ? _a : 400;
86
+ if (top < 40) {
87
+ top += 40;
88
+ }
89
+ if (rec.video) {
90
+ return (React.createElement(LikeButton, { key: rec.position, activeIcon: (_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIcon) !== null && _b !== void 0 ? _b : likeIcon, unActicveIcon: (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unlikeIcon) !== null && _c !== void 0 ? _c : unlikeIcon, position: index, active: rec.isCollected, recData: rec, className: 'clc-sxp-like-button', style: {
91
+ top,
92
+ right: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconX) !== null && _d !== void 0 ? _d : 0
93
+ } }));
94
+ }
95
+ return null;
96
+ };
97
+ const mutedIcon = useIconLink('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
98
+ const unmutedIcon = useIconLink('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
99
+ const renderView = (rec, index) => {
100
+ var _a, _b, _c, _d;
101
+ return (React.createElement("div", { style: { position: 'relative', border: '1px solid #e1e1e1' } },
102
+ renderLogo,
103
+ React.createElement(Tagbar, { tagList: tagList }),
104
+ React.createElement(ToggleButton, { style: {
105
+ position: 'absolute',
106
+ right: (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconX) !== null && _a !== void 0 ? _a : 0,
107
+ visibility: ((_c = (_b = data === null || data === void 0 ? void 0 : data[index]) === null || _b === void 0 ? void 0 : _b.video) === null || _c === void 0 ? void 0 : _c.url) ? 'visible' : 'hidden',
108
+ bottom: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _d !== void 0 ? _d : 23,
109
+ zIndex: 999
110
+ }, defaultValue: true, activeIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.unMuteIcon : mutedIcon, unactiveIcon: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon) ? globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIcon : unmutedIcon }),
111
+ renderContent(rec, index),
112
+ renderBottom(rec, index),
113
+ renderLikeButton(rec, index)));
114
+ };
115
+ return (React.createElement("div", { style: {
116
+ width: '100%',
117
+ height: containerHeight,
118
+ display: 'flex',
119
+ boxSizing: 'border-box',
120
+ gap: 16,
121
+ pointerEvents: 'none',
122
+ userSelect: 'none'
123
+ } }, data === null || data === void 0 ? void 0 : data.map((rec, index) => {
124
+ return renderView(rec, index);
125
+ })));
126
+ };
127
+ export default memo(DiyPortalPreview);
@@ -16,10 +16,10 @@ const SxpPageCore = ({ data, maxSize = 10, defaultSize = 10, hashTagSize = 20, l
16
16
  return searchParams;
17
17
  }, []);
18
18
  return (React.createElement(EditorCore, { resolver: RESOLVER, enableDataSource: false, schema: data === null || data === void 0 ? void 0 : data.data, utmVal: utmVal },
19
- React.createElement(SxpDataSourceProvider, { utmVal: utmVal, dataSources: data === null || data === void 0 ? void 0 : data.data_sources, sxpParameter: data === null || data === void 0 ? void 0 : data.sxp_parameter, maxSize: (_b = (_a = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _a === void 0 ? void 0 : _a.personalized_recommend) !== null && _b !== void 0 ? _b : maxSize, defaultSize: (_d = (_c = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _c === void 0 ? void 0 : _c.default_recommend) !== null && _d !== void 0 ? _d : defaultSize, hashTagSize: (_f = (_e = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _e === void 0 ? void 0 : _e.hash_tag_size) !== null && _f !== void 0 ? _f : hashTagSize, loadingImage: loadingImage, appDomain: appDomain, render: ({ rtcList }) => {
19
+ React.createElement(SxpDataSourceProvider, { utmVal: utmVal, dataSources: data === null || data === void 0 ? void 0 : data.data_sources, sxpParameter: data === null || data === void 0 ? void 0 : data.sxp_parameter, maxSize: (_b = (_a = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _a === void 0 ? void 0 : _a.personalized_recommend) !== null && _b !== void 0 ? _b : maxSize, defaultSize: (_d = (_c = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _c === void 0 ? void 0 : _c.default_recommend) !== null && _d !== void 0 ? _d : defaultSize, hashTagSize: (_f = (_e = data === null || data === void 0 ? void 0 : data.sxp_parameter) === null || _e === void 0 ? void 0 : _e.hash_tag_size) !== null && _f !== void 0 ? _f : hashTagSize, loadingImage: loadingImage, appDomain: appDomain, render: ({ rtcList, tagList }) => {
20
20
  var _a;
21
21
  return (React.createElement(React.Fragment, null,
22
- React.createElement(SxpPageRender, Object.assign({}, (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf, { data: rtcList, resolver: RESOLVER })),
22
+ React.createElement(SxpPageRender, Object.assign({}, (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.sxpPageConf, { tagList: tagList, data: rtcList, resolver: RESOLVER })),
23
23
  React.createElement(Popup, null)));
24
24
  } })));
25
25
  };
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  const Nudge = ({ nudge }) => {
3
+ var _a, _b, _c, _d, _e, _f, _g;
3
4
  return (React.createElement(React.Fragment, null, (nudge === null || nudge === void 0 ? void 0 : nudge.isOpen) && (React.createElement("div", { className: 'clc-sxp-bottom-nudge', style: {
4
- marginBottom: nudge === null || nudge === void 0 ? void 0 : nudge.marginBottom,
5
- width: nudge === null || nudge === void 0 ? void 0 : nudge.size.width,
6
- height: nudge === null || nudge === void 0 ? void 0 : nudge.size.height,
5
+ marginBottom: (_a = nudge === null || nudge === void 0 ? void 0 : nudge.marginBottom) !== null && _a !== void 0 ? _a : 5,
6
+ width: (_c = (_b = nudge === null || nudge === void 0 ? void 0 : nudge.size) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 212,
7
+ height: (_e = (_d = nudge === null || nudge === void 0 ? void 0 : nudge.size) === null || _d === void 0 ? void 0 : _d.height) !== null && _e !== void 0 ? _e : 38,
7
8
  backgroundColor: nudge === null || nudge === void 0 ? void 0 : nudge.backgroundColor,
8
- borderRadius: nudge === null || nudge === void 0 ? void 0 : nudge.borderRadius
9
+ borderRadius: (_f = nudge === null || nudge === void 0 ? void 0 : nudge.borderRadius) !== null && _f !== void 0 ? _f : 4
9
10
  } },
10
11
  (nudge === null || nudge === void 0 ? void 0 : nudge.icon) ? React.createElement("img", { src: nudge.icon, style: { height: '100%', objectFit: 'cover' } }) : null,
11
- React.createElement("p", { style: Object.assign({}, nudge === null || nudge === void 0 ? void 0 : nudge.textStyle) }, nudge === null || nudge === void 0 ? void 0 : nudge.content)))));
12
+ React.createElement("p", { style: Object.assign({}, nudge === null || nudge === void 0 ? void 0 : nudge.textStyle) }, (_g = nudge === null || nudge === void 0 ? void 0 : nudge.content) !== null && _g !== void 0 ? _g : '')))));
12
13
  };
13
14
  export default Nudge;
@@ -28,6 +28,7 @@ const Picture = (props) => {
28
28
  React.createElement(FormatImage, { src: src, style: Object.assign({ height: '100%', width: '100%', objectFit: 'cover' }, blurStyle) }),
29
29
  blur && (React.createElement(FormatImage, { src: src, style: {
30
30
  width: '100%',
31
+ height: '100%',
31
32
  objectFit: 'contain',
32
33
  position: 'absolute',
33
34
  top: '50%',
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface IProps {
3
+ tagList?: string[];
4
+ setActiveIndex?: React.Dispatch<React.SetStateAction<number>>;
5
+ }
6
+ declare const _default: React.NamedExoticComponent<IProps>;
7
+ export default _default;
@@ -0,0 +1,37 @@
1
+ import React, { memo, useMemo, useState } from 'react';
2
+ import { useSxpDataSource } from '../../../core/hooks';
3
+ const DEFAULT_TAG = 'FOR U';
4
+ const Tagbar = ({ tagList = [], setActiveIndex }) => {
5
+ const [selectTag, setSelectTag] = useState(DEFAULT_TAG);
6
+ const { getRecommendVideos, setRtcList, setCacheRtcList, setCacheActiveIndex, setLoading, swiperRef } = useSxpDataSource();
7
+ const realTagList = useMemo(() => {
8
+ return [DEFAULT_TAG, ...tagList];
9
+ }, [tagList]);
10
+ const handleSelectTag = (tag) => () => {
11
+ if (tag === selectTag)
12
+ return;
13
+ let hashTag;
14
+ if (tag !== DEFAULT_TAG) {
15
+ hashTag = tag;
16
+ }
17
+ setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
18
+ getRecommendVideos === null || getRecommendVideos === void 0 ? void 0 : getRecommendVideos({ hashTag }).then((res) => {
19
+ var _a, _b, _c, _d;
20
+ setRtcList === null || setRtcList === void 0 ? void 0 : setRtcList((_a = res === null || res === void 0 ? void 0 : res.recList) !== null && _a !== void 0 ? _a : []);
21
+ setCacheRtcList === null || setCacheRtcList === void 0 ? void 0 : setCacheRtcList((_b = res === null || res === void 0 ? void 0 : res.recList) !== null && _b !== void 0 ? _b : []);
22
+ setActiveIndex === null || setActiveIndex === void 0 ? void 0 : setActiveIndex(0);
23
+ setCacheActiveIndex === null || setCacheActiveIndex === void 0 ? void 0 : setCacheActiveIndex(0);
24
+ (_d = (_c = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _c === void 0 ? void 0 : _c.swiper) === null || _d === void 0 ? void 0 : _d.slideTo(0);
25
+ }).finally(() => {
26
+ setLoading === null || setLoading === void 0 ? void 0 : setLoading(false);
27
+ });
28
+ setSelectTag(tag);
29
+ };
30
+ if (tagList.length <= 0)
31
+ return null;
32
+ return (React.createElement("div", { className: 'clc-sxp-tagbar', style: { height: 45 } },
33
+ React.createElement("ul", { className: 'clc-sxp-tagbar-list', style: { margin: 'auto', gap: 24 } }, realTagList.map((tag) => {
34
+ return (React.createElement("li", { className: `clc-sxp-tagbar-list-item ${tag === selectTag ? 'clc-sxp-tagbar-list-item-active' : ''}`, key: tag, onClick: handleSelectTag(tag) }, tag));
35
+ }))));
36
+ };
37
+ export default memo(Tagbar);