pb-sxp-ui 1.0.5 → 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.
Files changed (45) hide show
  1. package/dist/index.cjs +85 -96
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +85 -96
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.cjs +3 -3
  6. package/dist/index.min.cjs.map +1 -1
  7. package/dist/index.min.js +3 -3
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/pb-ui.js +85 -96
  10. package/dist/pb-ui.js.map +1 -1
  11. package/dist/pb-ui.min.js +3 -3
  12. package/dist/pb-ui.min.js.map +1 -1
  13. package/es/core/components/SxpPageRender/Modal/index.d.ts +2 -2
  14. package/es/core/components/SxpPageRender/Modal/index.js +12 -11
  15. package/es/core/components/SxpPageRender/Popup/index.js +12 -12
  16. package/es/core/components/SxpPageRender/WaterFall/WaterfallList.js +3 -4
  17. package/es/core/components/SxpPageRender/WaterFall/index.js +1 -1
  18. package/es/core/context/EditorContext.d.ts +7 -5
  19. package/es/core/context/EditorContext.js +10 -25
  20. package/es/core/hooks/useEventReport.js +39 -35
  21. package/es/materials/sxp/popup/AppointForm/index.js +1 -2
  22. package/es/materials/sxp/popup/Prompt/index.js +0 -2
  23. package/es/materials/sxp/template/MultiCommodity/index.js +2 -2
  24. package/es/materials/sxp/template/MultiCommodityDiro/index.js +2 -2
  25. package/es/materials/sxp/template/MultiCommodityDiroNew/index.js +2 -2
  26. package/es/materials/sxp/template/components/EventProvider.js +2 -2
  27. package/lib/core/components/SxpPageRender/Modal/index.d.ts +2 -2
  28. package/lib/core/components/SxpPageRender/Modal/index.js +11 -10
  29. package/lib/core/components/SxpPageRender/Popup/index.js +12 -12
  30. package/lib/core/components/SxpPageRender/WaterFall/WaterfallList.js +2 -3
  31. package/lib/core/components/SxpPageRender/WaterFall/index.js +1 -1
  32. package/lib/core/context/EditorContext.d.ts +7 -5
  33. package/lib/core/context/EditorContext.js +10 -25
  34. package/lib/core/hooks/useEventReport.js +39 -35
  35. package/lib/materials/sxp/popup/AppointForm/index.js +0 -1
  36. package/lib/materials/sxp/popup/Prompt/index.js +0 -2
  37. package/lib/materials/sxp/template/MultiCommodity/index.js +2 -2
  38. package/lib/materials/sxp/template/MultiCommodityDiro/index.js +2 -2
  39. package/lib/materials/sxp/template/MultiCommodityDiroNew/index.js +2 -2
  40. package/lib/materials/sxp/template/components/EventProvider.js +2 -2
  41. package/package.json +1 -1
  42. package/es/core/components/SxpPageRender/ProductInfo/index.d.ts +0 -14
  43. package/es/core/components/SxpPageRender/ProductInfo/index.js +0 -55
  44. package/lib/core/components/SxpPageRender/ProductInfo/index.d.ts +0 -14
  45. package/lib/core/components/SxpPageRender/ProductInfo/index.js +0 -58
@@ -1,10 +1,10 @@
1
1
  import React, { CSSProperties } from 'react';
2
- import { IPopupAniType } from '../../../../core/context/EditorContext';
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, popupAniData }) => {
7
- const { popupAni } = useEditor();
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 (visible) {
25
+ if (isOpen) {
25
26
  setIsShow(true);
26
27
  }
27
28
  else {
28
29
  setTimeout(() => {
29
30
  setIsShow(false);
30
- }, cssAni === null || cssAni === void 0 ? void 0 : cssAni.duration);
31
+ }, popup === null || popup === void 0 ? void 0 : popup.duration);
31
32
  }
