pb-sxp-ui 1.20.17 → 1.20.19

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 (48) hide show
  1. package/dist/index.cjs +732 -32
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.css +291 -0
  4. package/dist/index.js +732 -32
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.cjs +44 -5
  7. package/dist/index.min.cjs.map +1 -1
  8. package/dist/index.min.js +44 -5
  9. package/dist/index.min.js.map +1 -1
  10. package/dist/pb-ui.js +732 -32
  11. package/dist/pb-ui.js.map +1 -1
  12. package/dist/pb-ui.min.js +44 -5
  13. package/dist/pb-ui.min.js.map +1 -1
  14. package/es/core/components/SxpPageRender/index.d.ts +2 -0
  15. package/es/core/context/SxpDataSourceProvider.d.ts +1 -1
  16. package/es/materials/sxp/popup/AddToCart/index.d.ts +33 -0
  17. package/es/materials/sxp/popup/AddToCart/index.js +279 -0
  18. package/es/materials/sxp/popup/AddToCart/interactionRender.d.ts +3 -0
  19. package/es/materials/sxp/popup/AddToCart/interactionRender.js +11 -0
  20. package/es/materials/sxp/popup/AddToCart/material.d.ts +2 -0
  21. package/es/materials/sxp/popup/AddToCart/material.js +75 -0
  22. package/es/materials/sxp/popup/AddToCart/settingRender.d.ts +160 -0
  23. package/es/materials/sxp/popup/AddToCart/settingRender.js +277 -0
  24. package/es/materials/sxp/popup/CommodityDetail/index.d.ts +2 -0
  25. package/es/materials/sxp/popup/CommodityDetail/index.js +24 -6
  26. package/es/materials/sxp/popup/CommodityDetail/settingRender.d.ts +13 -0
  27. package/es/materials/sxp/popup/CommodityDetail/settingRender.js +16 -0
  28. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -2
  29. package/es/materials/sxp/popup/index.d.ts +1 -0
  30. package/es/materials/sxp/popup/index.js +1 -0
  31. package/lib/core/components/SxpPageRender/index.d.ts +2 -0
  32. package/lib/core/context/SxpDataSourceProvider.d.ts +1 -1
  33. package/lib/materials/sxp/popup/AddToCart/index.d.ts +33 -0
  34. package/lib/materials/sxp/popup/AddToCart/index.js +281 -0
  35. package/lib/materials/sxp/popup/AddToCart/interactionRender.d.ts +3 -0
  36. package/lib/materials/sxp/popup/AddToCart/interactionRender.js +14 -0
  37. package/lib/materials/sxp/popup/AddToCart/material.d.ts +2 -0
  38. package/lib/materials/sxp/popup/AddToCart/material.js +79 -0
  39. package/lib/materials/sxp/popup/AddToCart/settingRender.d.ts +160 -0
  40. package/lib/materials/sxp/popup/AddToCart/settingRender.js +279 -0
  41. package/lib/materials/sxp/popup/CommodityDetail/index.d.ts +2 -0
  42. package/lib/materials/sxp/popup/CommodityDetail/index.js +24 -6
  43. package/lib/materials/sxp/popup/CommodityDetail/settingRender.d.ts +13 -0
  44. package/lib/materials/sxp/popup/CommodityDetail/settingRender.js +16 -0
  45. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -2
  46. package/lib/materials/sxp/popup/index.d.ts +1 -0
  47. package/lib/materials/sxp/popup/index.js +1 -0
  48. package/package.json +1 -1
package/dist/pb-ui.js CHANGED
@@ -2781,7 +2781,7 @@
2781
2781
  StructurePage: StructurePage
2782
2782
  });
2783
2783
 
