pb-sxp-ui 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +93 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +93 -107
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +93 -107
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/Modal/index.d.ts +2 -2
- package/es/core/components/SxpPageRender/Modal/index.js +12 -11
- package/es/core/components/SxpPageRender/Popup/index.js +12 -12
- package/es/core/components/SxpPageRender/WaterFall/WaterfallList.js +3 -4
- package/es/core/components/SxpPageRender/WaterFall/index.js +1 -1
- package/es/core/context/EditorContext.d.ts +7 -5
- package/es/core/context/EditorContext.js +10 -25
- package/es/core/hooks/useEventReport.js +39 -35
- package/es/materials/sxp/popup/AppointForm/index.js +1 -2
- package/es/materials/sxp/popup/Prompt/index.js +0 -2
- package/es/materials/sxp/template/MultiCommodity/index.js +4 -5
- package/es/materials/sxp/template/MultiCommodityDiro/index.js +4 -5
- package/es/materials/sxp/template/MultiCommodityDiroNew/index.js +4 -5
- package/es/materials/sxp/template/components/EventProvider.js +4 -4
- package/lib/core/components/SxpPageRender/Modal/index.d.ts +2 -2
- package/lib/core/components/SxpPageRender/Modal/index.js +11 -10
- package/lib/core/components/SxpPageRender/Popup/index.js +12 -12
- package/lib/core/components/SxpPageRender/WaterFall/WaterfallList.js +2 -3
- package/lib/core/components/SxpPageRender/WaterFall/index.js +1 -1
- package/lib/core/context/EditorContext.d.ts +7 -5
- package/lib/core/context/EditorContext.js +10 -25
- package/lib/core/hooks/useEventReport.js +39 -35
- package/lib/materials/sxp/popup/AppointForm/index.js +0 -1
- package/lib/materials/sxp/popup/Prompt/index.js +0 -2
- package/lib/materials/sxp/template/MultiCommodity/index.js +4 -5
- package/lib/materials/sxp/template/MultiCommodityDiro/index.js +4 -5
- package/lib/materials/sxp/template/MultiCommodityDiroNew/index.js +4 -5
- package/lib/materials/sxp/template/components/EventProvider.js +4 -4
- package/package.json +1 -1
- package/es/core/components/SxpPageRender/ProductInfo/index.d.ts +0 -14
- package/es/core/components/SxpPageRender/ProductInfo/index.js +0 -55
- package/lib/core/components/SxpPageRender/ProductInfo/index.d.ts +0 -14
- package/lib/core/components/SxpPageRender/ProductInfo/index.js +0 -58
@@ -1,10 +1,10 @@
|
|
1
1
|
import React, { CSSProperties } from 'react';
|
2
|
-
import {
|
2
|
+
import { IPopupType } from '../../../../core/context/EditorContext';
|
3
3
|
interface IModalProps {
|
4
4
|
visible?: boolean;
|
5
|
+
popup?: IPopupType;
|
5
6
|
padding?: number | string;
|
6
7
|
modalStyle?: CSSProperties;
|
7
|
-
popupAniData?: IPopupAniType;
|
8
8
|
onClose?: () => void;
|
9
9
|
}
|
10
10
|
declare const _default: React.NamedExoticComponent<React.PropsWithChildren<IModalProps>>;
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import { debounce } from 'lodash';
|
2
|
-
import React, { memo, useEffect, useRef, useState } from 'react';
|
2
|
+
import React, { memo, useEffect, useMemo, useRef, useState } from 'react';
|
3
3
|
import * as ReactDOM from 'react-dom';
|
4
|
-
import { useEditor } from '../../../../core/hooks';
|
5
4
|
const closeIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAjhJREFUWEfFlztOw0AQhmeWiJ4CCmpQ5DiRQsIJyAWg5A0lR0AIChDiCJS8ER0cADgBeRSxt4CCDgkaKiq8i+zYeWx2413HEWmiJJv9v535Z2aN8M8vFPT9z3zETD0aAUChUJjwvPFHAJhBhB3Hqd6OAsK2yyucwykAvP38eJX398Z3AJDLlVYR8ToU9Rhj25TWr9KEsKy5dULIGQCMtfZly45TvwsAstm56UwG6wA4FUFwzrdctxZBDcWSy5XWEPG8I84/GcMipdWPtgcsaz5PCHtKG0IuTiqUvjT9U/WYMG2IOPE+AP+LtCB0xKUAAyA2Xbd2o2OG0NQXvTnvhL17D7EPtH9TRCIWwkRcGYGIQgYBABuqPuHXOQBc6pw80lBGwBQiiXhsBHQhkoprA6iM6acjhDQKu5YJZW6XeOI3XJdpvfsdTu52VfXEekD8owQiXGIubpSCbhDbLu8DwKEAd+A41SOdPpE4BS0viFOtvV2iKWqUgn5x/tmS70xR01GuDSCKc86/OCcLgTyyZ0ScDGNhFAktAJV4NFJ9YyaFiAWIE+9uVkkgBgLoig8DMWAa9ro9ynkUdlW5maZDCmB6clmz0k1HH4Cs1Ezbq2p2yEpUuBOKTSZZex00RUWIrltxuuK6EOGDSbGIOPZicpMx6fny650377qNRgBgWeVFQuA+6UjVgREhGIMlSqsPUQqIbZdOOIdZQmCv2axRnU1N1+TzJYsxOEaEV8ep7frPZ7Gd0FTEdP0ft0/kMNdg0eoAAAAASUVORK5CYII=';
|
6
|
-
const Modal = ({ visible, onClose, children, modalStyle, padding,
|
7
|
-
|
8
|
-
const cssAni = popupAniData !== null && popupAniData !== void 0 ? popupAniData : popupAni;
|
5
|
+
const Modal = ({ visible, onClose, children, modalStyle, padding, popup }) => {
|
6
|
+
var _a;
|
9
7
|
const [isShow, setIsShow] = useState(false);
|
10
8
|
const modalEleRef = useRef(null);
|
11
9
|
useEffect(() => {
|
@@ -20,28 +18,31 @@ const Modal = ({ visible, onClose, children, modalStyle, padding, popupAniData }
|
|
20
18
|
parentNode === null || parentNode === void 0 ? void 0 : parentNode.appendChild(modalEleRef.current);
|
21
19
|
}
|
22
20
|
}, []);
|
21
|
+
const isOpen = useMemo(() => {
|
22
|
+
return ((popup === null || popup === void 0 ? void 0 : popup.id) && (popup === null || popup === void 0 ? void 0 : popup.id) !== '') || visible;
|
23
|
+
}, [visible, popup]);
|
23
24
|
useEffect(() => {
|
24
|
-
if (
|
25
|
+
if (isOpen) {
|
25
26
|
setIsShow(true);
|
26
27
|
}
|
27
28
|
else {
|
28
29
|
setTimeout(() => {
|
29
30
|
setIsShow(false);
|
30
|
-
},
|
31
|
+
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
31
32
|
}
|
32
|
-
}, [
|
33
|
+
}, [isOpen, popup]);
|
33
34
|
if (!modalEleRef.current)
|
34
35
|
return null;
|
35
36
|
const handleClose = debounce(() => {
|
36
37
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
37
38
|
}, 300);
|
38
|
-
return ReactDOM.createPortal(React.createElement("div", { className: 'modal-bg', style: Object.assign({ display:
|
39
|
-
React.createElement("div", { className: `modal-container ${
|
39
|
+
return ReactDOM.createPortal(React.createElement(React.Fragment, null, isShow && (React.createElement("div", { className: 'modal-bg', style: Object.assign({ display: 'flex', backgroundColor: isOpen ? 'rgba(0, 0, 0, 0.7)' : 'rgba(0, 0, 0, 0)' }, modalStyle), onClick: handleClose },
|
40
|
+
React.createElement("div", { className: `modal-container ${isOpen ? 'modal-popIn' : 'modal-popOut'}`, style: { padding, animationDuration: ((_a = popup === null || popup === void 0 ? void 0 : popup.duration) !== null && _a !== void 0 ? _a : 0) / 1000 + 's' }, onClick: (e) => {
|
40
41
|
e.stopPropagation();
|
41
42
|
e.preventDefault();
|
42
43
|
} },
|
43
44
|
React.createElement("div", { onClick: onClose, className: 'modal-icon-wrapper' },
|
44
45
|
React.createElement("img", { src: closeIcon, alt: 'close', className: 'modal-icon' })),
|
45
|
-
children)), modalEleRef.current);
|
46
|
+
children)))), modalEleRef.current);
|
46
47
|
};
|
47
48
|
export default memo(Modal);
|
@@ -4,10 +4,10 @@ import { useEditor, useSxpDataSource } from '../../../../core/hooks';
|
|
4
4
|
import withBindDataSource from '../../../../core/hoc/withBindDataSource';
|
5
5
|
import { useEventReport } from '../../../../core/hooks/useEventReport';
|
6
6
|
const Popup = () => {
|
7
|
-
const { schema, resolver, popup
|
7
|
+
const { schema, resolver, popup } = useEditor();
|
8
8
|
const { setPopupDetailData, popupDetailData, bffEventReport } = useSxpDataSource();
|
9
9
|
const { productView } = useEventReport();
|
10
|
-
const [visible, setVisible] = useState(
|
10
|
+
const [visible, setVisible] = useState();
|
11
11
|
const curTimeRef = useRef(null);
|
12
12
|
useEffect(() => {
|
13
13
|
const initTime = () => {
|
@@ -20,33 +20,33 @@ const Popup = () => {
|
|
20
20
|
};
|
21
21
|
}, []);
|
22
22
|
useEffect(() => {
|
23
|
-
if (popup && popup !== '') {
|
23
|
+
if (popup && (popup === null || popup === void 0 ? void 0 : popup.id) && (popup === null || popup === void 0 ? void 0 : popup.id) !== '') {
|
24
24
|
curTimeRef.current = new Date();
|
25
|
-
setVisible(
|
25
|
+
setVisible(popup);
|
26
26
|
}
|
27
27
|
}, [popup]);
|
28
28
|
const handleClose = () => {
|
29
|
-
var _a, _b, _c;
|
30
|
-
if (!popup || popup === '' || !visible || new Date() - curTimeRef.current < (
|
29
|
+
var _a, _b, _c, _d;
|
30
|
+
if (!popup || (popup === null || popup === void 0 ? void 0 : popup.id) === '' || !visible || new Date() - curTimeRef.current < ((_a = popup === null || popup === void 0 ? void 0 : popup.duration) !== null && _a !== void 0 ? _a : 0)) {
|
31
31
|
return;
|
32
32
|
}
|
33
|
-
setVisible(
|
33
|
+
setVisible(Object.assign(Object.assign({}, popup), { id: '' }));
|
34
34
|
const data = popupDetailData;
|
35
|
-
const product = (
|
36
|
-
const cta = (
|
35
|
+
const product = (_b = data === null || data === void 0 ? void 0 : data.video) === null || _b === void 0 ? void 0 : _b.bindProduct;
|
36
|
+
const cta = (_d = (_c = data === null || data === void 0 ? void 0 : data.video) === null || _c === void 0 ? void 0 : _c.bindProduct) === null || _d === void 0 ? void 0 : _d.bindCta;
|
37
37
|
if (product && cta) {
|
38
38
|
productView(data, product, cta, curTimeRef.current);
|
39
39
|
}
|
40
40
|
setTimeout(() => {
|
41
41
|
window === null || window === void 0 ? void 0 : window.sxpPopup('');
|
42
42
|
setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(null);
|
43
|
-
},
|
43
|
+
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
44
44
|
};
|
45
45
|
const renderPopupDetail = useMemo(() => {
|
46
46
|
var _a, _b, _c;
|
47
47
|
return (_c = (_b = (_a = schema === null || schema === void 0 ? void 0 : schema.sxpPageConf) === null || _a === void 0 ? void 0 : _a.globalConfig) === null || _b === void 0 ? void 0 : _b.popupList) === null || _c === void 0 ? void 0 : _c.map((value, index) => {
|
48
48
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
49
|
-
if ((value === null || value === void 0 ? void 0 : value.id) === popup) {
|
49
|
+
if ((value === null || value === void 0 ? void 0 : value.id) === (popup === null || popup === void 0 ? void 0 : popup.id)) {
|
50
50
|
const t = resolver[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
|
51
51
|
const Component = withBindDataSource(t);
|
52
52
|
const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
|
@@ -57,6 +57,6 @@ const Popup = () => {
|
|
57
57
|
}
|
58
58
|
});
|
59
59
|
}, [schema, popup, resolver]);
|
60
|
-
return (React.createElement(Modal, {
|
60
|
+
return (React.createElement(Modal, { popup: visible, onClose: handleClose, padding: 0, modalStyle: { position: 'fixed' } }, renderPopupDetail));
|
61
61
|
};
|
62
62
|
export default Popup;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { __rest } from "tslib";
|
2
2
|
import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
3
|
-
import {
|
3
|
+
import { useSxpDataSource } from '../../../../core/hooks';
|
4
4
|
import './WaterfallList.less';
|
5
5
|
const WaterfallFlowItem = (props) => {
|
6
6
|
const { rec, style = {}, sizeChange = () => { }, unitWidth, index, showBorder, list, reportTagsView, textStyles, lineClamp } = props;
|
@@ -145,7 +145,6 @@ const WaterfallFlowItem = (props) => {
|
|
145
145
|
export default function WaterfallList(_a) {
|
146
146
|
var _b, _c, _d, _e, _f, _g, _h;
|
147
147
|
var { reportTagsView } = _a, props = __rest(_a, ["reportTagsView"]);
|
148
|
-
const { popupAni } = useEditor();
|
149
148
|
const { waterFallData, getRecommendVideos, loadingImage } = useSxpDataSource();
|
150
149
|
const scrollParent = useRef(null);
|
151
150
|
const [scrollTop, setScrollTop] = useState(0);
|
@@ -163,7 +162,7 @@ export default function WaterfallList(_a) {
|
|
163
162
|
const [frameInfo, setFrameInfoInfo] = useState({ width: 0 });
|
164
163
|
const rowsNum = useMemo(() => {
|
165
164
|
const width = frameInfo.width || 0;
|
166
|
-
if (width >=
|
165
|
+
if (width >= 1200) {
|
167
166
|
return 6;
|
168
167
|
}
|
169
168
|
else if (width >= 768 && width <= 1199) {
|
@@ -172,7 +171,7 @@ export default function WaterfallList(_a) {
|
|
172
171
|
else {
|
173
172
|
return 2;
|
174
173
|
}
|
175
|
-
}, [frameInfo
|
174
|
+
}, [frameInfo]);
|
176
175
|
const unitWidth = useMemo(() => {
|
177
176
|
return frameInfo.width / rowsNum - 2;
|
178
177
|
}, [rowsNum, frameInfo]);
|
@@ -66,7 +66,7 @@ const WaterFall = (props) => {
|
|
66
66
|
relatedContentId: (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.itemId,
|
67
67
|
position: rec === null || rec === void 0 ? void 0 : rec.position,
|
68
68
|
contentTags: JSON.stringify((_e = rec === null || rec === void 0 ? void 0 : rec.video) === null || _e === void 0 ? void 0 : _e.tags),
|
69
|
-
traceInfo:
|
69
|
+
traceInfo: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.traceInfo,
|
70
70
|
hashTags: JSON.stringify([recData === null || recData === void 0 ? void 0 : recData.hashTag]),
|
71
71
|
fromKName,
|
72
72
|
fromKPage: location === null || location === void 0 ? void 0 : location.href,
|
@@ -16,9 +16,12 @@ export interface IPageParams {
|
|
16
16
|
mp_rul?: string;
|
17
17
|
}
|
18
18
|
export type IPopupAniType = {
|
19
|
-
name
|
20
|
-
duration
|
19
|
+
name?: string;
|
20
|
+
duration?: number;
|
21
21
|
};
|
22
|
+
export type IPopupType = {
|
23
|
+
id: string;
|
24
|
+
} & IPopupAniType;
|
22
25
|
export interface IEditorContext {
|
23
26
|
resolver: Record<string, MaterialComponet>;
|
24
27
|
currentNode: any | null;
|
@@ -57,9 +60,8 @@ export interface IEditorContext {
|
|
57
60
|
setUndoStack?: React.Dispatch<React.SetStateAction<any[]>>;
|
58
61
|
setRedoStack?: React.Dispatch<React.SetStateAction<any[]>>;
|
59
62
|
getCurPageConf?: any;
|
60
|
-
popup:
|
61
|
-
setPopup: React.Dispatch<React.SetStateAction<
|
62
|
-
popupAni: IPopupAniType;
|
63
|
+
popup: IPopupType;
|
64
|
+
setPopup: React.Dispatch<React.SetStateAction<IPopupType>>;
|
63
65
|
}
|
64
66
|
export interface IEditorCoreProps {
|
65
67
|
resolver: Record<string, MaterialComponet>;
|
@@ -25,6 +25,11 @@ const item = {
|
|
25
25
|
pathArr: [0],
|
26
26
|
positionY: 0
|
27
27
|
};
|
28
|
+
const popupInit = {
|
29
|
+
id: '',
|
30
|
+
duration: 0,
|
31
|
+
name: 'none'
|
32
|
+
};
|
28
33
|
export const EditorContext = React.createContext({
|
29
34
|
resolver: {},
|
30
35
|
currentNode: null,
|
@@ -44,12 +49,8 @@ export const EditorContext = React.createContext({
|
|
44
49
|
prePiontData: [],
|
45
50
|
undoStack: [item],
|
46
51
|
redoStack: [],
|
47
|
-
popup:
|
48
|
-
setPopup: () => { }
|
49
|
-
popupAni: {
|
50
|
-
name: 'none',
|
51
|
-
duration: 0
|
52
|
-
}
|
52
|
+
popup: popupInit,
|
53
|
+
setPopup: () => { }
|
53
54
|
});
|
54
55
|
const EditorCore = forwardRef(({ children, resolver, isSsr, schema, enableDataSource = true, utmVal }, ref) => {
|
55
56
|
const [currentNode, setCurrentNode] = useState(null);
|
@@ -67,25 +68,10 @@ const EditorCore = forwardRef(({ children, resolver, isSsr, schema, enableDataSo
|
|
67
68
|
const [prePiontData, setPrePiontData] = useState([item]);
|
68
69
|
const [undoStack, setUndoStack] = useState([[item]]);
|
69
70
|
const [redoStack, setRedoStack] = useState([]);
|
70
|
-
const [popup, setPopup] = useState(
|
71
|
-
const [popupAni, setPopupAni] = useState({
|
72
|
-
name: 'none',
|
73
|
-
duration: 0
|
74
|
-
});
|
71
|
+
const [popup, setPopup] = useState(popupInit);
|
75
72
|
typeof window !== 'undefined' &&
|
76
73
|
(window.sxpPopup = (type, aniType) => {
|
77
|
-
|
78
|
-
setPopupAni(Object.assign(Object.assign({}, popupAni), aniType));
|
79
|
-
}
|
80
|
-
else {
|
81
|
-
setPopupAni({
|
82
|
-
name: 'none',
|
83
|
-
duration: 0
|
84
|
-
});
|
85
|
-
}
|
86
|
-
setTimeout(() => {
|
87
|
-
setPopup(type);
|
88
|
-
});
|
74
|
+
setPopup(Object.assign(Object.assign(Object.assign({}, popupInit), { id: type }), aniType));
|
89
75
|
});
|
90
76
|
typeof window !== 'undefined' &&
|
91
77
|
(window.getJointUtmLink = (url) => {
|
@@ -154,8 +140,7 @@ const EditorCore = forwardRef(({ children, resolver, isSsr, schema, enableDataSo
|
|
154
140
|
setUndoStack,
|
155
141
|
getCurPageConf,
|
156
142
|
popup,
|
157
|
-
setPopup
|
158
|
-
popupAni
|
143
|
+
setPopup
|
159
144
|
} },
|
160
145
|
React.createElement(DataSourceProvider, { isSsr: isSsr, enable: enableDataSource }, children)));
|
161
146
|
});
|
@@ -20,23 +20,25 @@ export function useEventReport() {
|
|
20
20
|
else if (data === null || data === void 0 ? void 0 : data.product) {
|
21
21
|
fromKName = 'productPage';
|
22
22
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
23
|
+
if (product === null || product === void 0 ? void 0 : product.price) {
|
24
|
+
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
25
|
+
eventInfo: {
|
26
|
+
eventSubject: 'jumpToWeb',
|
27
|
+
eventDescription: 'User jumped to website',
|
28
|
+
productId: (_h = product === null || product === void 0 ? void 0 : product.itemId) !== null && _h !== void 0 ? _h : '',
|
29
|
+
productName: (_j = product === null || product === void 0 ? void 0 : product.title) !== null && _j !== void 0 ? _j : '',
|
30
|
+
price: (product === null || product === void 0 ? void 0 : product.price) ? (product === null || product === void 0 ? void 0 : product.price) + '' : '0',
|
31
|
+
productCollection: (_k = product === null || product === void 0 ? void 0 : product.collection) !== null && _k !== void 0 ? _k : '',
|
32
|
+
fromKName,
|
33
|
+
fromKPage: location === null || location === void 0 ? void 0 : location.href,
|
34
|
+
contentTags: (product === null || product === void 0 ? void 0 : product.tags) ? JSON.stringify(product === null || product === void 0 ? void 0 : product.tags) : '',
|
35
|
+
position: (data === null || data === void 0 ? void 0 : data.position) + '',
|
36
|
+
relatedContentId: (_m = (_l = data === null || data === void 0 ? void 0 : data.video) === null || _l === void 0 ? void 0 : _l.itemId) !== null && _m !== void 0 ? _m : '',
|
37
|
+
relatedCtatId: (_o = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _o !== void 0 ? _o : '',
|
38
|
+
traceInfo: (_p = product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _p !== void 0 ? _p : ''
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
40
42
|
}, [bffEventReport, popupDetailData, isFromHashtag]);
|
41
43
|
const productView = useCallback((data, product, cta, viewTime) => {
|
42
44
|
var _a, _b, _c, _d;
|
@@ -47,24 +49,26 @@ export function useEventReport() {
|
|
47
49
|
else if (data === null || data === void 0 ? void 0 : data.product) {
|
48
50
|
fromKName = 'productPage';
|
49
51
|
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
52
|
+
if (product === null || product === void 0 ? void 0 : product.price) {
|
53
|
+
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
54
|
+
eventInfo: {
|
55
|
+
productId: product === null || product === void 0 ? void 0 : product.itemId,
|
56
|
+
productName: product === null || product === void 0 ? void 0 : product.title,
|
57
|
+
price: (product === null || product === void 0 ? void 0 : product.price) + '',
|
58
|
+
productCollection: product === null || product === void 0 ? void 0 : product.collection,
|
59
|
+
fromKName,
|
60
|
+
fromKPage: location === null || location === void 0 ? void 0 : location.href,
|
61
|
+
contentTags: JSON.stringify(product === null || product === void 0 ? void 0 : product.tags),
|
62
|
+
position: (data === null || data === void 0 ? void 0 : data.position) + '',
|
63
|
+
relatedContentId: (_d = data === null || data === void 0 ? void 0 : data.video) === null || _d === void 0 ? void 0 : _d.itemId,
|
64
|
+
relatedCtatId: cta === null || cta === void 0 ? void 0 : cta.itemId,
|
65
|
+
traceInfo: product === null || product === void 0 ? void 0 : product.traceInfo,
|
66
|
+
timeOnSite: Math.floor((new Date() - viewTime) / 1000) + '',
|
67
|
+
eventSubject: 'productView',
|
68
|
+
eventDescription: 'User browsed the product'
|
69
|
+
}
|
70
|
+
});
|
71
|
+
}
|
68
72
|
}, [bffEventReport, popupDetailData]);
|
69
73
|
return {
|
70
74
|
jumpToWeb,
|
@@ -3,11 +3,10 @@ import { css } from '@emotion/css';
|
|
3
3
|
import React, { memo, useMemo, useRef, useState } from 'react';
|
4
4
|
import { BetaSchemaForm } from '@ant-design/pro-components';
|
5
5
|
import { cloneDeep, debounce } from 'lodash';
|
6
|
-
import {
|
6
|
+
import { useSxpDataSource } from '../../../../core/hooks';
|
7
7
|
import './index.less';
|
8
8
|
const AppointForm = (_a) => {
|
9
9
|
var { columns, style, title, textStyle, submitBgColor, submitColor, submitText, layoutType, onClick } = _a, props = __rest(_a, ["columns", "style", "title", "textStyle", "submitBgColor", "submitColor", "submitText", "layoutType", "onClick"]);
|
10
|
-
const { setPopup } = useEditor();
|
11
10
|
const { submitForm } = useSxpDataSource();
|
12
11
|
const formRef = useRef();
|
13
12
|
const [loading, setLoading] = useState(false);
|
@@ -3,11 +3,9 @@ import { css } from '@emotion/css';
|
|
3
3
|
import React, { memo } from 'react';
|
4
4
|
import success from './success.png';
|
5
5
|
import { getMediaValueByMode } from '../../../../core/utils/materials';
|
6
|
-
import { useEditor } from '../../../../core/hooks';
|
7
6
|
import './index.less';
|
8
7
|
const Prompt = (_a) => {
|
9
8
|
var { content, btnText, style, icon, onClick } = _a, props = __rest(_a, ["content", "btnText", "style", "icon", "onClick"]);
|
10
|
-
const { setPopup } = useEditor();
|
11
9
|
const iconSrc = typeof icon === 'string' ? icon : getMediaValueByMode(icon);
|
12
10
|
const handleOk = () => {
|
13
11
|
window === null || window === void 0 ? void 0 : window.sxpPopup('');
|
@@ -13,26 +13,25 @@ const MultiCommodity = (_a) => {
|
|
13
13
|
var { content, style, bgImg, recData, onClick, bottom_image, ctaTempStyles, isExternalLink } = _a, props = __rest(_a, ["content", "style", "bgImg", "recData", "onClick", "bottom_image", "ctaTempStyles", "isExternalLink"]);
|
14
14
|
const { sxpParameter } = useSxpDataSource();
|
15
15
|
const { ctaEvent, setPopupDetailData } = useSxpDataSource();
|
16
|
-
const {
|
16
|
+
const { popup } = useEditor();
|
17
17
|
const [products, setProducts] = useState((_c = (_b = recData === null || recData === void 0 ? void 0 : recData.video) === null || _b === void 0 ? void 0 : _b.bindProducts) !== null && _c !== void 0 ? _c : [1, 2]);
|
18
18
|
const { jumpToWeb } = useEventReport();
|
19
19
|
const handleClick = throttle((item) => {
|
20
|
-
var _a;
|
21
20
|
ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({
|
22
21
|
eventSubject: 'clickCta',
|
23
22
|
eventDescription: 'User clicked the CTA'
|
24
23
|
}, recData, item);
|
25
24
|
setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, recData), { video: Object.assign(Object.assign({}, recData === null || recData === void 0 ? void 0 : recData.video), { bindProduct: item }) }));
|
26
25
|
if (isExternalLink) {
|
27
|
-
if (
|
26
|
+
if (item === null || item === void 0 ? void 0 : item.link) {
|
28
27
|
jumpToWeb(recData, item, item.bindCta);
|
29
|
-
window.location.href = item.
|
28
|
+
window.location.href = item.link;
|
30
29
|
}
|
31
30
|
}
|
32
31
|
else {
|
33
32
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
34
33
|
}
|
35
|
-
},
|
34
|
+
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
36
35
|
return (React.createElement(Scroll, { isPadding: !!recData }, products === null || products === void 0 ? void 0 : products.map((item) => {
|
37
36
|
var _a, _b, _c, _d, _e, _f;
|
38
37
|
return (React.createElement(SwiperSlide, Object.assign({ hidden: recData && !(item === null || item === void 0 ? void 0 : item.bindCta), key: item.itemId, className: css(Object.assign(Object.assign({}, style), { display: 'flex', flexShrink: 0, marginLeft: 0, marginRight: '8px' })) }, props, { onClick: () => handleClick(item) }),
|
@@ -12,26 +12,25 @@ const MultiCommodityDiro = (_a) => {
|
|
12
12
|
var _b, _c;
|
13
13
|
var { content, style, bgImg, recData, onClick, bottom_image, ctaTempStyles, isExternalLink } = _a, props = __rest(_a, ["content", "style", "bgImg", "recData", "onClick", "bottom_image", "ctaTempStyles", "isExternalLink"]);
|
14
14
|
const { ctaEvent, setPopupDetailData, sxpParameter } = useSxpDataSource();
|
15
|
-
const {
|
15
|
+
const { popup } = useEditor();
|
16
16
|
const { jumpToWeb } = useEventReport();
|
17
17
|
const [products, setProducts] = useState((_c = (_b = recData === null || recData === void 0 ? void 0 : recData.video) === null || _b === void 0 ? void 0 : _b.bindProducts) !== null && _c !== void 0 ? _c : [1, 2]);
|
18
18
|
const handleClick = throttle((item) => {
|
19
|
-
var _a;
|
20
19
|
ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({
|
21
20
|
eventSubject: 'clickCta',
|
22
21
|
eventDescription: 'User clicked the CTA'
|
23
22
|
}, recData, item);
|
24
23
|
setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, recData), { video: Object.assign(Object.assign({}, recData === null || recData === void 0 ? void 0 : recData.video), { bindProduct: item }) }));
|
25
24
|
if (isExternalLink) {
|
26
|
-
if (
|
25
|
+
if (item === null || item === void 0 ? void 0 : item.link) {
|
27
26
|
jumpToWeb(recData, item, item.bindCta);
|
28
|
-
window.location.href = item.
|
27
|
+
window.location.href = item.link;
|
29
28
|
}
|
30
29
|
}
|
31
30
|
else {
|
32
31
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
33
32
|
}
|
34
|
-
},
|
33
|
+
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
35
34
|
return (React.createElement(Scroll, { isPadding: !!recData }, products === null || products === void 0 ? void 0 : products.map((item) => {
|
36
35
|
var _a, _b, _c, _d, _e, _f;
|
37
36
|
return (React.createElement(SwiperSlide, Object.assign({ hidden: recData && !(item === null || item === void 0 ? void 0 : item.bindCta), key: item === null || item === void 0 ? void 0 : item.itemId, className: css(Object.assign(Object.assign({}, style), { display: 'flex', flexShrink: 0, marginLeft: 0, marginRight: '8px' })) }, props, { onClick: () => handleClick(item) }),
|
@@ -12,26 +12,25 @@ const MultiCommodityDiroNew = (_a) => {
|
|
12
12
|
var _b, _c;
|
13
13
|
var { content, style, bgImg, recData, onClick, bottom_image, ctaTempStyles, isExternalLink } = _a, props = __rest(_a, ["content", "style", "bgImg", "recData", "onClick", "bottom_image", "ctaTempStyles", "isExternalLink"]);
|
14
14
|
const { ctaEvent, setPopupDetailData, sxpParameter } = useSxpDataSource();
|
15
|
-
const {
|
15
|
+
const { popup } = useEditor();
|
16
16
|
const { jumpToWeb } = useEventReport();
|
17
17
|
const [products, setProducts] = useState((_c = (_b = recData === null || recData === void 0 ? void 0 : recData.video) === null || _b === void 0 ? void 0 : _b.bindProducts) !== null && _c !== void 0 ? _c : [1, 2]);
|
18
18
|
const handleClick = throttle((item) => {
|
19
|
-
var _a;
|
20
19
|
ctaEvent === null || ctaEvent === void 0 ? void 0 : ctaEvent({
|
21
20
|
eventSubject: 'clickCta',
|
22
21
|
eventDescription: 'User clicked the CTA'
|
23
22
|
}, recData, item);
|
24
23
|
setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, recData), { video: Object.assign(Object.assign({}, recData === null || recData === void 0 ? void 0 : recData.video), { bindProduct: item }) }));
|
25
24
|
if (isExternalLink) {
|
26
|
-
if (
|
25
|
+
if (item === null || item === void 0 ? void 0 : item.link) {
|
27
26
|
jumpToWeb(recData, item, item.bindCta);
|
28
|
-
window.location.href = item.
|
27
|
+
window.location.href = item.link;
|
29
28
|
}
|
30
29
|
}
|
31
30
|
else {
|
32
31
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
33
32
|
}
|
34
|
-
},
|
33
|
+
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
35
34
|
return (React.createElement(Scroll, { isPadding: !!recData }, products === null || products === void 0 ? void 0 : products.map((item) => {
|
36
35
|
var _a, _b, _c, _d, _e, _f;
|
37
36
|
return (React.createElement(SwiperSlide, Object.assign({ hidden: recData && !(item === null || item === void 0 ? void 0 : item.bindCta), key: item === null || item === void 0 ? void 0 : item.itemId, className: css(Object.assign(Object.assign({}, style), { display: 'flex', flexShrink: 0, marginLeft: 0, marginRight: '8px' })) }, props, { onClick: () => handleClick(item) }),
|
@@ -8,7 +8,7 @@ const EventProvider = (_a) => {
|
|
8
8
|
var { rec, children, className, onClick, style, isExternalLink = false } = _a, props = __rest(_a, ["rec", "children", "className", "onClick", "style", "isExternalLink"]);
|
9
9
|
const ref = useRef(null);
|
10
10
|
const isOnScreen = useOnScreen(ref);
|
11
|
-
const {
|
11
|
+
const { popup } = useEditor();
|
12
12
|
const { setPopupDetailData, ctaEvent } = useSxpDataSource();
|
13
13
|
const { jumpToWeb } = useEventReport();
|
14
14
|
useEffect(() => {
|
@@ -30,17 +30,17 @@ const EventProvider = (_a) => {
|
|
30
30
|
}, rec, item);
|
31
31
|
setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(rec);
|
32
32
|
if (isExternalLink) {
|
33
|
-
if ((_d = (_c = rec === null || rec === void 0 ? void 0 : rec.video) === null || _c === void 0 ? void 0 : _c.
|
33
|
+
if ((_d = (_c = rec === null || rec === void 0 ? void 0 : rec.video) === null || _c === void 0 ? void 0 : _c.bindProduct) === null || _d === void 0 ? void 0 : _d.link) {
|
34
34
|
const cta = (_e = rec === null || rec === void 0 ? void 0 : rec.video) === null || _e === void 0 ? void 0 : _e.bindCta;
|
35
35
|
const product = (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.bindProduct;
|
36
36
|
jumpToWeb(rec, product, cta);
|
37
|
-
window.location.href = (_h = (_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.
|
37
|
+
window.location.href = (_h = (_g = rec === null || rec === void 0 ? void 0 : rec.video) === null || _g === void 0 ? void 0 : _g.bindProduct) === null || _h === void 0 ? void 0 : _h.link;
|
38
38
|
}
|
39
39
|
}
|
40
40
|
else {
|
41
41
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
42
42
|
}
|
43
|
-
},
|
43
|
+
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
44
44
|
return (React.createElement("div", { ref: ref, className: className, style: style, onClick: handleClick }, children));
|
45
45
|
};
|
46
46
|
export default memo(EventProvider);
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import React, { CSSProperties } from 'react';
|
2
|
-
import {
|
2
|
+
import { IPopupType } from '../../../../core/context/EditorContext';
|
3
3
|
interface IModalProps {
|
4
4
|
visible?: boolean;
|
5
|
+
popup?: IPopupType;
|
5
6
|
padding?: number | string;
|
6
7
|
modalStyle?: CSSProperties;
|
7
|
-
popupAniData?: IPopupAniType;
|
8
8
|
onClose?: () => void;
|
9
9
|
}
|
10
10
|
declare const _default: React.NamedExoticComponent<React.PropsWithChildren<IModalProps>>;
|
@@ -4,11 +4,9 @@ const tslib_1 = require("tslib");
|
|
4
4
|
const lodash_1 = require("lodash");
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
6
6
|
const ReactDOM = tslib_1.__importStar(require("react-dom"));
|
7
|
-
const hooks_1 = require("../../../../core/hooks");
|
8
7
|
const closeIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAjhJREFUWEfFlztOw0AQhmeWiJ4CCmpQ5DiRQsIJyAWg5A0lR0AIChDiCJS8ER0cADgBeRSxt4CCDgkaKiq8i+zYeWx2413HEWmiJJv9v535Z2aN8M8vFPT9z3zETD0aAUChUJjwvPFHAJhBhB3Hqd6OAsK2yyucwykAvP38eJX398Z3AJDLlVYR8ToU9Rhj25TWr9KEsKy5dULIGQCMtfZly45TvwsAstm56UwG6wA4FUFwzrdctxZBDcWSy5XWEPG8I84/GcMipdWPtgcsaz5PCHtKG0IuTiqUvjT9U/WYMG2IOPE+AP+LtCB0xKUAAyA2Xbd2o2OG0NQXvTnvhL17D7EPtH9TRCIWwkRcGYGIQgYBABuqPuHXOQBc6pw80lBGwBQiiXhsBHQhkoprA6iM6acjhDQKu5YJZW6XeOI3XJdpvfsdTu52VfXEekD8owQiXGIubpSCbhDbLu8DwKEAd+A41SOdPpE4BS0viFOtvV2iKWqUgn5x/tmS70xR01GuDSCKc86/OCcLgTyyZ0ScDGNhFAktAJV4NFJ9YyaFiAWIE+9uVkkgBgLoig8DMWAa9ro9ynkUdlW5maZDCmB6clmz0k1HH4Cs1Ezbq2p2yEpUuBOKTSZZex00RUWIrltxuuK6EOGDSbGIOPZicpMx6fny650377qNRgBgWeVFQuA+6UjVgREhGIMlSqsPUQqIbZdOOIdZQmCv2axRnU1N1+TzJYsxOEaEV8ep7frPZ7Gd0FTEdP0ft0/kMNdg0eoAAAAASUVORK5CYII=';
|
9
|
-
const Modal = ({ visible, onClose, children, modalStyle, padding,
|
10
|
-
|
11
|
-
const cssAni = popupAniData !== null && popupAniData !== void 0 ? popupAniData : popupAni;
|
8
|
+
const Modal = ({ visible, onClose, children, modalStyle, padding, popup }) => {
|
9
|
+
var _a;
|
12
10
|
const [isShow, setIsShow] = (0, react_1.useState)(false);
|
13
11
|
const modalEleRef = (0, react_1.useRef)(null);
|
14
12
|
(0, react_1.useEffect)(() => {
|
@@ -23,28 +21,31 @@ const Modal = ({ visible, onClose, children, modalStyle, padding, popupAniData }
|
|
23
21
|
parentNode === null || parentNode === void 0 ? void 0 : parentNode.appendChild(modalEleRef.current);
|
24
22
|
}
|
25
23
|
}, []);
|
24
|
+
const isOpen = (0, react_1.useMemo)(() => {
|
25
|
+
return ((popup === null || popup === void 0 ? void 0 : popup.id) && (popup === null || popup === void 0 ? void 0 : popup.id) !== '') || visible;
|
26
|
+
}, [visible, popup]);
|
26
27
|
(0, react_1.useEffect)(() => {
|
27
|
-
if (
|
28
|
+
if (isOpen) {
|
28
29
|
setIsShow(true);
|
29
30
|
}
|
30
31
|
else {
|
31
32
|
setTimeout(() => {
|
32
33
|
setIsShow(false);
|
33
|
-
},
|
34
|
+
}, popup === null || popup === void 0 ? void 0 : popup.duration);
|
34
35
|
}
|
35
|
-
}, [
|
36
|
+
}, [isOpen, popup]);
|
36
37
|
if (!modalEleRef.current)
|
37
38
|
return null;
|
38
39
|
const handleClose = (0, lodash_1.debounce)(() => {
|
39
40
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
40
41
|
}, 300);
|
41
|
-
return ReactDOM.createPortal(react_1.default.createElement("div", { className: 'modal-bg', style: Object.assign({ display:
|
42
|
-
react_1.default.createElement("div", { className: `modal-container ${
|
42
|
+
return ReactDOM.createPortal(react_1.default.createElement(react_1.default.Fragment, null, isShow && (react_1.default.createElement("div", { className: 'modal-bg', style: Object.assign({ display: 'flex', backgroundColor: isOpen ? 'rgba(0, 0, 0, 0.7)' : 'rgba(0, 0, 0, 0)' }, modalStyle), onClick: handleClose },
|
43
|
+
react_1.default.createElement("div", { className: `modal-container ${isOpen ? 'modal-popIn' : 'modal-popOut'}`, style: { padding, animationDuration: ((_a = popup === null || popup === void 0 ? void 0 : popup.duration) !== null && _a !== void 0 ? _a : 0) / 1000 + 's' }, onClick: (e) => {
|
43
44
|
e.stopPropagation();
|
44
45
|
e.preventDefault();
|
45
46
|
} },
|
46
47
|
react_1.default.createElement("div", { onClick: onClose, className: 'modal-icon-wrapper' },
|
47
48
|
react_1.default.createElement("img", { src: closeIcon, alt: 'close', className: 'modal-icon' })),
|
48
|
-
children)), modalEleRef.current);
|
49
|
+
children)))), modalEleRef.current);
|
49
50
|
};
|
50
51
|
exports.default = (0, react_1.memo)(Modal);
|