32
- }, [visible, cssAni]);
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: isShow ? 'flex' : 'none', backgroundColor: visible ? 'rgba(0, 0, 0, 0.7)' : 'rgba(0, 0, 0, 0)' }, modalStyle), onClick: handleClose },
39
- React.createElement("div", { className: `modal-container ${visible ? 'modal-popIn' : 'modal-popOut'}`, style: { padding, animationDuration: (cssAni === null || cssAni === void 0 ? void 0 : cssAni.duration) / 1000 + 's' }, onClick: (e) => {
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, popupAni } = useEditor();
7
+ const { schema, resolver, popup } = useEditor();
8
8
  const { setPopupDetailData, popupDetailData, bffEventReport } = useSxpDataSource();
9
9
  const { productView } = useEventReport();
10
- const [visible, setVisible] = useState(false);
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(true);
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 < (popupAni === null || popupAni === void 0 ? void 0 : popupAni.duration)) {
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(false);
33
+ setVisible(Object.assign(Object.assign({}, popup), { id: '' }));
34
34
  const data = popupDetailData;
35
- const product = (_a = data === null || data === void 0 ? void 0 : data.video) === null || _a === void 0 ? void 0 : _a.bindProduct;
36
- const cta = (_c = (_b = data === null || data === void 0 ? void 0 : data.video) === null || _b === void 0 ? void 0 : _b.bindProduct) === null || _c === void 0 ? void 0 : _c.bindCta;
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
- }, popupAni === null || popupAni === void 0 ? void 0 : popupAni.duration);
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, { visible: !!visible, onClose: handleClose, padding: 0, modalStyle: { position: 'fixed' } }, renderPopupDetail));
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 { useEditor, useSxpDataSource } from '../../../../core/hooks';
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 >= (popupAni === null || popupAni === void 0 ? void 0 : popupAni.duration)) {
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, popupAni]);
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: JSON.stringify((_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.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: string;
20
- duration: number;
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: string;
61
- setPopup: React.Dispatch<React.SetStateAction<string>>;
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
- if (aniType && (aniType === null || aniType === void 0 ? void 0 : aniType.name) !== 'none') {
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
- bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
24
- eventInfo: {
25
- eventSubject: 'jumpToWeb',
26
- eventDescription: 'User jumped to website',
27
- productId: (_h = product === null || product === void 0 ? void 0 : product.itemId) !== null && _h !== void 0 ? _h : '',
28
- productName: (_j = product === null || product === void 0 ? void 0 : product.title) !== null && _j !== void 0 ? _j : '',
29
- price: (product === null || product === void 0 ? void 0 : product.price) ? (product === null || product === void 0 ? void 0 : product.price) + '' : '0',
30
- productCollection: (_k = product === null || product === void 0 ? void 0 : product.collection) !== null && _k !== void 0 ? _k : '',
31
- fromKName,
32
- fromKPage: location === null || location === void 0 ? void 0 : location.href,
33
- contentTags: (product === null || product === void 0 ? void 0 : product.tags) ? JSON.stringify(product === null || product === void 0 ? void 0 : product.tags) : '',
34
- position: (data === null || data === void 0 ? void 0 : data.position) + '',
35
- 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 : '',
36
- relatedCtatId: (_o = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _o !== void 0 ? _o : '',
37
- traceInfo: (_p = product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _p !== void 0 ? _p : ''
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
- bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
51
- eventInfo: {
52
- productId: product === null || product === void 0 ? void 0 : product.itemId,
53
- productName: product === null || product === void 0 ? void 0 : product.title,
54
- price: (product === null || product === void 0 ? void 0 : product.price) + '',
55
- productCollection: product === null || product === void 0 ? void 0 : product.collection,
56
- fromKName,
57
- fromKPage: location === null || location === void 0 ? void 0 : location.href,
58
- contentTags: JSON.stringify(product === null || product === void 0 ? void 0 : product.tags),
59
- position: (data === null || data === void 0 ? void 0 : data.position) + '',
60
- relatedContentId: (_d = data === null || data === void 0 ? void 0 : data.video) === null || _d === void 0 ? void 0 : _d.itemId,
61
- relatedCtatId: cta === null || cta === void 0 ? void 0 : cta.itemId,
62
- traceInfo: product === null || product === void 0 ? void 0 : product.traceInfo,
63
- timeOnSite: Math.floor((new Date() - viewTime) / 1000) + '',
64
- eventSubject: 'productView',
65
- eventDescription: 'User browsed the product'
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 { useEditor, useSxpDataSource } from '../../../../core/hooks';
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,7 +13,7 @@ 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 { popupAni } = useEditor();
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) => {
@@ -31,7 +31,7 @@ const MultiCommodity = (_a) => {
31
31
  else {
32
32
  onClick === null || onClick === void 0 ? void 0 : onClick();
33
33
  }
34
- }, popupAni === null || popupAni === void 0 ? void 0 : popupAni.duration);
34
+ }, popup === null || popup === void 0 ? void 0 : popup.duration);
35
35
  return (React.createElement(Scroll, { isPadding: !!recData }, products === null || products === void 0 ? void 0 : products.map((item) => {
36
36
  var _a, _b, _c, _d, _e, _f;
37
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,7 +12,7 @@ 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 { popupAni } = useEditor();
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) => {
@@ -30,7 +30,7 @@ const MultiCommodityDiro = (_a) => {
30
30
  else {
31
31
  onClick === null || onClick === void 0 ? void 0 : onClick();
32
32
  }
33
- }, popupAni === null || popupAni === void 0 ? void 0 : popupAni.duration);
33
+ }, popup === null || popup === void 0 ? void 0 : popup.duration);
34
34
  return (React.createElement(Scroll, { isPadding: !!recData }, products === null || products === void 0 ? void 0 : products.map((item) => {
35
35
  var _a, _b, _c, _d, _e, _f;
36
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,7 +12,7 @@ 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 { popupAni } = useEditor();
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) => {
@@ -30,7 +30,7 @@ const MultiCommodityDiroNew = (_a) => {
30
30
  else {
31
31
  onClick === null || onClick === void 0 ? void 0 : onClick();
32
32
  }
33
- }, popupAni === null || popupAni === void 0 ? void 0 : popupAni.duration);
33
+ }, popup === null || popup === void 0 ? void 0 : popup.duration);
34
34
  return (React.createElement(Scroll, { isPadding: !!recData }, products === null || products === void 0 ? void 0 : products.map((item) => {
35
35
  var _a, _b, _c, _d, _e, _f;
36
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 { popupAni } = useEditor();
11
+ const { popup } = useEditor();
12
12
  const { setPopupDetailData, ctaEvent } = useSxpDataSource();
13
13
  const { jumpToWeb } = useEventReport();
14
14
  useEffect(() => {
@@ -40,7 +40,7 @@ const EventProvider = (_a) => {
40
40
  else {
41
41
  onClick === null || onClick === void 0 ? void 0 : onClick();
42
42
  }
43
- }, popupAni === null || popupAni === void 0 ? void 0 : popupAni.duration);
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 { IPopupAniType } from '../../../../core/context/EditorContext';
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, popupAniData }) => {
10
- const { popupAni } = (0, hooks_1.useEditor)();
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 (visible) {
28
+ if (isOpen) {
28
29
  setIsShow(true);
29
30
  }
30
31
  else {
31
32
  setTimeout(() => {
32
33
  setIsShow(false);
33
- }, cssAni === null || cssAni === void 0 ? void 0 : cssAni.duration);
34
+ }, popup === null || popup === void 0 ? void 0 : popup.duration);
34
35
  }
35
- }, [visible, cssAni]);
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: isShow ? 'flex' : 'none', backgroundColor: visible ? 'rgba(0, 0, 0, 0.7)' : 'rgba(0, 0, 0, 0)' }, modalStyle), onClick: handleClose },
42
- react_1.default.createElement("div", { className: `modal-container ${visible ? 'modal-popIn' : 'modal-popOut'}`, style: { padding, animationDuration: (cssAni === null || cssAni === void 0 ? void 0 : cssAni.duration) / 1000 + 's' }, onClick: (e) => {
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);
@@ -7,10 +7,10 @@ const hooks_1 = require("../../../../core/hooks");
7
7
  const withBindDataSource_1 = tslib_1.__importDefault(require("../../../../core/hoc/withBindDataSource"));
8
8
  const useEventReport_1 = require("../../../../core/hooks/useEventReport");
9
9
  const Popup = () => {
10
- const { schema, resolver, popup, popupAni } = (0, hooks_1.useEditor)();
10
+ const { schema, resolver, popup } = (0, hooks_1.useEditor)();
11
11
  const { setPopupDetailData, popupDetailData, bffEventReport } = (0, hooks_1.useSxpDataSource)();
12
12
  const { productView } = (0, useEventReport_1.useEventReport)();
13
- const [visible, setVisible] = (0, react_1.useState)(false);
13
+ const [visible, setVisible] = (0, react_1.useState)();
14
14
  const curTimeRef = (0, react_1.useRef)(null);
15
15
  (0, react_1.useEffect)(() => {
16
16
  const initTime = () => {
@@ -23,33 +23,33 @@ const Popup = () => {
23
23
  };
24
24
  }, []);
25
25
  (0, react_1.useEffect)(() => {
26
- if (popup && popup !== '') {
26
+ if (popup && (popup === null || popup === void 0 ? void 0 : popup.id) && (popup === null || popup === void 0 ? void 0 : popup.id) !== '') {
27
27
  curTimeRef.current = new Date();
28
- setVisible(true);
28
+ setVisible(popup);
29
29
  }
30
30
  }, [popup]);
31
31
  const handleClose = () => {
32
- var _a, _b, _c;
33
- if (!popup || popup === '' || !visible || new Date() - curTimeRef.current < (popupAni === null || popupAni === void 0 ? void 0 : popupAni.duration)) {
32
+ var _a, _b, _c, _d;
33
+ 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)) {
34
34
  return;
35
35
  }
36
- setVisible(false);
36
+ setVisible(Object.assign(Object.assign({}, popup), { id: '' }));
37
37
  const data = popupDetailData;
38
- const product = (_a = data === null || data === void 0 ? void 0 : data.video) === null || _a === void 0 ? void 0 : _a.bindProduct;
39
- const cta = (_c = (_b = data === null || data === void 0 ? void 0 : data.video) === null || _b === void 0 ? void 0 : _b.bindProduct) === null || _c === void 0 ? void 0 : _c.bindCta;
38
+ const product = (_b = data === null || data === void 0 ? void 0 : data.video) === null || _b === void 0 ? void 0 : _b.bindProduct;
39
+ 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;
40
40
  if (product && cta) {
41
41
  productView(data, product, cta, curTimeRef.current);
42
42
  }
43
43
  setTimeout(() => {
44
44
  window === null || window === void 0 ? void 0 : window.sxpPopup('');
45
45
  setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(null);
46
- }, popupAni === null || popupAni === void 0 ? void 0 : popupAni.duration);
46
+ }, popup === null || popup === void 0 ? void 0 : popup.duration);
47
47
  };
48
48
  const renderPopupDetail = (0, react_1.useMemo)(() => {
49
49
  var _a, _b, _c;
50
50
  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) => {
51
51
  var _a, _b, _c, _d, _e, _f, _g, _h;
52
- if ((value === null || value === void 0 ? void 0 : value.id) === popup) {
52
+ if ((value === null || value === void 0 ? void 0 : value.id) === (popup === null || popup === void 0 ? void 0 : popup.id)) {
53
53
  const t = resolver[(_a = value === null || value === void 0 ? void 0 : value.item) === null || _a === void 0 ? void 0 : _a.type];
54
54
  const Component = (0, withBindDataSource_1.default)(t);
55
55
  const defaulSetting = (_b = t === null || t === void 0 ? void 0 : t.extend) === null || _b === void 0 ? void 0 : _b.defaulSetting;
@@ -60,6 +60,6 @@ const Popup = () => {
60
60
  }
61
61
  });
62
62
  }, [schema, popup, resolver]);
63
- return (react_1.default.createElement(Modal_1.default, { visible: !!visible, onClose: handleClose, padding: 0, modalStyle: { position: 'fixed' } }, renderPopupDetail));
63
+ return (react_1.default.createElement(Modal_1.default, { popup: visible, onClose: handleClose, padding: 0, modalStyle: { position: 'fixed' } }, renderPopupDetail));
64
64
  };
65
65
  exports.default = Popup;