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.js CHANGED
@@ -2766,7 +2766,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
2766
2766
  StructurePage: StructurePage
2767
2767
  });
2768
2768
 
2769
- var interactionRender$h = [
2769
+ var interactionRender$i = [
2770
2770
  {
2771
2771
  title: '点击事件',
2772
2772
  child: [
@@ -2786,7 +2786,7 @@ var interactionRender$h = [
2786
2786
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\AppointForm\settingRender.tsx
2787
2787
  *
2788
2788
  */
2789
- var settingRender$f = [
2789
+ var settingRender$g = [
2790
2790
  {
2791
2791
  title: '弹窗背景',
2792
2792
  child: [
@@ -3223,9 +3223,9 @@ const AppointForm = createMaterial(AppointFormComponent, {
3223
3223
  category: 'popup',
3224
3224
  type: 'AppointForm',
3225
3225
  related: {
3226
- settingRender: settingRender$f,
3226
+ settingRender: settingRender$g,
3227
3227
  bindableProps: [],
3228
- interactionRender: interactionRender$h
3228
+ interactionRender: interactionRender$i
3229
3229
  },
3230
3230
  defaulSetting: {
3231
3231
  name: '表单',
@@ -3248,7 +3248,7 @@ const AppointForm = createMaterial(AppointFormComponent, {
3248
3248
  sort: 2
3249
3249
  });
3250
3250
 
3251
- var settingRender$e = [
3251
+ var settingRender$f = [
3252
3252
  {
3253
3253
  title: '弹窗背景',
3254
3254
  child: [
@@ -3646,6 +3646,22 @@ var settingRender$e = [
3646
3646
  name: ['props', 'enableFixedCloseButton']
3647
3647
  }
3648
3648
  ]
3649
+ },
3650
+ {
3651
+ title: '加购功能',
3652
+ child: [
3653
+ {
3654
+ label: '启用加购弹窗',
3655
+ type: 'Switch',
3656
+ name: ['props', 'enableAddToCart']
3657
+ },
3658
+ {
3659
+ label: '加购弹窗ID',
3660
+ type: 'Input',
3661
+ name: ['props', 'addToCartPopupId'],
3662
+ placeholder: '请输入加购弹窗的ID'
3663
+ }
3664
+ ]
3649
3665
  }
3650
3666
  ];
3651
3667
 
@@ -3665,7 +3681,7 @@ var settingRender$e = [
3665
3681
  * @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
3666
3682
  *
3667
3683
  */
3668
- var interactionRender$g = [
3684
+ var interactionRender$h = [
3669
3685
  {
3670
3686
  title: '滑动事件',
3671
3687
  child: [
@@ -11643,8 +11659,8 @@ const getPriceText = ({ product, enableFormattedPrice, globalConfig, isHiddenDef
11643
11659
 
11644
11660
  const CommodityDetail$1 = (_a) => {
11645
11661
  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;
11646
- 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"]);
11647
- const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef, globalConfig, ctaEvent } = useSxpDataSource();
11662
+ 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"]);
11663
+ const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef, globalConfig, ctaEvent, setPopupDetailData } = useSxpDataSource();
11648
11664
  const { jumpToWeb, productView } = useEventReport();
11649
11665
  const curTimeRef = useRef(null);
11650
11666
  const [showModal, setShowModal] = useState(false);
@@ -11665,6 +11681,28 @@ const CommodityDetail$1 = (_a) => {
11665
11681
  cta = p === null || p === void 0 ? void 0 : p.bindCta;
11666
11682
  }
11667
11683
  const handleLink = (e) => {
11684
+ // 如果启用了加购功能且配置了加购弹窗ID,则打开加购弹窗
11685
+ if (enableAddToCart && addToCartPopupId) {
11686
+ // 设置弹窗数据
11687
+ setPopupDetailData === null || setPopupDetailData === void 0 ? void 0 : setPopupDetailData(Object.assign(Object.assign({}, data), { index: position }));
11688
+ // 上报点击事件
11689
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
11690
+ eventName: 'ClickCTA',
11691
+ product: product ? [product] : undefined,
11692
+ contentType: 'product',
11693
+ data,
11694
+ position,
11695
+ cta_text: cta === null || cta === void 0 ? void 0 : cta.enTitle,
11696
+ cta_action_type: 'open_internal_popup',
11697
+ target_content_id: product === null || product === void 0 ? void 0 : product.itemId
11698
+ });
11699
+ // 打开加购弹窗
11700
+ if (typeof window !== 'undefined' && window.sxpPopup) {
11701
+ window.sxpPopup(addToCartPopupId);
11702
+ }
11703
+ return;
11704
+ }
11705
+ // 默认行为:跳转到商品链接
11668
11706
  if (product === null || product === void 0 ? void 0 : product.link) {
11669
11707
  jumpToWeb(e, data, product, cta, position);
11670
11708
  if (!isPost) {
@@ -11789,10 +11827,11 @@ const CommodityDetail$1 = (_a) => {
11789
11827
  };
11790
11828
  const renderBtn = () => {
11791
11829
  var _a, _b;
11792
- 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 },
11793
- React.createElement("span", { dangerouslySetInnerHTML: {
11794
- __html: setFontForText((_b = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _b !== void 0 ? _b : 'Purchase on Website', buttonStyle)
11795
- } })))));
11830
+ return (React.createElement(React.Fragment, null,
11831
+ 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 },
11832
+ React.createElement("span", { dangerouslySetInnerHTML: {
11833
+ __html: setFontForText((_b = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _b !== void 0 ? _b : 'Purchase on Website', buttonStyle)
11834
+ } }))));
11796
11835
  };
11797
11836
  const getStyle = useCallback((style) => {
11798
11837
  if (style === null || style === void 0 ? void 0 : style.lineClamp) {
@@ -11935,8 +11974,8 @@ const CommodityDetail = createMaterial(CommodityDetailComponent, {
11935
11974
  category: 'popup',
11936
11975
  type: 'CommodityDetail',
11937
11976
  related: {
11938
- settingRender: settingRender$e,
11939
- interactionRender: interactionRender$g
11977
+ settingRender: settingRender$f,
11978
+ interactionRender: interactionRender$h
11940
11979
  },
11941
11980
  defaulSetting: {
11942
11981
  props: {
@@ -11991,7 +12030,7 @@ const CommodityDetail = createMaterial(CommodityDetailComponent, {
11991
12030
  sort: 1
11992
12031
  });
11993
12032
 
11994
- var interactionRender$f = [
12033
+ var interactionRender$g = [
11995
12034
  {
11996
12035
  title: '点击事件',
11997
12036
  child: [
@@ -12011,7 +12050,7 @@ var interactionRender$f = [
12011
12050
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Prompt\settingRender.tsx
12012
12051
  *
12013
12052
  */
12014
- var settingRender$d = [
12053
+ var settingRender$e = [
12015
12054
  {
12016
12055
  title: '弹窗背景',
12017
12056
  child: [
@@ -12191,9 +12230,9 @@ const Prompt = createMaterial(PromptComponent, {
12191
12230
  category: 'popup',
12192
12231
  type: 'Prompt',
12193
12232
  related: {
12194
- settingRender: settingRender$d,
12233
+ settingRender: settingRender$e,
12195
12234
  bindableProps: [],
12196
- interactionRender: interactionRender$f
12235
+ interactionRender: interactionRender$g
12197
12236
  },
12198
12237
  defaulSetting: {
12199
12238
  props: {
@@ -12216,7 +12255,7 @@ const Prompt = createMaterial(PromptComponent, {
12216
12255
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\CommodityDetailDiroNew\settingRender.tsx
12217
12256
  *
12218
12257
  */
12219
- var settingRender$c = [
12258
+ var settingRender$d = [
12220
12259
  {
12221
12260
  title: '弹窗背景',
12222
12261
  child: [
@@ -12915,10 +12954,10 @@ Made in Italy` })));
12915
12954
  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: {
12916
12955
  __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)
12917
12956
  } }))),
12918
- (!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 },
12957
+ 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 },
12919
12958
  React.createElement("span", { dangerouslySetInnerHTML: {
12920
12959
  __html: setFontForText((_4 = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _4 !== void 0 ? _4 : 'Shop now', buttonStyle)
12921
- } }))),
12960
+ } })),
12922
12961
  productInfoText({ isPost }))),
12923
12962
  React.createElement(Modal$1, { visible: showModal, onClose: () => setShowModal(false) },
12924
12963
  React.createElement("div", { style: { paddingTop: '34px' } }, productInfoText({ isPost: false }))),
@@ -12949,7 +12988,7 @@ var CommodityDetailDiroNewComponent = memo(CommodityDetailDiroNew$1);
12949
12988
  * @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
12950
12989
  *
12951
12990
  */
12952
- var interactionRender$e = [
12991
+ var interactionRender$f = [
12953
12992
  {
12954
12993
  title: '滑动事件',
12955
12994
  child: [
@@ -12976,8 +13015,8 @@ const CommodityDetailDiroNew = createMaterial(CommodityDetailDiroNewComponent, {
12976
13015
  category: 'popup',
12977
13016
  type: 'CommodityDetailDiroNew',
12978
13017
  related: {
12979
- settingRender: settingRender$c,
12980
- interactionRender: interactionRender$e
13018
+ settingRender: settingRender$d,
13019
+ interactionRender: interactionRender$f
12981
13020
  },
12982
13021
  defaulSetting: {
12983
13022
  props: {
@@ -13041,7 +13080,7 @@ const CommodityDetailDiroNew = createMaterial(CommodityDetailDiroNewComponent, {
13041
13080
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\CommodityList\settingRender.tsx
13042
13081
  *
13043
13082
  */
13044
- var settingRender$b = [
13083
+ var settingRender$c = [
13045
13084
  {
13046
13085
  title: '弹窗背景',
13047
13086
  child: [
@@ -13466,7 +13505,7 @@ var CommodityListComponent = memo(CommodityList$1);
13466
13505
  * @FilePath: \pb-sxp-ui\src\materials\sxp\cta\AniLink\interactionRender.tsx
13467
13506
  *
13468
13507
  */
13469
- var interactionRender$d = [
13508
+ var interactionRender$e = [
13470
13509
  {
13471
13510
  title: '点击事件',
13472
13511
  child: [
@@ -13493,8 +13532,8 @@ const CommodityList = createMaterial(CommodityListComponent, {
13493
13532
  category: 'popup',
13494
13533
  type: 'CommodityList',
13495
13534
  related: {
13496
- settingRender: settingRender$b,
13497
- interactionRender: interactionRender$d
13535
+ settingRender: settingRender$c,
13536
+ interactionRender: interactionRender$e
13498
13537
  },
13499
13538
  defaulSetting: {
13500
13539
  props: {
@@ -13542,7 +13581,7 @@ const CommodityList = createMaterial(CommodityListComponent, {
13542
13581
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\Iframe\settingRender.tsx
13543
13582
  *
13544
13583
  */
13545
- var settingRender$a = [
13584
+ var settingRender$b = [
13546
13585
  {
13547
13586
  title: '背景样式',
13548
13587
  child: [
@@ -13576,7 +13615,7 @@ const Iframe = createMaterial(IframeComponent, {
13576
13615
  category: 'popup',
13577
13616
  type: 'Iframe',
13578
13617
  related: {
13579
- settingRender: settingRender$a,
13618
+ settingRender: settingRender$b,
13580
13619
  bindableProps: []
13581
13620
  },
13582
13621
  defaulSetting: {
@@ -13596,7 +13635,7 @@ const Iframe = createMaterial(IframeComponent, {
13596
13635
  * @FilePath: \pb-sxp-ui\src\materials\sxp\popup\ConsentDetail\settingRender.tsx
13597
13636
  *
13598
13637
  */
13599
- var settingRender$9 = [
13638
+ var settingRender$a = [
13600
13639
  {
13601
13640
  title: '弹窗文本',
13602
13641
  child: [
@@ -13625,7 +13664,7 @@ const ConsentDetail = createMaterial(ConsentDetail$2, {
13625
13664
  category: 'popup',
13626
13665
  type: 'ConsentDetail',
13627
13666
  related: {
13628
- settingRender: settingRender$9,
13667
+ settingRender: settingRender$a,
13629
13668
  bindableProps: []
13630
13669
  },
13631
13670
  defaulSetting: {
@@ -13637,6 +13676,666 @@ const ConsentDetail = createMaterial(ConsentDetail$2, {
13637
13676
  sort: 7
13638
13677
  });
13639
13678
 
13679
+ var settingRender$9 = [
13680
+ {
13681
+ title: 'Shopify配置',
13682
+ child: [
13683
+ {
13684
+ type: 'Input',
13685
+ label: 'Shopify域名',
13686
+ name: ['props', 'shopifyDomain'],
13687
+ placeholder: 'your-store.myshopify.com'
13688
+ },
13689
+ {
13690
+ type: 'Input',
13691
+ label: 'Storefront Token',
13692
+ name: ['props', 'storefrontAccessToken'],
13693
+ placeholder: 'Storefront Access Token'
13694
+ }
13695
+ ]
13696
+ },
13697
+ {
13698
+ title: '弹窗背景',
13699
+ child: [
13700
+ {
13701
+ type: 'Number',
13702
+ label: '左右边距',
13703
+ name: ['props', 'popupBg', 'horizontalMargin']
13704
+ },
13705
+ {
13706
+ type: 'Number',
13707
+ label: '下边距',
13708
+ name: ['props', 'popupBg', 'bottomMargin']
13709
+ }
13710
+ ]
13711
+ },
13712
+ {
13713
+ title: '商品信息样式',
13714
+ child: [
13715
+ {
13716
+ name: ['props', 'variantStyles'],
13717
+ type: 'SelectLinkage',
13718
+ child: [
13719
+ {
13720
+ label: '字段',
13721
+ type: 'Select',
13722
+ options: [
13723
+ {
13724
+ label: '商品标题',
13725
+ value: 'title'
13726
+ },
13727
+ {
13728
+ label: '价格',
13729
+ value: 'price'
13730
+ },
13731
+ {
13732
+ label: '规格选项',
13733
+ value: 'option'
13734
+ },
13735
+ {
13736
+ label: '已选规格',
13737
+ value: 'selectedOption'
13738
+ }
13739
+ ],
13740
+ name: ['props', 'variantStyles', 'field'],
13741
+ initialValue: 'title'
13742
+ },
13743
+ {
13744
+ type: 'Group',
13745
+ child: [
13746
+ {
13747
+ label: '上边距',
13748
+ type: 'Number',
13749
+ addonAfter: 'px',
13750
+ name: ['marginTop']
13751
+ },
13752
+ {
13753
+ label: '下边距',
13754
+ type: 'Number',
13755
+ addonAfter: 'px',
13756
+ name: ['marginBottom']
13757
+ }
13758
+ ]
13759
+ },
13760
+ {
13761
+ type: 'Group',
13762
+ label: '字体',
13763
+ child: [
13764
+ {
13765
+ type: 'Select',
13766
+ name: ['fontFamily-cn'],
13767
+ bottomText: '中文字体'
13768
+ },
13769
+ {
13770
+ type: 'Select',
13771
+ name: ['fontFamily-en'],
13772
+ bottomText: '英文/其他字体'
13773
+ }
13774
+ ]
13775
+ },
13776
+ {
13777
+ type: 'Group',
13778
+ label: '',
13779
+ child: [
13780
+ {
13781
+ type: 'Color',
13782
+ name: ['color']
13783
+ },
13784
+ {
13785
+ type: 'Number',
13786
+ addonAfter: 'px',
13787
+ name: ['fontSize']
13788
+ }
13789
+ ]
13790
+ },
13791
+ {
13792
+ label: '样式',
13793
+ type: 'TextStyle'
13794
+ },
13795
+ {
13796
+ label: '对齐',
13797
+ type: 'TextAlign'
13798
+ },
13799
+ {
13800
+ label: '间距',
13801
+ type: 'TextSpace'
13802
+ }
13803
+ ]
13804
+ }
13805
+ ]
13806
+ },
13807
+ {
13808
+ title: '加购按钮样式',
13809
+ child: [
13810
+ {
13811
+ label: '英文大小写',
13812
+ type: 'Select',
13813
+ name: ['props', 'buttonStyle', 'textTransform'],
13814
+ options: [
13815
+ {
13816
+ label: '默认',
13817
+ value: 'unset'
13818
+ },
13819
+ {
13820
+ label: '小写',
13821
+ value: 'lowercase'
13822
+ },
13823
+ {
13824
+ label: '大写',
13825
+ value: 'uppercase'
13826
+ }
13827
+ ]
13828
+ },
13829
+ {
13830
+ type: 'Color',
13831
+ label: '背景色',
13832
+ name: ['props', 'buttonStyle', 'backgroundColor'],
13833
+ initialValue: '#000'
13834
+ },
13835
+ {
13836
+ type: 'Group',
13837
+ label: '尺寸',
13838
+ child: [
13839
+ {
13840
+ type: 'Number',
13841
+ name: ['props', 'buttonStyle', 'height'],
13842
+ addonAfter: 'H'
13843
+ }
13844
+ ]
13845
+ },
13846
+ {
13847
+ type: 'Group',
13848
+ label: '圆角',
13849
+ child: [
13850
+ {
13851
+ type: 'Slider',
13852
+ name: ['props', 'buttonStyle', 'borderRadius'],
13853
+ max: 100
13854
+ },
13855
+ {
13856
+ type: 'Number',
13857
+ name: ['props', 'buttonStyle', 'borderRadius'],
13858
+ addonAfter: 'px',
13859
+ max: 100
13860
+ }
13861
+ ]
13862
+ },
13863
+ {
13864
+ type: 'TextMargin',
13865
+ name: ['props', 'buttonStyle']
13866
+ },
13867
+ {
13868
+ type: 'Group',
13869
+ label: '字体',
13870
+ child: [
13871
+ {
13872
+ type: 'Select',
13873
+ name: ['props', 'buttonStyle', 'fontFamily-cn'],
13874
+ bottomText: '中文字体'
13875
+ },
13876
+ {
13877
+ type: 'Select',
13878
+ name: ['props', 'buttonStyle', 'fontFamily-en'],
13879
+ bottomText: '英文/其他字体'
13880
+ }
13881
+ ]
13882
+ },
13883
+ {
13884
+ type: 'Group',
13885
+ label: '',
13886
+ child: [
13887
+ {
13888
+ type: 'Color',
13889
+ name: ['props', 'buttonStyle', 'color'],
13890
+ initialValue: '#fff'
13891
+ },
13892
+ {
13893
+ type: 'Number',
13894
+ name: ['props', 'buttonStyle', 'fontSize'],
13895
+ addonAfter: 'px'
13896
+ }
13897
+ ]
13898
+ },
13899
+ {
13900
+ type: 'TextStyle',
13901
+ name: ['props', 'buttonStyle']
13902
+ },
13903
+ {
13904
+ type: 'TextAlign',
13905
+ name: ['props', 'buttonStyle']
13906
+ },
13907
+ {
13908
+ label: '间距',
13909
+ type: 'TextSpace',
13910
+ name: ['props', 'buttonStyle']
13911
+ }
13912
+ ]
13913
+ },
13914
+ {
13915
+ title: '文案配置',
13916
+ child: [
13917
+ {
13918
+ type: 'Input',
13919
+ label: '加购按钮文案',
13920
+ name: ['props', 'texts', 'addToCart'],
13921
+ placeholder: 'Add to Cart'
13922
+ },
13923
+ {
13924
+ type: 'Input',
13925
+ label: '选择规格提示',
13926
+ name: ['props', 'texts', 'selectOptions'],
13927
+ placeholder: 'Please select options'
13928
+ },
13929
+ {
13930
+ type: 'Input',
13931
+ label: '加载文案',
13932
+ name: ['props', 'texts', 'loading'],
13933
+ placeholder: 'Loading...'
13934
+ },
13935
+ {
13936
+ type: 'Input',
13937
+ label: '错误文案',
13938
+ name: ['props', 'texts', 'error'],
13939
+ placeholder: 'Failed to load product'
13940
+ }
13941
+ ]
13942
+ },
13943
+ {
13944
+ title: '数量选择器',
13945
+ child: [
13946
+ {
13947
+ type: 'Number',
13948
+ label: '按钮间距',
13949
+ name: ['props', 'quantityStyle', 'gap'],
13950
+ addonAfter: 'px',
13951
+ initialValue: 12
13952
+ }
13953
+ ]
13954
+ }
13955
+ ];
13956
+
13957
+ /*
13958
+ * @Author: tao
13959
+ * @Date: 2026-01-12
13960
+ * @Description: Add to Cart 交互配置
13961
+ */
13962
+ var interactionRender$d = () => {
13963
+ return (React.createElement("div", { style: { padding: '20px', color: '#666' } },
13964
+ React.createElement("p", null, "\u52A0\u8D2D\u5546\u54C1\u5F39\u7A97\u4EA4\u4E92\u8BF4\u660E\uFF1A"),
13965
+ React.createElement("ul", { style: { paddingLeft: '20px', lineHeight: '1.8' } },
13966
+ React.createElement("li", null, "\u70B9\u51FB\u5546\u54C1\u8BE6\u60C5\u5F39\u7A97\u7684\"Shop Now\"\u6309\u94AE\u540E\u81EA\u52A8\u5C55\u793A"),
13967
+ React.createElement("li", null, "\u901A\u8FC7Shopify Storefront API\u83B7\u53D6\u5546\u54C1\u89C4\u683C\u548C\u5E93\u5B58\u4FE1\u606F"),
13968
+ React.createElement("li", null, "\u7528\u6237\u9009\u62E9\u89C4\u683C\u540E\u5B9E\u65F6\u663E\u793A\u5BF9\u5E94SKU\u7684\u4EF7\u683C\u548C\u5E93\u5B58"),
13969
+ React.createElement("li", null, "\u70B9\u51FB\"Add to Cart\"\u6309\u94AE\u540E\u8DF3\u8F6C\u81F3Shopify\u8D2D\u7269\u8F66\u9875\u9762"),
13970
+ React.createElement("li", null, "\u65E0\u5E93\u5B58\u6216\u4E0D\u53EF\u552E\u5356\u7684\u89C4\u683C\u81EA\u52A8\u7F6E\u7070\u4E0D\u53EF\u9009"))));
13971
+ };
13972
+
13973
+ const AddToCartPopup$1 = (_a) => {
13974
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
13975
+ 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"]);
13976
+ const { sxpParameter, popupDetailData, isPreview, bffFbReport, globalConfig } = useSxpDataSource();
13977
+ useEventReport();
13978
+ const curTimeRef = useRef(null);
13979
+ const [productData, setProductData] = useState(null);
13980
+ const [selectedOptions, setSelectedOptions] = useState({});
13981
+ const [selectedVariant, setSelectedVariant] = useState(null);
13982
+ const [quantity, setQuantity] = useState(1);
13983
+ const [loading, setLoading] = useState(true);
13984
+ const [error, setError] = useState(null);
13985
+ // 获取当前弹窗商品数据(自动从 popupDetailData 获取)
13986
+ const data = popupDetailData;
13987
+ 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];
13988
+ product === null || product === void 0 ? void 0 : product.bindCta;
13989
+ 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;
13990
+ // Shopify配置 - 优先级:props > globalConfig > 默认值
13991
+ const finalShopifyDomain = shopifyDomain || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.shopifyDomain) || 'dev-store-749237498237498636.myshopify.com';
13992
+ const finalStorefrontToken = storefrontAccessToken || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.storefrontAccessToken) || '77d894c490f79430ce7bd0a7efdff6b7';
13993
+ // 自动从商品数据获取 Shopify Product ID
13994
+ const productId = (product === null || product === void 0 ? void 0 : product.itemId) || '';
13995
+ // 文案
13996
+ const finalTexts = {
13997
+ addToCart: texts.addToCart || 'Add to Cart',
13998
+ selectOptions: texts.selectOptions || 'Please select options',
13999
+ loading: texts.loading || 'Loading...',
14000
+ error: texts.error || 'Failed to load product',
14001
+ color: texts.color || 'Color',
14002
+ size: texts.size || 'Size',
14003
+ material: texts.material || 'Material',
14004
+ style: texts.style || 'Style'
14005
+ };
14006
+ // 查询Shopify商品数据
14007
+ const fetchProductData = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
14008
+ var _m;
14009
+ if (!productId || !finalShopifyDomain || !finalStorefrontToken) {
14010
+ console.log('[AddToCartPopup] 缺少必要配置:', {
14011
+ productId,
14012
+ shopifyDomain: finalShopifyDomain,
14013
+ hasToken: !!finalStorefrontToken
14014
+ });
14015
+ setLoading(false);
14016
+ return;
14017
+ }
14018
+ console.log('[AddToCartPopup] 开始加载商品数据:', {
14019
+ productId,
14020
+ shopifyDomain: finalShopifyDomain
14021
+ });
14022
+ setLoading(true);
14023
+ setError(null);
14024
+ try {
14025
+ const query = `
14026
+ query getProduct($id: ID!) {
14027
+ product(id: $id) {
14028
+ id
14029
+ title
14030
+ images(first: 10) {
14031
+ edges {
14032
+ node {
14033
+ url
14034
+ }
14035
+ }
14036
+ }
14037
+ options {
14038
+ name
14039
+ values
14040
+ }
14041
+ variants(first: 100) {
14042
+ edges {
14043
+ node {
14044
+ id
14045
+ title
14046
+ availableForSale
14047
+ quantityAvailable
14048
+ price {
14049
+ amount
14050
+ currencyCode
14051
+ }
14052
+ image {
14053
+ url
14054
+ }
14055
+ selectedOptions {
14056
+ name
14057
+ value
14058
+ }
14059
+ }
14060
+ }
14061
+ }
14062
+ }
14063
+ }
14064
+ `;
14065
+ // 确保 Product ID 格式正确
14066
+ const formattedProductId = productId.startsWith('gid://')
14067
+ ? productId
14068
+ : `gid://shopify/Product/${productId}`;
14069
+ console.log('[AddToCartPopup] 使用的 Product ID:', formattedProductId);
14070
+ const response = yield fetch(`https://${finalShopifyDomain}/api/2024-01/graphql.json`, {
14071
+ method: 'POST',
14072
+ headers: {
14073
+ 'Content-Type': 'application/json',
14074
+ 'X-Shopify-Storefront-Access-Token': finalStorefrontToken
14075
+ },
14076
+ body: JSON.stringify({
14077
+ query,
14078
+ variables: { id: formattedProductId }
14079
+ })
14080
+ });
14081
+ if (!response.ok) {
14082
+ throw new Error(`HTTP ${response.status}`);
14083
+ }
14084
+ const result = yield response.json();
14085
+ if (result.errors) {
14086
+ console.error('[AddToCartPopup] GraphQL 错误:', result.errors);
14087
+ throw new Error(result.errors[0].message);
14088
+ }
14089
+ if (!((_m = result.data) === null || _m === void 0 ? void 0 : _m.product)) {
14090
+ console.error('[AddToCartPopup] 未找到商品');
14091
+ throw new Error('Product not found');
14092
+ }
14093
+ console.log('[AddToCartPopup] 商品数据加载成功:', result.data.product.title);
14094
+ setProductData(result.data.product);
14095
+ }
14096
+ catch (err) {
14097
+ const errorMessage = err instanceof Error ? err.message : finalTexts.error;
14098
+ setError(errorMessage);
14099
+ console.error('[AddToCartPopup] 加载失败:', err);
14100
+ }
14101
+ finally {
14102
+ setLoading(false);
14103
+ }
14104
+ }), [productId, finalShopifyDomain, finalStorefrontToken, finalTexts.error]);
14105
+ useEffect(() => {
14106
+ if (isActive) {
14107
+ fetchProductData();
14108
+ }
14109
+ }, [isActive, fetchProductData]);
14110
+ // 根据选中的规格匹配variant
14111
+ useEffect(() => {
14112
+ if (!productData)
14113
+ return;
14114
+ const variants = productData.variants.edges.map(edge => edge.node);
14115
+ const optionsCount = productData.options.length;
14116
+ const selectedCount = Object.keys(selectedOptions).length;
14117
+ if (selectedCount === 0 || selectedCount < optionsCount) {
14118
+ setSelectedVariant(null);
14119
+ return;
14120
+ }
14121
+ const matchedVariant = variants.find(variant => {
14122
+ return variant.selectedOptions.every(option => selectedOptions[option.name] === option.value);
14123
+ });
14124
+ setSelectedVariant(matchedVariant || null);
14125
+ setQuantity(1);
14126
+ }, [selectedOptions, productData]);
14127
+ // 处理规格选择
14128
+ const handleOptionSelect = useCallback((optionName, value) => {
14129
+ setSelectedOptions(prev => {
14130
+ const newOptions = Object.assign({}, prev);
14131
+ if (newOptions[optionName] === value) {
14132
+ delete newOptions[optionName];
14133
+ }
14134
+ else {
14135
+ newOptions[optionName] = value;
14136
+ }
14137
+ return newOptions;
14138
+ });
14139
+ }, []);
14140
+ // 处理数量变化
14141
+ const handleQuantityChange = useCallback((delta) => {
14142
+ setQuantity(prev => {
14143
+ var _a;
14144
+ const newQuantity = prev + delta;
14145
+ const maxQuantity = (_a = selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.quantityAvailable) !== null && _a !== void 0 ? _a : 999;
14146
+ return Math.max(1, Math.min(newQuantity, maxQuantity));
14147
+ });
14148
+ }, [selectedVariant]);
14149
+ // 检查某个规格值是否可用
14150
+ const isOptionValueAvailable = useCallback((optionName, value) => {
14151
+ if (!productData)
14152
+ return false;
14153
+ const variants = productData.variants.edges.map(edge => edge.node);
14154
+ const tempOptions = Object.assign(Object.assign({}, selectedOptions), { [optionName]: value });
14155
+ return variants.some(variant => {
14156
+ const matches = variant.selectedOptions.every(option => !tempOptions[option.name] || tempOptions[option.name] === option.value);
14157
+ const hasStock = variant.quantityAvailable === null || variant.quantityAvailable > 0;
14158
+ return matches && variant.availableForSale && hasStock;
14159
+ });
14160
+ }, [productData, selectedOptions]);
14161
+ // 处理加购
14162
+ const handleAddToCart = useCallback(() => {
14163
+ var _a;
14164
+ if (!selectedVariant || quantity === 0)
14165
+ return;
14166
+ const variantId = selectedVariant.id.split('/').pop();
14167
+ const cartUrl = `https://${finalShopifyDomain}/cart/add?id=${variantId}&quantity=${quantity}`;
14168
+ console.log('[AddToCartPopup] 加购:', {
14169
+ variantId,
14170
+ quantity,
14171
+ cartUrl
14172
+ });
14173
+ // 上报事件
14174
+ bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
14175
+ eventName: 'AddToCart',
14176
+ product: product ? [product] : undefined,
14177
+ contentType: 'product',
14178
+ data,
14179
+ position,
14180
+ content_id: (_a = product === null || product === void 0 ? void 0 : product.itemId) !== null && _a !== void 0 ? _a : '',
14181
+ value: parseFloat(selectedVariant.price.amount) * quantity,
14182
+ currency: selectedVariant.price.currencyCode,
14183
+ contents: [{
14184
+ id: variantId,
14185
+ quantity
14186
+ }]
14187
+ });
14188
+ // 跳转到Shopify购物车页面
14189
+ window.location.href = cartUrl;
14190
+ }, [selectedVariant, quantity, finalShopifyDomain, bffFbReport, product, data, position]);
14191
+ // 计算总价
14192
+ const totalPrice = useMemo(() => {
14193
+ if (!selectedVariant)
14194
+ return null;
14195
+ const price = parseFloat(selectedVariant.price.amount);
14196
+ const total = price * quantity;
14197
+ return total.toFixed(2);
14198
+ }, [selectedVariant, quantity]);
14199
+ // 初始化时间
14200
+ useEffect(() => {
14201
+ const initTime = () => {
14202
+ curTimeRef.current = new Date();
14203
+ };
14204
+ initTime();
14205
+ window.addEventListener('pageshow', initTime);
14206
+ return () => {
14207
+ window.removeEventListener('pageshow', initTime);
14208
+ };
14209
+ }, []);
14210
+ // 加载中
14211
+ if (loading) {
14212
+ return (React.createElement("div", { className: "add-to-cart-popup-loading", style: style },
14213
+ React.createElement("div", null, finalTexts.loading)));
14214
+ }
14215
+ // 错误状态
14216
+ if (error || !productData) {
14217
+ return (React.createElement("div", { className: "add-to-cart-popup-error", style: style },
14218
+ React.createElement("div", null,
14219
+ finalTexts.error,
14220
+ ": ",
14221
+ error || 'Product not found')));
14222
+ }
14223
+ 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]) || '';
14224
+ const hasAllOptionsSelected = productData.options.length === Object.keys(selectedOptions).length;
14225
+ const isAddToCartDisabled = !selectedVariant || quantity === 0;
14226
+ return (React.createElement("div", Object.assign({ className: "add-to-cart-popup-container", style: style }, props),
14227
+ React.createElement("div", { className: "variant-detail-section" },
14228
+ React.createElement("div", { className: "variant-image-wrapper" },
14229
+ React.createElement("img", { src: mainImage, alt: productData.title, className: "variant-image" })),
14230
+ React.createElement("div", { className: "variant-info-wrapper" },
14231
+ React.createElement("h2", { className: "product-title-text", style: variantStyles.title, dangerouslySetInnerHTML: {
14232
+ __html: setFontForText(productData.title, variantStyles.title)
14233
+ } }),
14234
+ selectedVariant && (React.createElement(React.Fragment, null,
14235
+ React.createElement("div", { className: "selected-options-tags" }, selectedVariant.selectedOptions.map(option => (React.createElement("span", { key: option.name, className: "option-tag", style: variantStyles.selectedOption },
14236
+ option.name,
14237
+ ": ",
14238
+ option.value)))),
14239
+ React.createElement("div", { className: "price-display" },
14240
+ React.createElement("span", { className: "price-value", style: variantStyles.price, dangerouslySetInnerHTML: {
14241
+ __html: setFontForText(`${selectedVariant.price.currencyCode} $${totalPrice}`, variantStyles.price)
14242
+ } })),
14243
+ React.createElement("div", { className: "quantity-selector-wrapper", style: quantityStyle },
14244
+ React.createElement("button", { className: "quantity-btn quantity-decrease", onClick: () => handleQuantityChange(-1), disabled: quantity <= 1, "aria-label": "Decrease quantity" }, "-"),
14245
+ React.createElement("input", { type: "number", value: quantity, readOnly: true, className: "quantity-input-field", "aria-label": "Quantity" }),
14246
+ 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" }, "+")))),
14247
+ !hasAllOptionsSelected && (React.createElement("div", { className: "no-selection-hint", style: variantStyles.option }, finalTexts.selectOptions)))),
14248
+ React.createElement("div", { className: "variant-options-section" }, productData.options.map(option => (React.createElement("div", { key: option.name, className: "option-group-wrapper" },
14249
+ React.createElement("h3", { className: "option-group-name", style: variantStyles.option, dangerouslySetInnerHTML: {
14250
+ __html: setFontForText(option.name, variantStyles.option)
14251
+ } }),
14252
+ React.createElement("div", { className: "option-values-grid" }, option.values.map(value => {
14253
+ const isSelected = selectedOptions[option.name] === value;
14254
+ const isAvailable = isOptionValueAvailable(option.name, value);
14255
+ 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));
14256
+ })))))),
14257
+ React.createElement("button", { className: `add-to-cart-button ${isAddToCartDisabled ? 'disabled' : ''}`, style: buttonStyle, onClick: handleAddToCart, disabled: isAddToCartDisabled, "aria-label": finalTexts.addToCart },
14258
+ React.createElement("span", { dangerouslySetInnerHTML: {
14259
+ __html: setFontForText(finalTexts.addToCart, buttonStyle)
14260
+ } }))));
14261
+ };
14262
+
14263
+ /*
14264
+ * @Author: tao
14265
+ * @Date: 2026-01-12
14266
+ * @Description: Add to Cart 弹窗组件物料配置
14267
+ */
14268
+ const AddToCartPopup = createMaterial(AddToCartPopup$1, {
14269
+ displayName: '加购商品',
14270
+ icon: '',
14271
+ category: 'popup',
14272
+ type: 'AddToCartPopup',
14273
+ related: {
14274
+ settingRender: settingRender$9,
14275
+ interactionRender: interactionRender$d
14276
+ },
14277
+ defaulSetting: {
14278
+ props: {
14279
+ shopifyDomain: '',
14280
+ storefrontAccessToken: '',
14281
+ variantStyles: {
14282
+ title: {
14283
+ color: '#000',
14284
+ fontSize: 20,
14285
+ fontWeight: 600,
14286
+ marginBottom: 12
14287
+ },
14288
+ price: {
14289
+ color: '#000',
14290
+ fontSize: 24,
14291
+ fontWeight: 700,
14292
+ marginBottom: 16
14293
+ },
14294
+ option: {
14295
+ color: '#111',
14296
+ fontSize: 16,
14297
+ fontWeight: 600,
14298
+ marginBottom: 12
14299
+ },
14300
+ selectedOption: {
14301
+ fontSize: 14,
14302
+ color: '#374151'
14303
+ }
14304
+ },
14305
+ buttonStyle: {
14306
+ backgroundColor: '#000',
14307
+ color: '#fff',
14308
+ fontSize: 16,
14309
+ height: 52,
14310
+ fontWeight: 600,
14311
+ textAlign: 'center',
14312
+ textTransform: 'uppercase'
14313
+ },
14314
+ quantityStyle: {
14315
+ gap: 12
14316
+ },
14317
+ texts: {
14318
+ addToCart: 'Add to Cart',
14319
+ selectOptions: 'Please select options',
14320
+ loading: 'Loading...',
14321
+ error: 'Failed to load product',
14322
+ color: 'Color',
14323
+ size: 'Size',
14324
+ material: 'Material',
14325
+ style: 'Style'
14326
+ },
14327
+ popupBg: {
14328
+ horizontalMargin: 0,
14329
+ bottomMargin: 0
14330
+ }
14331
+ },
14332
+ style: {}
14333
+ },
14334
+ w: 100,
14335
+ h: 40,
14336
+ sort: 7
14337
+ });
14338
+
13640
14339
  /*
13641
14340
  * @Author: binruan@chatlabs.com
13642
14341
  * @Date: 2024-03-26 16:50:25
@@ -19128,6 +19827,7 @@ const MultiPosts = createMaterial(MultiPosts$2, {
19128
19827
 
19129
19828
  var _materials_ = /*#__PURE__*/Object.freeze({
19130
19829
  __proto__: null,
19830
+ AddToCartPopup: AddToCartPopup,
19131
19831
  AniLink: AniLink,
19132
19832
  AniLinkPopup: AniLinkPopup,
19133
19833
  Appoint: Appoint,