2784
- var interactionRender$h = [
2784
+ var interactionRender$i = [
2785
2785
  {
2786
2786
  title: '点击事件',
2787
2787
  child: [
@@ -2801,7 +2801,7 @@
2801
2801
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\AppointForm\settingRender.tsx
2802
2802
  *
2803
2803
  */
2804
- var settingRender$f = [
2804
+ var settingRender$g = [
2805
2805
  {
2806
2806
  title: '弹窗背景',
2807
2807
  child: [
@@ -3238,9 +3238,9 @@
3238
3238
  category: 'popup',
3239
3239
  type: 'AppointForm',
3240
3240
  related: {
3241
- settingRender: settingRender$f,
3241
+ settingRender: settingRender$g,
3242
3242
  bindableProps: [],
3243
- interactionRender: interactionRender$h
3243
+ interactionRender: interactionRender$i
3244
3244
  },
3245
3245
  defaulSetting: {
3246
3246
  name: '表单',
@@ -3263,7 +3263,7 @@
3263
3263
  sort: 2
3264
3264
  });
3265
3265
 
3266
- var settingRender$e = [
3266
+ var settingRender$f = [
3267
3267
  {
3268
3268
  title: '弹窗背景',
3269
3269
  child: [
@@ -3661,6 +3661,22 @@
3661
3661
  name: ['props', 'enableFixedCloseButton']
3662
3662
  }
3663
3663
  ]
3664
+ },
3665
+ {
3666
+ title: '加购功能',
3667
+ child: [
3668
+ {
3669
+ label: '启用加购弹窗',
3670
+ type: 'Switch',
3671
+ name: ['props', 'enableAddToCart']
3672
+ },
3673
+ {
3674
+ label: '加购弹窗ID',
3675
+ type: 'Input',
3676
+ name: ['props', 'addToCartPopupId'],
3677
+ placeholder: '请输入加购弹窗的ID'
3678
+ }
3679
+ ]
3664
3680
  }
3665
3681
  ];
3666
3682
 
@@ -3680,7 +3696,7 @@
3680
3696
  * @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
3681
3697
  *
3682
3698
  */
3683
- var interactionRender$g = [
3699
+ var interactionRender$h = [
3684
3700
  {
3685
3701
  title: '滑动事件',
3686
3702
  child: [
@@ -11658,8 +11674,8 @@
11658
11674
 
11659
11675
  const CommodityDetail$1 = (_a) => {
11660
11676
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
11661
- var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio, isTel, iframeBgColor, isActive = true } = _a, props = __rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio", "isTel", "iframeBgColor", "isActive"]);
11662
- const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef, globalConfig, ctaEvent } = useSxpDataSource();
11677
+ var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio, isTel, iframeBgColor, isActive = true, enableAddToCart = false, addToCartPopupId = '' } = _a, props = __rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio", "isTel", "iframeBgColor", "isActive", "enableAddToCart", "addToCartPopupId"]);
11678
+ const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef, globalConfig, ctaEvent, setPopupDetailData } = useSxpDataSource();
11663
11679
  const { jumpToWeb, productView } = useEventReport();
11664
11680
  const curTimeRef = React.useRef(null);
11665
11681
  const [showModal, setShowModal] = React.useState(false);
@@ -11680,6 +11696,28 @@
11680
11696
  cta = p === null || p === void 0 ? void 0 : p.bindCta;
11681
11697
  }
11682
11698
  const handleLink = (e) => {
11699
+ // 如果启用了加购功能且配置了加购弹窗ID,则打开加购弹窗
11700
+ if (enableAddToCart && addToCartPopupId) {
11701
+ // 设置弹窗数据
11702
+ setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, data), { index: position }));
11703
+ // 上报点击事件
11704
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
11705
+ eventName: 'ClickCTA',
11706
+ product: product ? [product] : undefined,
11707
+ contentType: 'product',
11708
+ data,
11709
+ position,
11710
+ cta_text: cta === null || cta === void 0 ? void 0 : cta.enTitle,
11711
+ cta_action_type: 'open_internal_popup',
11712
+ target_content_id: product === null || product === void 0 ? void 0 : product.itemId
11713
+ });
11714
+ // 打开加购弹窗
11715
+ if (typeof window !== 'undefined' && window.sxpPopup) {
11716
+ window.sxpPopup(addToCartPopupId);
11717
+ }
11718
+ return;
11719
+ }
11720
+ // 默认行为:跳转到商品链接
11683
11721
  if (product === null || product === void 0 ? void 0 : product.link) {
11684
11722
  jumpToWeb(e, data, product, cta, position);
11685
11723
  if (!isPost) {
@@ -11804,10 +11842,11 @@
11804
11842
  };
11805
11843
  const renderBtn = () => {
11806
11844
  var _a, _b;
11807
- return (React.createElement(React.Fragment, null, (isDefault || (product === null || product === void 0 ? void 0 : product.link)) && (React.createElement("a", { "aria-label": (_a = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _a !== void 0 ? _a : 'Purchase on Website', role: 'button', tabIndex: 0, onClick: handleLink, className: 'pb-commondity-btn', style: buttonStyle },
11808
- React.createElement("span", { dangerouslySetInnerHTML: {
11809
- __html: setFontForText((_b = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _b !== void 0 ? _b : 'Purchase on Website', buttonStyle)
11810
- } })))));
11845
+ return (React.createElement(React.Fragment, null,
11846
+ React.createElement("a", { "aria-label": (_a = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _a !== void 0 ? _a : 'Purchase on Website', role: 'button', tabIndex: 0, onClick: handleLink, className: 'pb-commondity-btn', style: buttonStyle },
11847
+ React.createElement("span", { dangerouslySetInnerHTML: {
11848
+ __html: setFontForText((_b = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _b !== void 0 ? _b : 'Purchase on Website', buttonStyle)
11849
+ } }))));
11811
11850
  };
11812
11851
  const getStyle = React.useCallback((style) => {
11813
11852
  if (style === null || style === void 0 ? void 0 : style.lineClamp) {
@@ -11950,8 +11989,8 @@
11950
11989
  category: 'popup',
11951
11990
  type: 'CommodityDetail',
11952
11991
  related: {
11953
- settingRender: settingRender$e,
11954
- interactionRender: interactionRender$g
11992
+ settingRender: settingRender$f,
11993
+ interactionRender: interactionRender$h
11955
11994
  },
11956
11995
  defaulSetting: {
11957
11996
  props: {
@@ -12006,7 +12045,7 @@
12006
12045
  sort: 1
12007
12046
  });
12008
12047
 
12009
- var interactionRender$f = [
12048
+ var interactionRender$g = [
12010
12049
  {
12011
12050
  title: '点击事件',
12012
12051
  child: [
@@ -12026,7 +12065,7 @@
12026
12065
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Prompt\settingRender.tsx
12027
12066
  *
12028
12067
  */
12029
- var settingRender$d = [
12068
+ var settingRender$e = [
12030
12069
  {
12031
12070
  title: '弹窗背景',
12032
12071
  child: [
@@ -12206,9 +12245,9 @@
12206
12245
  category: 'popup',
12207
12246
  type: 'Prompt',
12208
12247
  related: {
12209
- settingRender: settingRender$d,
12248
+ settingRender: settingRender$e,
12210
12249
  bindableProps: [],
12211
- interactionRender: interactionRender$f
12250
+ interactionRender: interactionRender$g
12212
12251
  },
12213
12252
  defaulSetting: {
12214
12253
  props: {
@@ -12231,7 +12270,7 @@
12231
12270
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\CommodityDetailDiroNew\settingRender.tsx
12232
12271
  *
12233
12272
  */
12234
- var settingRender$c = [
12273
+ var settingRender$d = [
12235
12274
  {
12236
12275
  title: '弹窗背景',
12237
12276
  child: [
@@ -12930,10 +12969,10 @@ Made in Italy` })));
12930
12969
  React.createElement("div", { className: 'pb-commondityDiroNew-content-top-right-price', hidden: !!product && !(product === null || product === void 0 ? void 0 : product.taxInfo), style: getStyle(commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.taxInfo), dangerouslySetInnerHTML: {
12931
12970
  __html: setFontForText((_2 = product === null || product === void 0 ? void 0 : product.taxInfo) !== null && _2 !== void 0 ? _2 : '税费', commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.taxInfo)
12932
12971
  } }))),
12933
- (!product || (product === null || product === void 0 ? void 0 : product.link)) && (React.createElement("a", { "aria-label": (_3 = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _3 !== void 0 ? _3 : 'Shop now', role: 'button', tabIndex: 0, onClick: handleLink, className: 'pb-commondityDiroNew-btn', style: buttonStyle },
12972
+ React.createElement("a", { "aria-label": (_3 = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _3 !== void 0 ? _3 : 'Shop now', role: 'button', tabIndex: 0, onClick: handleLink, className: 'pb-commondityDiroNew-btn', style: buttonStyle },
12934
12973
  React.createElement("span", { dangerouslySetInnerHTML: {
12935
12974
  __html: setFontForText((_4 = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _4 !== void 0 ? _4 : 'Shop now', buttonStyle)
12936
- } }))),
12975
+ } })),
12937
12976
  productInfoText({ isPost }))),
12938
12977
  React.createElement(Modal$1, { visible: showModal, onClose: () => setShowModal(false) },
12939
12978
  React.createElement("div", { style: { paddingTop: '34px' } }, productInfoText({ isPost: false }))),
@@ -12964,7 +13003,7 @@ Made in Italy` })));
12964
13003
  * @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
12965
13004
  *
12966
13005
  */
12967
- var interactionRender$e = [
13006
+ var interactionRender$f = [
12968
13007
  {
12969
13008
  title: '滑动事件',
12970
13009
  child: [
@@ -12991,8 +13030,8 @@ Made in Italy` })));
12991
13030
  category: 'popup',
12992
13031
  type: 'CommodityDetailDiroNew',
12993
13032
  related: {
12994
- settingRender: settingRender$c,
12995
- interactionRender: interactionRender$e
13033
+ settingRender: settingRender$d,
13034
+ interactionRender: interactionRender$f
12996
13035
  },
12997
13036
  defaulSetting: {
12998
13037
  props: {
@@ -13056,7 +13095,7 @@ Made in Italy` })));
13056
13095
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\CommodityList\settingRender.tsx
13057
13096
  *
13058
13097
  */
13059
- var settingRender$b = [
13098
+ var settingRender$c = [
13060
13099
  {
13061
13100
  title: '弹窗背景',
13062
13101
  child: [
@@ -13481,7 +13520,7 @@ Made in Italy` })));
13481
13520
  * @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
13482
13521
  *
13483
13522
  */
13484
- var interactionRender$d = [
13523
+ var interactionRender$e = [
13485
13524
  {
13486
13525
  title: '点击事件',
13487
13526
  child: [
@@ -13508,8 +13547,8 @@ Made in Italy` })));
13508
13547
  category: 'popup',
13509
13548
  type: 'CommodityList',
13510
13549
  related: {
13511
- settingRender: settingRender$b,
13512
- interactionRender: interactionRender$d
13550
+ settingRender: settingRender$c,
13551
+ interactionRender: interactionRender$e
13513
13552
  },
13514
13553
  defaulSetting: {
13515
13554
  props: {
@@ -13557,7 +13596,7 @@ Made in Italy` })));
13557
13596
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Iframe\settingRender.tsx
13558
13597
  *
13559
13598
  */
13560
- var settingRender$a = [
13599
+ var settingRender$b = [
13561
13600
  {
13562
13601
  title: '背景样式',
13563
13602
  child: [
@@ -13591,7 +13630,7 @@ Made in Italy` })));
13591
13630
  category: 'popup',
13592
13631
  type: 'Iframe',
13593
13632
  related: {
13594
- settingRender: settingRender$a,
13633
+ settingRender: settingRender$b,
13595
13634
  bindableProps: []
13596
13635
  },
13597
13636
  defaulSetting: {
@@ -13611,7 +13650,7 @@ Made in Italy` })));
13611
13650
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\ConsentDetail\settingRender.tsx
13612
13651
  *
13613
13652
  */
13614
- var settingRender$9 = [
13653
+ var settingRender$a = [
13615
13654
  {
13616
13655
  title: '弹窗文本',
13617
13656
  child: [
@@ -13640,7 +13679,7 @@ Made in Italy` })));
13640
13679
  category: 'popup',
13641
13680
  type: 'ConsentDetail',
13642
13681
  related: {
13643
- settingRender: settingRender$9,
13682
+ settingRender: settingRender$a,
13644
13683
  bindableProps: []
13645
13684
  },
13646
13685
  defaulSetting: {
@@ -13652,6 +13691,666 @@ Made in Italy` })));
13652
13691
  sort: 7
13653
13692
  });
13654
13693
 
13694
+ var settingRender$9 = [
13695
+ {
13696
+ title: 'Shopify配置',
13697
+ child: [
13698
+ {
13699
+ type: 'Input',
13700
+ label: 'Shopify域名',
13701
+ name: ['props', 'shopifyDomain'],
13702
+ placeholder: 'your-store.myshopify.com'
13703
+ },
13704
+ {
13705
+ type: 'Input',
13706
+ label: 'Storefront Token',
13707
+ name: ['props', 'storefrontAccessToken'],
13708
+ placeholder: 'Storefront Access Token'
13709
+ }
13710
+ ]
13711
+ },
13712
+ {
13713
+ title: '弹窗背景',
13714
+ child: [
13715
+ {
13716
+ type: 'Number',
13717
+ label: '左右边距',
13718
+ name: ['props', 'popupBg', 'horizontalMargin']
13719
+ },
13720
+ {
13721
+ type: 'Number',
13722
+ label: '下边距',
13723
+ name: ['props', 'popupBg', 'bottomMargin']
13724
+ }
13725
+ ]
13726
+ },
13727
+ {
13728
+ title: '商品信息样式',
13729
+ child: [
13730
+ {
13731
+ name: ['props', 'variantStyles'],
13732
+ type: 'SelectLinkage',
13733
+ child: [
13734
+ {
13735
+ label: '字段',
13736
+ type: 'Select',
13737
+ options: [
13738
+ {
13739
+ label: '商品标题',
13740
+ value: 'title'
13741
+ },
13742
+ {
13743
+ label: '价格',
13744
+ value: 'price'
13745
+ },
13746
+ {
13747
+ label: '规格选项',
13748
+ value: 'option'
13749
+ },
13750
+ {
13751
+ label: '已选规格',
13752
+ value: 'selectedOption'
13753
+ }
13754
+ ],
13755
+ name: ['props', 'variantStyles', 'field'],
13756
+ initialValue: 'title'
13757
+ },
13758
+ {
13759
+ type: 'Group',
13760
+ child: [
13761
+ {
13762
+ label: '上边距',
13763
+ type: 'Number',
13764
+ addonAfter: 'px',
13765
+ name: ['marginTop']
13766
+ },
13767
+ {
13768
+ label: '下边距',
13769
+ type: 'Number',
13770
+ addonAfter: 'px',
13771
+ name: ['marginBottom']
13772
+ }
13773
+ ]
13774
+ },
13775
+ {
13776
+ type: 'Group',
13777
+ label: '字体',
13778
+ child: [
13779
+ {
13780
+ type: 'Select',
13781
+ name: ['fontFamily-cn'],
13782
+ bottomText: '中文字体'
13783
+ },
13784
+ {
13785
+ type: 'Select',
13786
+ name: ['fontFamily-en'],
13787
+ bottomText: '英文/其他字体'
13788
+ }
13789
+ ]
13790
+ },
13791
+ {
13792
+ type: 'Group',
13793
+ label: '',
13794
+ child: [
13795
+ {
13796
+ type: 'Color',
13797
+ name: ['color']
13798
+ },
13799
+ {
13800
+ type: 'Number',
13801
+ addonAfter: 'px',
13802
+ name: ['fontSize']
13803
+ }
13804
+ ]
13805
+ },
13806
+ {
13807
+ label: '样式',
13808
+ type: 'TextStyle'
13809
+ },
13810
+ {
13811
+ label: '对齐',
13812
+ type: 'TextAlign'
13813
+ },
13814
+ {
13815
+ label: '间距',
13816
+ type: 'TextSpace'
13817
+ }
13818
+ ]
13819
+ }
13820
+ ]
13821
+ },
13822
+ {
13823
+ title: '加购按钮样式',
13824
+ child: [
13825
+ {
13826
+ label: '英文大小写',
13827
+ type: 'Select',
13828
+ name: ['props', 'buttonStyle', 'textTransform'],
13829
+ options: [
13830
+ {
13831
+ label: '默认',
13832
+ value: 'unset'
13833
+ },
13834
+ {
13835
+ label: '小写',
13836
+ value: 'lowercase'
13837
+ },
13838
+ {
13839
+ label: '大写',
13840
+ value: 'uppercase'
13841
+ }
13842
+ ]
13843
+ },
13844
+ {
13845
+ type: 'Color',
13846
+ label: '背景色',
13847
+ name: ['props', 'buttonStyle', 'backgroundColor'],
13848
+ initialValue: '#000'
13849
+ },
13850
+ {
13851
+ type: 'Group',
13852
+ label: '尺寸',
13853
+ child: [
13854
+ {
13855
+ type: 'Number',
13856
+ name: ['props', 'buttonStyle', 'height'],
13857
+ addonAfter: 'H'
13858
+ }
13859
+ ]
13860
+ },
13861
+ {
13862
+ type: 'Group',
13863
+ label: '圆角',
13864
+ child: [
13865
+ {
13866
+ type: 'Slider',
13867
+ name: ['props', 'buttonStyle', 'borderRadius'],
13868
+ max: 100
13869
+ },
13870
+ {
13871
+ type: 'Number',
13872
+ name: ['props', 'buttonStyle', 'borderRadius'],
13873
+ addonAfter: 'px',
13874
+ max: 100
13875
+ }
13876
+ ]
13877
+ },
13878
+ {
13879
+ type: 'TextMargin',
13880
+ name: ['props', 'buttonStyle']
13881
+ },
13882
+ {
13883
+ type: 'Group',
13884
+ label: '字体',
13885
+ child: [
13886
+ {
13887
+ type: 'Select',
13888
+ name: ['props', 'buttonStyle', 'fontFamily-cn'],
13889
+ bottomText: '中文字体'
13890
+ },
13891
+ {
13892
+ type: 'Select',
13893
+ name: ['props', 'buttonStyle', 'fontFamily-en'],
13894
+ bottomText: '英文/其他字体'
13895
+ }
13896
+ ]
13897
+ },
13898
+ {
13899
+ type: 'Group',
13900
+ label: '',
13901
+ child: [
13902
+ {
13903
+ type: 'Color',
13904
+ name: ['props', 'buttonStyle', 'color'],
13905
+ initialValue: '#fff'
13906
+ },
13907
+ {
13908
+ type: 'Number',
13909
+ name: ['props', 'buttonStyle', 'fontSize'],
13910
+ addonAfter: 'px'
13911
+ }
13912
+ ]
13913
+ },
13914
+ {
13915
+ type: 'TextStyle',
13916
+ name: ['props', 'buttonStyle']
13917
+ },
13918
+ {
13919
+ type: 'TextAlign',
13920
+ name: ['props', 'buttonStyle']
13921
+ },
13922
+ {
13923
+ label: '间距',
13924
+ type: 'TextSpace',
13925
+ name: ['props', 'buttonStyle']
13926
+ }
13927
+ ]
13928
+ },
13929
+ {
13930
+ title: '文案配置',
13931
+ child: [
13932
+ {
13933
+ type: 'Input',
13934
+ label: '加购按钮文案',
13935
+ name: ['props', 'texts', 'addToCart'],
13936
+ placeholder: 'Add to Cart'
13937
+ },
13938
+ {
13939
+ type: 'Input',
13940
+ label: '选择规格提示',
13941
+ name: ['props', 'texts', 'selectOptions'],
13942
+ placeholder: 'Please select options'
13943
+ },
13944
+ {
13945
+ type: 'Input',
13946
+ label: '加载文案',
13947
+ name: ['props', 'texts', 'loading'],
13948
+ placeholder: 'Loading...'
13949
+ },
13950
+ {
13951
+ type: 'Input',
13952
+ label: '错误文案',
13953
+ name: ['props', 'texts', 'error'],
13954
+ placeholder: 'Failed to load product'
13955
+ }
13956
+ ]
13957
+ },
13958
+ {
13959
+ title: '数量选择器',
13960
+ child: [
13961
+ {
13962
+ type: 'Number',
13963
+ label: '按钮间距',
13964
+ name: ['props', 'quantityStyle', 'gap'],
13965
+ addonAfter: 'px',
13966
+ initialValue: 12
13967
+ }
13968
+ ]
13969
+ }
13970
+ ];
13971
+
13972
+ /*
13973
+ * @Author: tao
13974
+ * @Date: 2026-01-12
13975
+ * @Description: Add to Cart 交互配置
13976
+ */
13977
+ var interactionRender$d = () => {
13978
+ return (React.createElement("div", { style: { padding: '20px', color: '#666' } },
13979
+ React.createElement("p", null, "\u52A0\u8D2D\u5546\u54C1\u5F39\u7A97\u4EA4\u4E92\u8BF4\u660E\uFF1A"),
13980
+ React.createElement("ul", { style: { paddingLeft: '20px', lineHeight: '1.8' } },
13981
+ React.createElement("li", null, "\u70B9\u51FB\u5546\u54C1\u8BE6\u60C5\u5F39\u7A97\u7684\"Shop Now\"\u6309\u94AE\u540E\u81EA\u52A8\u5C55\u793A"),
13982
+ React.createElement("li", null, "\u901A\u8FC7Shopify Storefront API\u83B7\u53D6\u5546\u54C1\u89C4\u683C\u548C\u5E93\u5B58\u4FE1\u606F"),
13983
+ React.createElement("li", null, "\u7528\u6237\u9009\u62E9\u89C4\u683C\u540E\u5B9E\u65F6\u663E\u793A\u5BF9\u5E94SKU\u7684\u4EF7\u683C\u548C\u5E93\u5B58"),
13984
+ React.createElement("li", null, "\u70B9\u51FB\"Add to Cart\"\u6309\u94AE\u540E\u8DF3\u8F6C\u81F3Shopify\u8D2D\u7269\u8F66\u9875\u9762"),
13985
+ React.createElement("li", null, "\u65E0\u5E93\u5B58\u6216\u4E0D\u53EF\u552E\u5356\u7684\u89C4\u683C\u81EA\u52A8\u7F6E\u7070\u4E0D\u53EF\u9009"))));
13986
+ };
13987
+
13988
+ const AddToCartPopup$1 = (_a) => {
13989
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
13990
+ var { style, isActive = true, index, shopifyDomain = '', storefrontAccessToken = '', variantStyles = {}, buttonStyle = {}, quantityStyle = {}, texts = {}, popupBg = {} } = _a, props = __rest(_a, ["style", "isActive", "index", "shopifyDomain", "storefrontAccessToken", "variantStyles", "buttonStyle", "quantityStyle", "texts", "popupBg"]);
13991
+ const { sxpParameter, popupDetailData, isPreview, bffFbReport, globalConfig } = useSxpDataSource();
13992
+ useEventReport();
13993
+ const curTimeRef = React.useRef(null);
13994
+ const [productData, setProductData] = React.useState(null);
13995
+ const [selectedOptions, setSelectedOptions] = React.useState({});
13996
+ const [selectedVariant, setSelectedVariant] = React.useState(null);
13997
+ const [quantity, setQuantity] = React.useState(1);
13998
+ const [loading, setLoading] = React.useState(true);
13999
+ const [error, setError] = React.useState(null);
14000
+ // 获取当前弹窗商品数据(自动从 popupDetailData 获取)
14001
+ const data = popupDetailData;
14002
+ const product = (_c = (_b = data === null || data === void 0 ? void 0 : data.video) === null || _b === void 0 ? void 0 : _b.bindProduct) !== null && _c !== void 0 ? _c : (_e = (_d = data === null || data === void 0 ? void 0 : data.video) === null || _d === void 0 ? void 0 : _d.bindProducts) === null || _e === void 0 ? void 0 : _e[0];
14003
+ product === null || product === void 0 ? void 0 : product.bindCta;
14004
+ const position = (_g = (_f = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.index) !== null && _f !== void 0 ? _f : index) !== null && _g !== void 0 ? _g : 0;
14005
+ // Shopify配置 - 优先级:props > globalConfig > 默认值
14006
+ const finalShopifyDomain = shopifyDomain || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.shopifyDomain) || 'dev-store-749237498237498636.myshopify.com';
14007
+ const finalStorefrontToken = storefrontAccessToken || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.storefrontAccessToken) || '77d894c490f79430ce7bd0a7efdff6b7';
14008
+ // 自动从商品数据获取 Shopify Product ID
14009
+ const productId = (product === null || product === void 0 ? void 0 : product.itemId) || '';
14010
+ // 文案
14011
+ const finalTexts = {
14012
+ addToCart: texts.addToCart || 'Add to Cart',
14013
+ selectOptions: texts.selectOptions || 'Please select options',
14014
+ loading: texts.loading || 'Loading...',
14015
+ error: texts.error || 'Failed to load product',
14016
+ color: texts.color || 'Color',
14017
+ size: texts.size || 'Size',
14018
+ material: texts.material || 'Material',
14019
+ style: texts.style || 'Style'
14020
+ };
14021
+ // 查询Shopify商品数据
14022
+ const fetchProductData = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
14023
+ var _m;
14024
+ if (!productId || !finalShopifyDomain || !finalStorefrontToken) {
14025
+ console.log('[AddToCartPopup] 缺少必要配置:', {
14026
+ productId,
14027
+ shopifyDomain: finalShopifyDomain,
14028
+ hasToken: !!finalStorefrontToken
14029
+ });
14030
+ setLoading(false);
14031
+ return;
14032
+ }
14033
+ console.log('[AddToCartPopup] 开始加载商品数据:', {
14034
+ productId,
14035
+ shopifyDomain: finalShopifyDomain
14036
+ });
14037
+ setLoading(true);
14038
+ setError(null);
14039
+ try {
14040
+ const query = `
14041
+ query getProduct($id: ID!) {
14042
+ product(id: $id) {
14043
+ id
14044
+ title
14045
+ images(first: 10) {
14046
+ edges {
14047
+ node {
14048
+ url
14049
+ }
14050
+ }
14051
+ }
14052
+ options {
14053
+ name
14054
+ values
14055
+ }
14056
+ variants(first: 100) {
14057
+ edges {
14058
+ node {
14059
+ id
14060
+ title
14061
+ availableForSale
14062
+ quantityAvailable
14063
+ price {
14064
+ amount
14065
+ currencyCode
14066
+ }
14067
+ image {
14068
+ url
14069
+ }
14070
+ selectedOptions {
14071
+ name
14072
+ value
14073
+ }
14074
+ }
14075
+ }
14076
+ }
14077
+ }
14078
+ }
14079
+ `;
14080
+ // 确保 Product ID 格式正确
14081
+ const formattedProductId = productId.startsWith('gid://')
14082
+ ? productId
14083
+ : `gid://shopify/Product/${productId}`;
14084
+ console.log('[AddToCartPopup] 使用的 Product ID:', formattedProductId);
14085
+ const response = yield fetch(`https://${finalShopifyDomain}/api/2024-01/graphql.json`, {
14086
+ method: 'POST',
14087
+ headers: {
14088
+ 'Content-Type': 'application/json',
14089
+ 'X-Shopify-Storefront-Access-Token': finalStorefrontToken
14090
+ },
14091
+ body: JSON.stringify({
14092
+ query,
14093
+ variables: { id: formattedProductId }
14094
+ })
14095
+ });
14096
+ if (!response.ok) {
14097
+ throw new Error(`HTTP ${response.status}`);
14098
+ }
14099
+ const result = yield response.json();
14100
+ if (result.errors) {
14101
+ console.error('[AddToCartPopup] GraphQL 错误:', result.errors);
14102
+ throw new Error(result.errors[0].message);
14103
+ }
14104
+ if (!((_m = result.data) === null || _m === void 0 ? void 0 : _m.product)) {
14105
+ console.error('[AddToCartPopup] 未找到商品');
14106
+ throw new Error('Product not found');
14107
+ }
14108
+ console.log('[AddToCartPopup] 商品数据加载成功:', result.data.product.title);
14109
+ setProductData(result.data.product);
14110
+ }
14111
+ catch (err) {
14112
+ const errorMessage = err instanceof Error ? err.message : finalTexts.error;
14113
+ setError(errorMessage);
14114
+ console.error('[AddToCartPopup] 加载失败:', err);
14115
+ }
14116
+ finally {
14117
+ setLoading(false);
14118
+ }
14119
+ }), [productId, finalShopifyDomain, finalStorefrontToken, finalTexts.error]);
14120
+ React.useEffect(() => {
14121
+ if (isActive) {
14122
+ fetchProductData();
14123
+ }
14124
+ }, [isActive, fetchProductData]);
14125
+ // 根据选中的规格匹配variant
14126
+ React.useEffect(() => {
14127
+ if (!productData)
14128
+ return;
14129
+ const variants = productData.variants.edges.map(edge => edge.node);
14130
+ const optionsCount = productData.options.length;
14131
+ const selectedCount = Object.keys(selectedOptions).length;
14132
+ if (selectedCount === 0 || selectedCount < optionsCount) {
14133
+ setSelectedVariant(null);
14134
+ return;
14135
+ }
14136
+ const matchedVariant = variants.find(variant => {
14137
+ return variant.selectedOptions.every(option => selectedOptions[option.name] === option.value);
14138
+ });
14139
+ setSelectedVariant(matchedVariant || null);
14140
+ setQuantity(1);
14141
+ }, [selectedOptions, productData]);
14142
+ // 处理规格选择
14143
+ const handleOptionSelect = React.useCallback((optionName, value) => {
14144
+ setSelectedOptions(prev => {
14145
+ const newOptions = Object.assign({}, prev);
14146
+ if (newOptions[optionName] === value) {
14147
+ delete newOptions[optionName];
14148
+ }
14149
+ else {
14150
+ newOptions[optionName] = value;
14151
+ }
14152
+ return newOptions;
14153
+ });
14154
+ }, []);
14155
+ // 处理数量变化
14156
+ const handleQuantityChange = React.useCallback((delta) => {
14157
+ setQuantity(prev => {
14158
+ var _a;
14159
+ const newQuantity = prev + delta;
14160
+ const maxQuantity = (_a = selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.quantityAvailable) !== null && _a !== void 0 ? _a : 999;
14161
+ return Math.max(1, Math.min(newQuantity, maxQuantity));
14162
+ });
14163
+ }, [selectedVariant]);
14164
+ // 检查某个规格值是否可用
14165
+ const isOptionValueAvailable = React.useCallback((optionName, value) => {
14166
+ if (!productData)
14167
+ return false;
14168
+ const variants = productData.variants.edges.map(edge => edge.node);
14169
+ const tempOptions = Object.assign(Object.assign({}, selectedOptions), { [optionName]: value });
14170
+ return variants.some(variant => {
14171
+ const matches = variant.selectedOptions.every(option => !tempOptions[option.name] || tempOptions[option.name] === option.value);
14172
+ const hasStock = variant.quantityAvailable === null || variant.quantityAvailable > 0;
14173
+ return matches && variant.availableForSale && hasStock;
14174
+ });
14175
+ }, [productData, selectedOptions]);
14176
+ // 处理加购
14177
+ const handleAddToCart = React.useCallback(() => {
14178
+ var _a;
14179
+ if (!selectedVariant || quantity === 0)
14180
+ return;
14181
+ const variantId = selectedVariant.id.split('/').pop();
14182
+ const cartUrl = `https://${finalShopifyDomain}/cart/add?id=${variantId}&quantity=${quantity}`;
14183
+ console.log('[AddToCartPopup] 加购:', {
14184
+ variantId,
14185
+ quantity,
14186
+ cartUrl
14187
+ });
14188
+ // 上报事件
14189
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
14190
+ eventName: 'AddToCart',
14191
+ product: product ? [product] : undefined,
14192
+ contentType: 'product',
14193
+ data,
14194
+ position,
14195
+ content_id: (_a = product === null || product === void 0 ? void 0 : product.itemId) !== null && _a !== void 0 ? _a : '',
14196
+ value: parseFloat(selectedVariant.price.amount) * quantity,
14197
+ currency: selectedVariant.price.currencyCode,
14198
+ contents: [{
14199
+ id: variantId,
14200
+ quantity
14201
+ }]
14202
+ });
14203
+ // 跳转到Shopify购物车页面
14204
+ window.location.href = cartUrl;
14205
+ }, [selectedVariant, quantity, finalShopifyDomain, bffFbReport, product, data, position]);
14206
+ // 计算总价
14207
+ const totalPrice = React.useMemo(() => {
14208
+ if (!selectedVariant)
14209
+ return null;
14210
+ const price = parseFloat(selectedVariant.price.amount);
14211
+ const total = price * quantity;
14212
+ return total.toFixed(2);
14213
+ }, [selectedVariant, quantity]);
14214
+ // 初始化时间
14215
+ React.useEffect(() => {
14216
+ const initTime = () => {
14217
+ curTimeRef.current = new Date();
14218
+ };
14219
+ initTime();
14220
+ window.addEventListener('pageshow', initTime);
14221
+ return () => {
14222
+ window.removeEventListener('pageshow', initTime);
14223
+ };
14224
+ }, []);
14225
+ // 加载中
14226
+ if (loading) {
14227
+ return (React.createElement("div", { className: "add-to-cart-popup-loading", style: style },
14228
+ React.createElement("div", null, finalTexts.loading)));
14229
+ }
14230
+ // 错误状态
14231
+ if (error || !productData) {
14232
+ return (React.createElement("div", { className: "add-to-cart-popup-error", style: style },
14233
+ React.createElement("div", null,
14234
+ finalTexts.error,
14235
+ ": ",
14236
+ error || 'Product not found')));
14237
+ }
14238
+ const mainImage = ((_h = selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.image) === null || _h === void 0 ? void 0 : _h.url) || ((_j = productData.images.edges[0]) === null || _j === void 0 ? void 0 : _j.node.url) || ((_k = product === null || product === void 0 ? void 0 : product.homePage) === null || _k === void 0 ? void 0 : _k[0]) || '';
14239
+ const hasAllOptionsSelected = productData.options.length === Object.keys(selectedOptions).length;
14240
+ const isAddToCartDisabled = !selectedVariant || quantity === 0;
14241
+ return (React.createElement("div", Object.assign({ className: "add-to-cart-popup-container", style: style }, props),
14242
+ React.createElement("div", { className: "variant-detail-section" },
14243
+ React.createElement("div", { className: "variant-image-wrapper" },
14244
+ React.createElement("img", { src: mainImage, alt: productData.title, className: "variant-image" })),
14245
+ React.createElement("div", { className: "variant-info-wrapper" },
14246
+ React.createElement("h2", { className: "product-title-text", style: variantStyles.title, dangerouslySetInnerHTML: {
14247
+ __html: setFontForText(productData.title, variantStyles.title)
14248
+ } }),
14249
+ selectedVariant && (React.createElement(React.Fragment, null,
14250
+ React.createElement("div", { className: "selected-options-tags" }, selectedVariant.selectedOptions.map(option => (React.createElement("span", { key: option.name, className: "option-tag", style: variantStyles.selectedOption },
14251
+ option.name,
14252
+ ": ",
14253
+ option.value)))),
14254
+ React.createElement("div", { className: "price-display" },
14255
+ React.createElement("span", { className: "price-value", style: variantStyles.price, dangerouslySetInnerHTML: {
14256
+ __html: setFontForText(`${selectedVariant.price.currencyCode} $${totalPrice}`, variantStyles.price)
14257
+ } })),
14258
+ React.createElement("div", { className: "quantity-selector-wrapper", style: quantityStyle },
14259
+ React.createElement("button", { className: "quantity-btn quantity-decrease", onClick: () => handleQuantityChange(-1), disabled: quantity <= 1, "aria-label": "Decrease quantity" }, "-"),
14260
+ React.createElement("input", { type: "number", value: quantity, readOnly: true, className: "quantity-input-field", "aria-label": "Quantity" }),
14261
+ React.createElement("button", { className: "quantity-btn quantity-increase", onClick: () => handleQuantityChange(1), disabled: quantity >= ((_l = selectedVariant.quantityAvailable) !== null && _l !== void 0 ? _l : 999), "aria-label": "Increase quantity" }, "+")))),
14262
+ !hasAllOptionsSelected && (React.createElement("div", { className: "no-selection-hint", style: variantStyles.option }, finalTexts.selectOptions)))),
14263
+ React.createElement("div", { className: "variant-options-section" }, productData.options.map(option => (React.createElement("div", { key: option.name, className: "option-group-wrapper" },
14264
+ React.createElement("h3", { className: "option-group-name", style: variantStyles.option, dangerouslySetInnerHTML: {
14265
+ __html: setFontForText(option.name, variantStyles.option)
14266
+ } }),
14267
+ React.createElement("div", { className: "option-values-grid" }, option.values.map(value => {
14268
+ const isSelected = selectedOptions[option.name] === value;
14269
+ const isAvailable = isOptionValueAvailable(option.name, value);
14270
+ return (React.createElement("button", { key: value, className: `option-value-button ${isSelected ? 'selected' : ''} ${!isAvailable ? 'disabled' : ''}`, onClick: () => isAvailable && handleOptionSelect(option.name, value), disabled: !isAvailable, "aria-label": `${option.name}: ${value}`, "aria-pressed": isSelected }, value));
14271
+ })))))),
14272
+ React.createElement("button", { className: `add-to-cart-button ${isAddToCartDisabled ? 'disabled' : ''}`, style: buttonStyle, onClick: handleAddToCart, disabled: isAddToCartDisabled, "aria-label": finalTexts.addToCart },
14273
+ React.createElement("span", { dangerouslySetInnerHTML: {
14274
+ __html: setFontForText(finalTexts.addToCart, buttonStyle)
14275
+ } }))));
14276
+ };
14277
+
14278
+ /*
14279
+ * @Author: tao
14280
+ * @Date: 2026-01-12
14281
+ * @Description: Add to Cart 弹窗组件物料配置
14282
+ */
14283
+ const AddToCartPopup = createMaterial(AddToCartPopup$1, {
14284
+ displayName: '加购商品',
14285
+ icon: '',
14286
+ category: 'popup',
14287
+ type: 'AddToCartPopup',
14288
+ related: {
14289
+ settingRender: settingRender$9,
14290
+ interactionRender: interactionRender$d
14291
+ },
14292
+ defaulSetting: {
14293
+ props: {
14294
+ shopifyDomain: '',
14295
+ storefrontAccessToken: '',
14296
+ variantStyles: {
14297
+ title: {
14298
+ color: '#000',
14299
+ fontSize: 20,
14300
+ fontWeight: 600,
14301
+ marginBottom: 12
14302
+ },
14303
+ price: {
14304
+ color: '#000',
14305
+ fontSize: 24,
14306
+ fontWeight: 700,
14307
+ marginBottom: 16
14308
+ },
14309
+ option: {
14310
+ color: '#111',
14311
+ fontSize: 16,
14312
+ fontWeight: 600,
14313
+ marginBottom: 12
14314
+ },
14315
+ selectedOption: {
14316
+ fontSize: 14,
14317
+ color: '#374151'
14318
+ }
14319
+ },
14320
+ buttonStyle: {
14321
+ backgroundColor: '#000',
14322
+ color: '#fff',
14323
+ fontSize: 16,
14324
+ height: 52,
14325
+ fontWeight: 600,
14326
+ textAlign: 'center',
14327
+ textTransform: 'uppercase'
14328
+ },
14329
+ quantityStyle: {
14330
+ gap: 12
14331
+ },
14332
+ texts: {
14333
+ addToCart: 'Add to Cart',
14334
+ selectOptions: 'Please select options',
14335
+ loading: 'Loading...',
14336
+ error: 'Failed to load product',
14337
+ color: 'Color',
14338
+ size: 'Size',
14339
+ material: 'Material',
14340
+ style: 'Style'
14341
+ },
14342
+ popupBg: {
14343
+ horizontalMargin: 0,
14344
+ bottomMargin: 0
14345
+ }
14346
+ },
14347
+ style: {}
14348
+ },
14349
+ w: 100,
14350
+ h: 40,
14351
+ sort: 7
14352
+ });
14353
+
13655
14354
  /*
13656
14355
  * @Author: binruan@chatlabs.com
13657
14356
  * @Date: 2024-03-26 16:50:25
@@ -19143,6 +19842,7 @@ Made in Italy` })));
19143
19842
 
19144
19843
  var _materials_ = /*#__PURE__*/Object.freeze({
19145
19844
  __proto__: null,
19845
+ AddToCartPopup: AddToCartPopup,
19146
19846
  AniLink: AniLink,
19147
19847
  AniLinkPopup: AniLinkPopup,
19148
19848
  Appoint: Appoint,