@anker-in/headless-ui 1.3.87 → 1.3.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +57 -0
- package/dist/cjs/biz-components/ActiveShelf/ProductCard.d.ts +4 -1
- package/dist/cjs/biz-components/ActiveShelf/ProductCard.js +1 -1
- package/dist/cjs/biz-components/ActiveShelf/index.d.ts +2 -2
- package/dist/cjs/biz-components/ActiveShelf/index.js +1 -1
- package/dist/cjs/biz-components/ActiveShelf/types.d.ts +12 -1
- package/dist/cjs/biz-components/ActiveShelf/types.js +1 -1
- package/dist/cjs/biz-components/ActivitySchedule/index.js +1 -1
- package/dist/cjs/biz-components/AiuiProvider/index.d.ts +28 -0
- package/dist/cjs/biz-components/AiuiProvider/index.js +1 -1
- package/dist/cjs/biz-components/BrandEquity/BrandEquity.d.ts +2 -0
- package/dist/cjs/biz-components/BrandEquity/BrandEquity.js +1 -1
- package/dist/cjs/biz-components/BrandEquity/types.d.ts +2 -0
- package/dist/cjs/biz-components/BrandEquity/types.js +1 -1
- package/dist/cjs/biz-components/Chat/button.js +1 -1
- package/dist/cjs/biz-components/HeroBanner/HeroBanner.js +1 -1
- package/dist/cjs/biz-components/HeroBanner/HeroBannerCarousel.js +1 -1
- package/dist/cjs/biz-components/HeroBanner/types.d.ts +12 -6
- package/dist/cjs/biz-components/HeroBanner/types.js +1 -1
- package/dist/cjs/biz-components/ImageWithText/ImageWithText.js +1 -1
- package/dist/cjs/biz-components/ImageWithText/types.d.ts +8 -2
- package/dist/cjs/biz-components/ImageWithText/types.js +1 -1
- package/dist/cjs/biz-components/Ksp/index.d.ts +2 -0
- package/dist/cjs/biz-components/Ksp/index.js +1 -1
- package/dist/cjs/biz-components/MarqueeReview/index.js +1 -1
- package/dist/cjs/biz-components/MediaPlayerBase/index.js +1 -1
- package/dist/cjs/biz-components/MediaSceneSwitcher/MediaSceneSwitcher.js +2 -2
- package/dist/cjs/biz-components/ProductCompare/index.d.ts +1 -1
- package/dist/cjs/biz-components/ProductCompare/index.js +1 -1
- package/dist/cjs/biz-components/ProductHero/ProductHero.js +1 -1
- package/dist/cjs/biz-components/ProductHero/types.d.ts +2 -0
- package/dist/cjs/biz-components/ProductHero/types.js +1 -1
- package/dist/cjs/biz-components/ProductNav/ProductNav.js +1 -1
- package/dist/cjs/biz-components/ProductNav/types.d.ts +5 -2
- package/dist/cjs/biz-components/ProductNav/types.js +1 -1
- package/dist/cjs/biz-components/SecondaryBanner/index.d.ts +5 -4
- package/dist/cjs/biz-components/SecondaryBanner/index.js +1 -1
- package/dist/cjs/biz-components/Specs/dropdown.js +1 -2
- package/dist/cjs/biz-components/Specs/index.js +1 -1
- package/dist/cjs/biz-components/ThreeDCarousel/ThreeDCarousel.js +1 -1
- package/dist/cjs/biz-components/index.d.ts +1 -0
- package/dist/cjs/biz-components/index.js +1 -1
- package/dist/cjs/components/link.js +1 -1
- package/dist/cjs/hooks/useBoaButton.d.ts +27 -0
- package/dist/cjs/hooks/useBoaButton.js +1 -0
- package/dist/cjs/hooks/useDraggableScroll.js +1 -1
- package/dist/cjs/hooks/useExposure.d.ts +1 -1
- package/dist/cjs/hooks/useExposure.js +1 -1
- package/dist/cjs/hooks/useViewItemList.d.ts +1 -1
- package/dist/cjs/index.d.ts +10 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/shared/ContainerGridContext.d.ts +20 -0
- package/dist/cjs/shared/ContainerGridContext.js +1 -0
- package/dist/cjs/shared/Styles.d.ts +2 -0
- package/dist/cjs/shared/Styles.js +1 -1
- package/dist/cjs/shared/adTrack.d.ts +38 -0
- package/dist/cjs/shared/adTrack.js +1 -0
- package/dist/cjs/shared/amazonAttribution.d.ts +31 -0
- package/dist/cjs/shared/amazonAttribution.js +1 -0
- package/dist/cjs/shared/mediaGridSpec.d.ts +87 -0
- package/dist/cjs/shared/mediaGridSpec.js +1 -0
- package/dist/cjs/stories/BoaStoryProvider.d.ts +10 -0
- package/dist/cjs/stories/BoaStoryProvider.js +1 -0
- package/dist/esm/biz-components/ActiveShelf/ProductCard.d.ts +4 -1
- package/dist/esm/biz-components/ActiveShelf/ProductCard.js +1 -1
- package/dist/esm/biz-components/ActiveShelf/index.d.ts +2 -2
- package/dist/esm/biz-components/ActiveShelf/index.js +1 -1
- package/dist/esm/biz-components/ActiveShelf/types.d.ts +12 -1
- package/dist/esm/biz-components/ActivitySchedule/index.js +1 -1
- package/dist/esm/biz-components/AiuiProvider/index.d.ts +28 -0
- package/dist/esm/biz-components/AiuiProvider/index.js +1 -1
- package/dist/esm/biz-components/BrandEquity/BrandEquity.d.ts +2 -0
- package/dist/esm/biz-components/BrandEquity/BrandEquity.js +1 -1
- package/dist/esm/biz-components/BrandEquity/types.d.ts +2 -0
- package/dist/esm/biz-components/Chat/button.js +1 -1
- package/dist/esm/biz-components/HeroBanner/HeroBanner.js +1 -1
- package/dist/esm/biz-components/HeroBanner/HeroBannerCarousel.js +1 -1
- package/dist/esm/biz-components/HeroBanner/types.d.ts +12 -6
- package/dist/esm/biz-components/ImageWithText/ImageWithText.js +1 -1
- package/dist/esm/biz-components/ImageWithText/types.d.ts +8 -2
- package/dist/esm/biz-components/Ksp/index.d.ts +2 -0
- package/dist/esm/biz-components/Ksp/index.js +1 -1
- package/dist/esm/biz-components/MarqueeReview/index.js +1 -1
- package/dist/esm/biz-components/MediaPlayerBase/index.js +1 -1
- package/dist/esm/biz-components/MediaSceneSwitcher/MediaSceneSwitcher.js +2 -2
- package/dist/esm/biz-components/ProductCompare/index.d.ts +1 -1
- package/dist/esm/biz-components/ProductCompare/index.js +1 -1
- package/dist/esm/biz-components/ProductHero/ProductHero.js +1 -1
- package/dist/esm/biz-components/ProductHero/types.d.ts +2 -0
- package/dist/esm/biz-components/ProductNav/ProductNav.js +1 -1
- package/dist/esm/biz-components/ProductNav/types.d.ts +5 -2
- package/dist/esm/biz-components/SecondaryBanner/index.d.ts +5 -4
- package/dist/esm/biz-components/SecondaryBanner/index.js +1 -1
- package/dist/esm/biz-components/Specs/dropdown.js +1 -2
- package/dist/esm/biz-components/Specs/index.js +1 -1
- package/dist/esm/biz-components/ThreeDCarousel/ThreeDCarousel.js +1 -1
- package/dist/esm/biz-components/index.d.ts +1 -0
- package/dist/esm/biz-components/index.js +1 -1
- package/dist/esm/components/link.js +1 -1
- package/dist/esm/hooks/useBoaButton.d.ts +27 -0
- package/dist/esm/hooks/useBoaButton.js +1 -0
- package/dist/esm/hooks/useDraggableScroll.js +1 -1
- package/dist/esm/hooks/useExposure.d.ts +1 -1
- package/dist/esm/hooks/useExposure.js +1 -1
- package/dist/esm/hooks/useViewItemList.d.ts +1 -1
- package/dist/esm/index.d.ts +10 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/shared/ContainerGridContext.d.ts +20 -0
- package/dist/esm/shared/ContainerGridContext.js +1 -0
- package/dist/esm/shared/Styles.d.ts +2 -0
- package/dist/esm/shared/Styles.js +1 -1
- package/dist/esm/shared/adTrack.d.ts +38 -0
- package/dist/esm/shared/adTrack.js +1 -0
- package/dist/esm/shared/amazonAttribution.d.ts +31 -0
- package/dist/esm/shared/amazonAttribution.js +1 -0
- package/dist/esm/shared/mediaGridSpec.d.ts +87 -0
- package/dist/esm/shared/mediaGridSpec.js +1 -0
- package/dist/esm/stories/BoaStoryProvider.d.ts +10 -0
- package/dist/esm/stories/BoaStoryProvider.js +1 -0
- package/dist/tokens/base.css +22 -1
- package/package.json +5 -2
- package/style.css +250 -136
- package/tailwind.config.js +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var G=Object.create;var u=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var n in e)u(t,n,{get:e[n],enumerable:!0})},f=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j(e))!E.call(t,o)&&o!==n&&u(t,o,{get:()=>e[o],enumerable:!(r=L(e,o))||r.enumerable});return t};var C=(t,e,n)=>(n=t!=null?G(_(t)):{},f(e||!t||!t.__esModule?u(n,"default",{value:t,enumerable:!0}):n,t)),O=t=>f(u({},"__esModule",{value:!0}),t);var Q={};B(Q,{getStylesProps:()=>k,useStyles:()=>$,withLayout:()=>J});module.exports=O(Q);var s=require("react/jsx-runtime"),l=C(require("react")),b=require("./simpleHash.js"),w=C(require("./getKeyPropsString.js")),d=require("../components/grid.js"),N=require("../components/container.js"),T=C(require("./ErrorBoundary.js")),I=require("./ContainerGridContext.js");const v=[12,10,8,6,4],A=t=>{const e=typeof t=="string"?Number.parseInt(t,10):t;return v.includes(e??12)?e??12:12},F={12:"col-start-1 col-end-13",10:"col-start-2 col-end-12",8:"col-start-3 col-end-11",6:"col-start-4 col-end-10",4:"col-start-5 col-end-9"},S={12:"tablet:col-start-1 tablet:col-end-13",10:"tablet:col-start-2 tablet:col-end-12",8:"tablet:col-start-3 tablet:col-end-11",6:"tablet:col-start-4 tablet:col-end-10",4:"tablet:col-start-5 tablet:col-end-9"},K={12:"laptop:col-start-1 laptop:col-end-13",10:"laptop:col-start-2 laptop:col-end-12",8:"laptop:col-start-3 laptop:col-end-11",6:"laptop:col-start-4 laptop:col-end-10",4:"laptop:col-start-5 laptop:col-end-9"},R=t=>{const e=(0,w.default)(t);return`style_${(0,b.simpleHash)(e)}`},k=t=>{const{style:e,uid:n,disabled:r,containerClassName:o}=t;return{style:e,uid:n,disabled:r,containerClassName:o}},M=({style:t,uid:e=R({}),disabled:n=!1})=>!t||n?null:(0,s.jsx)("style",{suppressHydrationWarning:!0,"data-style-id":e,dangerouslySetInnerHTML:{__html:`.block-${e} { ${t} }`}}),$=(t,e)=>{const n=(0,l.useMemo)(()=>t?.uid||R({...t,...e??{}}),[e,t]),r=(0,l.useMemo)(()=>(0,s.jsx)(M,{...t,uid:n}),[t,n]);return{className:`block-${n} `,StyleComponent:r,uid:n,idx:e?.idx!=null?String(e.idx):void 0}},H=t=>{const{desktopSpan:e,mobileSpan:n,tabletSpan:r}=t||{},o=n?F[n]:"";if(!r){const p=e?S[e]:"";return`${o} ${p}`.trim()}const a=S[r]??"",c=e?K[e]:"";return`${o} ${a} ${c}`.trim()},D=t=>t?typeof t=="string"?t:typeof t=="object"&&Object.entries(t).length<=0?"":Object.entries(t).map(([e,n])=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${n}`).join("; ")+";":"",U=(t,e)=>[t,e].map(D).filter(n=>!!n).map(n=>n.trim().endsWith(";")?n:`${n};`).join(" ");function Z(t,e){const n=l.default.forwardRef((r,o)=>{const{container:a,containerClassName:c,className:p,...m}=r;if(!a||Reflect.ownKeys(a).length===0)return(0,s.jsx)(t,{...m,className:p,ref:o});const y=[e,c,p].filter(Boolean).join(" ").trim(),i=a,P={gridColumns:A(i?.desktopSpan),mobileSpan:i?.mobileSpan,tabletSpan:i?.tabletSpan};return(0,s.jsx)(N.Container,{className:y,children:(0,s.jsx)(d.Grid,{className:"container_grid",children:(0,s.jsx)(d.GridItem,{className:H(i),children:(0,s.jsx)(I.ContainerGridContext.Provider,{value:P,children:(0,s.jsx)(t,{...m,ref:o})})})})})});return n.displayName=`WithContainerLayout(${t.displayName||t.name||"Component"})`,n}function q(t,e){const n=l.default.forwardRef((r,o)=>{const a=k(r),c=U(e?.style,a.style),p={...e,...a,...c&&{style:c}},{className:m,StyleComponent:y,idx:i}=$(p,r.data),{style:P,uid:V,disabled:X,className:h,...x}=r;return(0,s.jsxs)(s.Fragment,{children:[y,(0,s.jsx)(t,{...i?{id:i}:{},...x,className:[m,h].filter(Boolean).join(" ").trim(),ref:o})]})});return n.displayName=`WithStyleInjection(${t.displayName||t.name||"Component"})`,n}function z(t){const e=l.default.forwardRef((n,r)=>(0,s.jsx)(T.default,{children:(0,s.jsx)(t,{...n,ref:r})}));return e.displayName=`WithErrorBoundary(${t.displayName||t.name||"Component"})`,e}const g=new WeakMap;function J(t,e){if(g.has(t))return t;const n=z(q(Z(t,e?.containerClassName),e));n.displayName=`WithLayout(${t.displayName||t.name||"Component"})`,g.set(t,!0);const r=n;return Object.getOwnPropertyNames(t).forEach(o=>{!(o in r)&&o!=="arguments"&&o!=="caller"&&o!=="length"&&o!=="name"&&(r[o]=t[o])}),r}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 广告埋点(Meta、Google 按钮点击)的数据结构与清洗规则。
|
|
3
|
+
* 组件只负责把按钮上配置的事件交给业务端(AiuiProvider.onAdTrack),不初始化三方脚本。
|
|
4
|
+
*/
|
|
5
|
+
export type AdTrackChannel = 'meta' | 'google';
|
|
6
|
+
export interface AdTrackEvent {
|
|
7
|
+
/** 渠道,一期只有 meta、google */
|
|
8
|
+
channel: AdTrackChannel;
|
|
9
|
+
/** Meta 作自定义事件名;Google 作转化名称 */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Google 转化标签,渠道为 google 时必填。不得填写访问令牌或密钥 */
|
|
12
|
+
googleLabel?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AdTrackFields {
|
|
15
|
+
/** 是否增加广告埋点,不勾选则本按钮不上报 */
|
|
16
|
+
hasTrack?: boolean;
|
|
17
|
+
/** 埋点事件,每行一个事件 */
|
|
18
|
+
trackEvents?: AdTrackEvent[];
|
|
19
|
+
}
|
|
20
|
+
export interface AdTrackContext {
|
|
21
|
+
/** 组件名,如 hero_banner */
|
|
22
|
+
componentName: string;
|
|
23
|
+
/** 按钮位置,如 primary、secondary、tertiary、buy、text_link */
|
|
24
|
+
buttonPosition: string;
|
|
25
|
+
/** 按钮文案 */
|
|
26
|
+
buttonText?: string;
|
|
27
|
+
/** 点击时的最终链接 */
|
|
28
|
+
href?: string;
|
|
29
|
+
}
|
|
30
|
+
export type OnAdTrackCallback = (events: AdTrackEvent[], context: AdTrackContext) => void;
|
|
31
|
+
/**
|
|
32
|
+
* 清洗事件行,返回可交给业务端的事件:
|
|
33
|
+
* - 未勾选 hasTrack:整体不交接
|
|
34
|
+
* - 事件名为空:该行跳过
|
|
35
|
+
* - Google 行缺转化标签:该行跳过,Meta 行不受影响
|
|
36
|
+
* - 渠道不是 meta、google:该行跳过
|
|
37
|
+
*/
|
|
38
|
+
export declare const getValidAdTrackEvents: (fields?: AdTrackFields) => AdTrackEvent[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var s=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},k=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of g(e))!l.call(t,n)&&n!==r&&c(t,n,{get:()=>e[n],enumerable:!(a=i(e,n))||a.enumerable});return t};var d=t=>k(c({},"__esModule",{value:!0}),t);var A={};s(A,{getValidAdTrackEvents:()=>T});module.exports=d(A);const o=t=>(t??"").trim(),T=t=>!t?.hasTrack||!Array.isArray(t.trackEvents)?[]:t.trackEvents.reduce((e,r)=>{const a=o(r?.name);if(!a)return e;if(r.channel==="meta")e.push({channel:"meta",name:a});else if(r.channel==="google"){const n=o(r.googleLabel);n&&e.push({channel:"google",name:a,googleLabel:n})}return e},[]);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 亚马逊(BOA)链接归因参数拼接,纯函数,不依赖 DOM。
|
|
3
|
+
*
|
|
4
|
+
* 取值优先级(逐个参数单独判断):链接自带 > 按钮级 > 页面级 > 自动计算。
|
|
5
|
+
* 「有值」指参数存在、值非空、且不是 {{xxx}} 占位符;unknown 视为有值。
|
|
6
|
+
*/
|
|
7
|
+
export interface AmazonLinkFields {
|
|
8
|
+
/** 是否为亚马逊链接,勾选后按标准规则拼接归因参数 */
|
|
9
|
+
isAmazonlink?: boolean;
|
|
10
|
+
/** 按钮级活动标识,非空时覆盖页面级广告活动 ID */
|
|
11
|
+
adCampaign?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface BuildAmazonUrlOptions {
|
|
14
|
+
/** 按钮级活动标识 */
|
|
15
|
+
buttonAdCampaign?: string;
|
|
16
|
+
/** 页面级广告活动 ID */
|
|
17
|
+
pageAdCampaign?: string;
|
|
18
|
+
/** 页面级 maas(业务端已按「页面级 > 店铺级 > 内置映射」算好) */
|
|
19
|
+
maas?: string;
|
|
20
|
+
/** 访客落地页的 location.search,用于取 utm 参数 */
|
|
21
|
+
search?: string;
|
|
22
|
+
}
|
|
23
|
+
/** 从链接路径取 10 位商品编号;识别前先去掉 ? 和 # 之后的内容 */
|
|
24
|
+
export declare const extractAmazonAsin: (url?: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* 给亚马逊链接补全归因参数。
|
|
27
|
+
* - 只补缺失的参数;链接自带的有值参数、其他参数(如 th=1)和锚点原样保留
|
|
28
|
+
* - 空链接、纯锚点原样返回
|
|
29
|
+
* - 拼不出来时返回原链接,不抛错
|
|
30
|
+
*/
|
|
31
|
+
export declare const buildAmazonUrl: (url: string | undefined, options?: BuildAmazonUrlOptions) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var A=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var U=(n,t)=>{for(var e in t)A(n,e,{get:t[e],enumerable:!0})},M=(n,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $(t))!I.call(n,i)&&i!==e&&A(n,i,{get:()=>t[i],enumerable:!(a=O(t,i))||a.enumerable});return n};var w=n=>M(A({},"__esModule",{value:!0}),n);var D={};U(D,{buildAmazonUrl:()=>T,extractAmazonAsin:()=>P});module.exports=w(D);const z=/^\{\{.*\}\}$/,E=/\/(?:dp|gp\/product)\/([A-Za-z0-9]{10})(?=[/?#]|$)/,f="maas",p="ref_",g="aa_campaignid",l="aa_adgroupid",h="aa_creativeid",b=[f,p,g,l,h],y=n=>{try{return decodeURIComponent(n)}catch{return n}},S=n=>{if(n==null)return!1;const t=y(n).trim();return t!==""&&!z.test(t)},u=n=>(n??"").trim(),P=(n="")=>n.split("#")[0].split("?")[0].match(E)?.[1]??"",B=n=>n.split("&").filter(Boolean).map(t=>{const e=t.indexOf("="),a=e===-1?t:t.slice(0,e),i=e===-1?"":t.slice(e+1);return{key:y(a),value:i,raw:t}}),L=n=>{const t=new URLSearchParams(n??""),e=a=>u(t.get(a)??void 0);return{term:e("utm_term"),source:e("utm_source"),medium:e("utm_medium"),campaign:e("utm_campaign")}},T=(n,t={})=>{if(!n)return n??"";if(n.startsWith("#"))return n;try{const e=n.indexOf("#"),a=e===-1?"":n.slice(e),i=e===-1?n:n.slice(0,e),m=i.indexOf("?"),k=m===-1?i:i.slice(0,m),x=m===-1?"":i.slice(m+1),r=new Set,C=B(x).filter(s=>b.includes(s.key)?!S(s.value)||r.has(s.key)?!1:(r.add(s.key),!0):!0),R=[],c=(s,d)=>{R.push(`${s}=${encodeURIComponent(d)}`)},o=L(t.search);if(!r.has(f)){const s=u(t.maas);s&&c(f,s)}if(r.has(p)||c(p,"aa_maas"),!r.has(g)){const s=P(n),d=u(t.buttonAdCampaign)||u(t.pageAdCampaign);d?s&&c(g,`${d}${s}`):s&&c(g,s)}r.has(l)||c(l,o.term?o.term.replace(/\s/g,"_"):"unknown"),r.has(h)||c(h,[o.source,o.medium,o.campaign].map(s=>s||"unknown").join("_"));const _=[...C.map(s=>s.raw),...R].join("&");return`${k}${_?`?${_}`:""}${a}`}catch{return n}};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Container Grid 媒体尺寸规格表(纯数据 + 纯函数,无 React 依赖)
|
|
3
|
+
*
|
|
4
|
+
* 用途:当 biz-component 通过 withLayout 的 `container` prop 被放置进
|
|
5
|
+
* Container > Grid > GridItem 栅格布局时,媒体区域(图片/视频)在各个
|
|
6
|
+
* 断点下的"满栅格"尺寸规格。组件可据此推导 aspect-ratio CSS 变量,
|
|
7
|
+
* 替代散落在各组件里的硬编码 aspect ratio 类名。
|
|
8
|
+
*
|
|
9
|
+
* ⚠️ 命名辨析:本模块的 `GridColumns` 描述的是 **withLayout container
|
|
10
|
+
* 布局的栅格跨度**(CMS `container.desktopSpan`,即组件在 12 列页面
|
|
11
|
+
* 栅格中占据的列数:12/10/8/6/4)。它与 Ksp 组件内部的 `gridColumns`
|
|
12
|
+
* prop(KSP 卡片瓦片布局自身的 10/12 列网格)是**同名不同概念**,
|
|
13
|
+
* 两者互不相关,请勿混用。
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* 栅格列数(withLayout container 的 desktopSpan 语义)
|
|
17
|
+
*
|
|
18
|
+
* 12 = 满宽(col-start-1 col-end-13)
|
|
19
|
+
* 10 = 10/12 宽(col-start-2 col-end-12)
|
|
20
|
+
* 8 = 8/12 宽(col-start-3 col-end-11)
|
|
21
|
+
* 6 = 6/12 宽(col-start-4 col-end-10)
|
|
22
|
+
* 4 = 4/12 宽(col-start-5 col-end-9)
|
|
23
|
+
*/
|
|
24
|
+
export type GridColumns = 12 | 10 | 8 | 6 | 4;
|
|
25
|
+
/**
|
|
26
|
+
* 媒体排布模式
|
|
27
|
+
* - bottom:媒体在文字下方(整块媒体占满栅格宽度)
|
|
28
|
+
* - left-right:媒体与文字左右并排(媒体只占栅格宽度的一部分)
|
|
29
|
+
*/
|
|
30
|
+
export type MediaMode = 'bottom' | 'left-right';
|
|
31
|
+
/**
|
|
32
|
+
* 单个断点的媒体尺寸规格(px)
|
|
33
|
+
*/
|
|
34
|
+
export interface BreakpointSpec {
|
|
35
|
+
/** 媒体区域宽度(px) */
|
|
36
|
+
w: number;
|
|
37
|
+
/** 媒体区域高度(px) */
|
|
38
|
+
h: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 一套完整的媒体栅格尺寸规格
|
|
42
|
+
*
|
|
43
|
+
* - lgDesktop / desktop / laptop:必填的三个桌面断点
|
|
44
|
+
* - tablet:可选;当前规格表沿用 laptop 档位(设计尚未给出独立 tablet 值,
|
|
45
|
+
* 待设计确认后可单独覆盖)
|
|
46
|
+
* - mobile:移动端只约束高度(宽度跟随视口)
|
|
47
|
+
*/
|
|
48
|
+
export interface MediaGridSpec {
|
|
49
|
+
lgDesktop: BreakpointSpec;
|
|
50
|
+
desktop: BreakpointSpec;
|
|
51
|
+
laptop: BreakpointSpec;
|
|
52
|
+
tablet?: BreakpointSpec;
|
|
53
|
+
mobile: {
|
|
54
|
+
height: number;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 规格表:gridColumns × mediaMode → 各断点媒体尺寸
|
|
59
|
+
*
|
|
60
|
+
* 数值来源:设计确认稿(CONFIRMED,勿随意改动)。
|
|
61
|
+
* 高度 560/488/336 为设计手工调优值;宽度由栅格推导(见测试中的
|
|
62
|
+
* 一致性校验:1920→1664、1440→1312、1025→897≈896,16px gutter)。
|
|
63
|
+
*/
|
|
64
|
+
export declare const MEDIA_GRID_SPEC: Record<GridColumns, Partial<Record<MediaMode, MediaGridSpec>>>;
|
|
65
|
+
/**
|
|
66
|
+
* 解析指定栅格跨度 × 排布模式下的媒体尺寸规格
|
|
67
|
+
*
|
|
68
|
+
* @returns 对应规格;未覆盖的组合(如 8/6/4 栏目前无设计规格)返回
|
|
69
|
+
* `undefined`,调用方应回退到组件既有的 legacy aspect-ratio 类名。
|
|
70
|
+
*/
|
|
71
|
+
export declare function resolveMediaGridSpec(columns: GridColumns, mode: MediaMode): MediaGridSpec | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* 将规格转换为 CSS 自定义属性(供组件以 inline style 挂载):
|
|
74
|
+
*
|
|
75
|
+
* - `--ar-t`:tablet 档 aspect-ratio('w/h',无 tablet 档时回退 laptop)
|
|
76
|
+
* - `--ar-l`:laptop 档 aspect-ratio('w/h')
|
|
77
|
+
* - `--ar-d`:desktop 档 aspect-ratio('w/h')
|
|
78
|
+
* - `--ar-x`:lg-desktop 档 aspect-ratio('w/h')
|
|
79
|
+
* - `--mh-m`:mobile 档媒体高度(如 '360px')
|
|
80
|
+
*
|
|
81
|
+
* 组件侧典型用法:
|
|
82
|
+
* ```tsx
|
|
83
|
+
* const spec = resolveMediaGridSpec(12, 'bottom')
|
|
84
|
+
* <div style={spec ? mediaGridSpecToCssVars(spec) : undefined} className="aspect-[var(--ar-l)] ..." />
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function mediaGridSpecToCssVars(spec: MediaGridSpec): Record<string, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var n=(e,t)=>{for(var i in t)r(e,i,{get:t[i],enumerable:!0})},s=(e,t,i,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of d(t))!h.call(e,o)&&o!==i&&r(e,o,{get:()=>t[o],enumerable:!(p=l(t,o))||p.enumerable});return e};var b=e=>s(r({},"__esModule",{value:!0}),e);var m={};n(m,{MEDIA_GRID_SPEC:()=>a,mediaGridSpecToCssVars:()=>k,resolveMediaGridSpec:()=>g});module.exports=b(m);const a={12:{bottom:{lgDesktop:{w:1664,h:560},desktop:{w:1312,h:488},laptop:{w:896,h:336},tablet:{w:896,h:336},mobile:{height:360}},"left-right":{lgDesktop:{w:964,h:560},desktop:{w:760,h:448},laptop:{w:516,h:336},tablet:{w:516,h:336},mobile:{height:360}}},10:{bottom:{lgDesktop:{w:1384,h:560},desktop:{w:1090,h:488},laptop:{w:744,h:336},tablet:{w:744,h:336},mobile:{height:360}},"left-right":{lgDesktop:{w:824,h:560},desktop:{w:648,h:448},laptop:{w:440,h:336},tablet:{w:440,h:336},mobile:{height:360}}},8:{},6:{},4:{}};function g(e,t){return a[e]?.[t]}function k(e){const t=({w:p,h:o})=>`${p}/${o}`,i=e.tablet??e.laptop;return{"--ar-t":t(i),"--ar-l":t(e.laptop),"--ar-d":t(e.desktop),"--ar-x":t(e.lgDesktop),"--mh-m":`${e.mobile.height}px`}}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { BoaButtonFields } from '../hooks/useBoaButton.js';
|
|
3
|
+
export declare const boaStoryButton: BoaButtonFields & {
|
|
4
|
+
text: string;
|
|
5
|
+
link: string;
|
|
6
|
+
};
|
|
7
|
+
/** 演示交接数据,不初始化或调用任何真实广告脚本。 */
|
|
8
|
+
export declare const BoaStoryProvider: ({ children }: {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var m=Object.create;var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var g=(t,a)=>{for(var o in a)i(t,o,{get:a[o],enumerable:!0})},s=(t,a,o,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of d(a))!k.call(t,e)&&e!==o&&i(t,e,{get:()=>a[e],enumerable:!(r=p(a,e))||r.enumerable});return t};var b=(t,a,o)=>(o=t!=null?m(u(t)):{},s(a||!t||!t.__esModule?i(o,"default",{value:t,enumerable:!0}):o,t)),A=t=>s(i({},"__esModule",{value:!0}),t);var v={};g(v,{BoaStoryProvider:()=>h,boaStoryButton:()=>B});module.exports=A(v);var n=require("react/jsx-runtime"),c=require("react"),l=b(require("../biz-components/AiuiProvider/index.js"));const B={text:"Buy on Amazon",link:"https://www.amazon.com/dp/B0HJW5F8L3?th=1#details",isAmazonlink:!0,hasTrack:!0,trackEvents:[{channel:"meta",name:"boa_banner"},{channel:"google",name:"boa_banner",googleLabel:"demo-label"}]},h=({children:t})=>{const[a,o]=(0,c.useState)(null);return(0,n.jsxs)(l.default,{trackingData:{pageGroup:"Activity Page_boa-demo"},pageHandle:"boa-demo",componentBoaEnabled:!0,amazonAttribution:{adCampaign:"demo_",maas:"demo-platform"},onAdTrack:(r,e)=>o({events:r,context:e}),children:[t,(0,n.jsxs)("section",{className:"bg-container-primary text-info-primary p-4",children:[(0,n.jsx)("p",{children:"\u70B9\u51FB\u6309\u94AE\u67E5\u770B\u4EA4\u63A5\u6570\u636E\u3002\u94FE\u63A5\u9ED8\u8BA4\u65B0\u7A97\u53E3\uFF1B\u53EF\u53F3\u952E\u68C0\u67E5\u6700\u7EC8\u5730\u5740\u3002\u8BBF\u95EE\u5730\u5740\u4E2D\u7684 utm \u53C2\u6570\u4F1A\u53C2\u4E0E\u5F52\u56E0\u3002"}),(0,n.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap",children:JSON.stringify(a,null,2)})]})]})};
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import type { ButtonFunctionType, CopyConfig, UserType, ActivityLabel, DiscountTagStyle, ActiveShelfLayoutMode, TagTypeConfig, TagColorConfig } from './types.js';
|
|
3
3
|
import type { BadgeProps } from '../../components/badge.js';
|
|
4
4
|
import type { Img } from '../../types/props.js';
|
|
5
|
+
import type { ShelfBoaFields } from './types.js';
|
|
5
6
|
/**
|
|
6
7
|
* 语义化类名
|
|
7
8
|
*/
|
|
@@ -100,8 +101,10 @@ export interface VariantData {
|
|
|
100
101
|
* 完整的产品卡片数据接口
|
|
101
102
|
*/
|
|
102
103
|
export interface ProductCardData extends BaseProductData, VariantData {
|
|
104
|
+
/** 亚马逊按钮使用的商品链接 */
|
|
105
|
+
customProductLink?: string;
|
|
103
106
|
}
|
|
104
|
-
export interface ProductCardProps {
|
|
107
|
+
export interface ProductCardProps extends ShelfBoaFields {
|
|
105
108
|
/** 产品数据 */
|
|
106
109
|
product: ProductCardData;
|
|
107
110
|
/** 当前所在 Tab 的文案,上报为 navigation */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as Ie,jsx as t,jsxs as l}from"react/jsx-runtime";import*as L from"react";import{cn as a}from"../../helpers/index.js";import{Button as J,Badge as Ne,Card as Pe,CardContent as Ae,Picture as Q,Text as x,Heading as D,Progress as Be}from"../../components/index.js";import{toPlainTrackingText as z}from"../../shared/track.js";import{trackUrlRef as Le}from"../../shared/trackUrlRef.js";import{useTracking as De}from"../../hooks/useTracking.js";import{MemberLabel as ze}from"./MemberLabel.js";import{layoutModeStyles as W}from"./styles.js";const _e=5,X="shelf",Y="active_shelf";function Re(e,n,r,y){if(e===void 0)return!0;switch(e){case"always":return!0;case"never":return!1;case"below-quantity":return n===void 0?!0:r<=n;case"below-percentage":return n===void 0?!0:r/y*100<=n;default:return!0}}const Me=({items:e})=>e?.length?t("div",{className:"active-shelf-display-social-endorsements desktop:gap-2 laptop:flex absolute right-0 top-0 z-10 hidden flex-col items-center gap-1",children:e.slice(0,3).map((n,r)=>typeof n.icon=="string"?t("img",{src:n.icon,alt:n.label||"",loading:"lazy",className:"desktop:size-10 lg-desktop:size-12 size-8 object-contain"},r):t(x,{"aria-label":n.label,className:"desktop:size-10 lg-desktop:size-12 size-8 [&_img]:size-full [&_svg]:size-full",children:n.icon},r))}):null,Z={style1:{bg:"https://cdn.shopify.com/s/files/1/0521/9411/5753/files/2_7746fc9c-d4e4-4a59-a972-fa4cb0f3f8bd.png?v=1789381635",textClass:"aiui-dark text-info-primary"},style2:{bg:"https://cdn.shopify.com/s/files/1/0521/9411/5753/files/1_e0438358-493b-40cb-9a58-89d6ee2d3751.png?v=1789381628",textClass:"aiui-dark text-info-primary"},style3:{bg:"https://cdn.shopify.com/s/files/1/0521/9411/5753/files/1_19208ba4-71ea-4580-892d-72167f1cf606.png?v=1789381639",textClass:"aiui-dark text-info-primary"}},we=({text:e,style:n="style1",icon:r,className:y,textClassName:_,textColor:h,layoutMode:C="flex",renderBadge:v})=>{if(!e)return null;const g=n==="custom",k=g&&!!v,o=g&&!v&&!!r?.url,m=g?void 0:Z[n],S=Z.style1,c=W[C],T={style1:c.discountBadgeText,style2:c.discountBadgeTextStyle2,style3:c.discountBadgeTextStyle3},N=g?c.discountBadgeTextCenter:T[n];return l("div",{className:a("active-shelf-discount-badge","absolute left-0 top-0 z-30",c.discountBadgeSize,y),children:[k?v({text:e,layoutMode:C}):o?t(Q,{source:r.url,alt:r.alt||e,className:"block size-full",imgClassName:"block size-full object-contain"}):t("img",{src:(m??S).bg,alt:e,loading:"lazy",className:"block size-full object-contain"}),!k&&t(x,{className:a("active-shelf-discount-badge-text text-center","absolute inset-0 font-bold !leading-[1.2]",N,(m??S).textClass,_),style:h?{color:h}:void 0,html:e})]})},w=L.forwardRef(({product:e,tabName:n="",position:r=1,className:y,showTags:_=!0,stockDisplayMode:h,stockThresholdValue:C,onLearnMore:v,onShopNow:g,onAddToCart:k,classNames:o,secondaryButtonText:m,secondaryButtonFun:S,primaryButtonText:c,primaryButtonFun:T,showOriginalPrice:N,renderOriginalPrice:I,copy:f,onProductImageClick:b,tagTypeConfig:E,fill:F,outline:j,memberPriceTextColor:q,userType:P,memberImages:ee,customTagsIcon:te,customTagStyle:ae,discountTagTextColor:ie,onMemberSignUp:ne,onPlusMemberAddCart:oe,showMemberPrice:V,layoutMode:R,renderDiscountBadge:se},re)=>{const[le,ce]=L.useState(!1),[de,ue]=L.useState(!1),{buildRef:ge}=De(),me=e.custom_name||e.name,A=i=>({"data-headless-type-name":`${X}#${Y}`,"data-headless-title-desc-button":`${z(me)}#${z(e.description)}#${z(i)}`,"data-headless-nav-position":`${z(n)}#${r}`,...e.sku?{"data-headless-sku":e.sku}:{}}),B=e?.listingLink?Le(e.listingLink,ge(X,Y)):void 0,fe=e?.memberDiscountAmount,be=e?.plusMemberDiscountAmount,pe=e?.activityLabels??[],ye=P==="guest"?"guest":"member",$=pe.find(i=>i.type===ye)?.label,ve=P==="guest"?f?.memberActivityLabelUnLogin:f?.memberActivityLabel,Se=!!$||!!ve,xe=e?.discountAmount,s=W[R??"flex"],he=L.useMemo(()=>e?.availableForSale&&e?.quantityAvailable<=0?_e:e?.availableForSale?(e?.quantityAvailable??0)/(e?.totalInventory??1)*100:0,[e?.availableForSale,e?.quantityAvailable,e?.totalInventory]),O=async(i,d)=>{if(!i)return;const u=d==="primary"?ce:ue;u(!0);try{switch(i){case"buyNow":await g?.(e);break;case"addCart":await k?.(e);break;case"learnMore":await v?.(e);break;default:break}}finally{u(!1)}},Ce=e.availableForSale&&e.quantityAvailable<=0,ke=(i,d)=>{const u=i===0?E?.firstTagVariant:i===1?E?.secondTagVariant:void 0,M=(u||void 0)??(d==="fill"?"fill":d!==void 0?"outline":i===0?"fill":"outline"),p=M==="fill"?{outline:F?.outlineColor,bg:F?.bgColor}:{outline:j?.outlineColor,bg:j?.bgColor},K={...p.outline?{outlineColor:p.outline}:{},...p.bg?{backgroundColor:p.bg,backgroundImage:"none"}:{}};return M==="outline"&&p.outline&&(K.color=p.outline),{variant:M,style:K}},U=!!e.custom_bg_image,Te=!!e.custom_scene_image,H=i=>i?{backgroundImage:`url(${i})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"}:void 0;return l(Pe,{ref:re,className:a("active-shelf-card","hover:bg-container-secondary-0 bg-container-primary relative flex h-full cursor-pointer flex-col overflow-hidden border-none",s.cardRadius,y,o?.productCard),children:[t(we,{text:xe,style:ae,icon:te,layoutMode:R,renderBadge:se,className:o?.discountBadge,textClassName:o?.discountBadgeText,textColor:ie}),l(Ae,{className:a(s.cardContent,"relative flex flex-1 flex-col justify-between"),children:[l("div",{className:"product-image-wrapper group/product-image laptop:pb-2 laptop:mb-4 desktop:pb-6 desktop:mb-4 relative mb-4",children:[U&&t("div",{"aria-hidden":!0,className:a("pointer-events-none absolute inset-0 z-20",s.imageOffset),style:H(e.custom_bg_image)}),Te&&t("div",{"aria-hidden":!0,className:a("laptop:block laptop:group-hover/product-image:opacity-100 pointer-events-none absolute inset-0 z-20 hidden opacity-0 transition-opacity duration-300",s.imageOffset),style:H(e.custom_scene_image)}),t("div",{className:a("product-image mx-auto cursor-pointer overflow-hidden",s.image),children:t("a",{onClick:()=>b?.(e),...!b&&{href:B},...b||B?A():{},rel:"noreferrer",className:a("block size-full",U&&"opacity-0"),children:t(Q,{source:e.image,alt:e.name,className:"aspect-square size-full object-contain",imgClassName:"size-full object-contain"})})}),t(Me,{items:e?.socialEndorsements})]}),_&&t("div",{className:"desktop:mb-2 mb-1 flex h-[24px] gap-1",children:e.tags?.map((i,d)=>{if(!i.label)return null;const{variant:u,style:G}=ke(d,i.variant);return t(Ne,{size:"sm",variant:u,className:"active-shelf-items-tag py-0",style:G,children:i.label},d)})}),l("div",{className:"flex h-full flex-1 grow flex-col justify-between gap-4",children:[l("div",{children:[t(D,{as:"h3",size:"none",className:a("text-info-primary",s.title,o?.productTitle),children:t("a",{onClick:()=>b?.(e),...!b&&{href:B},...b||B?A():{},rel:"noreferrer",className:"hover:text-brand-0 cursor-pointer ",children:e.custom_name||e.name})}),e?.description&&t(x,{size:"none",className:a("active-shelf-product-description text-info-primary",s.description,o?.productDescription),html:e.custom_description||e.description})]}),l("div",{children:[t("div",{className:a(o?.productPrice),children:t("div",{className:a("flex items-baseline",s.priceGap),children:e.availableForSale?l(Ie,{children:[t(D,{size:"none",className:a("text-info-primary",s.price),as:"h6",children:e.price}),I?I(e,{showOriginalPrice:N}):N&&e.originalPrice&&t(D,{size:"none",className:a("text-info-tertiary line-through",s.price,o?.originalPrice),as:"h6",children:e.originalPrice})]}):t(D,{size:"none",className:a("text-info-tertiary",s.price),children:f?.outOfStockLabel??"Sold Out"})})}),V&&e?.priceLabel&&e?.availableForSale&&t("div",{className:a("min-h-[1lh]",s.priceLabel),children:t(x,{size:"none",className:a("text-brand-0",o?.productPriceLabel),style:{...q?{color:q}:{}},children:e.priceLabel})}),l("div",{className:a("mt-2 flex",s.buttonContainer,o?.buttonGroup),children:[m&&t(J,{variant:"secondary",size:"lg",className:a(s.buttonItem,o?.secondaryButton),onClick:()=>O(S,"secondary"),disabled:!e.availableForSale&&S!=="learnMore",loading:de,...A(m),children:m}),c&&t(J,{variant:"primary",size:"lg",className:a(s.buttonItem,o?.primaryButton),onClick:()=>O(T,"primary"),disabled:!e.availableForSale&&T!=="learnMore",loading:le,...A(c),children:c})]}),Re(h,C,e?.quantityAvailable??0,e?.totalInventory??0)&&l("div",{className:"active-shelf-stock mt-4 flex flex-col gap-1",children:[t(Be,{value:he,max:100,min:0,size:"base",variant:"default","aria-label":"stock progress",classNames:{root:a("active-shelf-stock-track","bg-[var(--progress-track-bg,rgba(0,0,0,0.2))]",o?.stockTrack),progressBar:a("active-shelf-stock-bar","bg-brand-0 transition-all duration-300 ease-in-out",o?.stockBar)}}),t(x,{size:3,className:"text-info-tertiary text-[14px]",children:Ce?f?.limitedStock:f?.stockDisplayText?.replace("{count}",`${e.availableForSale?e.quantityAvailable:0}`)})]})]})]})]}),V&&P&&t(ze,{userType:P,copy:f,images:ee,onSignUp:ne,onPlusMemberAddCart:oe,hasActivity:Se,activityLabel:$,memberDiscountAmount:fe,plusMemberDiscountAmount:be,layoutMode:R})]})});w.displayName="ActiveShelf.ProductCard";var Ue=w;export{w as ProductCard,Ue as default};
|
|
1
|
+
"use client";import{Fragment as Ze,jsx as t,jsxs as m}from"react/jsx-runtime";import*as D from"react";import{cn as a}from"../../helpers/index.js";import{Button as ae,Badge as qe,Card as He,CardContent as Ve,Picture as ie,Text as S,Heading as _,Progress as $e}from"../../components/index.js";import{toPlainTrackingText as R}from"../../shared/track.js";import{trackUrlRef as Ue}from"../../shared/trackUrlRef.js";import{useTracking as Ge}from"../../hooks/useTracking.js";import{MemberLabel as Ke}from"./MemberLabel.js";import{layoutModeStyles as ne}from"./styles.js";import{useBoaButton as Je}from"../../hooks/useBoaButton.js";const Qe=5,oe="shelf",se="active_shelf";function We(e,n,c,h){if(e===void 0)return!0;switch(e){case"always":return!0;case"never":return!1;case"below-quantity":return n===void 0?!0:c<=n;case"below-percentage":return n===void 0?!0:c/h*100<=n;default:return!0}}const Xe=({items:e})=>e?.length?t("div",{className:"active-shelf-display-social-endorsements desktop:gap-2 laptop:flex absolute right-0 top-0 z-10 hidden flex-col items-center gap-1",children:e.slice(0,3).map((n,c)=>typeof n.icon=="string"?t("img",{src:n.icon,alt:n.label||"",loading:"lazy",className:"desktop:size-10 lg-desktop:size-12 size-8 object-contain"},c):t(S,{"aria-label":n.label,className:"desktop:size-10 lg-desktop:size-12 size-8 [&_img]:size-full [&_svg]:size-full",children:n.icon},c))}):null,re={style1:{bg:"https://cdn.shopify.com/s/files/1/0521/9411/5753/files/2_7746fc9c-d4e4-4a59-a972-fa4cb0f3f8bd.png?v=1789381635",textClass:"aiui-dark text-info-primary"},style2:{bg:"https://cdn.shopify.com/s/files/1/0521/9411/5753/files/1_e0438358-493b-40cb-9a58-89d6ee2d3751.png?v=1789381628",textClass:"aiui-dark text-info-primary"},style3:{bg:"https://cdn.shopify.com/s/files/1/0521/9411/5753/files/1_19208ba4-71ea-4580-892d-72167f1cf606.png?v=1789381639",textClass:"aiui-dark text-info-primary"}},Ye=({text:e,style:n="style1",icon:c,className:h,textClassName:M,textColor:x,layoutMode:C="flex",renderBadge:k})=>{if(!e)return null;const b=n==="custom",T=b&&!!k,o=b&&!k&&!!c?.url,u=b?void 0:re[n],r=re.style1,d=ne[C],l={style1:d.discountBadgeText,style2:d.discountBadgeTextStyle2,style3:d.discountBadgeTextStyle3},O=b?d.discountBadgeTextCenter:l[n];return m("div",{className:a("active-shelf-discount-badge","absolute left-0 top-0 z-30",d.discountBadgeSize,h),children:[T?k({text:e,layoutMode:C}):o?t(ie,{source:c.url,alt:c.alt||e,className:"block size-full",imgClassName:"block size-full object-contain"}):t("img",{src:(u??r).bg,alt:e,loading:"lazy",className:"block size-full object-contain"}),!T&&t(S,{className:a("active-shelf-discount-badge-text text-center","absolute inset-0 font-bold !leading-[1.2]",O,(u??r).textClass,M),style:x?{color:x}:void 0,html:e})]})},E=D.forwardRef(({product:e,tabName:n="",position:c=1,className:h,showTags:M=!0,stockDisplayMode:x,stockThresholdValue:C,onLearnMore:k,onShopNow:b,onAddToCart:T,classNames:o,secondaryButtonText:u,secondaryButtonFun:r,primaryButtonText:d,primaryButtonFun:l,secondaryAdCampaign:O,primaryAdCampaign:le,secondaryButtonTarget:ce,primaryButtonTarget:de,secondaryHasTrack:me,primaryHasTrack:ue,secondaryTrackEvents:ge,primaryTrackEvents:fe,showOriginalPrice:I,renderOriginalPrice:j,copy:y,onProductImageClick:p,tagTypeConfig:q,fill:H,outline:V,memberPriceTextColor:$,userType:A,memberImages:be,customTagsIcon:ye,customTagStyle:pe,discountTagTextColor:ve,onMemberSignUp:he,onPlusMemberAddCart:ke,showMemberPrice:U,layoutMode:w,renderDiscountBadge:Se},xe)=>{const[Ce,Te]=D.useState(!1),[Ae,ze]=D.useState(!1),{resolveLink:G,trackAd:K,hasAdTrack:J}=Je(),Q={hasTrack:me,trackEvents:ge},W={hasTrack:ue,trackEvents:fe},z=G(e.customProductLink,{isAmazonlink:r==="buyOnAmazon",adCampaign:O}).href,N=G(e.customProductLink,{isAmazonlink:l==="buyOnAmazon",adCampaign:le}).href,{buildRef:Ne}=Ge(),Pe=e.custom_name||e.name,P=i=>({"data-headless-type-name":`${oe}#${se}`,"data-headless-title-desc-button":`${R(Pe)}#${R(e.description)}#${R(i)}`,"data-headless-nav-position":`${R(n)}#${c}`,...e.sku?{"data-headless-sku":e.sku}:{}}),L=e?.listingLink?Ue(e.listingLink,Ne(oe,se)):void 0,Le=e?.memberDiscountAmount,De=e?.plusMemberDiscountAmount,_e=e?.activityLabels??[],Re=A==="guest"?"guest":"member",X=_e.find(i=>i.type===Re)?.label,Me=A==="guest"?y?.memberActivityLabelUnLogin:y?.memberActivityLabel,Oe=!!X||!!Me,we=e?.discountAmount,s=ne[w??"flex"],Be=D.useMemo(()=>e?.availableForSale&&e?.quantityAvailable<=0?Qe:e?.availableForSale?(e?.quantityAvailable??0)/(e?.totalInventory??1)*100:0,[e?.availableForSale,e?.quantityAvailable,e?.totalInventory]),Y=async(i,g)=>{if(!i)return;const f=g==="primary"?Te:ze;f(!0);try{switch(i){case"buyNow":await b?.(e);break;case"addCart":await T?.(e);break;case"learnMore":await k?.(e);break;default:break}}finally{f(!1)}},Ee=e.availableForSale&&e.quantityAvailable<=0,Ie=(i,g)=>{const f=i===0?q?.firstTagVariant:i===1?q?.secondTagVariant:void 0,B=(f||void 0)??(g==="fill"?"fill":g!==void 0?"outline":i===0?"fill":"outline"),v=B==="fill"?{outline:H?.outlineColor,bg:H?.bgColor}:{outline:V?.outlineColor,bg:V?.bgColor},te={...v.outline?{outlineColor:v.outline}:{},...v.bg?{backgroundColor:v.bg,backgroundImage:"none"}:{}};return B==="outline"&&v.outline&&(te.color=v.outline),{variant:B,style:te}},Z=!!e.custom_bg_image,je=!!e.custom_scene_image,F=i=>i?{backgroundImage:`url(${i})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"}:void 0;return m(He,{ref:xe,className:a("active-shelf-card","hover:bg-container-secondary-0 bg-container-primary relative flex h-full cursor-pointer flex-col overflow-hidden border-none",s.cardRadius,h,o?.productCard),children:[t(Ye,{text:we,style:pe,icon:ye,layoutMode:w,renderBadge:Se,className:o?.discountBadge,textClassName:o?.discountBadgeText,textColor:ve}),m(Ve,{className:a(s.cardContent,"relative flex flex-1 flex-col justify-between"),children:[m("div",{className:"product-image-wrapper group/product-image laptop:pb-2 laptop:mb-4 desktop:pb-6 desktop:mb-4 relative mb-4",children:[Z&&t("div",{"aria-hidden":!0,className:a("pointer-events-none absolute inset-0 z-20",s.imageOffset),style:F(e.custom_bg_image)}),je&&t("div",{"aria-hidden":!0,className:a("laptop:block laptop:group-hover/product-image:opacity-100 pointer-events-none absolute inset-0 z-20 hidden opacity-0 transition-opacity duration-300",s.imageOffset),style:F(e.custom_scene_image)}),t("div",{className:a("product-image mx-auto cursor-pointer overflow-hidden",s.image),children:t("a",{onClick:()=>p?.(e),...!p&&{href:L},...p||L?P():{},rel:"noreferrer",className:a("block size-full",Z&&"opacity-0"),children:t(ie,{source:e.image,alt:e.name,className:"aspect-square size-full object-contain",imgClassName:"size-full object-contain"})})}),t(Xe,{items:e?.socialEndorsements})]}),M&&t("div",{className:"desktop:mb-2 mb-1 flex h-[24px] gap-1",children:e.tags?.map((i,g)=>{if(!i.label)return null;const{variant:f,style:ee}=Ie(g,i.variant);return t(qe,{size:"sm",variant:f,className:"active-shelf-items-tag py-0",style:ee,children:i.label},g)})}),m("div",{className:"flex h-full flex-1 grow flex-col justify-between gap-4",children:[m("div",{children:[t(_,{as:"h3",size:"none",className:a("text-info-primary",s.title,o?.productTitle),children:t("a",{onClick:()=>p?.(e),...!p&&{href:L},...p||L?P():{},rel:"noreferrer",className:"hover:text-brand-0 cursor-pointer ",children:e.custom_name||e.name})}),e?.description&&t(S,{size:"none",className:a("active-shelf-product-description text-info-primary",s.description,o?.productDescription),html:e.custom_description||e.description})]}),m("div",{children:[t("div",{className:a(o?.productPrice),children:t("div",{className:a("flex items-baseline",s.priceGap),children:e.availableForSale?m(Ze,{children:[t(_,{size:"none",className:a("text-info-primary",s.price),as:"h6",children:e.price}),j?j(e,{showOriginalPrice:I}):I&&e.originalPrice&&t(_,{size:"none",className:a("text-info-tertiary line-through",s.price,o?.originalPrice),as:"h6",children:e.originalPrice})]}):t(_,{size:"none",className:a("text-info-tertiary",s.price),children:y?.outOfStockLabel??"Sold Out"})})}),U&&e?.priceLabel&&e?.availableForSale&&t("div",{className:a("min-h-[1lh]",s.priceLabel),children:t(S,{size:"none",className:a("text-brand-0",o?.productPriceLabel),style:{...$?{color:$}:{}},children:e.priceLabel})}),m("div",{className:a("mt-2 flex",s.buttonContainer,o?.buttonGroup),children:[u&&t(ae,{variant:"secondary",size:"lg",className:a(s.buttonItem,o?.secondaryButton),as:r==="buyOnAmazon"&&z?"a":"button",href:r==="buyOnAmazon"?z:void 0,target:r==="buyOnAmazon"?ce??"_blank":void 0,rel:r==="buyOnAmazon"?"noopener noreferrer":void 0,onClick:()=>{if(K(Q,{componentName:"active_shelf",buttonPosition:"secondary",buttonText:u,href:r==="buyOnAmazon"?z:void 0}),r!=="buyOnAmazon")return Y(r,"secondary")},disabled:r==="buyOnAmazon"?!z:!e.availableForSale&&r!=="learnMore",loading:Ae,"data-headless-ad-track":J(Q)?"true":void 0,"data-headless-amazon":r==="buyOnAmazon"?"true":void 0,...P(u),children:u}),d&&t(ae,{variant:"primary",size:"lg",className:a(s.buttonItem,o?.primaryButton),as:l==="buyOnAmazon"&&N?"a":"button",href:l==="buyOnAmazon"?N:void 0,target:l==="buyOnAmazon"?de??"_blank":void 0,rel:l==="buyOnAmazon"?"noopener noreferrer":void 0,onClick:()=>{if(K(W,{componentName:"active_shelf",buttonPosition:"primary",buttonText:d,href:l==="buyOnAmazon"?N:void 0}),l!=="buyOnAmazon")return Y(l,"primary")},disabled:l==="buyOnAmazon"?!N:!e.availableForSale&&l!=="learnMore",loading:Ce,"data-headless-ad-track":J(W)?"true":void 0,"data-headless-amazon":l==="buyOnAmazon"?"true":void 0,...P(d),children:d})]}),We(x,C,e?.quantityAvailable??0,e?.totalInventory??0)&&m("div",{className:"active-shelf-stock mt-4 flex flex-col gap-1",children:[t($e,{value:Be,max:100,min:0,size:"base",variant:"default","aria-label":"stock progress",classNames:{root:a("active-shelf-stock-track","bg-[var(--progress-track-bg,rgba(0,0,0,0.2))]",o?.stockTrack),progressBar:a("active-shelf-stock-bar","bg-brand-0 transition-all duration-300 ease-in-out",o?.stockBar)}}),t(S,{size:3,className:"text-info-tertiary text-[14px]",children:Ee?y?.limitedStock:y?.stockDisplayText?.replace("{count}",`${e.availableForSale?e.quantityAvailable:0}`)})]})]})]})]}),U&&A&&t(Ke,{userType:A,copy:y,images:be,onSignUp:he,onPlusMemberAddCart:ke,hasActivity:Oe,activityLabel:X,memberDiscountAmount:Le,plusMemberDiscountAmount:De,layoutMode:w})]})});E.displayName="ActiveShelf.ProductCard";var rt=E;export{E as ProductCard,rt as default};
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { type PromotionalBarProps } from '../PromotionalBar/index.js';
|
|
3
3
|
import 'swiper/css';
|
|
4
4
|
import 'swiper/css/navigation';
|
|
5
|
-
import type { ButtonFunctionType, CopyConfig, UserType, DiscountTagStyle, ActiveShelfLayoutMode, TagTypeConfig, TagColorConfig } from './types.js';
|
|
5
|
+
import type { ShelfBoaFields, ButtonFunctionType, CopyConfig, UserType, DiscountTagStyle, ActiveShelfLayoutMode, TagTypeConfig, TagColorConfig } from './types.js';
|
|
6
6
|
import { ProductCard, type ProductCardData, type ActiveShelfSemanticName, type StockDisplayMode } from './ProductCard.js';
|
|
7
7
|
import type { Img } from '../../types/props.js';
|
|
8
8
|
/**
|
|
@@ -33,7 +33,7 @@ export interface ProductTab {
|
|
|
33
33
|
/**
|
|
34
34
|
* ActiveShelf 业务组件数据接口
|
|
35
35
|
*/
|
|
36
|
-
export interface ActiveShelfData {
|
|
36
|
+
export interface ActiveShelfData extends ShelfBoaFields {
|
|
37
37
|
theme?: 'light' | 'dark';
|
|
38
38
|
/** 组件标题 */
|
|
39
39
|
title?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as Te,jsx as t,jsxs as a}from"react/jsx-runtime";import*as s from"react";import{cn as f}from"../../helpers/index.js";import{withLayout as Se}from"../../shared/Styles.js";import{Text as Be,Heading as De,Tabs as Le,TabsList as Ne,TabsTrigger as Re,TabsContent as Ae}from"../../components/index.js";import ue from"../PromotionalBar/index.js";import{Swiper as Ee,SwiperSlide as Ie}from"swiper/react";import{Navigation as ze}from"swiper/modules";import"swiper/css";import"swiper/css/navigation";import{ProductCard as se}from"./ProductCard.js";import{useExposure as $e}from"../../hooks/useExposure.js";import{toPlainTrackingText as h}from"../../shared/track.js";const re="shelf",ne="active_shelf",Fe=()=>a("span",{className:"lg-desktop:size-14 relative flex size-10 items-center justify-center",children:[t("span",{className:"prev-mask bg-masks-0 group-hover/prev-mask:bg-masks-1 absolute inset-0 rounded-full transition-colors"}),t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",className:"lg-desktop:size-6 relative size-5",children:t("path",{d:"M15 6L9 12L15 18",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),He=()=>a("span",{className:"lg-desktop:size-14 relative flex size-10 items-center justify-center",children:[t("span",{className:"next-mask bg-masks-0 group-hover/next-mask:bg-masks-1 absolute inset-0 rounded-full transition-colors"}),t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",className:"lg-desktop:size-6 relative size-5",children:t("path",{d:"M9 6L15 12L9 18",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]});function pe(d){return typeof window>"u"?2:window.matchMedia("(min-width: 1440px)").matches?d==="3"?3:4:window.matchMedia("(min-width: 768px)").matches?3:2}function me(){return typeof window>"u"?!0:!window.matchMedia("(min-width: 768px)").matches}function ge(){return typeof window>"u"?!1:window.matchMedia("(min-width: 1025px)").matches}const ae=s.forwardRef(({tabName:d="",shelfTitle:o="",shelfDescription:q="",products:n,layoutMode:b,className:Z,copy:u,showTags:w,stockDisplayMode:r,stockThresholdValue:C,onLearnMore:v,onShopNow:G,onAddToCart:J,onProductImageClick:T,classNames:x,secondaryButtonText:P,secondaryButtonFun:M,primaryButtonText:k,primaryButtonFun:S,showOriginalPrice:B,renderOriginalPrice:D,tagTypeConfig:L,fill:N,outline:R,memberPriceTextColor:K,renderDiscountBadge:A,userType:E,memberImages:I,customTagsIcon:z,customTagStyle:Q,discountTagTextColor:$,onMemberSignUp:F,onPlusMemberAddCart:H,tileMaxRowsPc:X,tileMaxRowsMob:Y,tileDesktopColumns:l,tileExpandText:O,tileCollapseText:V,showMemberPrice:U},ee)=>{const j=s.useId().replace(/:/g,""),W=`swiper-button-next-custom-${j}`,te=`swiper-button-prev-custom-${j}`,[y,p]=s.useState({isBeginning:!0,isEnd:!1}),i=s.useRef(null),c=s.useCallback(()=>{const e=i.current;if(!e?.slides||e.slides.length===0)return;e.slides.forEach(_=>{_.style.height="auto"});const g=Array.from(e.slides).map(_=>_.scrollHeight),de=Math.max(...g);de>0&&e.slides.forEach(_=>{_.style.height=`${de}px`})},[]);s.useEffect(()=>{const e=()=>{requestAnimationFrame(c)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[c]);const[m,ye]=s.useState(!1),[be,we]=s.useState(()=>pe(l)),[Ce,ve]=s.useState(()=>me()),[xe,Pe]=s.useState(()=>ge());s.useEffect(()=>{const e=()=>{we(pe(l)),ve(me()),Pe(ge())};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[l]);const oe=b==="horizontal"&&!xe?"flex":b,ie=Ce?Y:X,le=oe==="flex"&&!!ie&&ie>0,ce=ie?ie*be:n.length,Me=le&&n.length>ce,ke=le&&!m?n.slice(0,ce):n;return n?.length===0?null:t("div",{ref:ee,className:Z,children:oe==="flex"?a(Te,{children:[t("div",{className:f("tablet:grid-cols-3 tablet:gap-4 grid grid-cols-2 justify-start gap-3",l==="3"?"desktop:grid-cols-3 lg-desktop:grid-cols-3":"desktop:grid-cols-4 lg-desktop:grid-cols-4"),children:ke.map((e,g)=>t(se,{product:e,tabName:d,position:g+1,layoutMode:oe,className:"shrink-0",showTags:w,stockDisplayMode:r,stockThresholdValue:C,onLearnMore:v,onShopNow:G,onAddToCart:J,onProductImageClick:T,classNames:x,secondaryButtonText:P,secondaryButtonFun:M,primaryButtonText:k,primaryButtonFun:S,showOriginalPrice:B,renderOriginalPrice:D,renderDiscountBadge:A,tagTypeConfig:L,fill:N,outline:R,memberPriceTextColor:K,copy:u,userType:E,memberImages:I,customTagsIcon:z,customTagStyle:Q,discountTagTextColor:$,onMemberSignUp:F,onPlusMemberAddCart:H,showMemberPrice:U},e.shopify_id+"-"+e.sku||g))}),Me&&a("div",{className:"active-shelf-toggle laptop:hover:text-brand-0 text-info-primary mt-6 flex items-center justify-center",children:[t("button",{className:"laptop:text-base text-sm font-bold",onClick:()=>ye(e=>!e),"data-headless-type-name":`${re}#${ne}`,"data-headless-title-desc-button":`${h(o)}#${h(q)}#${m?V??"Show less":O??"Show more"}`,"data-headless-nav-position":`${h(d)}#1`,children:m?V??"Show less":O??"Show more"}),t("svg",{xmlns:"http://www.w3.org/2000/svg",className:f("laptop:size-5 size-4",m&&"rotate-180"),width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:t("path",{d:"M17.2929 8.29302C17.6834 7.90249 18.3164 7.90249 18.707 8.29302C19.0975 8.68354 19.0975 9.31655 18.707 9.70708L12.707 15.7071C12.3164 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70708C4.90237 9.31655 4.90237 8.68354 5.29289 8.29302C5.68342 7.90249 6.31643 7.90249 6.70696 8.29302L11.9999 13.586L17.2929 8.29302Z",fill:"currentColor"})})]})]}):a("div",{className:"group relative",children:[t(Ee,{modules:[ze],spaceBetween:16,navigation:{nextEl:`.${W}`,prevEl:`.${te}`},onSwiper:e=>{i.current=e,p({isBeginning:e.isBeginning,isEnd:e.isEnd}),setTimeout(c,100)},slidesPerView:3,breakpoints:{1025:{freeMode:!1,slidesPerView:3},1440:{freeMode:!1,slidesPerView:l==="3"?3:4}},onReachEnd:()=>{p(e=>({...e,isEnd:!0}))},onReachBeginning:()=>{p(e=>({...e,isBeginning:!0}))},onFromEdge:()=>{p({isBeginning:!1,isEnd:!1})},className:"!overflow-visible [&_.swiper-wrapper]:items-start",children:n.map((e,g)=>t(Ie,{className:"overflow-hidden",children:t(se,{product:e,tabName:d,position:g+1,layoutMode:oe,className:"w-full max-w-full",showTags:w,stockDisplayMode:r,stockThresholdValue:C,onLearnMore:v,onShopNow:G,onAddToCart:J,onProductImageClick:T,classNames:x,secondaryButtonText:P,secondaryButtonFun:M,primaryButtonText:k,primaryButtonFun:S,showOriginalPrice:B,renderOriginalPrice:D,renderDiscountBadge:A,tagTypeConfig:L,fill:N,outline:R,memberPriceTextColor:K,copy:u,userType:E,memberImages:I,customTagsIcon:z,customTagStyle:Q,discountTagTextColor:$,onMemberSignUp:F,onPlusMemberAddCart:H,showMemberPrice:U})},e.shopify_id+"-"+e.sku||g))}),t("button",{className:`${te} tablet:block group/prev-mask absolute left-4 top-1/2 z-10 hidden -translate-y-1/2 ${y.isBeginning?"pointer-events-none opacity-0":"opacity-100"}`,"aria-label":u?.previousSlideLabel,children:t(Fe,{})}),t("button",{className:`${W} tablet:block group/next-mask absolute right-4 top-1/2 z-10 hidden -translate-y-1/2 ${y.isEnd?"pointer-events-none opacity-0":"opacity-100"}`,"aria-label":u?.nextSlideLabel,children:t(He,{})})]})})});ae.displayName="ProductsList";const fe=s.forwardRef(({className:d,data:o,onLearnMore:q,onShopNow:n,onAddToCart:b,onProductImageClick:Z,onMemberSignUp:u,onPlusMemberAddCart:w,classNames:r,renderOriginalPrice:C,renderDiscountBadge:v,...G},J)=>{const T=s.useRef(null);$e(T,{componentType:re,componentName:ne,componentTitle:o.title,componentDescription:o.description}),s.useImperativeHandle(J,()=>T.current);const{theme:x="light",layoutMode:P="flex",showTags:M=!0,stockDisplayMode:k,stockThresholdValue:S,showOriginalPrice:B,secondaryButtonText:D,primaryButtonText:L,secondaryButtonFun:N,primaryButtonFun:R,isShowTab:K=!0,tagTypeConfig:A,fill:E,outline:I,memberPriceTextColor:z,copy:Q,userType:$,memberImages:F,customTagsIcon:H,customTagStyle:X,discountTagTextColor:Y,showMemberPrice:l,tileMaxRowsPc:O,tileMaxRowsMob:V,tileDesktopColumns:U,tileExpandText:ee,tileCollapseText:j}=o,W=Q||{},te=o.productsTab&&o.productsTab.length>0,y=K&&te,p=y?void 0:o.resourceBlocks?.find(i=>i.blockType==="PromotionalBar"&&i.display==="visible");return a("div",{ref:T,className:f("w-full",{"aiui-dark":x==="dark"},d,r?.root),style:{"--progress-track-bg":x==="dark"?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.2)"},...G,children:[o.title&&t(De,{as:"h2",html:o.title,size:4,className:f("text-info-primary mb-4 leading-tight",r?.title)}),o.description&&t(Be,{size:3,as:"p",html:o.description,className:f("text-info-primary mb-6",r?.description)}),a(Le,{defaultValue:o.productsTab?.[0]?.id,className:"w-full",children:[y&&t(Ne,{className:"mb-6",children:o.productsTab?.map((i,c)=>t(Re,{value:i.id,"data-headless-type-name":`${re}#${ne}`,"data-headless-title-desc-button":`${h(o.title)}#${h(o.description)}#${h(i.tab)}`,"data-headless-nav-position":`${h(i.tab)}#${c+1}`,children:i.tab},"tab-"+i.id))}),y?o.productsTab?.map(i=>{const c=i.resourceBlocks?.find(m=>m.blockType==="PromotionalBar"&&m.display==="visible");return a(Ae,{value:i.id,children:[c&&t(ue,{data:c,className:f("laptop:mb-4 mb-3",r?.promotionalBar)}),t(ae,{tabName:i.tab,shelfTitle:o.title,shelfDescription:o.description,products:i.data,layoutMode:P,copy:W,showTags:M,stockDisplayMode:k,stockThresholdValue:S,onLearnMore:q,onShopNow:n,onAddToCart:b,onProductImageClick:Z,classNames:r,secondaryButtonText:D,secondaryButtonFun:N,primaryButtonText:L,primaryButtonFun:R,showOriginalPrice:B,renderOriginalPrice:C,renderDiscountBadge:v,tagTypeConfig:A,fill:E,outline:I,memberPriceTextColor:z,userType:$,memberImages:F,customTagsIcon:H,customTagStyle:X,discountTagTextColor:Y,onMemberSignUp:u,onPlusMemberAddCart:w,showMemberPrice:l,tileMaxRowsPc:O,tileMaxRowsMob:V,tileDesktopColumns:U,tileExpandText:ee,tileCollapseText:j})]},"tab-content-"+i.id)}):a(Te,{children:[p&&t(ue,{data:p,className:f("laptop:mb-4 mb-3",r?.promotionalBar)}),t(ae,{shelfTitle:o.title,shelfDescription:o.description,products:o.productsCard,layoutMode:P,copy:W,showTags:M,stockDisplayMode:k,stockThresholdValue:S,onLearnMore:q,onShopNow:n,onAddToCart:b,onProductImageClick:Z,classNames:r,secondaryButtonText:D,secondaryButtonFun:N,primaryButtonText:L,primaryButtonFun:R,showOriginalPrice:B,renderOriginalPrice:C,renderDiscountBadge:v,tagTypeConfig:A,fill:E,outline:I,memberPriceTextColor:z,userType:$,memberImages:F,customTagsIcon:H,customTagStyle:X,discountTagTextColor:Y,onMemberSignUp:u,onPlusMemberAddCart:w,showMemberPrice:l,tileMaxRowsPc:O,tileMaxRowsMob:V,tileDesktopColumns:U,tileExpandText:ee,tileCollapseText:j})]})]})]})});fe.displayName="ActiveShelf";const he=fe;he.ProductCard=se;const Oe=Se(he);var Ye=Oe;export{Ye as default};
|
|
1
|
+
"use client";import{Fragment as he,jsx as o,jsxs as n}from"react/jsx-runtime";import*as s from"react";import{cn as T}from"../../helpers/index.js";import{withLayout as Be}from"../../shared/Styles.js";import{Text as De,Heading as Le,Tabs as Ne,TabsList as Ae,TabsTrigger as Ee,TabsContent as Re}from"../../components/index.js";import pe from"../PromotionalBar/index.js";import{Swiper as Ie,SwiperSlide as Fe}from"swiper/react";import{Navigation as ze}from"swiper/modules";import"swiper/css";import"swiper/css/navigation";import{ProductCard as re}from"./ProductCard.js";import{useExposure as He}from"../../hooks/useExposure.js";import{toPlainTrackingText as y}from"../../shared/track.js";const ae="shelf",ne="active_shelf",$e=()=>n("span",{className:"lg-desktop:size-14 relative flex size-10 items-center justify-center",children:[o("span",{className:"prev-mask bg-masks-0 group-hover/prev-mask:bg-masks-1 absolute inset-0 rounded-full transition-colors"}),o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",className:"lg-desktop:size-6 relative size-5",children:o("path",{d:"M15 6L9 12L15 18",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),Oe=()=>n("span",{className:"lg-desktop:size-14 relative flex size-10 items-center justify-center",children:[o("span",{className:"next-mask bg-masks-0 group-hover/next-mask:bg-masks-1 absolute inset-0 rounded-full transition-colors"}),o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",className:"lg-desktop:size-6 relative size-5",children:o("path",{d:"M9 6L15 12L9 18",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]});function me(d){return typeof window>"u"?2:window.matchMedia("(min-width: 1440px)").matches?d==="3"?3:4:window.matchMedia("(min-width: 768px)").matches?3:2}function ge(){return typeof window>"u"?!0:!window.matchMedia("(min-width: 768px)").matches}function Te(){return typeof window>"u"?!1:window.matchMedia("(min-width: 1025px)").matches}const le=s.forwardRef(({tabName:d="",shelfTitle:e="",shelfDescription:Z="",products:a,layoutMode:b,className:G,copy:u,showTags:w,stockDisplayMode:r,stockThresholdValue:C,onLearnMore:v,onShopNow:J,onAddToCart:K,onProductImageClick:f,classNames:x,secondaryButtonText:P,secondaryButtonFun:k,primaryButtonText:M,primaryButtonFun:S,boaFields:B,showOriginalPrice:D,renderOriginalPrice:L,tagTypeConfig:N,fill:A,outline:Q,memberPriceTextColor:E,renderDiscountBadge:R,userType:I,memberImages:F,customTagsIcon:X,customTagStyle:z,discountTagTextColor:H,onMemberSignUp:$,onPlusMemberAddCart:O,tileMaxRowsPc:Y,tileMaxRowsMob:ee,tileDesktopColumns:l,tileExpandText:V,tileCollapseText:U,showMemberPrice:j},te)=>{const W=s.useId().replace(/:/g,""),_=`swiper-button-next-custom-${W}`,oe=`swiper-button-prev-custom-${W}`,[h,p]=s.useState({isBeginning:!0,isEnd:!1}),i=s.useRef(null),c=s.useCallback(()=>{const t=i.current;if(!t?.slides||t.slides.length===0)return;t.slides.forEach(q=>{q.style.height="auto"});const g=Array.from(t.slides).map(q=>q.scrollHeight),ue=Math.max(...g);ue>0&&t.slides.forEach(q=>{q.style.height=`${ue}px`})},[]);s.useEffect(()=>{const t=()=>{requestAnimationFrame(c)};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[c]);const[m,be]=s.useState(!1),[we,Ce]=s.useState(()=>me(l)),[ve,xe]=s.useState(()=>ge()),[Pe,ke]=s.useState(()=>Te());s.useEffect(()=>{const t=()=>{Ce(me(l)),xe(ge()),ke(Te())};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[l]);const ie=b==="horizontal"&&!Pe?"flex":b,se=ve?ee:Y,ce=ie==="flex"&&!!se&&se>0,de=se?se*we:a.length,Me=ce&&a.length>de,Se=ce&&!m?a.slice(0,de):a;return a?.length===0?null:o("div",{ref:te,className:G,children:ie==="flex"?n(he,{children:[o("div",{className:T("tablet:grid-cols-3 tablet:gap-4 grid grid-cols-2 justify-start gap-3",l==="3"?"desktop:grid-cols-3 lg-desktop:grid-cols-3":"desktop:grid-cols-4 lg-desktop:grid-cols-4"),children:Se.map((t,g)=>o(re,{product:t,tabName:d,position:g+1,layoutMode:ie,className:"shrink-0",showTags:w,stockDisplayMode:r,stockThresholdValue:C,onLearnMore:v,onShopNow:J,onAddToCart:K,onProductImageClick:f,classNames:x,secondaryButtonText:P,secondaryButtonFun:k,...B,primaryButtonText:M,primaryButtonFun:S,showOriginalPrice:D,renderOriginalPrice:L,renderDiscountBadge:R,tagTypeConfig:N,fill:A,outline:Q,memberPriceTextColor:E,copy:u,userType:I,memberImages:F,customTagsIcon:X,customTagStyle:z,discountTagTextColor:H,onMemberSignUp:$,onPlusMemberAddCart:O,showMemberPrice:j},t.shopify_id+"-"+t.sku||g))}),Me&&n("div",{className:"active-shelf-toggle laptop:hover:text-brand-0 text-info-primary mt-6 flex items-center justify-center",children:[o("button",{className:"laptop:text-base text-sm font-bold",onClick:()=>be(t=>!t),"data-headless-type-name":`${ae}#${ne}`,"data-headless-title-desc-button":`${y(e)}#${y(Z)}#${m?U??"Show less":V??"Show more"}`,"data-headless-nav-position":`${y(d)}#1`,children:m?U??"Show less":V??"Show more"}),o("svg",{xmlns:"http://www.w3.org/2000/svg",className:T("laptop:size-5 size-4",m&&"rotate-180"),width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:o("path",{d:"M17.2929 8.29302C17.6834 7.90249 18.3164 7.90249 18.707 8.29302C19.0975 8.68354 19.0975 9.31655 18.707 9.70708L12.707 15.7071C12.3164 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70708C4.90237 9.31655 4.90237 8.68354 5.29289 8.29302C5.68342 7.90249 6.31643 7.90249 6.70696 8.29302L11.9999 13.586L17.2929 8.29302Z",fill:"currentColor"})})]})]}):n("div",{className:"group relative",children:[o(Ie,{modules:[ze],spaceBetween:16,navigation:{nextEl:`.${_}`,prevEl:`.${oe}`},onSwiper:t=>{i.current=t,p({isBeginning:t.isBeginning,isEnd:t.isEnd}),setTimeout(c,100)},slidesPerView:3,breakpoints:{1025:{freeMode:!1,slidesPerView:3},1440:{freeMode:!1,slidesPerView:l==="3"?3:4}},onReachEnd:()=>{p(t=>({...t,isEnd:!0}))},onReachBeginning:()=>{p(t=>({...t,isBeginning:!0}))},onFromEdge:()=>{p({isBeginning:!1,isEnd:!1})},className:"!overflow-visible [&_.swiper-wrapper]:items-start",children:a.map((t,g)=>o(Fe,{className:"overflow-hidden",children:o(re,{product:t,tabName:d,position:g+1,layoutMode:ie,className:"w-full max-w-full",showTags:w,stockDisplayMode:r,stockThresholdValue:C,onLearnMore:v,onShopNow:J,onAddToCart:K,onProductImageClick:f,classNames:x,secondaryButtonText:P,secondaryButtonFun:k,...B,primaryButtonText:M,primaryButtonFun:S,showOriginalPrice:D,renderOriginalPrice:L,renderDiscountBadge:R,tagTypeConfig:N,fill:A,outline:Q,memberPriceTextColor:E,copy:u,userType:I,memberImages:F,customTagsIcon:X,customTagStyle:z,discountTagTextColor:H,onMemberSignUp:$,onPlusMemberAddCart:O,showMemberPrice:j})},t.shopify_id+"-"+t.sku||g))}),o("button",{className:`${oe} tablet:block group/prev-mask absolute left-4 top-1/2 z-10 hidden -translate-y-1/2 ${h.isBeginning?"pointer-events-none opacity-0":"opacity-100"}`,"aria-label":u?.previousSlideLabel,children:o($e,{})}),o("button",{className:`${_} tablet:block group/next-mask absolute right-4 top-1/2 z-10 hidden -translate-y-1/2 ${h.isEnd?"pointer-events-none opacity-0":"opacity-100"}`,"aria-label":u?.nextSlideLabel,children:o(Oe,{})})]})})});le.displayName="ProductsList";const ye=s.forwardRef(({className:d,data:e,onLearnMore:Z,onShopNow:a,onAddToCart:b,onProductImageClick:G,onMemberSignUp:u,onPlusMemberAddCart:w,classNames:r,renderOriginalPrice:C,renderDiscountBadge:v,...J},K)=>{const f=s.useRef(null);He(f,{componentType:ae,componentName:ne,componentTitle:e.title,componentDescription:e.description}),s.useImperativeHandle(K,()=>f.current);const{theme:x="light",layoutMode:P="flex",showTags:k=!0,stockDisplayMode:M,stockThresholdValue:S,showOriginalPrice:B,secondaryButtonText:D,primaryButtonText:L,secondaryButtonFun:N,primaryButtonFun:A,isShowTab:Q=!0,tagTypeConfig:E,fill:R,outline:I,memberPriceTextColor:F,copy:X,userType:z,memberImages:H,customTagsIcon:$,customTagStyle:O,discountTagTextColor:Y,showMemberPrice:ee,tileMaxRowsPc:l,tileMaxRowsMob:V,tileDesktopColumns:U,tileExpandText:j,tileCollapseText:te}=e,W={secondaryAdCampaign:e.secondaryAdCampaign,primaryAdCampaign:e.primaryAdCampaign,secondaryButtonTarget:e.secondaryButtonTarget,primaryButtonTarget:e.primaryButtonTarget,secondaryHasTrack:e.secondaryHasTrack,primaryHasTrack:e.primaryHasTrack,secondaryTrackEvents:e.secondaryTrackEvents,primaryTrackEvents:e.primaryTrackEvents},_=X||{},oe=e.productsTab&&e.productsTab.length>0,h=Q&&oe,p=h?void 0:e.resourceBlocks?.find(i=>i.blockType==="PromotionalBar"&&i.display==="visible");return n("div",{ref:f,className:T("w-full",{"aiui-dark":x==="dark"},d,r?.root),style:{"--progress-track-bg":x==="dark"?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.2)"},...J,children:[e.title&&o(Le,{as:"h2",html:e.title,size:4,className:T("text-info-primary mb-4 leading-tight",r?.title)}),e.description&&o(De,{size:3,as:"p",html:e.description,className:T("text-info-primary mb-6",r?.description)}),n(Ne,{defaultValue:e.productsTab?.[0]?.id,className:"w-full",children:[h&&o(Ae,{className:"mb-6",children:e.productsTab?.map((i,c)=>o(Ee,{value:i.id,"data-headless-type-name":`${ae}#${ne}`,"data-headless-title-desc-button":`${y(e.title)}#${y(e.description)}#${y(i.tab)}`,"data-headless-nav-position":`${y(i.tab)}#${c+1}`,children:i.tab},"tab-"+i.id))}),h?e.productsTab?.map(i=>{const c=i.resourceBlocks?.find(m=>m.blockType==="PromotionalBar"&&m.display==="visible");return n(Re,{value:i.id,children:[c&&o(pe,{data:c,className:T("laptop:mb-4 mb-3",r?.promotionalBar)}),o(le,{tabName:i.tab,shelfTitle:e.title,shelfDescription:e.description,products:i.data,layoutMode:P,copy:_,showTags:k,stockDisplayMode:M,stockThresholdValue:S,onLearnMore:Z,onShopNow:a,onAddToCart:b,onProductImageClick:G,classNames:r,secondaryButtonText:D,secondaryButtonFun:N,boaFields:W,primaryButtonText:L,primaryButtonFun:A,showOriginalPrice:B,renderOriginalPrice:C,renderDiscountBadge:v,tagTypeConfig:E,fill:R,outline:I,memberPriceTextColor:F,userType:z,memberImages:H,customTagsIcon:$,customTagStyle:O,discountTagTextColor:Y,onMemberSignUp:u,onPlusMemberAddCart:w,showMemberPrice:ee,tileMaxRowsPc:l,tileMaxRowsMob:V,tileDesktopColumns:U,tileExpandText:j,tileCollapseText:te})]},"tab-content-"+i.id)}):n(he,{children:[p&&o(pe,{data:p,className:T("laptop:mb-4 mb-3",r?.promotionalBar)}),o(le,{shelfTitle:e.title,shelfDescription:e.description,products:e.productsCard,layoutMode:P,copy:_,showTags:k,stockDisplayMode:M,stockThresholdValue:S,onLearnMore:Z,onShopNow:a,onAddToCart:b,onProductImageClick:G,classNames:r,secondaryButtonText:D,secondaryButtonFun:N,boaFields:W,primaryButtonText:L,primaryButtonFun:A,showOriginalPrice:B,renderOriginalPrice:C,renderDiscountBadge:v,tagTypeConfig:E,fill:R,outline:I,memberPriceTextColor:F,userType:z,memberImages:H,customTagsIcon:$,customTagStyle:O,discountTagTextColor:Y,onMemberSignUp:u,onPlusMemberAddCart:w,showMemberPrice:ee,tileMaxRowsPc:l,tileMaxRowsMob:V,tileDesktopColumns:U,tileExpandText:j,tileCollapseText:te})]})]})]})});ye.displayName="ActiveShelf";const fe=ye;fe.ProductCard=re;const Ve=Be(fe);var et=Ve;export{et as default};
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import type { AdTrackEvent } from '../../shared/adTrack.js';
|
|
1
2
|
/**
|
|
2
3
|
* 按钮功能类型
|
|
3
4
|
*/
|
|
4
|
-
export type ButtonFunctionType = 'buyNow' | 'addCart' | 'learnMore';
|
|
5
|
+
export type ButtonFunctionType = 'buyNow' | 'addCart' | 'learnMore' | 'buyOnAmazon';
|
|
6
|
+
export interface ShelfBoaFields {
|
|
7
|
+
secondaryAdCampaign?: string;
|
|
8
|
+
primaryAdCampaign?: string;
|
|
9
|
+
secondaryButtonTarget?: '_self' | '_blank';
|
|
10
|
+
primaryButtonTarget?: '_self' | '_blank';
|
|
11
|
+
secondaryHasTrack?: boolean;
|
|
12
|
+
primaryHasTrack?: boolean;
|
|
13
|
+
secondaryTrackEvents?: AdTrackEvent[];
|
|
14
|
+
primaryTrackEvents?: AdTrackEvent[];
|
|
15
|
+
}
|
|
5
16
|
/**
|
|
6
17
|
* 自定义折扣标签图标样式
|
|
7
18
|
* style1/style2/style3 为内置预设样式(写死在组件中),custom 为自定义上传图标
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as f}from"react/jsx-runtime";import*as c from"react";import{cn as r}from"../../helpers/index.js";import{Text as
|
|
1
|
+
"use client";import{jsx as i,jsxs as f}from"react/jsx-runtime";import*as c from"react";import{cn as r}from"../../helpers/index.js";import{Text as C,Picture as I,Heading as g,Link as L}from"../../components/index.js";import{cva as w}from"class-variance-authority";import{Swiper as T,SwiperSlide as V}from"swiper/react";import{withLayout as z}from"../../shared/Styles.js";import{useExposure as B}from"../../hooks/useExposure.js";import{useTracking as E}from"../../hooks/useTracking.js";import{trackUrlRef as R}from"../../shared/trackUrlRef.js";import{buildClickTrackingProps as j,toPlainTrackingText as x}from"../../shared/track.js";const m="image",v="activity_schedule",D=w("rounded-card laptop:px-6 laptop:py-4 relative flex min-w-0 flex-col justify-between gap-2 overflow-hidden px-4 py-3",{variants:{state:{"active-light":"bg-gradient-to-r from-[#3555aa] to-[#6988e3]","active-dark":"bg-gradient-to-r from-[#3555aa] to-[#6988e3]","inactive-light":"bg-[#EAEAEC]","inactive-dark":"bg-[#1E2024]"},size:{small:"laptop:h-[160px] h-[120px]",large:"laptop:h-[240px] h-[200px]"}},defaultVariants:{state:"inactive-light",size:"small"}}),h=w("font-bold leading-[1.2]",{variants:{state:{"active-light":"text-white","active-dark":"text-white","inactive-light":"text-[#080A0F]","inactive-dark":"text-white"}},defaultVariants:{state:"inactive-light"}}),y=c.memo(({item:e,theme:s="light",className:d,size:n,position:u})=>{const l=e.isActive||!1,{buildRef:o}=E(),t=`${l?"active":"inactive"}-${s}`;return i("div",{className:r(D({state:t,size:n}),d),"data-ui-component-id":"ActivityScheduleCard",children:f(L,{asChild:!e?.link,href:e?.link?R(e.link,o(m,v)):void 0,className:"size-full no-underline hover:text-current",...j({interactive:!!e?.link,componentType:m,componentName:v,title:e.title,description:e.subtitle,position:u}),children:[(l?e.activeIcon:e.inactiveIcon)&&i("div",{className:"laptop:w-[160px] aspect-1 absolute right-0 top-0 z-10 w-[120px]",children:i(I,{source:l?e.activeIcon.url:e.inactiveIcon.url,alt:l?e.activeIcon.alt:e.inactiveIcon.alt,className:"aspect-square"})}),f("div",{className:"relative z-20 flex h-full flex-col justify-between",children:[i(g,{as:"h3",size:3,html:e.title,className:r(h({state:t}))}),f("div",{className:"flex flex-col gap-1",children:[i("div",{className:"flex flex-col justify-end overflow-hidden",children:i(g,{as:"h4",size:2,html:e.subtitle,className:r(" line-clamp-2",h({state:t}))})}),n==="large"&&e.description&&i(C,{html:e.description,className:r("lg-desktop:text-[18px] desktop:text-[16px] line-clamp-3 text-[14px] leading-[1.4]",h({state:t}))})]})]})]})})});y.displayName="ActivityScheduleCard";const k=c.forwardRef(({classNames:e={},data:s,...d},n)=>{const u=s.theme||"light",l=s.size||"small",o=c.useRef(null);c.useImperativeHandle(n,()=>o.current),B(o,{componentType:m,componentName:v,componentTitle:s.scheduleList?.map(a=>x(a.title)).join(" | "),componentDescription:s.scheduleList?.map(a=>x(a.subtitle)).join(" | ")});const t=c.useMemo(()=>s?.scheduleList?.length||2,[s?.scheduleList]),b=c.useMemo(()=>{const a=P=>{switch(P){case"mobile":return{slidesPerView:1.17,spaceBetween:12};case"tablet":return t===2?{slidesPerView:2,spaceBetween:12}:{slidesPerView:2.4,spaceBetween:12};case"laptop":return t===2?{}:t===4?{slidesPerView:3.2,spaceBetween:16}:{slidesPerView:t,spaceBetween:16};case"desktop":return t===2?{slidesPerView:2,spaceBetween:16}:{slidesPerView:t,spaceBetween:16}}},p=a("mobile"),S=a("tablet"),A=a("laptop"),N=a("desktop");return{0:p,768:S,1024:A,1440:N}},[t]);return i("div",{ref:o,className:r(e?.root),"data-ui-component-id":"ActivitySchedule",...d,children:i(T,{breakpoints:b,className:"w-full !overflow-visible",children:s?.scheduleList?.map((a,p)=>i(V,{children:i(y,{item:a,theme:u,size:l,className:e?.card,position:p+1})},"activityScheduleCardItem"+p))??null})})});k.displayName="ActivitySchedule";var K=z(k);export{K as default};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CurrencyDisplayType } from '../../types/props.js';
|
|
3
|
+
import type { OnAdTrackCallback } from '../../shared/adTrack.js';
|
|
3
4
|
/**
|
|
4
5
|
* Exposure tracking parameters
|
|
5
6
|
*/
|
|
@@ -77,6 +78,33 @@ interface AiuiContextType {
|
|
|
77
78
|
* </AiuiProvider>
|
|
78
79
|
*/
|
|
79
80
|
onExposure?: OnExposureCallback;
|
|
81
|
+
/**
|
|
82
|
+
* 页面级开关:是否启用组件化 BOA 链接处理。
|
|
83
|
+
* 关闭(默认)时,页面保持原逻辑,按钮上的亚马逊链接字段不生效。
|
|
84
|
+
*/
|
|
85
|
+
componentBoaEnabled?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* 页面级亚马逊归因配置。maas 由业务端按「页面级 > 店铺级 > 内置映射」算好后传入,
|
|
88
|
+
* 没有值时不生成 maas 参数。
|
|
89
|
+
*/
|
|
90
|
+
amazonAttribution?: {
|
|
91
|
+
/** 广告活动 ID,与商品编号直接相连;需要分隔符请在末尾自行写下划线 */
|
|
92
|
+
adCampaign?: string;
|
|
93
|
+
/** MAAS 广告平台 ID */
|
|
94
|
+
maas?: string;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* 广告埋点交接回调:按钮被点击时,把按钮上配置的 Meta、Google 事件交给业务端。
|
|
98
|
+
* 三方脚本的初始化与上报由业务端实现;未传入时埋点静默不生效,不会报错。
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* <AiuiProvider
|
|
102
|
+
* onAdTrack={(events, context) => {
|
|
103
|
+
* events.forEach(e => (e.channel === 'meta' ? fbq('trackCustom', e.name) : gtag('event', 'conversion', { send_to: `${ID}/${e.googleLabel}` })))
|
|
104
|
+
* }}
|
|
105
|
+
* />
|
|
106
|
+
*/
|
|
107
|
+
onAdTrack?: OnAdTrackCallback;
|
|
80
108
|
/**
|
|
81
109
|
* 自定义 locale → BCP47 语言标签映射,会与内置 map merge(外部优先级更高)。
|
|
82
110
|
* 消费方无需修改 headless-ui 源码即可支持新 locale 的价格格式化。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as h}from"react/jsx-runtime";import{gaTrack as P}from"../../shared/track.js";import{buildPageGroup as R}from"../../shared/trackUrlRef.js";import{createContext as N,useContext as H,useEffect as i,useMemo as
|
|
1
|
+
"use client";import{jsx as h}from"react/jsx-runtime";import{gaTrack as P}from"../../shared/track.js";import{buildPageGroup as R}from"../../shared/trackUrlRef.js";import{createContext as N,useContext as H,useEffect as i,useMemo as O,useRef as d,useState as G}from"react";import{extendLocaleMap as L}from"../../helpers/index.js";const C=N({trackingData:{},locale:void 0,copyWriting:{}}),z=()=>{const o=H(C);if(!o)throw new Error("useAiui must be used in <AiuiProvider>");return o},w=({children:o,...e})=>{const l=d(null),u=d(e?.trackingData),g=d(e?.pageHandle),[m,x]=G(void 0);i(()=>{e.localeMap&&Object.keys(e.localeMap).length>0&&L(e.localeMap)},[e.localeMap]),i(()=>{u.current=e?.trackingData},[e?.trackingData]),i(()=>{g.current=e?.pageHandle},[e?.pageHandle]),i(()=>{const r=l.current;if(!r)return;const v=()=>{r.querySelectorAll("[data-headless-type-name]").forEach(n=>{n.closest("[data-aiui-provider-root]")===r&&(n.hasAttribute("data-headless-track-bound")||(n.addEventListener("click",a=>T(a,n)),n.setAttribute("data-headless-track-bound","true")))})},T=(n,a)=>{const t={};if(!a||!a.attributes)return t;for(const M of Array.from(a.attributes)){const p=M?.name;p?.startsWith("data-headless-")&&(t[p]=a.getAttribute(p))}const E=t?.["data-headless-sku"],D=t?.["data-headless-creative-id"],f=t?.["data-headless-type-name"]?.split?.("#"),s=t?.["data-headless-title-desc-button"]?.split?.("#"),y=t?.["data-headless-nav-position"]?.split?.("#"),_=R({pageHandle:g.current,pageGroup:u.current?.pageGroup}),c=y?.[1],k=c===void 0||c===""?"":Number(c);P({event:"ga4Event",event_name:"component_click",event_parameters:{page_group:_,component_type:f?.[0]||"",component_name:f?.[1]||"",position:Number.isNaN(k)?"":k,navigation:y?.[0]||"",button_name:s?.[2]||"",SKU:E||"",creative_id:D||"",component_title:s?.[0]||"",component_description:s?.[1]||""}})},b=new MutationObserver(v);return b.observe(r,{childList:!0,subtree:!0}),v(),()=>b.disconnect()},[]);const A=O(()=>({...e,navCollapsed:m,setNavCollapsed:x}),[e,m]);return h(C.Provider,{value:A,children:h("div",{ref:l,"data-aiui-provider-root":"",children:o})})};var B=w;export{C as AiuiContext,B as default,z as useAiuiContext};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { BrandEquityProps } from './types.js';
|
|
2
|
+
import 'swiper/css';
|
|
3
|
+
import 'swiper/css/pagination';
|
|
2
4
|
declare const _default: import("react").ForwardRefExoticComponent<Omit<BrandEquityProps & import("react").RefAttributes<HTMLDivElement>, "container" | keyof import("../../shared/Styles.js").StylesProps> & import("../../shared/Styles.js").StylesProps & import("../index.js").ContainerProps & import("react").RefAttributes<unknown>> & {
|
|
3
5
|
readonly $$typeof: symbol;
|
|
4
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{Fragment as $,jsx as t,jsxs as c}from"react/jsx-runtime";import{forwardRef as E,useEffect as q,useRef as S,useState as x,useImperativeHandle as I}from"react";import{cn as l}from"../../helpers/utils.js";import g from"../../components/picture.js";import{withLayout as M}from"../../shared/Styles.js";import{useMediaQuery as B}from"react-responsive";import{useExposure as T}from"../../hooks/useExposure.js";import{Swiper as P,SwiperSlide as j}from"swiper/react";import{Pagination as L,FreeMode as z,Mousewheel as A}from"swiper/modules";import"swiper/css";import"swiper/css/pagination";import H from"../Title/index.js";const D="copy",R="store_benefits",Q=(e,a)=>{const i=[];for(let r=0;r<e.length;r+=a)i.push(e.slice(r,r+a));return i},v=E(({data:{items:e=[],itemShape:a,title:i,theme:r},className:o},n)=>{const[p,h]=x(!1),u=B({query:"(max-width: 767px)"}),[k,N]=x(null),d=S(null);I(n,()=>d.current),T(d,{componentType:D,componentName:R}),q(()=>{h(u)},[u]);const w=p?Q(e,3):e;return c("div",{ref:d,className:l("brand-equity-wrapper w-full",{"aiui-dark":r==="dark"},o),children:[i&&t(H,{data:{title:i}}),p?c($,{children:[t(P,{className:l(o),modules:[z,A,L],freeMode:!0,mousewheel:{forceToAxis:!0},pagination:{clickable:!0,el:k},breakpoints:{0:{spaceBetween:12}},children:w?.map((s,m)=>t(j,{className:"!flex flex-col gap-3",children:Array.isArray(s)&&s?.map((f,y)=>t(b,{data:f,itemShape:a,index:y,theme:f.theme??r},y))},"SwiperSlide"+m))}),t("div",{ref:N,className:"brand-equity-pagination !static mt-[20px] flex justify-center"})]}):t("div",{className:l("grid grid-cols-1 gap-3","tablet:grid-cols-2","laptop:gap-4 laptop:grid-cols-10"),children:e.map((s,m)=>t(b,{data:s,itemShape:a,index:m,theme:s.theme??r},m))})]})}),b=({data:e,itemShape:a,index:i,theme:r})=>{const o=r==="dark"&&e.iconImage?e.iconImage:e.icon;return c("div",{className:l("brand-equity-item",`brand-equity-item-${i+1}`,e.containerName?`brand-equity-item--${e.containerName}`:void 0,"bg-container-secondary-1 box-border flex w-full flex-col p-4","desktop:p-6 justify-between","laptop:col-span-3 lg-desktop:p-8","laptop:h-[192px] lg-desktop:h-[240px] h-[160px]",{"laptop:col-span-4":[0,5,6,11].includes(i),"bg-container-primary":r==="dark"},"rounded-box",e.className),children:[c("div",{className:"lg-desktop:h-[36px] flex h-[32px] items-center justify-between gap-3",children:[t("h3",{className:"lg-desktop:text-[18px] desktop:text-[16px] text-info-primary text-[14px] font-bold leading-[1.2] tracking-[-0.02em]",children:e.title}),e.type==="avatar"?t("div",{className:"flex shrink-0 -space-x-2",children:e?.avatarList?.map((n,p)=>t("div",{className:l("border-container-primary size-[32px] overflow-hidden rounded-full border-2","relative inline-block shrink-0","lg-desktop:size-[36px]"),children:t(g,{source:n.avatar?.url,alt:n.avatar?.alt,className:"size-full object-cover"})},p))}):t("div",{className:"lg-desktop:size-[36px] size-[32px] shrink-0",children:t(g,{className:"size-full object-cover",source:o?.url,alt:o?.alt,imgClassName:"w-full h-full object-cover"})})]}),t("p",{className:"lg-desktop:text-[24px] text-info-primary line-clamp-3 text-[20px] font-bold leading-[1.2] tracking-[-0.04em]",children:e.description})]})};v.displayName="BrandEquity";var Y=M(v);export{Y as default};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ComponentCommonProps, Img } from '../../types/props.js';
|
|
2
2
|
export interface BrandEquityItemProps {
|
|
3
3
|
icon?: Img;
|
|
4
|
+
/** 暗色主题专用图标:item 或全局 theme 为 dark 时优先于 icon 渲染(semantic-media 命名遵循 ADR 0010) */
|
|
5
|
+
iconImage?: Img;
|
|
4
6
|
type?: 'icon' | 'avatar';
|
|
5
7
|
title: string;
|
|
6
8
|
description: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as p}from"react/jsx-runtime";import{useChatContext as c}from"@copilotkit/react-ui";const i=({setOpen:n})=>{const o=c();return p("button",{onClick:()=>n(),className:"copilotKitButton ","aria-label":"Open Chat",children:[t("div",{className:"copilotKitButtonIcon copilotKitButtonIconOpen",children:o.icons.openIcon}),t("div",{className:"copilotKitButtonIcon copilotKitButtonIconClose",children:o.icons.closeIcon})]})};var
|
|
1
|
+
import{jsx as t,jsxs as p}from"react/jsx-runtime";import"react";import{useChatContext as c}from"@copilotkit/react-ui";const i=({setOpen:n})=>{const o=c();return p("button",{onClick:()=>n(),className:"copilotKitButton ","aria-label":"Open Chat",children:[t("div",{className:"copilotKitButtonIcon copilotKitButtonIconOpen",children:o.icons.openIcon}),t("div",{className:"copilotKitButtonIcon copilotKitButtonIconClose",children:o.icons.closeIcon})]})};var a=i;export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as rt,jsx as t,jsxs as u}from"react/jsx-runtime";import ce,{useImperativeHandle as Ee,useRef as k,useState as Me,useEffect as Pe}from"react";import N from"gsap";import{ScrollTrigger as C}from"gsap/dist/ScrollTrigger";import O from"jump.js";import{buildPictureSource as Re,resolveTierMedia as L,useMediaTier as De}from"./mediaResolver.js";import{useInView as je}from"react-intersection-observer";import Ae from"../../helpers/ScrollLoadVideo.js";import{Button as V,Heading as Oe,Picture as U,Text as G,Countdown as Ue}from"../../components/index.js";import{cn as c}from"../../helpers/index.js";import{cva as S}from"class-variance-authority";import{withLayout as Ge}from"../../shared/Styles.js";import{useExposure as Je}from"../../hooks/useExposure.js";import{buildTrackingRef as _e,trackUrlRef as z}from"../../shared/trackUrlRef.js";import{buildClickTrackingProps as h,resolveComponentMediaType as qe}from"../../shared/track.js";import{getLocalizedPath as Fe}from"../../helpers/utils.js";import{useAiuiContext as We}from"../AiuiProvider/index.js";import{sizeMap as Ye}from"../../components/button.js";import{VideoModal as Ze}from"../VideoModal/index.js";import Ke from"./HeroBannerCarousel.js";const f="hero_banner",Qe=S("hero-banner-content lg-desktop:gap-[32px] pointer-events-none absolute top-24 z-10 flex w-full flex-col gap-[24px]",{variants:{align:{left:"laptop:top-1/2 px-grid laptop:-translate-y-1/2 left-0",center:"tablet:top-[84px] laptop:top-[76px] desktop:top-[176px] lg-desktop:top-[192px] left-1/2 top-[84px] -translate-x-1/2 translate-y-0 items-center text-center"}},defaultVariants:{align:"left"}}),Xe=S("hero-banner-wrap-text lg-desktop:max-w-[824px] desktop:max-w-[648px] laptop:max-w-[440px] tablet:max-w-[704px] max-w-[358px]",{variants:{align:{left:"laptop:text-left",center:"text-center"}},defaultVariants:{align:"left"}}),$e=S("hero-banner-button-group lg-desktop:gap-x-3 pointer-events-auto flex flex-wrap items-center gap-x-2 gap-y-3",{variants:{align:{left:"laptop:justify-start",center:"justify-center"}},defaultVariants:{align:"left"}}),et=S("hero-banner-icon-group flex items-center gap-2",{variants:{align:{left:"justify-start",center:"justify-center"}},defaultVariants:{align:"left"}}),tt=({size:s="base"})=>{const{width:T,height:p}=Ye[s];return t("svg",{width:T,height:p,viewBox:"0 0 20 20",fill:"currentcolor",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M13.9599 9.30662C14.4547 9.63647 14.4547 10.3635 13.9599 10.6934L6.29558 15.8029C5.74179 16.1721 5 15.7751 5 15.1096V4.89042C5 4.22484 5.74179 3.82785 6.29558 4.19705L13.9599 9.30662Z",fill:"currentcolor"})})},pe=ce.forwardRef(({data:s,className:T,classNames:p={},onSecondaryClick:J,onPrimaryClick:_,onTertiaryClick:q,jumpOptions:ue={},a11yLabels:me,...F},W)=>{const{locale:Y,pageHandle:de}=We(),Z=s.mode!=="single"&&!!s.items&&s.items.length>0,I={...{duration:500,offset:0},...ue},w=e=>!e||!Y?e:Fe(e,Y),{label:K,title:l,subtitle:o,endDate:Q,endDate_tz:fe,dateFormat:ge,pcImage:E,isShowVideo:X,isVideoLoop:be=!0,primaryButton:a,secondaryButton:r,tertiaryButton:i,theme:ve="light",size:M="default",titleSize:P,caption:$=[],blockLink:B,iconArray:ee,align:b="left",enableParallax:te=!0}=s,R=Array.isArray($)?$:[],ye=Array.isArray(ee)?ee:void 0,re=De(),ne=Re(s),xe=L(s,re,"video")?.url||"",[oe,ae]=Me(!1),{ref:ke,inView:ie}=je(),D=k(null),j=k(null),A=k(null),v=k(null),d=k(null),m=qe(X),H=_e(de??"",m,f),g=L(s,re,m==="video"?"video":"image")?.id||E?.id||"",he=l?.trim()||o?.trim()||E?.alt?.trim()||void 0,Te=l!==void 0?l?.trim()||o?.trim()||E?.alt?.trim()||void 0:o&&o.trim()||"",we=o&&o.trim()||"";Je(d,{componentType:m,componentName:f,componentTitle:Te,componentDescription:we,creativeId:g,position:1});const Be=B?z(w(B),H):void 0,He=r?.link?z(w(r.link),H):void 0,Ne=a?.link?z(w(a.link),H):void 0,Ce=i?.link?z(w(i.link),H):void 0,Le=h({interactive:!!B,componentType:m,componentName:f,title:l,description:o,position:1,creativeId:g}),Ve=h({interactive:!0,componentType:m,componentName:f,title:l,description:o,buttonName:"video play",position:1,creativeId:g}),Se=h({interactive:!!(r?.link||r?.isCustomSecondaryButton),componentType:m,componentName:f,title:l,description:o,buttonName:r?.text,position:1,creativeId:g}),ze=h({interactive:!!(a?.link||a?.isCustomPrimaryButton),componentType:m,componentName:f,title:l,description:o,buttonName:a?.text,position:1,creativeId:g}),Ie=h({interactive:!!(i?.link||i?.isCustomTertiaryButton),componentType:m,componentName:f,title:l,description:o,buttonName:i?.text,position:1,creativeId:g});return Ee(W,()=>d.current),Pe(()=>{if(Z||!te)return;N.registerPlugin(C);function e(){if(!v.current)return;const n=d.current?.clientHeight||100;window.innerHeight<=n?D.current=C.create({trigger:d.current,start:"top bottom",end:"bottom top",scrub:!0,onUpdate:y=>{const x=y.progress*40-20;N.set(v.current,{yPercent:x})}}):(A.current=C.create({trigger:d.current,start:"top bottom",end:"bottom bottom",scrub:!0,onUpdate:y=>{const x=y.progress*20-20;N.set(v.current,{yPercent:x})}}),j.current=C.create({trigger:d.current,start:"top top",end:"bottom top",scrub:!0,onUpdate:y=>{const x=y.progress*20;N.set(v.current,{yPercent:x})}}))}return ie&&e(),()=>{D.current&&D.current.kill(),A.current&&A.current.kill(),j.current&&j.current.kill()}},[ie,s.items,te]),Z?t(Ke,{data:s,className:T,classNames:p,onPrimaryClick:_,onSecondaryClick:J,onTertiaryClick:q,a11yLabels:me,ref:W,...F}):t("div",{...F,ref:ke,"data-ui-component-id":"HeroBanner",className:c(p.root),children:u("div",{ref:d,className:c(ve==="dark"?"aiui-dark":"","text-info-primary relative w-full overflow-hidden",{"tablet:aspect-[768/560] laptop:aspect-[1024/400] desktop:aspect-[1440/560] lg-desktop:aspect-[1920/800] aspect-[390/560]":M==="default","lg-desktop:aspect-[1920/800] desktop:aspect-[1440/640] laptop:aspect-[1024/480] tablet:aspect-[768/560] aspect-[390/560]":M==="sm"},T),children:[B&&t("a",{className:"absolute inset-0 z-10",href:Be,tabIndex:-1,"aria-hidden":"true","aria-label":he,...Le}),t("div",{ref:v,className:c("absolute left-0 top-0 size-full"),children:X?u(rt,{children:[t(Ae,{poster:void 0,src:xe,className:"laptop:w-full absolute inset-0 h-full transition-opacity duration-500",videoLayerClassName:"opacity-0",videoClassName:"h-full object-cover",muted:!0,loop:be,playsInline:!0,onPlaying:e=>{const n=e.currentTarget;n.parentElement?.classList.remove("opacity-0"),n.closest('[data-ui-component-id="HeroBanner"]')?.querySelector('[data-video-poster="true"]')?.classList.add("opacity-0")},onWaiting:e=>{const n=e.currentTarget;if(n.currentTime>=.5)return;n.parentElement?.classList.add("opacity-0"),n.closest('[data-ui-component-id="HeroBanner"]')?.querySelector('[data-video-poster="true"]')?.classList.remove("opacity-0")}}),t("div",{"data-video-poster":"true",className:"laptop:w-full bg-container-primary pointer-events-none absolute inset-0 h-full transition-opacity duration-500",children:t(U,{className:"absolute inset-0 size-full",imgClassName:"size-full object-cover",loading:"eager",fetchPriority:"high",alt:L(s,"lgDesktop","image")?.alt||"",source:ne})})]}):t(U,{className:"laptop:w-full h-full",imgClassName:"h-full object-cover",loading:"eager",fetchPriority:"high",alt:L(s,"lgDesktop","image")?.alt||"",source:ne})}),u("div",{className:Qe({align:b}),children:[u("div",{className:Xe({align:b}),children:[K&&t(G,{size:2,as:"p",className:c("hero-banner-label font-heading lg-desktop:text-[18px] desktop:text-base text-sm"),html:K}),l&&t(Oe,{as:P==="4"?"h1":"h2",html:l,className:c("hero-banner-title",p.title),size:P?Number(P||"5"):M==="sm"?4:5}),o&&t(G,{as:"p",size:2,className:c("hero-banner-subtitle font-heading lg-desktop:text-[18px] desktop:text-base laptop:mt-2 lg-desktop:mt-4 mt-1 text-sm",p.subtitle),html:o}),Q&&t("div",{className:"mt-3",children:t(Ue,{endDate:Q,endDate_tz:fe,dateFormat:ge,variant:"spacious",align:b})})]}),u("div",{className:c($e({align:b}),p.buttonGroup),children:[u("div",{className:"lg-desktop:gap-3 flex items-center gap-2",children:[r?.isShowPlayVideoButton&&r?.playVideoButtonText?u(V,{onClick:()=>ae(!0),size:"lg",variant:"secondary",className:"hero-banner-play-video-button",...Ve,children:[r?.playVideoButtonText," ",t(tt,{size:"lg"})]}):r?.text?u(V,{"aria-label":l??o,size:"lg",variant:"secondary",className:c("hero-banner-secondary-button",p.secondaryButton),as:r?.isCustomSecondaryButton?"button":"a",href:He,target:r?.target,rel:r?.target==="_blank"?r?.rel??"noopener noreferrer":r?.rel,onClick:e=>{if(r.link?.startsWith("#")){e.preventDefault();const n=document.querySelector(r.link);n&&O(n,I)}r?.isCustomSecondaryButton&&J?.(s,e,r?.customSecondaryEventId)},...Se,children:[r?.text,t("span",{className:"sr-only",children:l??o})]}):null,a&&a.text&&t(V,{"aria-label":l??o,size:"lg",variant:"primary",className:c("hero-banner-primary-button",p.primaryButton),as:a?.isCustomPrimaryButton?"button":"a",href:Ne,target:a?.target,rel:a?.target==="_blank"?a?.rel??"noopener noreferrer":a?.rel,onClick:e=>{if(a.link?.startsWith("#")){e.preventDefault();const n=document.querySelector(a.link);n&&O(n,I)}a?.isCustomPrimaryButton&&_?.(s,e,a?.customPrimaryEventId)},...ze,children:a.text})]}),i&&i.text&&u(V,{"aria-label":l??o,size:"lg",variant:"link",className:c("hero-banner-tertiary-button w-auto p-0",p.tertiaryButton),as:i?.isCustomTertiaryButton?"button":"a",href:Ce,target:i?.target,rel:i?.target==="_blank"?i?.rel??"noopener noreferrer":i?.rel,onClick:e=>{if(i.link?.startsWith("#")){e.preventDefault();const n=document.querySelector(i.link);n&&O(n,I)}i?.isCustomTertiaryButton&&q?.(s,e,i?.customTertiaryEventId)},...Ie,children:[i.text,t("span",{className:"sr-only",children:l??o})]})]}),t("div",{className:et({align:b}),children:ye?.map(e=>t("div",{className:"h-12",children:t(U,{className:"!inline-block h-full !w-auto",imgClassName:"!w-auto h-full object-contain",loading:"eager",alt:e?.pcImage?.alt||"",source:e?.pcImage?.url})},e?.pcImage?.url||e?.pcImage?.alt))})]}),R.length>0&&t("div",{className:c("hero-banner-caption-group laptop:gap-3 px-grid desktop:pb-[24px] pointer-events-none absolute bottom-0 z-10 flex items-stretch gap-2 pb-[16px]",p.captionGroup),children:R.map((e,n)=>u(ce.Fragment,{children:[t(G,{size:2,className:c("hero-banner-product-text tablet:w-[108px] loptop:w-[150px] desktop:w-[156px] lg-desktop:w-[180px] laptop:text-[14px] flex-1 text-[12px]"),html:e.title}),n<R.length-1&&t("div",{className:c("bg-info-primary w-px")})]},e.title))}),oe&&t(Ze,{visible:oe,videoUrl:r?.isYoutubeVideo?void 0:r?.videoUrl?.url,youTubeId:r?.isYoutubeVideo?r?.youtubeId:void 0,onCloseModal:()=>ae(!1)})]})})});pe.displayName="HeroBanner";var wt=Ge(pe);export{wt as default};
|
|
1
|
+
"use client";import{Fragment as gt,jsx as n,jsxs as u}from"react/jsx-runtime";import Be,{useImperativeHandle as Je,useRef as w,useState as qe,useEffect as We}from"react";import N from"gsap";import{ScrollTrigger as V}from"gsap/dist/ScrollTrigger";import Y from"jump.js";import{buildPictureSource as Ye,resolveTierMedia as S,useMediaTier as Ze}from"./mediaResolver.js";import{useInView as Ke}from"react-intersection-observer";import Qe from"../../helpers/ScrollLoadVideo.js";import{Button as I,Heading as Xe,Picture as Z,Text as K,Countdown as $e}from"../../components/index.js";import{cn as c}from"../../helpers/index.js";import{cva as E}from"class-variance-authority";import{withLayout as et}from"../../shared/Styles.js";import{useExposure as tt}from"../../hooks/useExposure.js";import{useBoaButton as nt}from"../../hooks/useBoaButton.js";import{buildTrackingRef as rt,trackUrlRef as we}from"../../shared/trackUrlRef.js";import{buildClickTrackingProps as L,resolveComponentMediaType as at}from"../../shared/track.js";import{getLocalizedPath as ot}from"../../helpers/utils.js";import{useAiuiContext as it}from"../AiuiProvider/index.js";import{sizeMap as st}from"../../components/button.js";import{VideoModal as lt}from"../VideoModal/index.js";import ct from"./HeroBannerCarousel.js";const d="hero_banner",pt=E("hero-banner-content lg-desktop:gap-[32px] pointer-events-none absolute top-24 z-10 flex w-full flex-col gap-[24px]",{variants:{align:{left:"laptop:top-1/2 px-grid laptop:-translate-y-1/2 left-0",center:"tablet:top-[84px] laptop:top-[76px] desktop:top-[176px] lg-desktop:top-[192px] left-1/2 top-[84px] -translate-x-1/2 translate-y-0 items-center text-center"}},defaultVariants:{align:"left"}}),ut=E("hero-banner-wrap-text lg-desktop:max-w-[824px] desktop:max-w-[648px] laptop:max-w-[440px] tablet:max-w-[704px] max-w-[358px]",{variants:{align:{left:"laptop:text-left",center:"text-center"}},defaultVariants:{align:"left"}}),dt=E("hero-banner-button-group lg-desktop:gap-x-3 pointer-events-auto flex flex-wrap items-center gap-x-2 gap-y-3",{variants:{align:{left:"laptop:justify-start",center:"justify-center"}},defaultVariants:{align:"left"}}),mt=E("hero-banner-icon-group flex items-center gap-2",{variants:{align:{left:"justify-start",center:"justify-center"}},defaultVariants:{align:"left"}}),ft=({size:s="base"})=>{const{width:z,height:p}=st[s];return n("svg",{width:z,height:p,viewBox:"0 0 20 20",fill:"currentcolor",xmlns:"http://www.w3.org/2000/svg",children:n("path",{d:"M13.9599 9.30662C14.4547 9.63647 14.4547 10.3635 13.9599 10.6934L6.29558 15.8029C5.74179 16.1721 5 15.7751 5 15.1096V4.89042C5 4.22484 5.74179 3.82785 6.29558 4.19705L13.9599 9.30662Z",fill:"currentcolor"})})},Le=Be.forwardRef(({data:s,className:z,classNames:p={},onSecondaryClick:Q,onPrimaryClick:X,onTertiaryClick:$,jumpOptions:ze={},a11yLabels:Ce,...ee},te)=>{const{locale:ne,pageHandle:He}=it(),{resolveLink:g,hasAdTrack:y,trackAd:re}=nt(),ae=s.mode!=="single"&&!!s.items&&s.items.length>0,M={...{duration:500,offset:0},...ze},oe=e=>!e||!ne?e:ot(e,ne),{label:ie,title:l,subtitle:i,endDate:se,endDate_tz:Ne,dateFormat:Ve,pcImage:P,isShowVideo:le,isVideoLoop:Se=!0,primaryButton:o,secondaryButton:r,tertiaryButton:a,theme:Ie="light",size:A="default",titleSize:R,caption:ce=[],blockLink:v,blockLinkConfig:k,iconArray:pe,align:h="left",enableParallax:ue=!0}=s,D=Array.isArray(ce)?ce:[],Ee=Array.isArray(pe)?pe:void 0,de=Ze(),me=Ye(s),Me=S(s,de,"video")?.url||"",[fe,ge]=qe(!1),{ref:Pe,inView:be}=Ke(),j=w(null),F=w(null),_=w(null),x=w(null),f=w(null),m=at(le),ye=rt(He??"",m,d),b=S(s,de,m==="video"?"video":"image")?.id||P?.id||"",Ae=l?.trim()||i?.trim()||P?.alt?.trim()||void 0,Re=l!==void 0?l?.trim()||i?.trim()||P?.alt?.trim()||void 0:i&&i.trim()||"",De=i&&i.trim()||"";tt(f,{componentType:m,componentName:d,componentTitle:Re,componentDescription:De,creativeId:b,position:1});const O=e=>{if(!e?.link)return{href:void 0,target:e?.target};const t=g(e.link,e);return t.isAmazon?{href:t.href,target:e.target??"_blank"}:{href:we(oe(e.link),ye),target:e.target}},U=O(r),G=O(o),J=O(a),C=g(v,k),ve=C.isAmazon?C.href:v?we(oe(v),ye):void 0,je=C.isAmazon?k?.target??"_blank":k?.target,ke=U.href,he=G.href,xe=J.href,q=(e,t)=>!!e&&!(t?.link&&y(t)),W=(e,t,H)=>re(e,{componentName:d,buttonPosition:t,buttonText:e?.text,href:H}),Fe=L({interactive:!!v,componentType:m,componentName:d,title:l,description:i,position:1,creativeId:b}),_e=L({interactive:!0,componentType:m,componentName:d,title:l,description:i,buttonName:"video play",position:1,creativeId:b}),Oe=L({interactive:!!(r?.link||r?.isCustomSecondaryButton),componentType:m,componentName:d,title:l,description:i,buttonName:r?.text,position:1,creativeId:b}),Ue=L({interactive:!!(o?.link||o?.isCustomPrimaryButton),componentType:m,componentName:d,title:l,description:i,buttonName:o?.text,position:1,creativeId:b}),Ge=L({interactive:!!(a?.link||a?.isCustomTertiaryButton),componentType:m,componentName:d,title:l,description:i,buttonName:a?.text,position:1,creativeId:b});return Je(te,()=>f.current),We(()=>{if(ae||!ue)return;N.registerPlugin(V);function e(){if(!x.current)return;const t=f.current?.clientHeight||100;window.innerHeight<=t?j.current=V.create({trigger:f.current,start:"top bottom",end:"bottom top",scrub:!0,onUpdate:T=>{const B=T.progress*40-20;N.set(x.current,{yPercent:B})}}):(_.current=V.create({trigger:f.current,start:"top bottom",end:"bottom bottom",scrub:!0,onUpdate:T=>{const B=T.progress*20-20;N.set(x.current,{yPercent:B})}}),F.current=V.create({trigger:f.current,start:"top top",end:"bottom top",scrub:!0,onUpdate:T=>{const B=T.progress*20;N.set(x.current,{yPercent:B})}}))}return be&&e(),()=>{j.current&&j.current.kill(),_.current&&_.current.kill(),F.current&&F.current.kill()}},[be,s.items,ue]),ae?n(ct,{data:s,className:z,classNames:p,onPrimaryClick:X,onSecondaryClick:Q,onTertiaryClick:$,a11yLabels:Ce,ref:te,...ee}):n("div",{...ee,ref:Pe,"data-ui-component-id":"HeroBanner",className:c(p.root),children:u("div",{ref:f,className:c(Ie==="dark"?"aiui-dark":"","text-info-primary relative w-full overflow-hidden",{"tablet:aspect-[768/560] laptop:aspect-[1024/400] desktop:aspect-[1440/560] lg-desktop:aspect-[1920/800] aspect-[390/560]":A==="default","lg-desktop:aspect-[1920/800] desktop:aspect-[1440/640] laptop:aspect-[1024/480] tablet:aspect-[768/560] aspect-[390/560]":A==="sm"},z),children:[v&&n("a",{className:"absolute inset-0 z-10 !bg-transparent hover:!bg-transparent",href:ve,target:je,"data-headless-ad-track":y(k)?"true":void 0,"data-headless-amazon":C.isAmazon?"true":void 0,onClick:()=>re(k,{componentName:d,buttonPosition:"block",href:ve}),tabIndex:-1,"aria-hidden":"true","aria-label":Ae,...Fe}),n("div",{ref:x,className:c("absolute left-0 top-0 size-full"),children:le?u(gt,{children:[n(Qe,{poster:void 0,src:Me,className:"laptop:w-full absolute inset-0 h-full transition-opacity duration-500",videoLayerClassName:"opacity-0",videoClassName:"h-full object-cover",muted:!0,loop:Se,playsInline:!0,onPlaying:e=>{const t=e.currentTarget;t.parentElement?.classList.remove("opacity-0"),t.closest('[data-ui-component-id="HeroBanner"]')?.querySelector('[data-video-poster="true"]')?.classList.add("opacity-0")},onWaiting:e=>{const t=e.currentTarget;if(t.currentTime>=.5)return;t.parentElement?.classList.add("opacity-0"),t.closest('[data-ui-component-id="HeroBanner"]')?.querySelector('[data-video-poster="true"]')?.classList.remove("opacity-0")}}),n("div",{"data-video-poster":"true",className:"laptop:w-full bg-container-primary pointer-events-none absolute inset-0 h-full transition-opacity duration-500",children:n(Z,{className:"absolute inset-0 size-full",imgClassName:"size-full object-cover",loading:"eager",fetchPriority:"high",alt:S(s,"lgDesktop","image")?.alt||"",source:me})})]}):n(Z,{className:"laptop:w-full h-full",imgClassName:"h-full object-cover",loading:"eager",fetchPriority:"high",alt:S(s,"lgDesktop","image")?.alt||"",source:me})}),u("div",{className:pt({align:h}),children:[u("div",{className:ut({align:h}),children:[ie&&n(K,{size:2,as:"p",className:c("hero-banner-label font-heading lg-desktop:text-[18px] desktop:text-base text-sm"),html:ie}),l&&n(Xe,{as:R==="4"?"h1":"h2",html:l,className:c("hero-banner-title",p.title),size:R?Number(R||"5"):A==="sm"?4:5}),i&&n(K,{as:"p",size:2,className:c("hero-banner-subtitle font-heading lg-desktop:text-[18px] desktop:text-base laptop:mt-2 lg-desktop:mt-4 mt-1 text-sm",p.subtitle),html:i}),se&&n("div",{className:"mt-3",children:n($e,{endDate:se,endDate_tz:Ne,dateFormat:Ve,variant:"spacious",align:h})})]}),u("div",{className:c(dt({align:h}),p.buttonGroup),children:[u("div",{className:"lg-desktop:gap-3 flex items-center gap-2",children:[r?.isShowPlayVideoButton&&r?.playVideoButtonText?u(I,{onClick:()=>ge(!0),size:"lg",variant:"secondary",className:"hero-banner-play-video-button",..._e,children:[r?.playVideoButtonText," ",n(ft,{size:"lg"})]}):r?.text?u(I,{"aria-label":l??i,size:"lg",variant:"secondary",className:c("hero-banner-secondary-button",p.secondaryButton),as:q(r?.isCustomSecondaryButton,r)?"button":"a",href:ke,"data-headless-ad-track":y(r)?"true":void 0,"data-headless-amazon":g(r.link,r).isAmazon?"true":void 0,target:U.target,rel:U.target==="_blank"?r?.rel??"noopener noreferrer":r?.rel,onClick:e=>{if(W(r,"secondary",ke),r.link?.startsWith("#")){e.preventDefault();const t=document.querySelector(r.link);t&&Y(t,M)}r?.isCustomSecondaryButton&&Q?.(s,e,r?.customSecondaryEventId)},...Oe,children:[r?.text,n("span",{className:"sr-only",children:l??i})]}):null,o&&o.text&&n(I,{"aria-label":l??i,size:"lg",variant:"primary",className:c("hero-banner-primary-button",p.primaryButton),as:q(o?.isCustomPrimaryButton,o)?"button":"a",href:he,"data-headless-ad-track":y(o)?"true":void 0,"data-headless-amazon":g(o.link,o).isAmazon?"true":void 0,target:G.target,rel:G.target==="_blank"?o?.rel??"noopener noreferrer":o?.rel,onClick:e=>{if(W(o,"primary",he),o.link?.startsWith("#")){e.preventDefault();const t=document.querySelector(o.link);t&&Y(t,M)}o?.isCustomPrimaryButton&&X?.(s,e,o?.customPrimaryEventId)},...Ue,children:o.text})]}),a&&a.text&&u(I,{"aria-label":l??i,size:"lg",variant:"link",className:c("hero-banner-tertiary-button w-auto p-0",p.tertiaryButton),as:q(a?.isCustomTertiaryButton,a)?"button":"a",href:xe,"data-headless-ad-track":y(a)?"true":void 0,"data-headless-amazon":g(a.link,a).isAmazon?"true":void 0,"data-headless-amazon-style":g(a.link,a).isAmazon?"link":void 0,target:J.target,rel:J.target==="_blank"?a?.rel??"noopener noreferrer":a?.rel,onClick:e=>{if(W(a,"tertiary",xe),a.link?.startsWith("#")){e.preventDefault();const t=document.querySelector(a.link);t&&Y(t,M)}a?.isCustomTertiaryButton&&$?.(s,e,a?.customTertiaryEventId)},...Ge,children:[a.text,n("span",{className:"sr-only",children:l??i})]})]}),n("div",{className:mt({align:h}),children:Ee?.map(e=>n("div",{className:"h-12",children:n(Z,{className:"!inline-block h-full !w-auto",imgClassName:"!w-auto h-full object-contain",loading:"eager",alt:e?.pcImage?.alt||"",source:e?.pcImage?.url})},e?.pcImage?.url||e?.pcImage?.alt))})]}),D.length>0&&n("div",{className:c("hero-banner-caption-group laptop:gap-3 px-grid desktop:pb-[24px] pointer-events-none absolute bottom-0 z-10 flex items-stretch gap-2 pb-[16px]",p.captionGroup),children:D.map((e,t)=>u(Be.Fragment,{children:[n(K,{size:2,className:c("hero-banner-product-text tablet:w-[108px] loptop:w-[150px] desktop:w-[156px] lg-desktop:w-[180px] laptop:text-[14px] flex-1 text-[12px]"),html:e.title}),t<D.length-1&&n("div",{className:c("bg-info-primary w-px")})]},e.title))}),fe&&n(lt,{visible:fe,videoUrl:r?.isYoutubeVideo?void 0:r?.videoUrl?.url,youTubeId:r?.isYoutubeVideo?r?.youtubeId:void 0,onCloseModal:()=>ge(!1)})]})})});Le.displayName="HeroBanner";var Rt=et(Le);export{Rt as default};
|