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/index.cjs CHANGED
@@ -2788,7 +2788,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
2788
2788
  StructurePage: StructurePage
2789
2789
  });
2790
2790
 
2791
- var interactionRender$h = [
2791
+ var interactionRender$i = [
2792
2792
  {
2793
2793
  title: '点击事件',
2794
2794
  child: [
@@ -2808,7 +2808,7 @@ var interactionRender$h = [
2808
2808
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\AppointForm\settingRender.tsx
2809
2809
  *
2810
2810
  */
2811
- var settingRender$f = [
2811
+ var settingRender$g = [
2812
2812
  {
2813
2813
  title: '弹窗背景',
2814
2814
  child: [
@@ -3245,9 +3245,9 @@ const AppointForm = createMaterial(AppointFormComponent, {
3245
3245
  category: 'popup',
3246
3246
  type: 'AppointForm',
3247
3247
  related: {
3248
- settingRender: settingRender$f,
3248
+ settingRender: settingRender$g,
3249
3249
  bindableProps: [],
3250
- interactionRender: interactionRender$h
3250
+ interactionRender: interactionRender$i
3251
3251
  },
3252
3252
  defaulSetting: {
3253
3253
  name: '表单',
@@ -3270,7 +3270,7 @@ const AppointForm = createMaterial(AppointFormComponent, {
3270
3270
  sort: 2
3271
3271
  });
3272
3272
 
3273
- var settingRender$e = [
3273
+ var settingRender$f = [
3274
3274
  {
3275
3275
  title: '弹窗背景',
3276
3276
  child: [
@@ -3668,6 +3668,22 @@ var settingRender$e = [
3668
3668
  name: ['props', 'enableFixedCloseButton']
3669
3669
  }
3670
3670
  ]
3671
+ },
3672
+ {
3673
+ title: '加购功能',
3674
+ child: [
3675
+ {
3676
+ label: '启用加购弹窗',
3677
+ type: 'Switch',
3678
+ name: ['props', 'enableAddToCart']
3679
+ },
3680
+ {
3681
+ label: '加购弹窗ID',
3682
+ type: 'Input',
3683
+ name: ['props', 'addToCartPopupId'],
3684
+ placeholder: '请输入加购弹窗的ID'
3685
+ }
3686
+ ]
3671
3687
  }
3672
3688
  ];
3673
3689
 
@@ -3687,7 +3703,7 @@ var settingRender$e = [
3687
3703
  * @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
3688
3704
  *
3689
3705
  */
3690
- var interactionRender$g = [
3706
+ var interactionRender$h = [
3691
3707
  {
3692
3708
  title: '滑动事件',
3693
3709
  child: [
@@ -11665,8 +11681,8 @@ const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef
11665
11681
 
11666
11682
  const CommodityDetail$1 = (_a) => {
11667
11683
  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;
11668
- 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"]);
11669
- const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef, globalConfig, ctaEvent } = useSxpDataSource();
11684
+ 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"]);
11685
+ const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef, globalConfig, ctaEvent, setPopupDetailData } = useSxpDataSource();
11670
11686
  const { jumpToWeb, productView } = useEventReport();
11671
11687
  const curTimeRef = React.useRef(null);
11672
11688
  const [showModal, setShowModal] = React.useState(false);
@@ -11687,6 +11703,28 @@ const CommodityDetail$1 = (_a) => {
11687
11703
  cta = p === null || p === void 0 ? void 0 : p.bindCta;
11688
11704
  }
11689
11705
  const handleLink = (e) => {
11706
+ // 如果启用了加购功能且配置了加购弹窗ID,则打开加购弹窗
11707
+ if (enableAddToCart && addToCartPopupId) {
11708
+ // 设置弹窗数据
11709
+ setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, data), { index: position }));
11710
+ // 上报点击事件
11711
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
11712
+ eventName: 'ClickCTA',
11713
+ product: product ? [product] : undefined,
11714
+ contentType: 'product',
11715
+ data,
11716
+ position,
11717
+ cta_text: cta === null || cta === void 0 ? void 0 : cta.enTitle,
11718
+ cta_action_type: 'open_internal_popup',
11719
+ target_content_id: product === null || product === void 0 ? void 0 : product.itemId
11720
+ });
11721
+ // 打开加购弹窗
11722
+ if (typeof window !== 'undefined' && window.sxpPopup) {
11723
+ window.sxpPopup(addToCartPopupId);
11724
+ }
11725
+ return;
11726
+ }
11727
+ // 默认行为:跳转到商品链接
11690
11728
  if (product === null || product === void 0 ? void 0 : product.link) {
11691
11729
  jumpToWeb(e, data, product, cta, position);
11692
11730
  if (!isPost) {
@@ -11811,10 +11849,11 @@ const CommodityDetail$1 = (_a) => {
11811
11849
  };
11812
11850
  const renderBtn = () => {
11813
11851
  var _a, _b;
11814
- 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 },
11815
- React.createElement("span", { dangerouslySetInnerHTML: {
11816
- __html: setFontForText((_b = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _b !== void 0 ? _b : 'Purchase on Website', buttonStyle)
11817
- } })))));
11852
+ return (React.createElement(React.Fragment, null,
11853
+ 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 },
11854
+ React.createElement("span", { dangerouslySetInnerHTML: {
11855
+ __html: setFontForText((_b = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _b !== void 0 ? _b : 'Purchase on Website', buttonStyle)
11856
+ } }))));
11818
11857
  };
11819
11858
  const getStyle = React.useCallback((style) => {
11820
11859
  if (style === null || style === void 0 ? void 0 : style.lineClamp) {
@@ -11957,8 +11996,8 @@ const CommodityDetail = createMaterial(CommodityDetailComponent, {
11957
11996
  category: 'popup',
11958
11997
  type: 'CommodityDetail',
11959
11998
  related: {
11960
- settingRender: settingRender$e,
11961
- interactionRender: interactionRender$g
11999
+ settingRender: settingRender$f,
12000
+ interactionRender: interactionRender$h
11962
12001
  },
11963
12002
  defaulSetting: {
11964
12003
  props: {
@@ -12013,7 +12052,7 @@ const CommodityDetail = createMaterial(CommodityDetailComponent, {
12013
12052
  sort: 1
12014
12053
  });
12015
12054
 
12016
- var interactionRender$f = [
12055
+ var interactionRender$g = [
12017
12056
  {
12018
12057
  title: '点击事件',
12019
12058
  child: [
@@ -12033,7 +12072,7 @@ var interactionRender$f = [
12033
12072
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Prompt\settingRender.tsx
12034
12073
  *
12035
12074
  */
12036
- var settingRender$d = [
12075
+ var settingRender$e = [
12037
12076
  {
12038
12077
  title: '弹窗背景',
12039
12078
  child: [
@@ -12213,9 +12252,9 @@ const Prompt = createMaterial(PromptComponent, {
12213
12252
  category: 'popup',
12214
12253
  type: 'Prompt',
12215
12254
  related: {
12216
- settingRender: settingRender$d,
12255
+ settingRender: settingRender$e,
12217
12256
  bindableProps: [],
12218
- interactionRender: interactionRender$f
12257
+ interactionRender: interactionRender$g
12219
12258
  },
12220
12259
  defaulSetting: {
12221
12260
  props: {
@@ -12238,7 +12277,7 @@ const Prompt = createMaterial(PromptComponent, {
12238
12277
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\CommodityDetailDiroNew\settingRender.tsx
12239
12278
  *
12240
12279
  */
12241
- var settingRender$c = [
12280
+ var settingRender$d = [
12242
12281
  {
12243
12282
  title: '弹窗背景',
12244
12283
  child: [
@@ -12937,10 +12976,10 @@ Made in Italy` })));
12937
12976
  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: {
12938
12977
  __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)
12939
12978
  } }))),
12940
- (!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 },
12979
+ 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 },
12941
12980
  React.createElement("span", { dangerouslySetInnerHTML: {
12942
12981
  __html: setFontForText((_4 = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _4 !== void 0 ? _4 : 'Shop now', buttonStyle)
12943
- } }))),
12982
+ } })),
12944
12983
  productInfoText({ isPost }))),
12945
12984
  React.createElement(Modal$1, { visible: showModal, onClose: () => setShowModal(false) },
12946
12985
  React.createElement("div", { style: { paddingTop: '34px' } }, productInfoText({ isPost: false }))),
@@ -12971,7 +13010,7 @@ var CommodityDetailDiroNewComponent = React.memo(CommodityDetailDiroNew$1);
12971
13010
  * @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
12972
13011
  *
12973
13012
  */
12974
- var interactionRender$e = [
13013
+ var interactionRender$f = [
12975
13014
  {
12976
13015
  title: '滑动事件',
12977
13016
  child: [
@@ -12998,8 +13037,8 @@ const CommodityDetailDiroNew = createMaterial(CommodityDetailDiroNewComponent, {
12998
13037
  category: 'popup',
12999
13038
  type: 'CommodityDetailDiroNew',
13000
13039
  related: {
13001
- settingRender: settingRender$c,
13002
- interactionRender: interactionRender$e
13040
+ settingRender: settingRender$d,
13041
+ interactionRender: interactionRender$f
13003
13042
  },
13004
13043
  defaulSetting: {
13005
13044
  props: {
@@ -13063,7 +13102,7 @@ const CommodityDetailDiroNew = createMaterial(CommodityDetailDiroNewComponent, {
13063
13102
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\CommodityList\settingRender.tsx
13064
13103
  *
13065
13104
  */
13066
- var settingRender$b = [
13105
+ var settingRender$c = [
13067
13106
  {
13068
13107
  title: '弹窗背景',
13069
13108
  child: [
@@ -13488,7 +13527,7 @@ var CommodityListComponent = React.memo(CommodityList$1);
13488
13527
  * @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
13489
13528
  *
13490
13529
  */
13491
- var interactionRender$d = [
13530
+ var interactionRender$e = [
13492
13531
  {
13493
13532
  title: '点击事件',
13494
13533
  child: [
@@ -13515,8 +13554,8 @@ const CommodityList = createMaterial(CommodityListComponent, {
13515
13554
  category: 'popup',
13516
13555
  type: 'CommodityList',
13517
13556
  related: {
13518
- settingRender: settingRender$b,
13519
- interactionRender: interactionRender$d
13557
+ settingRender: settingRender$c,
13558
+ interactionRender: interactionRender$e
13520
13559
  },
13521
13560
  defaulSetting: {
13522
13561
  props: {
@@ -13564,7 +13603,7 @@ const CommodityList = createMaterial(CommodityListComponent, {
13564
13603
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Iframe\settingRender.tsx
13565
13604
  *
13566
13605
  */
13567
- var settingRender$a = [
13606
+ var settingRender$b = [
13568
13607
  {
13569
13608
  title: '背景样式',
13570
13609
  child: [
@@ -13598,7 +13637,7 @@ const Iframe = createMaterial(IframeComponent, {
13598
13637
  category: 'popup',
13599
13638
  type: 'Iframe',
13600
13639
  related: {
13601
- settingRender: settingRender$a,
13640
+ settingRender: settingRender$b,
13602
13641
  bindableProps: []
13603
13642
  },
13604
13643
  defaulSetting: {
@@ -13618,7 +13657,7 @@ const Iframe = createMaterial(IframeComponent, {
13618
13657
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\ConsentDetail\settingRender.tsx
13619
13658
  *
13620
13659
  */
13621
- var settingRender$9 = [
13660
+ var settingRender$a = [
13622
13661
  {
13623
13662
  title: '弹窗文本',
13624
13663
  child: [
@@ -13647,7 +13686,7 @@ const ConsentDetail = createMaterial(ConsentDetail$2, {
13647
13686
  category: 'popup',
13648
13687
  type: 'ConsentDetail',
13649
13688
  related: {
13650
- settingRender: settingRender$9,
13689
+ settingRender: settingRender$a,
13651
13690
  bindableProps: []
13652
13691
  },
13653
13692
  defaulSetting: {
@@ -13659,6 +13698,666 @@ const ConsentDetail = createMaterial(ConsentDetail$2, {
13659
13698
  sort: 7
13660
13699
  });
13661
13700
 
13701
+ var settingRender$9 = [
13702
+ {
13703
+ title: 'Shopify配置',
13704
+ child: [
13705
+ {
13706
+ type: 'Input',
13707
+ label: 'Shopify域名',
13708
+ name: ['props', 'shopifyDomain'],
13709
+ placeholder: 'your-store.myshopify.com'
13710
+ },
13711
+ {
13712
+ type: 'Input',
13713
+ label: 'Storefront Token',
13714
+ name: ['props', 'storefrontAccessToken'],
13715
+ placeholder: 'Storefront Access Token'
13716
+ }
13717
+ ]
13718
+ },
13719
+ {
13720
+ title: '弹窗背景',
13721
+ child: [
13722
+ {
13723
+ type: 'Number',
13724
+ label: '左右边距',
13725
+ name: ['props', 'popupBg', 'horizontalMargin']
13726
+ },
13727
+ {
13728
+ type: 'Number',
13729
+ label: '下边距',
13730
+ name: ['props', 'popupBg', 'bottomMargin']
13731
+ }
13732
+ ]
13733
+ },
13734
+ {
13735
+ title: '商品信息样式',
13736
+ child: [
13737
+ {
13738
+ name: ['props', 'variantStyles'],
13739
+ type: 'SelectLinkage',
13740
+ child: [
13741
+ {
13742
+ label: '字段',
13743
+ type: 'Select',
13744
+ options: [
13745
+ {
13746
+ label: '商品标题',
13747
+ value: 'title'
13748
+ },
13749
+ {
13750
+ label: '价格',
13751
+ value: 'price'
13752
+ },
13753
+ {
13754
+ label: '规格选项',
13755
+ value: 'option'
13756
+ },
13757
+ {
13758
+ label: '已选规格',
13759
+ value: 'selectedOption'
13760
+ }
13761
+ ],
13762
+ name: ['props', 'variantStyles', 'field'],
13763
+ initialValue: 'title'
13764
+ },
13765
+ {
13766
+ type: 'Group',
13767
+ child: [
13768
+ {
13769
+ label: '上边距',
13770
+ type: 'Number',
13771
+ addonAfter: 'px',
13772
+ name: ['marginTop']
13773
+ },
13774
+ {
13775
+ label: '下边距',
13776
+ type: 'Number',
13777
+ addonAfter: 'px',
13778
+ name: ['marginBottom']
13779
+ }
13780
+ ]
13781
+ },
13782
+ {
13783
+ type: 'Group',
13784
+ label: '字体',
13785
+ child: [
13786
+ {
13787
+ type: 'Select',
13788
+ name: ['fontFamily-cn'],
13789
+ bottomText: '中文字体'
13790
+ },
13791
+ {
13792
+ type: 'Select',
13793
+ name: ['fontFamily-en'],
13794
+ bottomText: '英文/其他字体'
13795
+ }
13796
+ ]
13797
+ },
13798
+ {
13799
+ type: 'Group',
13800
+ label: '',
13801
+ child: [
13802
+ {
13803
+ type: 'Color',
13804
+ name: ['color']
13805
+ },
13806
+ {
13807
+ type: 'Number',
13808
+ addonAfter: 'px',
13809
+ name: ['fontSize']
13810
+ }
13811
+ ]
13812
+ },
13813
+ {
13814
+ label: '样式',
13815
+ type: 'TextStyle'
13816
+ },
13817
+ {
13818
+ label: '对齐',
13819
+ type: 'TextAlign'
13820
+ },
13821
+ {
13822
+ label: '间距',
13823
+ type: 'TextSpace'
13824
+ }
13825
+ ]
13826
+ }
13827
+ ]
13828
+ },
13829
+ {
13830
+ title: '加购按钮样式',
13831
+ child: [
13832
+ {
13833
+ label: '英文大小写',
13834
+ type: 'Select',
13835
+ name: ['props', 'buttonStyle', 'textTransform'],
13836
+ options: [
13837
+ {
13838
+ label: '默认',
13839
+ value: 'unset'
13840
+ },
13841
+ {
13842
+ label: '小写',
13843
+ value: 'lowercase'
13844
+ },
13845
+ {
13846
+ label: '大写',
13847
+ value: 'uppercase'
13848
+ }
13849
+ ]
13850
+ },
13851
+ {
13852
+ type: 'Color',
13853
+ label: '背景色',
13854
+ name: ['props', 'buttonStyle', 'backgroundColor'],
13855
+ initialValue: '#000'
13856
+ },
13857
+ {
13858
+ type: 'Group',
13859
+ label: '尺寸',
13860
+ child: [
13861
+ {
13862
+ type: 'Number',
13863
+ name: ['props', 'buttonStyle', 'height'],
13864
+ addonAfter: 'H'
13865
+ }
13866
+ ]
13867
+ },
13868
+ {
13869
+ type: 'Group',
13870
+ label: '圆角',
13871
+ child: [
13872
+ {
13873
+ type: 'Slider',
13874
+ name: ['props', 'buttonStyle', 'borderRadius'],
13875
+ max: 100
13876
+ },
13877
+ {
13878
+ type: 'Number',
13879
+ name: ['props', 'buttonStyle', 'borderRadius'],
13880
+ addonAfter: 'px',
13881
+ max: 100
13882
+ }
13883
+ ]
13884
+ },
13885
+ {
13886
+ type: 'TextMargin',
13887
+ name: ['props', 'buttonStyle']
13888
+ },
13889
+ {
13890
+ type: 'Group',
13891
+ label: '字体',
13892
+ child: [
13893
+ {
13894
+ type: 'Select',
13895
+ name: ['props', 'buttonStyle', 'fontFamily-cn'],
13896
+ bottomText: '中文字体'
13897
+ },
13898
+ {
13899
+ type: 'Select',
13900
+ name: ['props', 'buttonStyle', 'fontFamily-en'],
13901
+ bottomText: '英文/其他字体'
13902
+ }
13903
+ ]
13904
+ },
13905
+ {
13906
+ type: 'Group',
13907
+ label: '',
13908
+ child: [
13909
+ {
13910
+ type: 'Color',
13911
+ name: ['props', 'buttonStyle', 'color'],
13912
+ initialValue: '#fff'
13913
+ },
13914
+ {
13915
+ type: 'Number',
13916
+ name: ['props', 'buttonStyle', 'fontSize'],
13917
+ addonAfter: 'px'
13918
+ }
13919
+ ]
13920
+ },
13921
+ {
13922
+ type: 'TextStyle',
13923
+ name: ['props', 'buttonStyle']
13924
+ },
13925
+ {
13926
+ type: 'TextAlign',
13927
+ name: ['props', 'buttonStyle']
13928
+ },
13929
+ {
13930
+ label: '间距',
13931
+ type: 'TextSpace',
13932
+ name: ['props', 'buttonStyle']
13933
+ }
13934
+ ]
13935
+ },
13936
+ {
13937
+ title: '文案配置',
13938
+ child: [
13939
+ {
13940
+ type: 'Input',
13941
+ label: '加购按钮文案',
13942
+ name: ['props', 'texts', 'addToCart'],
13943
+ placeholder: 'Add to Cart'
13944
+ },
13945
+ {
13946
+ type: 'Input',
13947
+ label: '选择规格提示',
13948
+ name: ['props', 'texts', 'selectOptions'],
13949
+ placeholder: 'Please select options'
13950
+ },
13951
+ {
13952
+ type: 'Input',
13953
+ label: '加载文案',
13954
+ name: ['props', 'texts', 'loading'],
13955
+ placeholder: 'Loading...'
13956
+ },
13957
+ {
13958
+ type: 'Input',
13959
+ label: '错误文案',
13960
+ name: ['props', 'texts', 'error'],
13961
+ placeholder: 'Failed to load product'
13962
+ }
13963
+ ]
13964
+ },
13965
+ {
13966
+ title: '数量选择器',
13967
+ child: [
13968
+ {
13969
+ type: 'Number',
13970
+ label: '按钮间距',
13971
+ name: ['props', 'quantityStyle', 'gap'],
13972
+ addonAfter: 'px',
13973
+ initialValue: 12
13974
+ }
13975
+ ]
13976
+ }
13977
+ ];
13978
+
13979
+ /*
13980
+ * @Author: tao
13981
+ * @Date: 2026-01-12
13982
+ * @Description: Add to Cart 交互配置
13983
+ */
13984
+ var interactionRender$d = () => {
13985
+ return (React.createElement("div", { style: { padding: '20px', color: '#666' } },
13986
+ React.createElement("p", null, "\u52A0\u8D2D\u5546\u54C1\u5F39\u7A97\u4EA4\u4E92\u8BF4\u660E\uFF1A"),
13987
+ React.createElement("ul", { style: { paddingLeft: '20px', lineHeight: '1.8' } },
13988
+ React.createElement("li", null, "\u70B9\u51FB\u5546\u54C1\u8BE6\u60C5\u5F39\u7A97\u7684\"Shop Now\"\u6309\u94AE\u540E\u81EA\u52A8\u5C55\u793A"),
13989
+ React.createElement("li", null, "\u901A\u8FC7Shopify Storefront API\u83B7\u53D6\u5546\u54C1\u89C4\u683C\u548C\u5E93\u5B58\u4FE1\u606F"),
13990
+ React.createElement("li", null, "\u7528\u6237\u9009\u62E9\u89C4\u683C\u540E\u5B9E\u65F6\u663E\u793A\u5BF9\u5E94SKU\u7684\u4EF7\u683C\u548C\u5E93\u5B58"),
13991
+ React.createElement("li", null, "\u70B9\u51FB\"Add to Cart\"\u6309\u94AE\u540E\u8DF3\u8F6C\u81F3Shopify\u8D2D\u7269\u8F66\u9875\u9762"),
13992
+ React.createElement("li", null, "\u65E0\u5E93\u5B58\u6216\u4E0D\u53EF\u552E\u5356\u7684\u89C4\u683C\u81EA\u52A8\u7F6E\u7070\u4E0D\u53EF\u9009"))));
13993
+ };
13994
+
13995
+ const AddToCartPopup$1 = (_a) => {
13996
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
13997
+ 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"]);
13998
+ const { sxpParameter, popupDetailData, isPreview, bffFbReport, globalConfig } = useSxpDataSource();
13999
+ useEventReport();
14000
+ const curTimeRef = React.useRef(null);
14001
+ const [productData, setProductData] = React.useState(null);
14002
+ const [selectedOptions, setSelectedOptions] = React.useState({});
14003
+ const [selectedVariant, setSelectedVariant] = React.useState(null);
14004
+ const [quantity, setQuantity] = React.useState(1);
14005
+ const [loading, setLoading] = React.useState(true);
14006
+ const [error, setError] = React.useState(null);
14007
+ // 获取当前弹窗商品数据(自动从 popupDetailData 获取)
14008
+ const data = popupDetailData;
14009
+ 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];
14010
+ product === null || product === void 0 ? void 0 : product.bindCta;
14011
+ 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;
14012
+ // Shopify配置 - 优先级:props > globalConfig > 默认值
14013
+ const finalShopifyDomain = shopifyDomain || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.shopifyDomain) || 'dev-store-749237498237498636.myshopify.com';
14014
+ const finalStorefrontToken = storefrontAccessToken || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.storefrontAccessToken) || '77d894c490f79430ce7bd0a7efdff6b7';
14015
+ // 自动从商品数据获取 Shopify Product ID
14016
+ const productId = (product === null || product === void 0 ? void 0 : product.itemId) || '';
14017
+ // 文案
14018
+ const finalTexts = {
14019
+ addToCart: texts.addToCart || 'Add to Cart',
14020
+ selectOptions: texts.selectOptions || 'Please select options',
14021
+ loading: texts.loading || 'Loading...',
14022
+ error: texts.error || 'Failed to load product',
14023
+ color: texts.color || 'Color',
14024
+ size: texts.size || 'Size',
14025
+ material: texts.material || 'Material',
14026
+ style: texts.style || 'Style'
14027
+ };
14028
+ // 查询Shopify商品数据
14029
+ const fetchProductData = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
14030
+ var _m;
14031
+ if (!productId || !finalShopifyDomain || !finalStorefrontToken) {
14032
+ console.log('[AddToCartPopup] 缺少必要配置:', {
14033
+ productId,
14034
+ shopifyDomain: finalShopifyDomain,
14035
+ hasToken: !!finalStorefrontToken
14036
+ });
14037
+ setLoading(false);
14038
+ return;
14039
+ }
14040
+ console.log('[AddToCartPopup] 开始加载商品数据:', {
14041
+ productId,
14042
+ shopifyDomain: finalShopifyDomain
14043
+ });
14044
+ setLoading(true);
14045
+ setError(null);
14046
+ try {
14047
+ const query = `
14048
+ query getProduct($id: ID!) {
14049
+ product(id: $id) {
14050
+ id
14051
+ title
14052
+ images(first: 10) {
14053
+ edges {
14054
+ node {
14055
+ url
14056
+ }
14057
+ }
14058
+ }
14059
+ options {
14060
+ name
14061
+ values
14062
+ }
14063
+ variants(first: 100) {
14064
+ edges {
14065
+ node {
14066
+ id
14067
+ title
14068
+ availableForSale
14069
+ quantityAvailable
14070
+ price {
14071
+ amount
14072
+ currencyCode
14073
+ }
14074
+ image {
14075
+ url
14076
+ }
14077
+ selectedOptions {
14078
+ name
14079
+ value
14080
+ }
14081
+ }
14082
+ }
14083
+ }
14084
+ }
14085
+ }
14086
+ `;
14087
+ // 确保 Product ID 格式正确
14088
+ const formattedProductId = productId.startsWith('gid://')
14089
+ ? productId
14090
+ : `gid://shopify/Product/${productId}`;
14091
+ console.log('[AddToCartPopup] 使用的 Product ID:', formattedProductId);
14092
+ const response = yield fetch(`https://${finalShopifyDomain}/api/2024-01/graphql.json`, {
14093
+ method: 'POST',
14094
+ headers: {
14095
+ 'Content-Type': 'application/json',
14096
+ 'X-Shopify-Storefront-Access-Token': finalStorefrontToken
14097
+ },
14098
+ body: JSON.stringify({
14099
+ query,
14100
+ variables: { id: formattedProductId }
14101
+ })
14102
+ });
14103
+ if (!response.ok) {
14104
+ throw new Error(`HTTP ${response.status}`);
14105
+ }
14106
+ const result = yield response.json();
14107
+ if (result.errors) {
14108
+ console.error('[AddToCartPopup] GraphQL 错误:', result.errors);
14109
+ throw new Error(result.errors[0].message);
14110
+ }
14111
+ if (!((_m = result.data) === null || _m === void 0 ? void 0 : _m.product)) {
14112
+ console.error('[AddToCartPopup] 未找到商品');
14113
+ throw new Error('Product not found');
14114
+ }
14115
+ console.log('[AddToCartPopup] 商品数据加载成功:', result.data.product.title);
14116
+ setProductData(result.data.product);
14117
+ }
14118
+ catch (err) {
14119
+ const errorMessage = err instanceof Error ? err.message : finalTexts.error;
14120
+ setError(errorMessage);
14121
+ console.error('[AddToCartPopup] 加载失败:', err);
14122
+ }
14123
+ finally {
14124
+ setLoading(false);
14125
+ }
14126
+ }), [productId, finalShopifyDomain, finalStorefrontToken, finalTexts.error]);
14127
+ React.useEffect(() => {
14128
+ if (isActive) {
14129
+ fetchProductData();
14130
+ }
14131
+ }, [isActive, fetchProductData]);
14132
+ // 根据选中的规格匹配variant
14133
+ React.useEffect(() => {
14134
+ if (!productData)
14135
+ return;
14136
+ const variants = productData.variants.edges.map(edge => edge.node);
14137
+ const optionsCount = productData.options.length;
14138
+ const selectedCount = Object.keys(selectedOptions).length;
14139
+ if (selectedCount === 0 || selectedCount < optionsCount) {
14140
+ setSelectedVariant(null);
14141
+ return;
14142
+ }
14143
+ const matchedVariant = variants.find(variant => {
14144
+ return variant.selectedOptions.every(option => selectedOptions[option.name] === option.value);
14145
+ });
14146
+ setSelectedVariant(matchedVariant || null);
14147
+ setQuantity(1);
14148
+ }, [selectedOptions, productData]);
14149
+ // 处理规格选择
14150
+ const handleOptionSelect = React.useCallback((optionName, value) => {
14151
+ setSelectedOptions(prev => {
14152
+ const newOptions = Object.assign({}, prev);
14153
+ if (newOptions[optionName] === value) {
14154
+ delete newOptions[optionName];
14155
+ }
14156
+ else {
14157
+ newOptions[optionName] = value;
14158
+ }
14159
+ return newOptions;
14160
+ });
14161
+ }, []);
14162
+ // 处理数量变化
14163
+ const handleQuantityChange = React.useCallback((delta) => {
14164
+ setQuantity(prev => {
14165
+ var _a;
14166
+ const newQuantity = prev + delta;
14167
+ const maxQuantity = (_a = selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.quantityAvailable) !== null && _a !== void 0 ? _a : 999;
14168
+ return Math.max(1, Math.min(newQuantity, maxQuantity));
14169
+ });
14170
+ }, [selectedVariant]);
14171
+ // 检查某个规格值是否可用
14172
+ const isOptionValueAvailable = React.useCallback((optionName, value) => {
14173
+ if (!productData)
14174
+ return false;
14175
+ const variants = productData.variants.edges.map(edge => edge.node);
14176
+ const tempOptions = Object.assign(Object.assign({}, selectedOptions), { [optionName]: value });
14177
+ return variants.some(variant => {
14178
+ const matches = variant.selectedOptions.every(option => !tempOptions[option.name] || tempOptions[option.name] === option.value);
14179
+ const hasStock = variant.quantityAvailable === null || variant.quantityAvailable > 0;
14180
+ return matches && variant.availableForSale && hasStock;
14181
+ });
14182
+ }, [productData, selectedOptions]);
14183
+ // 处理加购
14184
+ const handleAddToCart = React.useCallback(() => {
14185
+ var _a;
14186
+ if (!selectedVariant || quantity === 0)
14187
+ return;
14188
+ const variantId = selectedVariant.id.split('/').pop();
14189
+ const cartUrl = `https://${finalShopifyDomain}/cart/add?id=${variantId}&quantity=${quantity}`;
14190
+ console.log('[AddToCartPopup] 加购:', {
14191
+ variantId,
14192
+ quantity,
14193
+ cartUrl
14194
+ });
14195
+ // 上报事件
14196
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
14197
+ eventName: 'AddToCart',
14198
+ product: product ? [product] : undefined,
14199
+ contentType: 'product',
14200
+ data,
14201
+ position,
14202
+ content_id: (_a = product === null || product === void 0 ? void 0 : product.itemId) !== null && _a !== void 0 ? _a : '',
14203
+ value: parseFloat(selectedVariant.price.amount) * quantity,
14204
+ currency: selectedVariant.price.currencyCode,
14205
+ contents: [{
14206
+ id: variantId,
14207
+ quantity
14208
+ }]
14209
+ });
14210
+ // 跳转到Shopify购物车页面
14211
+ window.location.href = cartUrl;
14212
+ }, [selectedVariant, quantity, finalShopifyDomain, bffFbReport, product, data, position]);
14213
+ // 计算总价
14214
+ const totalPrice = React.useMemo(() => {
14215
+ if (!selectedVariant)
14216
+ return null;
14217
+ const price = parseFloat(selectedVariant.price.amount);
14218
+ const total = price * quantity;
14219
+ return total.toFixed(2);
14220
+ }, [selectedVariant, quantity]);
14221
+ // 初始化时间
14222
+ React.useEffect(() => {
14223
+ const initTime = () => {
14224
+ curTimeRef.current = new Date();
14225
+ };
14226
+ initTime();
14227
+ window.addEventListener('pageshow', initTime);
14228
+ return () => {
14229
+ window.removeEventListener('pageshow', initTime);
14230
+ };
14231
+ }, []);
14232
+ // 加载中
14233
+ if (loading) {
14234
+ return (React.createElement("div", { className: "add-to-cart-popup-loading", style: style },
14235
+ React.createElement("div", null, finalTexts.loading)));
14236
+ }
14237
+ // 错误状态
14238
+ if (error || !productData) {
14239
+ return (React.createElement("div", { className: "add-to-cart-popup-error", style: style },
14240
+ React.createElement("div", null,
14241
+ finalTexts.error,
14242
+ ": ",
14243
+ error || 'Product not found')));
14244
+ }
14245
+ 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]) || '';
14246
+ const hasAllOptionsSelected = productData.options.length === Object.keys(selectedOptions).length;
14247
+ const isAddToCartDisabled = !selectedVariant || quantity === 0;
14248
+ return (React.createElement("div", Object.assign({ className: "add-to-cart-popup-container", style: style }, props),
14249
+ React.createElement("div", { className: "variant-detail-section" },
14250
+ React.createElement("div", { className: "variant-image-wrapper" },
14251
+ React.createElement("img", { src: mainImage, alt: productData.title, className: "variant-image" })),
14252
+ React.createElement("div", { className: "variant-info-wrapper" },
14253
+ React.createElement("h2", { className: "product-title-text", style: variantStyles.title, dangerouslySetInnerHTML: {
14254
+ __html: setFontForText(productData.title, variantStyles.title)
14255
+ } }),
14256
+ selectedVariant && (React.createElement(React.Fragment, null,
14257
+ React.createElement("div", { className: "selected-options-tags" }, selectedVariant.selectedOptions.map(option => (React.createElement("span", { key: option.name, className: "option-tag", style: variantStyles.selectedOption },
14258
+ option.name,
14259
+ ": ",
14260
+ option.value)))),
14261
+ React.createElement("div", { className: "price-display" },
14262
+ React.createElement("span", { className: "price-value", style: variantStyles.price, dangerouslySetInnerHTML: {
14263
+ __html: setFontForText(`${selectedVariant.price.currencyCode} $${totalPrice}`, variantStyles.price)
14264
+ } })),
14265
+ React.createElement("div", { className: "quantity-selector-wrapper", style: quantityStyle },
14266
+ React.createElement("button", { className: "quantity-btn quantity-decrease", onClick: () => handleQuantityChange(-1), disabled: quantity <= 1, "aria-label": "Decrease quantity" }, "-"),
14267
+ React.createElement("input", { type: "number", value: quantity, readOnly: true, className: "quantity-input-field", "aria-label": "Quantity" }),
14268
+ 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" }, "+")))),
14269
+ !hasAllOptionsSelected && (React.createElement("div", { className: "no-selection-hint", style: variantStyles.option }, finalTexts.selectOptions)))),
14270
+ React.createElement("div", { className: "variant-options-section" }, productData.options.map(option => (React.createElement("div", { key: option.name, className: "option-group-wrapper" },
14271
+ React.createElement("h3", { className: "option-group-name", style: variantStyles.option, dangerouslySetInnerHTML: {
14272
+ __html: setFontForText(option.name, variantStyles.option)
14273
+ } }),
14274
+ React.createElement("div", { className: "option-values-grid" }, option.values.map(value => {
14275
+ const isSelected = selectedOptions[option.name] === value;
14276
+ const isAvailable = isOptionValueAvailable(option.name, value);
14277
+ 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));
14278
+ })))))),
14279
+ React.createElement("button", { className: `add-to-cart-button ${isAddToCartDisabled ? 'disabled' : ''}`, style: buttonStyle, onClick: handleAddToCart, disabled: isAddToCartDisabled, "aria-label": finalTexts.addToCart },
14280
+ React.createElement("span", { dangerouslySetInnerHTML: {
14281
+ __html: setFontForText(finalTexts.addToCart, buttonStyle)
14282
+ } }))));
14283
+ };
14284
+
14285
+ /*
14286
+ * @Author: tao
14287
+ * @Date: 2026-01-12
14288
+ * @Description: Add to Cart 弹窗组件物料配置
14289
+ */
14290
+ const AddToCartPopup = createMaterial(AddToCartPopup$1, {
14291
+ displayName: '加购商品',
14292
+ icon: '',
14293
+ category: 'popup',
14294
+ type: 'AddToCartPopup',
14295
+ related: {
14296
+ settingRender: settingRender$9,
14297
+ interactionRender: interactionRender$d
14298
+ },
14299
+ defaulSetting: {
14300
+ props: {
14301
+ shopifyDomain: '',
14302
+ storefrontAccessToken: '',
14303
+ variantStyles: {
14304
+ title: {
14305
+ color: '#000',
14306
+ fontSize: 20,
14307
+ fontWeight: 600,
14308
+ marginBottom: 12
14309
+ },
14310
+ price: {
14311
+ color: '#000',
14312
+ fontSize: 24,
14313
+ fontWeight: 700,
14314
+ marginBottom: 16
14315
+ },
14316
+ option: {
14317
+ color: '#111',
14318
+ fontSize: 16,
14319
+ fontWeight: 600,
14320
+ marginBottom: 12
14321
+ },
14322
+ selectedOption: {
14323
+ fontSize: 14,
14324
+ color: '#374151'
14325
+ }
14326
+ },
14327
+ buttonStyle: {
14328
+ backgroundColor: '#000',
14329
+ color: '#fff',
14330
+ fontSize: 16,
14331
+ height: 52,
14332
+ fontWeight: 600,
14333
+ textAlign: 'center',
14334
+ textTransform: 'uppercase'
14335
+ },
14336
+ quantityStyle: {
14337
+ gap: 12
14338
+ },
14339
+ texts: {
14340
+ addToCart: 'Add to Cart',
14341
+ selectOptions: 'Please select options',
14342
+ loading: 'Loading...',
14343
+ error: 'Failed to load product',
14344
+ color: 'Color',
14345
+ size: 'Size',
14346
+ material: 'Material',
14347
+ style: 'Style'
14348
+ },
14349
+ popupBg: {
14350
+ horizontalMargin: 0,
14351
+ bottomMargin: 0
14352
+ }
14353
+ },
14354
+ style: {}
14355
+ },
14356
+ w: 100,
14357
+ h: 40,
14358
+ sort: 7
14359
+ });
14360
+
13662
14361
  /*
13663
14362
  * @Author: binruan@chatlabs.com
13664
14363
  * @Date: 2024-03-26 16:50:25
@@ -19150,6 +19849,7 @@ const MultiPosts = createMaterial(MultiPosts$2, {
19150
19849
 
19151
19850
  var _materials_ = /*#__PURE__*/Object.freeze({
19152
19851
  __proto__: null,
19852
+ AddToCartPopup: AddToCartPopup,
19153
19853
  AniLink: AniLink,
19154
19854
  AniLinkPopup: AniLinkPopup,
19155
19855
  Appoint: Appoint,