pb-sxp-ui 1.15.12-alpha.8 → 1.15.13-alpha.2

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 (43) hide show
  1. package/dist/index.cjs +666 -56
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +664 -55
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +6 -6
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +6 -6
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +666 -56
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +6 -6
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  14. package/es/core/components/DiyStoryPreview/PictureGroup.js +34 -0
  15. package/es/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
  16. package/es/core/components/DiyStoryPreview/VideoWidget.js +196 -0
  17. package/es/core/components/DiyStoryPreview/index.d.ts +28 -0
  18. package/es/core/components/DiyStoryPreview/index.js +377 -0
  19. package/es/core/components/SxpPageRender/ExpandableText.js +10 -2
  20. package/es/core/components/SxpPageRender/RenderCard.js +4 -4
  21. package/es/core/context/SxpDataSourceProvider.js +5 -17
  22. package/es/index.d.ts +1 -0
  23. package/es/index.js +1 -0
  24. package/es/materials/sxp/template/MultiCommodity/index.js +1 -1
  25. package/es/materials/sxp/template/MultiCommodityDiro/index.js +2 -1
  26. package/es/materials/sxp/template/MultiCommodityDiroNew/index.js +2 -1
  27. package/es/materials/sxp/template/components/EventProvider.js +2 -2
  28. package/lib/core/components/DiyStoryPreview/PictureGroup.d.ts +16 -0
  29. package/lib/core/components/DiyStoryPreview/PictureGroup.js +37 -0
  30. package/lib/core/components/DiyStoryPreview/VideoWidget.d.ts +17 -0
  31. package/lib/core/components/DiyStoryPreview/VideoWidget.js +199 -0
  32. package/lib/core/components/DiyStoryPreview/index.d.ts +28 -0
  33. package/lib/core/components/DiyStoryPreview/index.js +380 -0
  34. package/lib/core/components/SxpPageRender/ExpandableText.js +10 -2
  35. package/lib/core/components/SxpPageRender/RenderCard.js +4 -4
  36. package/lib/core/context/SxpDataSourceProvider.js +5 -17
  37. package/lib/index.d.ts +1 -0
  38. package/lib/index.js +3 -1
  39. package/lib/materials/sxp/template/MultiCommodity/index.js +1 -1
  40. package/lib/materials/sxp/template/MultiCommodityDiro/index.js +2 -1
  41. package/lib/materials/sxp/template/MultiCommodityDiroNew/index.js +2 -1
  42. package/lib/materials/sxp/template/components/EventProvider.js +2 -2
  43. package/package.json +1 -1
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { postConfigType } from '../SxpPageRender';
3
+ import { IScene, ScenesType } from '.';
4
+ interface IVideoWidgetProps {
5
+ rec: IScene;
6
+ index: number;
7
+ height: number;
8
+ width: number;
9
+ data: ScenesType;
10
+ muted: boolean;
11
+ activeIndex?: number;
12
+ videoPostConfig?: postConfigType;
13
+ swiperRef?: any;
14
+ loopPlay?: boolean;
15
+ }
16
+ declare const _default: React.NamedExoticComponent<IVideoWidgetProps>;
17
+ export default _default;
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const react_2 = require("swiper/react");
6
+ const useIconLink_1 = require("../SxpPageRender/useIconLink");
7
+ const VideoPlayer_1 = require("../SxpPageRender/VideoWidget/VideoPlayer");
8
+ const hooks_1 = require("../../../core/hooks");
9
+ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, width, swiperRef, loopPlay }) => {
10
+ const { isActive } = (0, react_2.useSwiperSlide)();
11
+ const [isPauseVideo, setIsPauseVideo] = (0, react_1.useState)(false);
12
+ const videoRef = (0, react_1.useRef)(null);
13
+ const { bffEventReport, sxpParameter, waterFallData, openHashtag } = (0, hooks_1.useSxpDataSource)();
14
+ const videoStartTime = (0, react_1.useRef)(0);
15
+ const [isLoadFinish, setIsLoadFinish] = (0, react_1.useState)(false);
16
+ const [isFirstPlay, setIsFirstPlay] = (0, react_1.useState)(true);
17
+ const canvasRef = (0, react_1.useRef)(null);
18
+ const [firstFrameSrc, setFirstFrameSrc] = (0, react_1.useState)('');
19
+ const videoId = `pb-cache-video-${index}`;
20
+ const hlsRef = (0, react_1.useRef)(null);
21
+ (0, react_1.useEffect)(() => {
22
+ if (!videoRef.current)
23
+ return;
24
+ videoRef.current.muted = muted;
25
+ }, [muted]);
26
+ const handleVideoStart = (0, react_1.useCallback)(() => {
27
+ var _a;
28
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
29
+ }, []);
30
+ const PAUSE_ICON = (0, useIconLink_1.useIconLink)('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
31
+ const handlePlaying = (0, react_1.useCallback)(() => {
32
+ var _a, _b, _c, _d, _e, _f;
33
+ setIsPauseVideo(false);
34
+ const item = data[index];
35
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
36
+ videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
37
+ const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
38
+ const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
39
+ const playType = isFirstPlay ? '0' : '1';
40
+ setIsFirstPlay(false);
41
+ }
42
+ }, [bffEventReport, data, index, isFirstPlay]);
43
+ const handleLoadedMetadata = (0, react_1.useCallback)(() => {
44
+ var _a;
45
+ videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
46
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
47
+ setIsLoadFinish(true);
48
+ }, []);
49
+ const handleClickVideo = (0, react_1.useCallback)((type) => () => {
50
+ var _a, _b, _c, _d, _e;
51
+ if (!isLoadFinish)
52
+ return;
53
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
54
+ switch (type) {
55
+ case 'start':
56
+ if (!isPause)
57
+ return;
58
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
59
+ setIsPauseVideo(false);
60
+ break;
61
+ case 'pause':
62
+ if (isPause)
63
+ return;
64
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
65
+ setIsPauseVideo(true);
66
+ break;
67
+ default:
68
+ if (isPause) {
69
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
70
+ }
71
+ else {
72
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
73
+ }
74
+ setIsPauseVideo(!isPause);
75
+ break;
76
+ }
77
+ }, [isLoadFinish]);
78
+ const onPause = (0, react_1.useCallback)(() => {
79
+ var _a, _b, _c, _d, _e, _f;
80
+ const item = data[index];
81
+ const videoDuration = ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
82
+ const videoCurrentTime = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
83
+ if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
84
+ const playDuration = (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
85
+ }
86
+ }, [data, index, bffEventReport]);
87
+ const blur = (0, react_1.useMemo)(() => {
88
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2';
89
+ }, [videoPostConfig]);
90
+ const translateY = (0, react_1.useMemo)(() => {
91
+ var _a;
92
+ return (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.mode) === '2'
93
+ ? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%) translate3d(0px, 0px, 0px)`
94
+ : 'translateY(-50%)';
95
+ }, [videoPostConfig]);
96
+ const handLoadeddata = (0, react_1.useCallback)(() => {
97
+ if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
98
+ return;
99
+ const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
100
+ const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
101
+ const ctx = canvas.getContext('2d');
102
+ const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
103
+ const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
104
+ canvas.height = targetHeight;
105
+ canvas.width = targetWidth;
106
+ ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
107
+ setFirstFrameSrc(canvas.toDataURL());
108
+ }, []);
109
+ const handleTimeUpload = (0, react_1.useCallback)(() => {
110
+ var _a, _b, _c;
111
+ if (!videoRef.current)
112
+ return;
113
+ if (((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) >= ((_b = rec === null || rec === void 0 ? void 0 : rec.endTime) !== null && _b !== void 0 ? _b : 0)) {
114
+ (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
115
+ }
116
+ }, []);
117
+ const handlePause = () => {
118
+ var _a, _b, _c, _d, _e, _f;
119
+ if (!videoRef.current || !isActive)
120
+ return;
121
+ if (!loopPlay)
122
+ return;
123
+ if (index === (data === null || data === void 0 ? void 0 : data.length) - 1) {
124
+ (_b = (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper) === null || _b === void 0 ? void 0 : _b.slideTo(0);
125
+ }
126
+ else {
127
+ const i = (_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.activeIndex;
128
+ (_f = (_e = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _e === void 0 ? void 0 : _e.swiper) === null || _f === void 0 ? void 0 : _f.slideTo(i + 1);
129
+ }
130
+ };
131
+ (0, react_1.useEffect)(() => {
132
+ var _a, _b, _c;
133
+ if (!isActive)
134
+ return;
135
+ const videoSrc = rec === null || rec === void 0 ? void 0 : rec.mediaUrl;
136
+ if (!videoSrc)
137
+ return;
138
+ setIsPauseVideo(false);
139
+ const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
140
+ if (!videoPlayerWrapperNode)
141
+ return;
142
+ videoRef.current = VideoPlayer_1.mountVideoPlayerAtNode === null || VideoPlayer_1.mountVideoPlayerAtNode === void 0 ? void 0 : (0, VideoPlayer_1.mountVideoPlayerAtNode)(videoPlayerWrapperNode);
143
+ if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
144
+ return;
145
+ const Hls = window === null || window === void 0 ? void 0 : window.Hls;
146
+ let hls = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current;
147
+ if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
148
+ hls = new Hls();
149
+ hls === null || hls === void 0 ? void 0 : hls.loadSource(videoSrc);
150
+ hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
151
+ hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
152
+ var _a;
153
+ videoRef.current.currentTime = rec === null || rec === void 0 ? void 0 : rec.startTime;
154
+ (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
155
+ });
156
+ }
157
+ else {
158
+ videoRef.current.src = videoSrc;
159
+ }
160
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
161
+ (_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('pause', handlePause);
162
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('timeupdate', handleTimeUpload);
163
+ return () => {
164
+ var _a, _b, _c, _d;
165
+ if (hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current)
166
+ (_a = hlsRef === null || hlsRef === void 0 ? void 0 : hlsRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
167
+ setIsLoadFinish(false);
168
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadedmetadata', handleLoadedMetadata);
169
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('pause', handlePause);
170
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('timeupdate', handleTimeUpload);
171
+ };
172
+ }, [handleLoadedMetadata, handlePlaying, rec, handLoadeddata, isActive, loopPlay]);
173
+ const renderPoster = (0, react_1.useMemo)(() => {
174
+ if (!(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image) || isLoadFinish) {
175
+ return null;
176
+ }
177
+ return (react_1.default.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, alt: 'video poster' }));
178
+ }, [isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
179
+ const blurStyle = (0, react_1.useMemo)(() => {
180
+ return blur
181
+ ? {
182
+ filter: 'blur(10px)',
183
+ transform: 'translate3d(0px, 0px, 0px) scale(1.2)'
184
+ }
185
+ : {};
186
+ }, [blur]);
187
+ if (!(rec === null || rec === void 0 ? void 0 : rec.mediaUrl)) {
188
+ return null;
189
+ }
190
+ return (react_1.default.createElement("div", { className: 'video-container', key: rec.itemId, style: {
191
+ position: 'relative',
192
+ width: '100%',
193
+ height,
194
+ overflow: 'hidden',
195
+ pointerEvents: 'none'
196
+ } },
197
+ react_1.default.createElement("div", { className: 'n-full-screen', id: videoId, style: { width: '100%', height: '100%' } })));
198
+ };
199
+ exports.default = (0, react_1.memo)(VideoWidget);
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { ISxpPageRenderProps } from '../SxpPageRender';
3
+ import '../SxpPageRender/index.less';
4
+ export interface IScene {
5
+ blueprintStep: number;
6
+ endTime: number;
7
+ itemId: string;
8
+ mediaFileNo: string;
9
+ mediaUrl: string;
10
+ position: number;
11
+ postId: string;
12
+ sceneId: string;
13
+ sceneInfo: string;
14
+ sceneTag: string;
15
+ startTime: number;
16
+ traceInfo: string;
17
+ bindProducts?: any[];
18
+ }
19
+ export type ScenesType = IScene[];
20
+ export type DiyStoryPreviewType = ISxpPageRenderProps & {
21
+ appDomain?: string;
22
+ scenes?: ScenesType;
23
+ activeIndex?: number;
24
+ onActiveChange?: (v: number) => void;
25
+ loopPlay?: boolean;
26
+ };
27
+ declare const _default: React.NamedExoticComponent<DiyStoryPreviewType>;
28
+ export default _default;
@@ -0,0 +1,380 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const react_2 = require("swiper/react");
6
+ const lodash_1 = require("lodash");
7
+ const RenderCard_1 = tslib_1.__importDefault(require("../SxpPageRender/RenderCard"));
8
+ const ExpandableText_1 = tslib_1.__importDefault(require("../SxpPageRender/ExpandableText"));
9
+ const LikeButton_1 = tslib_1.__importDefault(require("../SxpPageRender/LikeButton"));
10
+ const useIconLink_1 = require("../SxpPageRender/useIconLink");
11
+ const ToggleButton_1 = tslib_1.__importDefault(require("../SxpPageRender/ToggleButton"));
12
+ const PictureGroup_1 = tslib_1.__importDefault(require("./PictureGroup"));
13
+ const VideoWidget_1 = tslib_1.__importDefault(require("./VideoWidget"));
14
+ const _materials_ = tslib_1.__importStar(require("../../../materials"));
15
+ require("../SxpPageRender/index.less");
16
+ const RESOLVER = {};
17
+ Object.values(_materials_).forEach((v) => {
18
+ RESOLVER[v.extend.type] = v;
19
+ });
20
+ const defaultUnLikeIconPath = '/pb_static/f71266d2c64446c5ae6a5a7f5489cc0a.png';
21
+ const defaultLikeIconPath = '/pb_static/f07900fe3f0f4ae188ea1611d4801a44.png';
22
+ const recData = {
23
+ position: 0,
24
+ isCollected: false,
25
+ product: null,
26
+ video: {
27
+ appId: null,
28
+ itemId: 'VIDEOSsRgI1695278974368',
29
+ title: '8张尺寸不一样的图片8张尺寸不一样的图片8张尺寸不一样的图片8张尺寸不一样的图片8张尺寸不一样的图片8张尺寸不一样的图片8张尺寸不一样的图片8张尺寸不一样的图片8张尺寸不一样的图片8张尺寸不一样的图片8张尺寸不一样的图片',
30
+ enTitle: null,
31
+ icon: null,
32
+ cover: 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20231017/fsJFWmW1dGyW7XmDspbJPTn5esL3U1697538777398.png',
33
+ link: null,
34
+ linkTitle: null,
35
+ linkType: null,
36
+ menuCategoryId: null,
37
+ remark: null,
38
+ tags: [
39
+ 'Gift-Giving',
40
+ 'Daily Wear',
41
+ 'Business Formal',
42
+ 'Sports/Casual',
43
+ 'Anniversary Gifts',
44
+ 'Wedding/Engagement',
45
+ 'Formal Dinner/Party'
46
+ ],
47
+ traceInfo: ':VIDEO:VIDEOSsRgI1695278974368:regular:1:VPRHSkRS1697701789894:main::0:EXPMW20250305155940:COMBTh20250305160047:',
48
+ value: 385,
49
+ weight: null,
50
+ bindCta: null,
51
+ bindProduct: null,
52
+ bindProducts: [
53
+ {
54
+ appId: 'wx448578f8851f3dce',
55
+ itemId: 'test02178888',
56
+ title: 'christian dior小包包 新CDN',
57
+ enTitle: null,
58
+ icon: null,
59
+ cover: 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20240913/fs2jqiurjftpoaba67iiwr9jt5sc31726213277754.avif',
60
+ link: '/pages/details/index?spu_id=1702262707659534338',
61
+ linkTitle: '',
62
+ linkType: 'MP',
63
+ menuCategoryId: null,
64
+ remark: null,
65
+ tags: [],
66
+ traceInfo: ':PRODUCT:test02178888:regular:1:VPRHSkRS1697701789894:main::0:EXPMW20250305155940:COMBTh20250305160047:',
67
+ value: null,
68
+ weight: null,
69
+ bindCta: {
70
+ appId: 'wx448578f8851f3dce',
71
+ itemId: 'CTA3KofE1716186622249',
72
+ title: 'SHOP NOW 立即购买',
73
+ enTitle: 'BUY NOW立即购买,选择你所喜爱的;',
74
+ icon: 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20240520/fssfxbmiwghixmgblz9uriwennd2r1716186615574.avif',
75
+ cover: null,
76
+ link: '/pages/details/index?spu_id=1702262707659534338',
77
+ linkTitle: '',
78
+ linkType: 'MP',
79
+ menuCategoryId: '64b60b202caf0e1c1ce1e17d',
80
+ remark: null,
81
+ tags: [
82
+ "Woman's Perfumes",
83
+ 'Plates & Bowls',
84
+ 'Glasses',
85
+ 'Multicolor',
86
+ 'Carafes',
87
+ 'Tea & Coffee',
88
+ 'Green',
89
+ 'Grey',
90
+ 'Cutlery'
91
+ ],
92
+ traceInfo: ':CTA:CTA3KofE1716186622249:regular:1:VPRHSkRS1697701789894:main::0:EXPMW20250305155940:COMBTh20250305160047:',
93
+ value: null,
94
+ weight: null
95
+ },
96
+ collection: 'Ricco',
97
+ currency: 'INR-₹',
98
+ homePage: [
99
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20240913/fs2jqiurjftpoaba67iiwr9jt5sc31726213277754.avif',
100
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20240913/fsr9ttuzuljs85smqi6lsidovnyoy1726213285994.avif',
101
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20240913/fsknmfhx2lxukxews05guwwxr8rju1726213281108.avif',
102
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20240913/fs0acnua4f1clamdpwdsrh0v5dgc61726213289247.avif'
103
+ ],
104
+ info: 'test',
105
+ price: 53200,
106
+ shippingInfo: null,
107
+ taxInfo: null
108
+ },
109
+ {
110
+ appId: null,
111
+ itemId: '113J631A0684_C520',
112
+ title: 'Sweatshirt à capuche Dior Oblique, coupe relax',
113
+ enTitle: null,
114
+ icon: null,
115
+ cover: 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20241115/fsaf0xq8vx8gkkl30y1h1swpinmbt1731661943891.avif',
116
+ link: 'https://www.dior.com/fr_fr/fashion/products/113J631A0684_C520',
117
+ linkTitle: null,
118
+ linkType: 'WEB',
119
+ menuCategoryId: null,
120
+ remark: null,
121
+ tags: [],
122
+ traceInfo: ':PRODUCT:113J631A0684_C520:regular:1:VPRHSkRS1697701789894:main::0:EXPMW20250305155940:COMBTh20250305160047:',
123
+ value: null,
124
+ weight: null,
125
+ bindCta: {
126
+ appId: null,
127
+ itemId: 'CTAAfaKf1730796437032',
128
+ title: 'test',
129
+ enTitle: 'test',
130
+ icon: 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20241105/fsjblxoud2tmehpiqqomh0oktwqrd1730796431496.avif',
131
+ cover: null,
132
+ link: null,
133
+ linkTitle: null,
134
+ linkType: null,
135
+ menuCategoryId: '64b60b202caf0e1c1ce1e17d',
136
+ remark: '',
137
+ tags: [],
138
+ traceInfo: ':CTA:CTAAfaKf1730796437032:regular:1:VPRHSkRS1697701789894:main::0:EXPMW20250305155940:COMBTh20250305160047:',
139
+ value: null,
140
+ weight: null
141
+ },
142
+ collection: 'Jacquard de coton éponge bleu',
143
+ currency: 'EUR-€',
144
+ homePage: [
145
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20241115/fsaf0xq8vx8gkkl30y1h1swpinmbt1731661943891.avif',
146
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20241115/fszxkdcjfjql2oiy90ffbal5tsfd81731661964913.avif',
147
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20241115/fs1jhd9jwxvfqmrbjwy5abfzb0fde1731661994996.avif'
148
+ ],
149
+ info: "Le sweatshirt à capuche bleu met à l'honneur l'emblématique motif dior oblique. Confectionné en jacquard de coton éponge bleu, il présente une coupe relax très confortable. Doté de poches latérales fendues, ce sweatshirt à capuche s'associera à tous vos jeans ou pantalons de survêtement pour un look décontracté.. Sweatshirt à capuche dior oblique, coupe relax Jacquard de coton éponge bleu",
150
+ price: 1800,
151
+ shippingInfo: null,
152
+ taxInfo: null
153
+ },
154
+ {
155
+ appId: null,
156
+ itemId: 'S5573CRIW_M928',
157
+ title: 'Mini Dior Book Tote',
158
+ enTitle: null,
159
+ icon: null,
160
+ cover: 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20250213/fsvewk9etrawxrzznmvvewgt1bctu1739415576729.avif',
161
+ link: 'https://www.dior.com/en_gb/fashion/products/S5573CRIW_M928',
162
+ linkTitle: null,
163
+ linkType: 'WEB',
164
+ menuCategoryId: null,
165
+ remark: null,
166
+ tags: ['ダイヤモンド'],
167
+ traceInfo: ':PRODUCT:S5573CRIW_M928:regular:1:VPRHSkRS1697701789894:main::0:EXPMW20250305155940:COMBTh20250305160047:',
168
+ value: null,
169
+ weight: null,
170
+ bindCta: null,
171
+ collection: null,
172
+ currency: 'GBP-£',
173
+ homePage: [
174
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20250213/fsvewk9etrawxrzznmvvewgt1bctu1739415576729.avif',
175
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20250213/fsngtlvhid7xwt5if0viw7vqanm831739415582147.avif',
176
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20250213/fs4hotdvyzjtnqb9vszlynuzplddc1739415586910.avif',
177
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20250213/fswffx9kwexf3z3vcnxisut1qxtez1739415591629.avif',
178
+ 'https://graff-cdn.chatlabs.net/dev/img/8922b5b8-a954-4a61-9ffc-80edebdf02b4/sxp-portal/20250213/fsbfsi7tttx1hnzldoiw7eoea7fvh1739415597388.avif'
179
+ ],
180
+ info: "The Dior Book Tote is a House classic and original design by Maria Grazia Chiuri, Creative Director of Christian Dior. The style is fully embroidered with the House's hallmark blue Dior Oblique motif and showcases the Christian Dior Paris signature. Exemplifying House savoir-faire, the miniature style features an adjustable and removable strap that allows it to be carried by hand, worn over the shoulder or crossbody.",
181
+ price: 1950,
182
+ shippingInfo: null,
183
+ taxInfo: null
184
+ }
185
+ ],
186
+ url: null,
187
+ blockCta: 1,
188
+ blockProduct: 1,
189
+ hashTags: [
190
+ 'Sports/Casual',
191
+ 'Formal Dinner/Party',
192
+ 'Business Formal',
193
+ 'Wedding/Engagement',
194
+ 'Gift-Giving',
195
+ 'Daily Wear',
196
+ 'Anniversary Gifts'
197
+ ]
198
+ }
199
+ };
200
+ const DiyStoryPreview = ({ data = [], globalConfig, tipText, nudge, tempMap, descStyle, hashTagStyle, containerHeight = 664, containerWidth = 375, appDomain, tagList = [], scenes, onActiveChange, activeIndex, loopPlay = false }) => {
201
+ const swiperRef = (0, react_1.useRef)(null);
202
+ const height = (0, react_1.useMemo)(() => {
203
+ let minusHeight = 0;
204
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
205
+ minusHeight += 45;
206
+ }
207
+ if (tagList.length > 0) {
208
+ minusHeight += 45;
209
+ }
210
+ return containerHeight - minusHeight;
211
+ }, [globalConfig, containerHeight, tagList]);
212
+ const isVideoUrl = (url) => {
213
+ if (url && url !== '' && typeof url === 'string') {
214
+ const imageExtensions = ['.mp4', '.m3u8'];
215
+ const lowerCaseUrl = url === null || url === void 0 ? void 0 : url.toLowerCase();
216
+ return imageExtensions.some((ext) => lowerCaseUrl === null || lowerCaseUrl === void 0 ? void 0 : lowerCaseUrl.endsWith(ext));
217
+ }
218
+ else {
219
+ return false;
220
+ }
221
+ };
222
+ const renderContent = (rec, index) => {
223
+ const isVideo = isVideoUrl(rec === null || rec === void 0 ? void 0 : rec.mediaUrl);
224
+ if (isVideo) {
225
+ return (react_1.default.createElement(VideoWidget_1.default, { rec: rec, index: index, muted: true, width: containerWidth, data: scenes !== null && scenes !== void 0 ? scenes : [], height: containerHeight, activeIndex: index, videoPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.videoPost, swiperRef: swiperRef, loopPlay: loopPlay }));
226
+ }
227
+ else {
228
+ return (react_1.default.createElement(PictureGroup_1.default, { key: rec.itemId, imgUrls: [rec === null || rec === void 0 ? void 0 : rec.mediaUrl], width: containerWidth, height: containerHeight, rec: rec, index: index, imgUrlsPostConfig: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.imgUrlsPost, data: scenes !== null && scenes !== void 0 ? scenes : [], swiperRef: swiperRef, loopPlay: loopPlay }));
229
+ }
230
+ };
231
+ const renderLogo = (0, react_1.useMemo)(() => {
232
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl) && (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLogo)) {
233
+ return (react_1.default.createElement("div", { className: 'clc-sxp-logo-banner', style: { backgroundColor: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.color } },
234
+ react_1.default.createElement("img", { src: globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.logoUrl, alt: 'logo' })));
235
+ }
236
+ return null;
237
+ }, [globalConfig]);
238
+ const CTA = (rec, index) => {
239
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA)) {
240
+ console.log(globalConfig, rec, '111');
241
+ return (react_1.default.createElement("div", { className: 'clc-sxp-bottom-card' },
242
+ react_1.default.createElement(RenderCard_1.default, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER })));
243
+ }
244
+ return null;
245
+ };
246
+ const renderBottom = (rec, index) => {
247
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
248
+ if (rec === null || rec === void 0 ? void 0 : rec.video) {
249
+ let cta = null;
250
+ if ((_b = (_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.bindProducts) === null || _b === void 0 ? void 0 : _b.length) {
251
+ cta = '多商品CTA';
252
+ }
253
+ else if ((_c = rec === null || rec === void 0 ? void 0 : rec.video) === null || _c === void 0 ? void 0 : _c.bindProduct) {
254
+ cta = '商品CTA';
255
+ }
256
+ else {
257
+ cta = (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.bindCta) === null || _e === void 0 ? void 0 : _e.itemId;
258
+ }
259
+ const value = tempMap === null || tempMap === void 0 ? void 0 : tempMap[cta];
260
+ return (react_1.default.createElement(react_1.default.Fragment, null,
261
+ ((_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.title) && (react_1.default.createElement("div", { style: {
262
+ background: 'repeating-linear-gradient(0deg, rgba(26, 26, 25, 0.7), hsla(0, 0%, 100%, 0))',
263
+ height: '130px',
264
+ position: 'absolute',
265
+ bottom: 0,
266
+ width: '100%',
267
+ willChange: 'transform',
268
+ zIndex: 2,
269
+ pointerEvents: 'none'
270
+ } })),
271
+ react_1.default.createElement("div", { style: {
272
+ marginBottom: `${(_g = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.bottomInfoDist) !== null && _g !== void 0 ? _g : 40}px`,
273
+ zIndex: 999,
274
+ position: 'absolute',
275
+ bottom: 0,
276
+ left: 0,
277
+ right: 0,
278
+ paddingTop: '20px'
279
+ } },
280
+ (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowCTA) ? (react_1.default.createElement("div", { style: {} },
281
+ react_1.default.createElement(RenderCard_1.default, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER, isActive: index === activeIndex, value: value }))) : null,
282
+ react_1.default.createElement("div", null,
283
+ react_1.default.createElement(ExpandableText_1.default, { isPost: true, foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, text: (_j = (_h = rec === null || rec === void 0 ? void 0 : rec.video) === null || _h === void 0 ? void 0 : _h.title) !== null && _j !== void 0 ? _j : '', 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', padding: '0 20px', fontSize: '12px' }) }),
284
+ react_1.default.createElement(RenderCard_1.default, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER, includesCtaType: ['AniLink'], isActive: index === activeIndex, value: value }))),
285
+ react_1.default.createElement(RenderCard_1.default, { rec: rec, index: index, tempMap: tempMap, resolver: RESOLVER, includesCtaType: ['AniLinkPopup'], isActive: index === activeIndex, value: value })));
286
+ }
287
+ return null;
288
+ };
289
+ const likeIcon = (0, useIconLink_1.useIconLink)(defaultLikeIconPath, appDomain);
290
+ const unlikeIcon = (0, useIconLink_1.useIconLink)(defaultUnLikeIconPath, appDomain);
291
+ const renderLikeButton = (rec, index) => {
292
+ var _a, _b, _c, _d;
293
+ if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowLike))
294
+ return;
295
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconY) !== null && _a !== void 0 ? _a : 400;
296
+ if (top < 40) {
297
+ top += 40;
298
+ }
299
+ if (rec === null || rec === void 0 ? void 0 : rec.video) {
300
+ return (react_1.default.createElement(LikeButton_1.default, { 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, style: {
301
+ top,
302
+ right: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconX) !== null && _d !== void 0 ? _d : 0,
303
+ position: 'absolute',
304
+ zIndex: 999,
305
+ backgroundColor: 'transparent',
306
+ width: '50px',
307
+ height: '50px',
308
+ outline: 'none',
309
+ border: 'none',
310
+ boxSizing: 'content-box',
311
+ padding: 0,
312
+ transform: 'translate3d(0px, 0px, 0px)'
313
+ } }));
314
+ }
315
+ return null;
316
+ };
317
+ const mutedIcon = (0, useIconLink_1.useIconLink)('/pb_static/5beaaa5ce7f3477b99db3838619cc471.png', appDomain);
318
+ const unmutedIcon = (0, useIconLink_1.useIconLink)('/pb_static/fea8668a8a894e4aa3a86bcc775e895e.png', appDomain);
319
+ const renderToggleButton = (visible) => {
320
+ var _a, _b, _c, _d;
321
+ if (!visible)
322
+ return;
323
+ let top = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _a !== void 0 ? _a : 23;
324
+ if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) === 'top') {
325
+ top += 45;
326
+ }
327
+ return (((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === undefined || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.isShowMute) === true) && (react_1.default.createElement(ToggleButton_1.default, { style: {
328
+ position: 'absolute',
329
+ visibility: 'visible',
330
+ zIndex: 999,
331
+ transform: 'translate3d(0px,0px,0px)',
332
+ [(_b = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconXPosit) !== null && _b !== void 0 ? _b : 'right']: (_c = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconX) !== null && _c !== void 0 ? _c : 0,
333
+ [(_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconYPosit) !== null && _d !== void 0 ? _d : 'bottom']: top,
334
+ backgroundColor: 'transparent',
335
+ width: '50px',
336
+ height: '50px',
337
+ outline: 'none',
338
+ border: 'none',
339
+ boxSizing: 'content-box',
340
+ padding: 0
341
+ }, 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 })));
342
+ };
343
+ const renderView = (item, index) => {
344
+ var _a, _b, _c, _d;
345
+ const rec = (0, lodash_1.cloneDeep)(recData);
346
+ rec.video.bindProducts = item === null || item === void 0 ? void 0 : item.bindProducts;
347
+ return (react_1.default.createElement("div", { style: { position: 'relative' } },
348
+ react_1.default.createElement(react_2.SwiperSlide, { key: index, virtualIndex: index, style: { overflow: 'hidden', position: 'relative' } },
349
+ renderBottom(rec, index),
350
+ renderLikeButton(rec, index),
351
+ renderToggleButton(!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed)),
352
+ react_1.default.createElement(ToggleButton_1.default, { style: {
353
+ position: 'absolute',
354
+ right: (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconX) !== null && _a !== void 0 ? _a : 0,
355
+ 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',
356
+ bottom: (_d = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconY) !== null && _d !== void 0 ? _d : 23,
357
+ zIndex: 999
358
+ }, 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 }),
359
+ renderContent(item, index))));
360
+ };
361
+ (0, react_1.useEffect)(() => {
362
+ var _a, _b;
363
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
364
+ return;
365
+ (_b = (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper) === null || _b === void 0 ? void 0 : _b.slideTo(activeIndex);
366
+ }, [activeIndex]);
367
+ (0, react_1.useEffect)(() => {
368
+ var _a, _b;
369
+ if (!(swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current))
370
+ return;
371
+ (_b = (_a = swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper) === null || _b === void 0 ? void 0 : _b.slideTo(0);
372
+ }, [loopPlay]);
373
+ return (react_1.default.createElement("div", { id: 'sxp-render', style: { height: containerHeight, position: 'relative', pointerEvents: 'none' } },
374
+ react_1.default.createElement(react_2.Swiper, { ref: swiperRef, allowTouchMove: false, onActiveIndexChange: (swiper) => {
375
+ onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(swiper.activeIndex);
376
+ }, direction: 'vertical', style: { overflow: 'hidden', height: containerHeight }, height: containerHeight }, scenes === null || scenes === void 0 ? void 0 : scenes.map((rec, index) => {
377
+ return renderView(rec, index);
378
+ }))));
379
+ };
380
+ exports.default = (0, react_1.memo)(DiyStoryPreview);