@anker-in/headless-ui 1.3.50 → 1.3.52
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/dist/cjs/biz-components/ImageTextOverlay/index.js +1 -1
- package/dist/cjs/biz-components/ImageTextOverlay/index.js.map +2 -2
- package/dist/cjs/biz-components/Listing/BizProductProvider.d.ts +11 -9
- package/dist/cjs/biz-components/Listing/BizProductProvider.js +1 -1
- package/dist/cjs/biz-components/Listing/BizProductProvider.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +4 -4
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefits/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefits/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.d.ts +1 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/types.d.ts +48 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/types.js +2 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/types.js.map +7 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductCoupon/index.d.ts +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductCoupon/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductCoupon/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.d.ts +0 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.js.map +4 -4
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/index.d.ts +3 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/index.js +2 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/index.js.map +7 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/types.d.ts +115 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/types.js +2 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/types.js.map +7 -0
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/index.d.ts +0 -1
- package/dist/cjs/biz-components/Listing/components/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/hooks/useBenefits.d.ts +8 -2
- package/dist/cjs/biz-components/Listing/hooks/useBenefits.js +1 -1
- package/dist/cjs/biz-components/Listing/hooks/useBenefits.js.map +3 -3
- package/dist/cjs/biz-components/Listing/types/product.d.ts +0 -21
- package/dist/cjs/biz-components/Listing/types/product.js +1 -1
- package/dist/cjs/biz-components/Listing/types/product.js.map +1 -1
- package/dist/cjs/biz-components/index.d.ts +3 -3
- package/dist/cjs/biz-components/index.js +1 -1
- package/dist/cjs/biz-components/index.js.map +3 -3
- package/dist/esm/biz-components/ImageTextOverlay/index.js +1 -1
- package/dist/esm/biz-components/ImageTextOverlay/index.js.map +2 -2
- package/dist/esm/biz-components/Listing/BizProductProvider.d.ts +11 -9
- package/dist/esm/biz-components/Listing/BizProductProvider.js +1 -1
- package/dist/esm/biz-components/Listing/BizProductProvider.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +4 -4
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefits/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefits/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.d.ts +1 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/types.d.ts +48 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/types.js +1 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/types.js.map +7 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductCoupon/index.d.ts +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductCoupon/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductCoupon/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.d.ts +0 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/index.d.ts +3 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/index.js +2 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/index.js.map +7 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/types.d.ts +115 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/types.js +1 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/types.js.map +7 -0
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductSummary/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/index.d.ts +0 -1
- package/dist/esm/biz-components/Listing/components/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/index.js.map +2 -2
- package/dist/esm/biz-components/Listing/hooks/useBenefits.d.ts +8 -2
- package/dist/esm/biz-components/Listing/hooks/useBenefits.js +1 -1
- package/dist/esm/biz-components/Listing/hooks/useBenefits.js.map +3 -3
- package/dist/esm/biz-components/Listing/types/product.d.ts +0 -21
- package/dist/esm/biz-components/Listing/types/product.js.map +1 -1
- package/dist/esm/biz-components/index.d.ts +3 -3
- package/dist/esm/biz-components/index.js +1 -1
- package/dist/esm/biz-components/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/index.d.ts +0 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/index.js +0 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/index.js.map +0 -7
- package/dist/cjs/biz-components/Listing/components/ProductCard/index.d.ts +0 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/index.js +0 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/index.js.map +0 -7
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/index.d.ts +0 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/index.js +0 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/index.js.map +0 -7
- package/dist/esm/biz-components/Listing/components/ProductCard/index.d.ts +0 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/index.js +0 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/index.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../src/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Text, Picture, Checkbox } from '../../../../../../components/index.js'\nimport { cn } from '../../../../../../helpers/index.js'\nimport {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "Text", "Picture", "Checkbox", "cn", "
|
|
4
|
+
"sourcesContent": ["import { Text, Picture, Checkbox } from '../../../../../../components/index.js'\nimport { cn } from '../../../../../../helpers/index.js'\nimport { withLayout } from '../../../../../../shared/Styles.js'\nimport { useFollowTooltip, FollowTooltip } from '../../../../hooks/useFollowTooltip.js'\nimport type { BundleOption } from './types.js'\nimport { useBizProductContext } from '../../../../BizProductProvider.js'\n\nconst ProductBundle = () => {\n const { bundle, checkedBundle, setCheckedBundle } = useBizProductContext()\n if (!bundle || !bundle?.bundleOptions?.length) return null\n\n const { tooltip, getTooltipProps } = useFollowTooltip()\n\n const handleSelectedChange = (bundleItem: BundleOption) => {\n if (checkedBundle?.ruleId === bundleItem.ruleId) {\n bundle?.onCheckedChange?.(undefined)\n setCheckedBundle?.(undefined)\n } else {\n setCheckedBundle?.(bundleItem)\n bundle?.onCheckedChange?.(bundleItem)\n }\n }\n\n return (\n <div className={cn('ipc-product-detail-bundle', bundle?.className)}>\n <Text className=\"font-bold leading-[1.2] text-[14px] lg-desktop:text-[16px]\" html={bundle?.title} />\n <div className=\"laptop:grid-cols-2 laptop-md:grid-cols-1 lg-desktop:mt-4 mt-3 grid grid-cols-1 gap-3\">\n {bundle?.bundleOptions.map((bundle, index) => (\n <div key={index}>\n <div\n className={cn(\n 'rounded-box h-[80px] laptop:h-[100px] flex items-center gap-2 border-2 border-[#E4E5E6] px-4 text-left font-bold',\n {\n ['border-brand']: checkedBundle?.ruleId === bundle.ruleId,\n }\n )}\n >\n <Checkbox\n onCheckedChange={() => handleSelectedChange(bundle)}\n size=\"lg\"\n className={cn('rounded-full border-2 border-[#E4E5E6]', {\n 'border-brand-0 data-[state=checked]:bg-brand-0': checkedBundle?.ruleId === bundle.ruleId,\n })}\n id={bundle.ruleId}\n value={bundle.ruleId}\n checked={checkedBundle?.ruleId === bundle.ruleId}\n />\n <label\n htmlFor={bundle.ruleId}\n className=\"size-full flex items-center cursor-pointer py-4 lg-desktop:py-6\"\n >\n {bundle.bundleVariants.map(variant => (\n <div className=\"flex items-center flex-1 justify-between gap-6\" key={variant.variantId}>\n <div className=\"flex items-center gap-2\">\n <Picture source={variant.imageUrl} className=\"size-12 shrink-0\" imgClassName=\"h-full\" />\n <Text\n {...getTooltipProps(variant.title)}\n className=\"laptop:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-sm font-bold\"\n html={variant.title}\n />\n <FollowTooltip {...tooltip} />\n </div>\n <div className=\"laptop:flex-row flex shrink-0 flex-col items-center justify-end gap-1\">\n <Text\n className=\"laptop:text-[20px] lg-desktop:text-2xl text-base !leading-[1.2] font-bold\"\n html={variant.price}\n />\n {variant.comparePrice && (\n <Text\n className=\"laptop:text-[20px] lg-desktop:text-2xl text-base !leading-[1.2] font-bold text-[#6D6D6F] line-through\"\n html={variant.comparePrice}\n />\n )}\n </div>\n </div>\n ))}\n </label>\n </div>\n </div>\n ))}\n </div>\n </div>\n )\n}\n\nProductBundle.displayName = 'ProductBundle'\n\nexport default withLayout(ProductBundle)\nexport type { ProductBundleProps, BundleOption, BundleVariantItem } from './types.js'\n"],
|
|
5
|
+
"mappings": "AAyBM,cAAAA,EA4Bc,QAAAC,MA5Bd,oBAzBN,OAAS,QAAAC,EAAM,WAAAC,EAAS,YAAAC,MAAgB,wCACxC,OAAS,MAAAC,MAAU,qCACnB,OAAS,cAAAC,MAAkB,qCA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Q,KAAK,EACjC,UAAU,2EACV,KAAMA,EAAQ,MAChB,EACAnB,EAACQ,EAAA,CAAe,GAAGM,EAAS,GAC9B,EACAb,EAAC,OAAI,UAAU,wEACb,UAAAD,EAACE,EAAA,CACC,UAAU,4EACV,KAAMiB,EAAQ,MAChB,EACCA,EAAQ,cACPnB,EAACE,EAAA,CACC,UAAU,wGACV,KAAMiB,EAAQ,aAChB,GAEJ,IArBmEA,EAAQ,SAsB7E,CACD,EACH,GACF,GAjDQD,CAkDV,CACD,EACH,GACF,CAEJ,EAEAR,EAAc,YAAc,gBAE5B,IAAOU,EAAQd,EAAWI,CAAa",
|
|
6
|
+
"names": ["jsx", "jsxs", "Text", "Picture", "Checkbox", "cn", "withLayout", "useFollowTooltip", "FollowTooltip", "useBizProductContext", "ProductBundle", "bundle", "checkedBundle", "setCheckedBundle", "tooltip", "getTooltipProps", "handleSelectedChange", "bundleItem", "index", "variant", "ProductBundle_default"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface BundleVariantItem {
|
|
2
|
+
/** 变体唯一标识符(对应 API variant_id) */
|
|
3
|
+
variantId: string | number;
|
|
4
|
+
/** 对应主商品的 sku,用于 ProductSummary 摘要中匹配当前商品折扣 */
|
|
5
|
+
sku?: string;
|
|
6
|
+
/** 产品名称(业务端从商品数据中获取) */
|
|
7
|
+
title: string;
|
|
8
|
+
/** 产品主图 URL(可选,业务端提供) */
|
|
9
|
+
imageUrl: string;
|
|
10
|
+
/**
|
|
11
|
+
* 格式化后的折扣价字符串,由业务端计算并格式化
|
|
12
|
+
* 示例:'$89.99'、'€79,99'
|
|
13
|
+
*/
|
|
14
|
+
price: string;
|
|
15
|
+
/**
|
|
16
|
+
* 折扣价的数字原始值(可选)
|
|
17
|
+
* 仅供 ProductSummary 内部做价格折算,不用于展示
|
|
18
|
+
*/
|
|
19
|
+
priceAmount?: number;
|
|
20
|
+
/**
|
|
21
|
+
* 格式化后的划线原价字符串(可选)
|
|
22
|
+
* 仅在有折扣时传入,组件会显示划线样式
|
|
23
|
+
* 示例:'$99.99'
|
|
24
|
+
*/
|
|
25
|
+
comparePrice?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 单个 bundle 选项(对应 API bundle_list 中的一项)
|
|
29
|
+
*/
|
|
30
|
+
export interface BundleOption {
|
|
31
|
+
/** bundle 唯一 规则ID */
|
|
32
|
+
ruleId?: string;
|
|
33
|
+
/**
|
|
34
|
+
* 需要展示的其他商品列表
|
|
35
|
+
* 注意:业务端应排除当前主商品,只传入搭配商品
|
|
36
|
+
*/
|
|
37
|
+
bundleVariants: BundleVariantItem[];
|
|
38
|
+
/** 单个bundle节省总金额 */
|
|
39
|
+
savings?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ProductBundleProps {
|
|
42
|
+
title?: string;
|
|
43
|
+
/** bundle最大节省金额 */
|
|
44
|
+
maxSavings?: string;
|
|
45
|
+
bundleOptions?: BundleOption[];
|
|
46
|
+
onCheckedChange?: (bundle?: BundleOption) => void;
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBundle/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductCoupon/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{Fragment as
|
|
1
|
+
"use client";import{Fragment as P,jsx as e,jsxs as r}from"react/jsx-runtime";import w from"react";import{cn as k,formatPrice as y}from"../../../../../../helpers/index.js";import{Text as p,Link as F,Checkbox as N}from"../../../../../../components/index.js";import M from"../../../../hooks/useCopy.js";import{useBenefits as I}from"../../../../hooks/useBenefits.js";import{useBizProductContext as _}from"../../../../BizProductProvider.js";import{useComponentData as S}from"../../../../hooks/useComponentData.js";import{replaceTemplate as g}from"../../../../utils/textFormat.js";import{useAiuiContext as B}from"../../../../../AiuiProvider/index.js";import R from"../../../../../../hooks/useCountDown.js";const L=w.memo(function({endTime:a,template:t}){const{days:c,hours:i,minutes:s,seconds:m}=R({endTime:a});return e(P,{children:g(t,{countdown:`${c}:${i}:${s}:${m}`})})}),h=({checked:d,discountText:a,codeText:t,code:c,countdownText:i,copyText:s,copiedText:m,onClick:l,className:x})=>{const{copied:b,copy:C}=M();return e("div",{className:k("flex flex-col gap-3 rounded-box overflow-hidden",x),role:"button",tabIndex:0,onClick:l,children:r("div",{className:"flex flex-col gap-3 overflow-hidden rounded-box bg-[#EDFBFF] p-3 laptop:p-4",children:[r("div",{className:"flex flex-col gap-1",children:[r("div",{className:"flex items-center gap-1",children:[e(N,{size:"lg",className:"data-[state=checked]:border-info-primary data-[state=checked]:bg-info-primary mr-2 rounded-full border-[1.6px] border-info-primary",checked:d}),e(p,{className:"text-info-primary text-base laptop:text-xl lg-desktop:text-2xl font-bold leading-[1.2] tracking-[-0.8px]",children:a})]}),r("div",{className:"flex w-full items-center gap-2",children:[e("div",{className:"flex shrink-0 flex-col items-start",children:e(p,{className:"text-info-primary lg-desktop:text-[16px] text-[14px] font-bold leading-[1.4] tracking-[-0.28px]",children:t})}),e(F,{className:"lg-desktop:text-[16px] text-[14px] font-bold underline",role:"button",tabIndex:0,onClick:o=>{o.preventDefault(),o.stopPropagation(),C(c)},children:b?m:s})]})]}),i&&e(p,{className:"text-brand-0 text-sm lg-desktop:text-base font-bold leading-[1.4] tracking-[-0.28px]",children:i})]})})};h.displayName="CouponCard";const T=({checked:d,discountText:a,description:t,onClick:c,className:i})=>e("div",{className:k("flex flex-col gap-3 rounded-box overflow-hidden",i),role:"button",tabIndex:0,onClick:c,children:e("div",{className:"flex flex-col gap-3 overflow-hidden rounded-box bg-[#EDFBFF] p-3 laptop:p-4",children:r("div",{className:"flex flex-col gap-1",children:[r("div",{className:"flex items-center gap-1",children:[e(N,{size:"lg",className:"data-[state=checked]:border-info-primary data-[state=checked]:bg-info-primary mr-2 rounded-full border-[1.6px] border-info-primary",checked:d}),e(p,{className:"text-info-primary text-base laptop:text-xl lg-desktop:text-2xl font-bold leading-[1.2] tracking-[-0.8px]",children:a})]}),t&&e(p,{className:"text-info-primary lg-desktop:text-[16px] text-[14px] font-bold leading-[1.4] tracking-[-0.28px] pl-8",children:t})]})})});T.displayName="MemberDiscountCard";const D=({className:d})=>{const{profile:a,variant:t,onUseCouponChange:c,onUseMemberDiscountChange:i,openSignInPopup:s,discount:m,savingDetail:l}=_(),{locale:x="us",trackingData:b}=B(),C=I({variant:t}),{commonCoupon:o,memberDiscount:f}=C,v=b?.common?.coupon,n=S("ProductCoupon")??{};return!o?.enable&&!f?.enable||!t?.availableForSale?null:r("div",{className:k("ipc-product-detail-product-coupon flex flex-col gap-3 lg-desktop:gap-4",d),children:[n?.title&&e(p,{className:"text-info-primary text-[14px] lg-desktop:text-[16px] font-bold leading-[1.2] tracking-[-0.56px]",children:n.title}),o?.enable&&e(h,{checked:l?.coupon>0,discountText:g(n?.common?.offCoupon,{discount:o?.config?.value_type=="percentage"?Math.abs(Number(o?.config?.value||0))+"%":y({amount:Math.abs(Number(o?.config?.fixed_value||0)),currencyCode:t.price.currencyCode,locale:x})||""}),codeText:g(n?.common?.withCode,{code:o?.config?.title??""}),code:o?.config?.title??"",countdownText:o?.config?.ends_at?e(L,{endTime:o.config.ends_at,template:n?.common?.endsIn??""}):void 0,copyText:v?.copy||n?.copyCode,copiedText:v?.copied||n?.copied,onClick:()=>{const u=l?.coupon?0:m?.codeSavings??0;c?.(u)}}),f?.enable&&e(T,{checked:!!a?.email&&!!l?.member,discountText:g(n?.member?.offMember,{discount:y({amount:f?.config?.amount??0,currencyCode:t.price.currencyCode,locale:x})||""}),description:a?.email?n?.member?.loginDesc:r(P,{children:[e("span",{className:"mr-2",dangerouslySetInnerHTML:{__html:n?.member?.unloginDesc}}),e("span",{role:"button",tabIndex:0,onClick:u=>{u?.stopPropagation(),s?.()},className:"underline text-nowrap",dangerouslySetInnerHTML:{__html:n?.member?.login}})]}),onClick:()=>{if(!a?.email){s?.();return}const u=l?.member?0:f?.config?.amount??0;i?.(u)}})]})};D.displayName="ProductCoupon";var O=D;export{h as CouponCard,T as MemberDiscountCard,O as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../src/biz-components/Listing/components/ProductCard/ProductDetail/ProductCoupon/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport React from 'react'\nimport { cn, formatPrice } from '../../../../../../helpers/index.js'\nimport { Text, Link, Checkbox } from '../../../../../../components/index.js'\nimport useCopy from '../../../../hooks/useCopy.js'\nimport { useBenefits } from '../../../../hooks/useBenefits.js'\nimport { useBizProductContext } from '../../../../BizProductProvider.js'\nimport { useComponentData } from '../../../../hooks/useComponentData.js'\nimport { replaceTemplate } from '../../../../utils/textFormat.js'\nimport { useAiuiContext } from '../../../../../AiuiProvider/index.js'\nimport useCountDown from '../../../../../../hooks/useCountDown.js'\n\nexport interface ProductCouponProps {\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n}\n\n// \u4F18\u60E0\u5238\u5361\u7247\u7EC4\u4EF6\nexport interface CouponCardProps {\n /** \u662F\u5426\u9009\u4E2D */\n checked: boolean\n /** \u6298\u6263\u6587\u6848 (\u5982 \"20% OFF\") */\n discountText: string\n /** \u4F18\u60E0\u7801\u6587\u6848 (\u5982 \"With code: ABC123\") */\n codeText: string\n /** \u4F18\u60E0\u7801 */\n code: string\n /** \u5012\u8BA1\u65F6\u6587\u6848 (\u5982 \"Ends in: 1:23:45:00\") */\n countdownText?: string\n /** \u590D\u5236\u6309\u94AE\u6587\u6848 */\n copyText: string\n /** \u5DF2\u590D\u5236\u6587\u6848 */\n copiedText: string\n /** \u70B9\u51FB\u4E8B\u4EF6 */\n onClick?: () => void\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n}\n\nexport const CouponCard: React.FC<CouponCardProps> = ({\n checked,\n discountText,\n codeText,\n code,\n countdownText,\n copyText,\n copiedText,\n onClick,\n className,\n}) => {\n const { copied: isCopied, copy: copyToClipboard } = useCopy()\n\n return (\n <div\n className={cn('flex flex-col gap-3 rounded-box overflow-hidden', className)}\n role=\"button\"\n tabIndex={0}\n onClick={onClick}\n >\n <div className=\"flex flex-col gap-3 overflow-hidden rounded-box bg-[#EDFBFF] p-3 laptop:p-4\">\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex items-center gap-1\">\n <Checkbox\n size=\"lg\"\n className=\"data-[state=checked]:border-info-primary data-[state=checked]:bg-info-primary mr-2 rounded-full border-[1.6px] border-info-primary\"\n checked={checked}\n />\n <Text className=\"text-info-primary text-base laptop:text-xl lg-desktop:text-2xl font-bold leading-[1.2] tracking-[-0.8px]\">\n {discountText}\n </Text>\n </div>\n\n <div className=\"flex w-full items-center gap-2\">\n <div className=\"flex shrink-0 flex-col items-start\">\n <Text className=\"text-info-primary lg-desktop:text-[16px] text-[14px] font-bold leading-[1.4] tracking-[-0.28px]\">\n {codeText}\n </Text>\n </div>\n <Link\n className=\"lg-desktop:text-[16px] text-[14px] font-bold underline\"\n role=\"button\"\n tabIndex={0}\n onClick={event => {\n event.preventDefault()\n event.stopPropagation()\n copyToClipboard(code)\n }}\n >\n {isCopied ? copiedText : copyText}\n </Link>\n </div>\n </div>\n\n {countdownText && (\n <Text className=\"text-brand-0 text-sm lg-desktop:text-base font-bold leading-[1.4] tracking-[-0.28px]\">\n {countdownText}\n </Text>\n )}\n </div>\n </div>\n )\n}\n\nCouponCard.displayName = 'CouponCard'\n\n// \u4F1A\u5458\u4EF7\u4F18\u60E0\u5361\u7247\u7EC4\u4EF6\nexport interface MemberDiscountCardProps {\n /** \u662F\u5426\u9009\u4E2D */\n checked: boolean\n /** \u6298\u6263\u6587\u6848 (\u5982 \"$10 OFF Member Price\") */\n discountText: string\n /** \u63CF\u8FF0\u6587\u6848 */\n description?: string\n /** \u70B9\u51FB\u4E8B\u4EF6 */\n onClick?: () => void\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n}\n\nexport const MemberDiscountCard: React.FC<MemberDiscountCardProps> = ({\n checked,\n discountText,\n description,\n onClick,\n className,\n}) => {\n return (\n <div\n className={cn('flex flex-col gap-3 rounded-box overflow-hidden', className)}\n role=\"button\"\n tabIndex={0}\n onClick={onClick}\n >\n <div className=\"flex flex-col gap-3 overflow-hidden rounded-box bg-[#EDFBFF] p-3 laptop:p-4\">\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex items-center gap-1\">\n <Checkbox\n size=\"lg\"\n className=\"data-[state=checked]:border-info-primary data-[state=checked]:bg-info-primary mr-2 rounded-full border-[1.6px] border-info-primary\"\n checked={checked}\n />\n <Text className=\"text-info-primary text-base laptop:text-xl lg-desktop:text-2xl font-bold leading-[1.2] tracking-[-0.8px]\">\n {discountText}\n </Text>\n </div>\n\n {description && (\n <Text className=\"text-info-primary lg-desktop:text-[16px] text-[14px] font-bold leading-[1.4] tracking-[-0.28px] pl-8\">\n {description}\n </Text>\n )}\n </div>\n </div>\n </div>\n )\n}\n\nMemberDiscountCard.displayName = 'MemberDiscountCard'\n\nconst ProductCoupon: React.FC<ProductCouponProps> = ({ className }) => {\n const { profile, variant, onUseCouponChange, onUseMemberDiscountChange, openSignInPopup, discount, savingDetail } =\n useBizProductContext()\n const { locale = 'us', trackingData } = useAiuiContext()\n const benefits = useBenefits({ variant })\n const { commonCoupon, memberDiscount } = benefits\n\n const { days, hours, minutes, seconds } = useCountDown({ endTime: commonCoupon?.config?.ends_at })\n\n const couponCopy = trackingData?.common?.coupon\n\n const productCouponData = useComponentData('ProductCoupon') ?? {}\n\n if ((!commonCoupon?.enable && !memberDiscount?.enable) || !variant?.availableForSale) {\n return null\n }\n\n return (\n <div className={cn('ipc-product-detail-product-coupon flex flex-col gap-3 lg-desktop:gap-4', className)}>\n {productCouponData?.title && (\n <Text className=\"text-info-primary text-[14px] lg-desktop:text-[16px] font-bold leading-[1.2] tracking-[-0.56px]\">\n {productCouponData.title}\n </Text>\n )}\n {commonCoupon?.enable && (\n <CouponCard\n checked={savingDetail?.coupon > 0}\n discountText={replaceTemplate(productCouponData?.common?.offCoupon, {\n discount:\n commonCoupon?.config?.value_type == 'percentage'\n ? Math.abs(Number(commonCoupon?.config?.value || 0)) + '%'\n : formatPrice({\n amount: Math.abs(Number(commonCoupon?.config?.fixed_value || 0)),\n currencyCode: variant.price.currencyCode,\n locale,\n }) || '',\n })}\n codeText={replaceTemplate(productCouponData?.common?.withCode, {\n code: commonCoupon?.config?.title ?? '',\n })}\n code={commonCoupon?.config?.title ?? ''}\n countdownText={\n commonCoupon?.config?.ends_at\n ? replaceTemplate(productCouponData?.common?.endsIn, {\n countdown: `${days}:${hours}:${minutes}:${seconds}`,\n })\n : undefined\n }\n copyText={couponCopy?.copy || productCouponData?.copyCode}\n copiedText={couponCopy?.copied || productCouponData?.copied}\n onClick={() => {\n const couponSaving = !savingDetail?.coupon ? (discount?.codeSavings ?? 0) : 0\n onUseCouponChange?.(couponSaving)\n }}\n />\n )}\n\n {memberDiscount?.enable && (\n <MemberDiscountCard\n checked={Boolean(profile?.email) && !!savingDetail?.member}\n discountText={replaceTemplate(productCouponData?.member?.offMember, {\n discount:\n formatPrice({\n amount: memberDiscount?.config?.amount ?? 0,\n currencyCode: variant.price.currencyCode,\n locale,\n }) || '',\n })}\n description={\n Boolean(profile?.email) ? (\n productCouponData?.member?.loginDesc\n ) : (\n <>\n <span className=\"mr-2\" dangerouslySetInnerHTML={{ __html: productCouponData?.member?.unloginDesc }} />\n <span\n role=\"button\"\n tabIndex={0}\n onClick={e => {\n e?.stopPropagation()\n openSignInPopup?.()\n }}\n className=\"underline text-nowrap\"\n dangerouslySetInnerHTML={{ __html: productCouponData?.member?.login }}\n />\n </>\n )\n }\n onClick={() => {\n if (!profile?.email) {\n openSignInPopup?.()\n return\n }\n const memberSaving = !savingDetail?.member ? (memberDiscount?.config?.amount ?? 0) : 0\n onUseMemberDiscountChange?.(memberSaving)\n }}\n />\n )}\n </div>\n )\n}\n\nProductCoupon.displayName = 'ProductCoupon'\n\nexport default ProductCoupon\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Fragment", "jsx", "jsxs", "cn", "formatPrice", "Text", "Link", "Checkbox", "useCopy", "useBenefits", "useBizProductContext", "useComponentData", "replaceTemplate", "useAiuiContext", "useCountDown", "CouponCard", "checked", "discountText", "codeText", "code", "countdownText", "copyText", "copiedText", "onClick", "className", "isCopied", "copyToClipboard", "event", "MemberDiscountCard", "description", "ProductCoupon", "profile", "variant", "onUseCouponChange", "onUseMemberDiscountChange", "openSignInPopup", "discount", "savingDetail", "locale", "trackingData", "benefits", "commonCoupon", "memberDiscount", "
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport React from 'react'\nimport { cn, formatPrice } from '../../../../../../helpers/index.js'\nimport { Text, Link, Checkbox } from '../../../../../../components/index.js'\nimport useCopy from '../../../../hooks/useCopy.js'\nimport { useBenefits } from '../../../../hooks/useBenefits.js'\nimport { useBizProductContext } from '../../../../BizProductProvider.js'\nimport { useComponentData } from '../../../../hooks/useComponentData.js'\nimport { replaceTemplate } from '../../../../utils/textFormat.js'\nimport { useAiuiContext } from '../../../../../AiuiProvider/index.js'\nimport useCountDown from '../../../../../../hooks/useCountDown.js'\n\n// \u5012\u8BA1\u65F6\u663E\u793A\u7EC4\u4EF6\uFF08memo \u9694\u79BB\uFF0C\u907F\u514D\u5916\u5C42 ProductCoupon \u6BCF\u79D2\u91CD\u6E32\u67D3\uFF09\nconst CountdownDisplay = React.memo(function CountdownDisplay({\n endTime,\n template,\n}: {\n endTime: string\n template: string\n}) {\n const { days, hours, minutes, seconds } = useCountDown({ endTime })\n\n return (\n <>\n {replaceTemplate(template, {\n countdown: `${days}:${hours}:${minutes}:${seconds}`,\n })}\n </>\n )\n})\n\nexport interface ProductCouponProps {\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n}\n\n// \u4F18\u60E0\u5238\u5361\u7247\u7EC4\u4EF6\nexport interface CouponCardProps {\n /** \u662F\u5426\u9009\u4E2D */\n checked: boolean\n /** \u6298\u6263\u6587\u6848 (\u5982 \"20% OFF\") */\n discountText: string\n /** \u4F18\u60E0\u7801\u6587\u6848 (\u5982 \"With code: ABC123\") */\n codeText: string\n /** \u4F18\u60E0\u7801 */\n code: string\n /** \u5012\u8BA1\u65F6\u6587\u6848 (\u5982 \"Ends in: 1:23:45:00\") */\n countdownText?: React.ReactNode\n /** \u590D\u5236\u6309\u94AE\u6587\u6848 */\n copyText: string\n /** \u5DF2\u590D\u5236\u6587\u6848 */\n copiedText: string\n /** \u70B9\u51FB\u4E8B\u4EF6 */\n onClick?: () => void\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n}\n\nexport const CouponCard: React.FC<CouponCardProps> = ({\n checked,\n discountText,\n codeText,\n code,\n countdownText,\n copyText,\n copiedText,\n onClick,\n className,\n}) => {\n const { copied: isCopied, copy: copyToClipboard } = useCopy()\n\n return (\n <div\n className={cn('flex flex-col gap-3 rounded-box overflow-hidden', className)}\n role=\"button\"\n tabIndex={0}\n onClick={onClick}\n >\n <div className=\"flex flex-col gap-3 overflow-hidden rounded-box bg-[#EDFBFF] p-3 laptop:p-4\">\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex items-center gap-1\">\n <Checkbox\n size=\"lg\"\n className=\"data-[state=checked]:border-info-primary data-[state=checked]:bg-info-primary mr-2 rounded-full border-[1.6px] border-info-primary\"\n checked={checked}\n />\n <Text className=\"text-info-primary text-base laptop:text-xl lg-desktop:text-2xl font-bold leading-[1.2] tracking-[-0.8px]\">\n {discountText}\n </Text>\n </div>\n\n <div className=\"flex w-full items-center gap-2\">\n <div className=\"flex shrink-0 flex-col items-start\">\n <Text className=\"text-info-primary lg-desktop:text-[16px] text-[14px] font-bold leading-[1.4] tracking-[-0.28px]\">\n {codeText}\n </Text>\n </div>\n <Link\n className=\"lg-desktop:text-[16px] text-[14px] font-bold underline\"\n role=\"button\"\n tabIndex={0}\n onClick={event => {\n event.preventDefault()\n event.stopPropagation()\n copyToClipboard(code)\n }}\n >\n {isCopied ? copiedText : copyText}\n </Link>\n </div>\n </div>\n\n {countdownText && (\n <Text className=\"text-brand-0 text-sm lg-desktop:text-base font-bold leading-[1.4] tracking-[-0.28px]\">\n {countdownText}\n </Text>\n )}\n </div>\n </div>\n )\n}\n\nCouponCard.displayName = 'CouponCard'\n\n// \u4F1A\u5458\u4EF7\u4F18\u60E0\u5361\u7247\u7EC4\u4EF6\nexport interface MemberDiscountCardProps {\n /** \u662F\u5426\u9009\u4E2D */\n checked: boolean\n /** \u6298\u6263\u6587\u6848 (\u5982 \"$10 OFF Member Price\") */\n discountText: string\n /** \u63CF\u8FF0\u6587\u6848 */\n description?: string\n /** \u70B9\u51FB\u4E8B\u4EF6 */\n onClick?: () => void\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n}\n\nexport const MemberDiscountCard: React.FC<MemberDiscountCardProps> = ({\n checked,\n discountText,\n description,\n onClick,\n className,\n}) => {\n return (\n <div\n className={cn('flex flex-col gap-3 rounded-box overflow-hidden', className)}\n role=\"button\"\n tabIndex={0}\n onClick={onClick}\n >\n <div className=\"flex flex-col gap-3 overflow-hidden rounded-box bg-[#EDFBFF] p-3 laptop:p-4\">\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex items-center gap-1\">\n <Checkbox\n size=\"lg\"\n className=\"data-[state=checked]:border-info-primary data-[state=checked]:bg-info-primary mr-2 rounded-full border-[1.6px] border-info-primary\"\n checked={checked}\n />\n <Text className=\"text-info-primary text-base laptop:text-xl lg-desktop:text-2xl font-bold leading-[1.2] tracking-[-0.8px]\">\n {discountText}\n </Text>\n </div>\n\n {description && (\n <Text className=\"text-info-primary lg-desktop:text-[16px] text-[14px] font-bold leading-[1.4] tracking-[-0.28px] pl-8\">\n {description}\n </Text>\n )}\n </div>\n </div>\n </div>\n )\n}\n\nMemberDiscountCard.displayName = 'MemberDiscountCard'\n\nconst ProductCoupon: React.FC<ProductCouponProps> = ({ className }) => {\n const { profile, variant, onUseCouponChange, onUseMemberDiscountChange, openSignInPopup, discount, savingDetail } =\n useBizProductContext()\n const { locale = 'us', trackingData } = useAiuiContext()\n const benefits = useBenefits({ variant })\n const { commonCoupon, memberDiscount } = benefits\n\n const couponCopy = trackingData?.common?.coupon\n\n const productCouponData = useComponentData('ProductCoupon') ?? {}\n\n if ((!commonCoupon?.enable && !memberDiscount?.enable) || !variant?.availableForSale) {\n return null\n }\n\n return (\n <div className={cn('ipc-product-detail-product-coupon flex flex-col gap-3 lg-desktop:gap-4', className)}>\n {productCouponData?.title && (\n <Text className=\"text-info-primary text-[14px] lg-desktop:text-[16px] font-bold leading-[1.2] tracking-[-0.56px]\">\n {productCouponData.title}\n </Text>\n )}\n {commonCoupon?.enable && (\n <CouponCard\n checked={savingDetail?.coupon > 0}\n discountText={replaceTemplate(productCouponData?.common?.offCoupon, {\n discount:\n commonCoupon?.config?.value_type == 'percentage'\n ? Math.abs(Number(commonCoupon?.config?.value || 0)) + '%'\n : formatPrice({\n amount: Math.abs(Number(commonCoupon?.config?.fixed_value || 0)),\n currencyCode: variant.price.currencyCode,\n locale,\n }) || '',\n })}\n codeText={replaceTemplate(productCouponData?.common?.withCode, {\n code: commonCoupon?.config?.title ?? '',\n })}\n code={commonCoupon?.config?.title ?? ''}\n countdownText={\n commonCoupon?.config?.ends_at\n ? (\n <CountdownDisplay\n endTime={commonCoupon.config.ends_at}\n template={productCouponData?.common?.endsIn ?? ''}\n />\n )\n : undefined\n }\n copyText={couponCopy?.copy || productCouponData?.copyCode}\n copiedText={couponCopy?.copied || productCouponData?.copied}\n onClick={() => {\n const couponSaving = !savingDetail?.coupon ? (discount?.codeSavings ?? 0) : 0\n onUseCouponChange?.(couponSaving)\n }}\n />\n )}\n\n {memberDiscount?.enable && (\n <MemberDiscountCard\n checked={Boolean(profile?.email) && !!savingDetail?.member}\n discountText={replaceTemplate(productCouponData?.member?.offMember, {\n discount:\n formatPrice({\n amount: memberDiscount?.config?.amount ?? 0,\n currencyCode: variant.price.currencyCode,\n locale,\n }) || '',\n })}\n description={\n Boolean(profile?.email) ? (\n productCouponData?.member?.loginDesc\n ) : (\n <>\n <span className=\"mr-2\" dangerouslySetInnerHTML={{ __html: productCouponData?.member?.unloginDesc }} />\n <span\n role=\"button\"\n tabIndex={0}\n onClick={e => {\n e?.stopPropagation()\n openSignInPopup?.()\n }}\n className=\"underline text-nowrap\"\n dangerouslySetInnerHTML={{ __html: productCouponData?.member?.login }}\n />\n </>\n )\n }\n onClick={() => {\n if (!profile?.email) {\n openSignInPopup?.()\n return\n }\n const memberSaving = !savingDetail?.member ? (memberDiscount?.config?.amount ?? 0) : 0\n onUseMemberDiscountChange?.(memberSaving)\n }}\n />\n )}\n </div>\n )\n}\n\nProductCoupon.displayName = 'ProductCoupon'\n\nexport default ProductCoupon\n"],
|
|
5
|
+
"mappings": "aAwBI,mBAAAA,EAAA,OAAAC,EAyDM,QAAAC,MAzDN,oBAtBJ,OAAOC,MAAW,QAClB,OAAS,MAAAC,EAAI,eAAAC,MAAmB,qCAChC,OAAS,QAAAC,EAAM,QAAAC,EAAM,YAAAC,MAAgB,wCACrC,OAAOC,MAAa,+BACpB,OAAS,eAAAC,MAAmB,mCAC5B,OAAS,wBAAAC,MAA4B,oCACrC,OAAS,oBAAAC,MAAwB,wCACjC,OAAS,mBAAAC,MAAuB,kCAChC,OAAS,kBAAAC,MAAsB,uCAC/B,OAAOC,MAAkB,0CAGzB,MAAMC,EAAmBb,EAAM,KAAK,SAA0B,CAC5D,QAAAc,EACA,SAAAC,CACF,EAGG,CACD,KAAM,CAAE,KAAAC,EAAM,MAAAC,EAAO,QAAAC,EAAS,QAAAC,CAAQ,EAAIP,EAAa,CAAE,QAAAE,CAAQ,CAAC,EAElE,OACEhB,EAAAD,EAAA,CACG,SAAAa,EAAg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jsxs", "React", "cn", "formatPrice", "Text", "Link", "Checkbox", "useCopy", "useBenefits", "useBizProductContext", "useComponentData", "replaceTemplate", "useAiuiContext", "useCountDown", "CountdownDisplay", "endTime", "template", "days", "hours", "minutes", "seconds", "CouponCard", "checked", "discountText", "codeText", "code", "countdownText", "copyText", "copiedText", "onClick", "className", "isCopied", "copyToClipboard", "event", "MemberDiscountCard", "description", "ProductCoupon", "profile", "variant", "onUseCouponChange", "onUseMemberDiscountChange", "openSignInPopup", "discount", "savingDetail", "locale", "trackingData", "benefits", "commonCoupon", "memberDiscount", "couponCopy", "productCouponData", "couponSaving", "e", "memberSaving", "ProductCoupon_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const _default: import("react").ForwardRefExoticComponent<Omit<unknown, "container" | keyof import("../../../../../../shared/Styles.js").StylesProps> & import("../../../../../../shared/Styles.js").StylesProps & import("../../../../../index.js").ContainerProps & import("react").RefAttributes<unknown>> & {};
|
|
2
|
-
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
var c=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var d=c(()=>{});export default d();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../src/biz-components/Listing/components/ProductCard/ProductDetail/ProductExchangePurchase/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Text, Picture, Checkbox } from '../../../../../../components/index.js'\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["// import { Text, Picture, Checkbox } from '../../../../../../components/index.js'\n// import { cn } from '../../../../../../helpers/index.js'\n// import { useMemo } from 'react'\n// import { useBizProductContext } from '../../../../BizProductProvider.js'\n// import { formatPrice } from '../../../../utils/index.js'\n// import { useAiuiContext } from '../../../../../AiuiProvider/index.js'\n// import type { ProductVariant, ProductPrice } from '../../../../types/product'\n// import { withLayout } from '../../../../../../shared/Styles.js'\n// import { useFollowTooltip, FollowTooltip } from '../../../../hooks/useFollowTooltip.js'\n\n// const ProductExchangePurchase = () => {\n// const { locale = 'us' } = useAiuiContext()\n// const { tooltip, getTooltipProps } = useFollowTooltip()\n// const {\n// // checkedExchangePurchase,\n// // exchangePurchase,\n// setCheckedBundle,\n// setJoinedRecommendBuyProducts,\n// setSavingDetail,\n// // setCheckedExchangePurchase,\n// joinedRecommendBuyProducts,\n// savingDetail,\n// setAddOrder,\n// } = useBizProductContext()\n// const { title, giftList = [], freeLabel } = exchangePurchase || {}\n// const availableGifts = useMemo(() => giftList?.filter(item => item.availableForSale), [giftList])\n\n// const handleCheckboxClick = (value: ProductVariant) => {\n// if (checkedExchangePurchase?.id === value.id) {\n// setCheckedExchangePurchase?.(undefined)\n// setJoinedRecommendBuyProducts?.({\n// ...joinedRecommendBuyProducts,\n// exchange: {\n// value: undefined,\n// canOperate: true,\n// },\n// })\n// setSavingDetail?.({ ...savingDetail, exchangePurchase: 0 })\n// // \u4ECE\u6DFB\u52A0\u987A\u5E8F\u4E2D\u79FB\u9664\n// setAddOrder?.(prev => prev.filter(t => t !== 'exchange'))\n// } else {\n// setCheckedExchangePurchase?.(value)\n// setJoinedRecommendBuyProducts?.({\n// ...joinedRecommendBuyProducts,\n// exchange: {\n// value,\n// canOperate: false,\n// },\n// })\n// // \u6DFB\u52A0\u5230\u987A\u5E8F\u6570\u7EC4\u7684\u672B\u5C3E\n// setAddOrder?.(prev => {\n// // \u5982\u679C\u5DF2\u7ECF\u5B58\u5728\uFF0C\u5148\u79FB\u9664\u518D\u6DFB\u52A0\u5230\u672B\u5C3E\n// const filtered = prev.filter(t => t !== 'exchange')\n// return [...filtered, 'exchange']\n// })\n// }\n// }\n\n// if (!availableGifts?.length) return null\n\n// return (\n// <div className=\"ipc-product-detail-exchange-purchase\">\n// <Text className=\"font-bold leading-[1.2] text-[14px] lg-desktop:text-[16px]\" html={title} />\n// <div className=\"laptop:grid-cols-2 laptop-md:grid-cols-1 lg-desktop:mt-4 mt-3 grid grid-cols-1 gap-3\">\n// {availableGifts.map((gift: ProductVariant & { finalPrice?: ProductPrice }) => (\n// <div\n// key={gift.id}\n// className={cn(\n// 'rounded-box h-[80px] laptop:h-[100px] flex items-center gap-2 border-2 border-[#E4E5E6] px-4 text-left font-bold',\n// {\n// ['border-brand']: checkedExchangePurchase?.id === gift.id,\n// }\n// )}\n// >\n// <Checkbox\n// onCheckedChange={() => handleCheckboxClick(gift)}\n// size=\"lg\"\n// className={cn('rounded-full border-2 border-[#E4E5E6]', {\n// 'border-brand-0 data-[state=checked]:bg-brand-0': checkedExchangePurchase?.id === gift.id,\n// })}\n// id={gift.id}\n// checked={checkedExchangePurchase?.id === gift.id}\n// value={gift.id}\n// ></Checkbox>\n// <label\n// htmlFor={gift.id}\n// className=\"flex w-full cursor-pointer items-center justify-between gap-4 py-4 lg-desktop:py-6\"\n// >\n// <div className=\"flex items-center gap-2\">\n// <Picture source={gift.image?.url} className=\"size-12 shrink-0\" imgClassName=\"h-full\" />\n// <Text\n// {...getTooltipProps(gift.product.title)}\n// className=\"laptop:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-sm font-bold\"\n// html={gift.product.title}\n// />\n// <FollowTooltip {...tooltip} />\n// </div>\n// <div className=\"tablet:flex-row flex shrink-0 flex-col items-center gap-1\">\n// <Text\n// className=\"laptop:text-[20px] lg-desktop:text-2xl !leading-[1.2] text-base font-bold\"\n// html={formatPrice({\n// amount: gift?.finalPrice?.amount || 0,\n// locale,\n// currencyCode: gift?.finalPrice?.currencyCode || 'USD',\n// })}\n// />\n// <Text\n// className=\"laptop:text-[20px] lg-desktop:text-2xl text-base !leading-[1.2] font-bold text-[#6D6D6F] line-through\"\n// html={formatPrice({\n// amount: gift.price.amount,\n// locale,\n// currencyCode: gift.price.currencyCode,\n// })}\n// />\n// </div>\n// </label>\n// </div>\n// ))}\n// </div>\n// </div>\n// )\n// }\n\n// export default withLayout(ProductExchangePurchase)\n"],
|
|
5
|
+
"mappings": "8DAAA,IAAAA,EAAAC,EAAA",
|
|
6
|
+
"names": ["require_ProductExchangePurchase", "__commonJSMin"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: import("react").ForwardRefExoticComponent<Omit<unknown, "container" | keyof import("../../../../../../shared/Styles.js").StylesProps> & import("../../../../../../shared/Styles.js").StylesProps & import("../../../../../index.js").ContainerProps & import("react").RefAttributes<unknown>> & {};
|
|
2
|
+
export default _default;
|
|
3
|
+
export type { ProductFunctionFreeGiftProps, FunctionFreeGiftItem } from './types.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as o,jsxs as i}from"react/jsx-runtime";import{Text as n,Picture as v,Checkbox as y}from"../../../../../../components/index.js";import{cn as a}from"../../../../../../helpers/index.js";import{withLayout as G}from"../../../../../../shared/Styles.js";import{useFollowTooltip as P,FollowTooltip as w}from"../../../../hooks/useFollowTooltip.js";import{useBizProductContext as I}from"../../../../BizProductProvider.js";const u=()=>{const{functionFreeGift:r,checkedFunctionGifts:c,setCheckedFunctionGifts:p}=I();if(!r||!c||!p)return null;const{title:f,freeLabel:m,giftItems:s=[]}=r,{tooltip:x,getTooltipProps:h}=P(),g=r.mode==="multiple";if(!s.length)return null;const b=e=>c?.has(String(e.id))??!1,F=e=>{const t=String(e.id);p?.(k=>{const l=new Set(k),d=l.has(t);if(g){d?l.delete(t):l.add(t);const N=s.filter(C=>l.has(String(C.id)));r.onCheckedChange?.(N)}else l.clear(),d||l.add(t),r.onCheckedChange?.(d?void 0:e);return l})};return i("div",{className:a("ipc-product-detail-free-gift"),children:[o(n,{className:"font-bold leading-[1.2] text-[14px] lg-desktop:text-[16px]",html:f}),o("div",{className:"laptop:grid-cols-2 laptop-md:grid-cols-1 lg-desktop:mt-4 mt-3 grid grid-cols-1 gap-3",children:s.map(e=>{const t=b(e);return i("div",{className:a("rounded-box h-[80px] laptop:h-[100px] flex items-center gap-2 border-2 border-[#E4E5E6] px-4 text-left font-bold",{"border-brand":t}),children:[o(y,{onCheckedChange:()=>F(e),size:"lg",className:a("rounded-full border-2 border-[#E4E5E6]",{"border-brand-0 data-[state=checked]:bg-brand-0":t}),id:String(e.id),checked:t,value:String(e.id)}),i("label",{htmlFor:String(e.id),className:"flex w-full cursor-pointer items-center justify-between gap-4 py-4 lg-desktop:py-6",children:[i("div",{className:"flex items-center gap-2",children:[o(v,{source:e.imageUrl,className:"size-12 shrink-0",imgClassName:"h-full"}),o(n,{...h(e.title),className:"laptop:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-sm font-bold",html:e.title}),o(w,{...x})]}),i("div",{className:"tablet:flex-row flex shrink-0 flex-col items-center gap-1",children:[m&&o(n,{className:"laptop:text-[20px] lg-desktop:text-2xl text-base font-bold !leading-[1.2]",html:m}),e.comparePrice&&o(n,{className:"laptop:text-[20px] lg-desktop:text-2xl text-base font-bold text-[#6D6D6F] line-through !leading-[1.2]",html:e.comparePrice})]})]})]},e.id)})})]})};u.displayName="ProductFunctionFreeGift";var D=G(u);export{D as default};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../src/biz-components/Listing/components/ProductCard/ProductDetail/ProductFunctionFreeGift/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Text, Picture, Checkbox } from '../../../../../../components/index.js'\nimport { cn } from '../../../../../../helpers/index.js'\nimport { withLayout } from '../../../../../../shared/Styles.js'\nimport { useFollowTooltip, FollowTooltip } from '../../../../hooks/useFollowTooltip.js'\nimport type { FunctionFreeGiftItem } from './types.js'\nimport { useBizProductContext } from '../../../../BizProductProvider.js'\n\nconst ProductFunctionFreeGift = () => {\n const { functionFreeGift: freeGift, checkedFunctionGifts, setCheckedFunctionGifts } = useBizProductContext()\n\n if (!freeGift) return null\n if (!checkedFunctionGifts || !setCheckedFunctionGifts) return null\n\n const { title, freeLabel, giftItems = [] } = freeGift\n const { tooltip, getTooltipProps } = useFollowTooltip()\n\n const isMultiple = freeGift.mode === 'multiple'\n\n if (!giftItems.length) return null\n\n const isChecked = (gift: FunctionFreeGiftItem): boolean => {\n return checkedFunctionGifts?.has(String(gift.id)) ?? false\n }\n\n const handleToggle = (gift: FunctionFreeGiftItem) => {\n const giftId = String(gift.id)\n setCheckedFunctionGifts?.(prev => {\n const next = new Set(prev)\n const alreadyChecked = next.has(giftId)\n\n if (isMultiple) {\n alreadyChecked ? next.delete(giftId) : next.add(giftId)\n const nextItems = giftItems.filter(g => next.has(String(g.id)))\n freeGift.onCheckedChange?.(nextItems)\n } else {\n next.clear()\n if (!alreadyChecked) {\n next.add(giftId)\n }\n freeGift.onCheckedChange?.(alreadyChecked ? undefined : gift)\n }\n return next\n })\n }\n\n return (\n <div className={cn('ipc-product-detail-free-gift')}>\n <Text className=\"font-bold leading-[1.2] text-[14px] lg-desktop:text-[16px]\" html={title} />\n <div className=\"laptop:grid-cols-2 laptop-md:grid-cols-1 lg-desktop:mt-4 mt-3 grid grid-cols-1 gap-3\">\n {giftItems.map(gift => {\n const checked = isChecked(gift)\n return (\n <div\n key={gift.id}\n className={cn(\n 'rounded-box h-[80px] laptop:h-[100px] flex items-center gap-2 border-2 border-[#E4E5E6] px-4 text-left font-bold',\n { 'border-brand': checked }\n )}\n >\n <Checkbox\n onCheckedChange={() => handleToggle(gift)}\n size=\"lg\"\n className={cn('rounded-full border-2 border-[#E4E5E6]', {\n 'border-brand-0 data-[state=checked]:bg-brand-0': checked,\n })}\n id={String(gift.id)}\n checked={checked}\n value={String(gift.id)}\n />\n <label\n htmlFor={String(gift.id)}\n className=\"flex w-full cursor-pointer items-center justify-between gap-4 py-4 lg-desktop:py-6\"\n >\n <div className=\"flex items-center gap-2\">\n <Picture source={gift.imageUrl} className=\"size-12 shrink-0\" imgClassName=\"h-full\" />\n <Text\n {...getTooltipProps(gift.title)}\n className=\"laptop:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-sm font-bold\"\n html={gift.title}\n />\n <FollowTooltip {...tooltip} />\n </div>\n <div className=\"tablet:flex-row flex shrink-0 flex-col items-center gap-1\">\n {freeLabel && (\n <Text\n className=\"laptop:text-[20px] lg-desktop:text-2xl text-base font-bold !leading-[1.2]\"\n html={freeLabel}\n />\n )}\n {gift.comparePrice && (\n <Text\n className=\"laptop:text-[20px] lg-desktop:text-2xl text-base font-bold text-[#6D6D6F] line-through !leading-[1.2]\"\n html={gift.comparePrice}\n />\n )}\n </div>\n </label>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n\nProductFunctionFreeGift.displayName = 'ProductFunctionFreeGift'\n\nexport default withLayout(ProductFunctionFreeGift)\nexport type { ProductFunctionFreeGiftProps, FunctionFreeGiftItem } from './types.js'\n"],
|
|
5
|
+
"mappings": "AA+CM,cAAAA,EA0BU,QAAAC,MA1BV,oBA/CN,OAAS,QAAAC,EAAM,WAAAC,EAAS,YAAAC,MAAgB,wCACxC,OAAS,MAAAC,MAAU,qCACnB,OAAS,cAAAC,MAAkB,qCAC3B,OAAS,oBAAAC,EAAkB,iBAAAC,MAAqB,wCAEhD,OAAS,wBAAAC,MAA4B,oCAErC,MAAMC,EAA0B,IAAM,CACpC,KAAM,CAAE,iBAAkBC,EAAU,qBAAAC,EAAsB,wBAAAC,CAAwB,EAAIJ,EAAqB,EAG3G,GADI,CAACE,GACD,CAACC,GAAwB,CAACC,EAAyB,OAAO,KAE9D,KAAM,CAAE,MAAAC,EAAO,UAAAC,EAAW,UAAAC,EAAY,CAAC,CAAE,EAAIL,EACvC,CAAE,QAAAM,EAAS,gBAAAC,CAAgB,EAAIX,EAAiB,EAEhDY,EAAaR,EAAS,OAAS,WAErC,GAAI,CAACK,EAAU,OAAQ,OAAO,KAE9B,MAAMI,EAAaC,GACVT,GAAsB,IAAI,OAAOS,EAAK,EAAE,CAAC,GAAK,GAGjDC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,EAACQ,EAAA,CAAe,GAAGS,EAAS,GAC9B,EACAhB,EAAC,OAAI,UAAU,4DACZ,UAAAc,GACCf,EAACE,EAAA,CACC,UAAU,4EACV,KAAMa,EACR,EAEDM,EAAK,cACJrB,EAACE,EAAA,CACC,UAAU,wGACV,KAAMmB,EAAK,aACb,GAEJ,GACF,IA3CKA,EAAK,EA4CZ,CAEJ,CAAC,EACH,GACF,CAEJ,EAEAX,EAAwB,YAAc,0BAEtC,IAAOoB,EAAQxB,EAAWI,CAAuB",
|
|
6
|
+
"names": ["jsx", "jsxs", "Text", "Picture", "Checkbox", "cn", "withLayout", "useFollowTooltip", "FollowTooltip", "useBizProductContext", "ProductFunctionFreeGift", "freeGift", "checkedFunctionGifts", "setCheckedFunctionGifts", "title", "freeLabel", "giftItems", "tooltip", "getTooltipProps", "isMultiple", "isChecked", "gift", "handleToggle", "giftId", "prev", "next", "alreadyChecked", "nextItems", "g", "checked", "ProductFunctionFreeGift_default"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单个买赠礼品项
|
|
3
|
+
*
|
|
4
|
+
* 由业务端将 API reward_list 映射而来,所有展示字段已处理为字符串,
|
|
5
|
+
* 组件内部不再做任何格式化计算。
|
|
6
|
+
*/
|
|
7
|
+
export interface FunctionFreeGiftItem {
|
|
8
|
+
/**
|
|
9
|
+
* 礼品唯一标识符,用于 checkbox 选中判断
|
|
10
|
+
* 通常对应 API 中的 variant_id
|
|
11
|
+
*/
|
|
12
|
+
id: string | number;
|
|
13
|
+
/** 商品标题,业务端从商品数据中获取后传入 */
|
|
14
|
+
title: string;
|
|
15
|
+
/** 商品主图 URL(可选,业务端提供) */
|
|
16
|
+
imageUrl?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 格式化后的划线原价字符串(可选)
|
|
19
|
+
* 仅在有原价需要展示时传入,组件会显示划线样式
|
|
20
|
+
* 示例:'$89.99'、'€79,99'
|
|
21
|
+
*/
|
|
22
|
+
comparePrice?: string;
|
|
23
|
+
}
|
|
24
|
+
interface ProductFunctionFreeGiftBaseProps {
|
|
25
|
+
/** 区块标题文案,支持 HTML */
|
|
26
|
+
title?: string;
|
|
27
|
+
/**
|
|
28
|
+
* "FREE" 标签文案,所有礼品共享同一个标签
|
|
29
|
+
* 示例:'FREE'、'Gift'、'Free Gift'
|
|
30
|
+
* 来源:API discount_label.cart_checkout_label
|
|
31
|
+
*/
|
|
32
|
+
freeLabel?: string;
|
|
33
|
+
/**
|
|
34
|
+
* 礼品列表
|
|
35
|
+
* 业务端负责:过滤可用项(availableForSale)、映射数据结构
|
|
36
|
+
* 组件直接渲染,不做额外过滤
|
|
37
|
+
*/
|
|
38
|
+
giftItems?: FunctionFreeGiftItem[];
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 单选模式(默认)
|
|
43
|
+
* 同一时刻最多选中一个礼品;再次点击已选中项则取消选中。
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <ProductFreeGift
|
|
48
|
+
* title="Choose a free gift"
|
|
49
|
+
* freeLabel="FREE"
|
|
50
|
+
* giftItems={items}
|
|
51
|
+
* checkedId={selectedId}
|
|
52
|
+
* onCheckedChange={(gift) => setSelectedId(gift?.id)}
|
|
53
|
+
* />
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
interface ProductFunctionFreeGiftSingleProps extends ProductFunctionFreeGiftBaseProps {
|
|
57
|
+
mode?: 'single';
|
|
58
|
+
/** 当前选中的礼品 id;undefined 表示无选中 */
|
|
59
|
+
checkedId?: string | number;
|
|
60
|
+
/** 选中时返回 FreeGiftItem,取消选中时返回 undefined */
|
|
61
|
+
onCheckedChange?: (gift?: FunctionFreeGiftItem) => void;
|
|
62
|
+
checkedIds?: never;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 多选模式
|
|
66
|
+
* 可同时选中多个礼品,回调始终返回当前全部已选项数组。
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* <ProductFreeGift
|
|
71
|
+
* mode="multiple"
|
|
72
|
+
* title="Choose your free gifts"
|
|
73
|
+
* freeLabel="FREE"
|
|
74
|
+
* giftItems={items}
|
|
75
|
+
* checkedIds={selectedIds}
|
|
76
|
+
* onCheckedChange={(gifts) => setSelectedIds(gifts.map(g => g.id))}
|
|
77
|
+
* />
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
interface ProductFunctionFreeGiftMultipleProps extends ProductFunctionFreeGiftBaseProps {
|
|
81
|
+
mode: 'multiple';
|
|
82
|
+
/** 当前选中的礼品 id 数组;空数组表示无选中 */
|
|
83
|
+
checkedIds?: (string | number)[];
|
|
84
|
+
/** 每次勾选/取消后返回当前全部已选的 FreeGiftItem 数组 */
|
|
85
|
+
onCheckedChange?: (gifts: FunctionFreeGiftItem[]) => void;
|
|
86
|
+
checkedId?: never;
|
|
87
|
+
}
|
|
88
|
+
export type ProductFunctionFreeGiftProps = ProductFunctionFreeGiftSingleProps | ProductFunctionFreeGiftMultipleProps;
|
|
89
|
+
export {};
|
|
90
|
+
/**
|
|
91
|
+
* 业务端 free gift rule API 数据结构
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```json
|
|
95
|
+
* {
|
|
96
|
+
* "rule_id": 1598,
|
|
97
|
+
* "rule_type": 1,
|
|
98
|
+
* "discount_label": {
|
|
99
|
+
* "cart_checkout_label": "Gift",
|
|
100
|
+
* "product_label": "",
|
|
101
|
+
* "sold_out_label": ""
|
|
102
|
+
* },
|
|
103
|
+
* "frontend_labels": null,
|
|
104
|
+
* "apply_unit": 1,
|
|
105
|
+
* "discount_combinations": { ... },
|
|
106
|
+
* "gift_type": 1,
|
|
107
|
+
* "reward_list": [
|
|
108
|
+
* {
|
|
109
|
+
* "get_unit": 1,
|
|
110
|
+
* "variant_list": [{ "variant_id": "44302515404975", "sku": "A3062Z11-97", "handle": "a3062z11-97-travel-case" }]
|
|
111
|
+
* }
|
|
112
|
+
* ]
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Text as s,Button as _,Grid as ae,GridItem as q,Picture as A,Heading as oe}from"../../../../../components/index.js";import{useBizProductContext as S}from"../../../BizProductProvider.js";import{useComponentData as ne}from"../../../hooks/useComponentData.js";import{useEffect as le,useMemo as T,useState as ie}from"react";import{formatPrice as y}from"../../../utils/index.js";import{useAiuiContext as j}from"../../../../AiuiProvider/index.js";import J from"decimal.js";import{replaceTemplate as re}from"../../../utils/textFormat.js";import{withLayout as ce}from"../../../../../shared/Styles.js";import{ExposureDetector as se}from"../../../../../components/index.js";import{gaTrack as de}from"../../../../../shared/track.js";import pe from"../../CartActionButtons/index.js";const ue=()=>{const{locale:m="us",copyWriting:a,trackingData:g}=j(),{product:p,variant:n,finalPrice:x,comparePrice:v,coupon:k,selectedOptions:d,selectedVariants:i,totalSavings:B,onAddToCart:w,onBuyNow:E,savingDetail:f,checkedBundle:N,joinedRecommendBuyProducts:t,setJoinedRecommendBuyProducts:C,setSavingDetail:P,addToCartLoading:L,buyNowLoading:U,notifyMeMode:X,onNotifyMeClick:Y,profile:G,addOrder:$,setAddOrder:D}=S(),I=g?.showComparePrice??!0,F=ne("ProductSummary")??{},[z]=i,V=T(()=>{const r=N?.variants.find(h=>h.variant.sku===z?.sku),l=new J(z?.price?.amount||0).minus(r?.price||z?.price?.amount).toNumber();let u=new J(z?.price?.amount||0);G?.email&&(u=u.minus(f?.member||0));const b=u.minus(f?.coupon).minus(l).toNumber();return parseFloat(b.toFixed(2))},[z,N,G,f?.member,f?.coupon]),{bundleVariant:M,giftVariant:R,exchangeVariant:W}=me()||{},[c,O]=ie();le(()=>{O({bundle:t.bundle?.value?void 0:M,gift:t.gift?.value?void 0:R,exchange:t.exchange?.value?void 0:W})},[M,R,W,t]);const Z=T(()=>{const r=[];return $&&$.forEach((l,u)=>{t[l]?.value&&r.push({type:l,key:`${l}-${u}`})}),r},[$,t]),ee=T(()=>{const r=d?.quantity||"",l=d?.color||d?.colour||d?.couleur||"";return`${r&&l?`${r} | ${l}`:r||l}`},[d?.quantity,d?.color,d?.colour,d?.couleur]),te=T(()=>{const{image_1920:r,image_1440:l,image_1024:u,image_768:b,image_390:h}=F?.thumbnail||{};return(F?.thumbnail?`${r} 1920, ${l} 1440, ${u} 1024, ${b} 768, ${h} 390`:n.image?.url)||n.image?.url},[F?.thumbnail,n.image?.url]);return n.availableForSale?e("div",{className:"ipc-product-summary laptop:px-16 laptop-md:px-0 laptop-md:mt-[96px] lg-desktop:mt-[128px] mt-16",children:e("div",{className:"laptop:rounded-2xl bg-[#F5F5F7]",children:o(ae,{className:"tablet:p-8 tablet:!pb-0 px-4 pt-6",children:[o(q,{className:"laptop:col-start-1 laptop:col-span-5 col-span-12 flex flex-col justify-between gap-4",children:[e(oe,{className:"lg-desktop:text-[48px] laptop:text-[32px] laptop-md:text-[40px] mb-4 text-[24px] font-bold leading-none [&>span]:text-[#D1D1D1]",html:F?.readyWant?.replace?.("{title}",p?.title)}),e("div",{className:"",children:e(A,{source:te,className:"lg-desktop:aspect-[644/320] laptop-md:aspect-[503/270] laptop:aspect-[332/190] tablet:aspect-[704/380] aspect-[358/190]",imgClassName:"object-cover h-full"})})]}),o(q,{className:"tablet:pb-8 laptop:col-start-7 laptop:mt-0 laptop:col-span-6 col-span-12 mt-8 flex flex-col justify-between gap-6 pb-6",children:[o("div",{children:[o("div",{className:"flex flex-col gap-4",children:[e(se,{exposureKey:"listing_selector",onExposure:()=>{de({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:`Product Detail Page${n.sku}`,component_type:"image",component_name:"listing_selector",position:1}})},children:o("div",{className:"flex items-center justify-between gap-6",children:[o("div",{className:"flex items-center gap-4",children:[e(A,{source:n.image?.url||p?.images?.[0]?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),o("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:p.title}),e(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]",html:ee})]})]}),o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:y({amount:V,currencyCode:n.price.currencyCode,locale:m})}),I&&V<n?.price?.amount&&e(s,{className:"laptop-md:text-2xl laptop:text-xl text-base font-bold text-[#6D6D6F] line-through",html:y({amount:n?.price?.amount,currencyCode:n.price.currencyCode,locale:m})})]})]})}),Z.map(({type:r,key:l})=>r==="gift"&&t?.gift?.value?e(H,{giftOperation:u=>{C?.({...t,gift:{value:void 0,canOperate:!0}}),O?.({...c,gift:u}),D?.(b=>b.filter(h=>h!=="gift"))},status:!!t?.gift,gift:t?.gift?.value,canOperate:t?.gift?.canOperate},l):r==="bundle"&&t?.bundle?.value?e(Q,{bundleOperation:u=>{C?.({...t,bundle:{value:void 0,canOperate:!0}}),O?.({...c,bundle:u}),D?.(b=>b.filter(h=>h!=="bundle"))},status:!!t?.bundle,bundleListItem:t?.bundle?.value,canOperate:t?.bundle?.canOperate},l):r==="exchange"&&t?.exchange?.value?e(K,{exchangeOperation:u=>{C?.({...t,exchange:{value:void 0,canOperate:!0}}),O?.({...c,exchange:u}),D?.(b=>b.filter(h=>h!=="exchange"))},status:!!t?.exchange,canOperate:t?.exchange?.canOperate,exchange:t?.exchange?.value},l):null)]}),(c?.bundle||c?.gift||c?.exchange)&&o("div",{className:"laptop-md:mt-8 mt-6",children:[e(s,{className:"laptop-md:text-[18px] text-sm font-bold",html:F?.recommendBuy}),o("div",{className:"laptop-md:gap-4 mt-4 flex flex-col gap-6",children:[c?.exchange&&e(K,{exchangeOperation:r=>{C?.({...t,exchange:{value:r,canOperate:!0}}),O?.({...c,exchange:void 0}),D?.(l=>[...l,"exchange"])},canOperate:t?.exchange?.canOperate,status:!c?.exchange,exchange:c?.exchange}),c?.bundle&&e(Q,{bundleOperation:r=>{P?.({...f,exchangePurchase:0}),C?.({...t,bundle:{value:r,canOperate:!0}}),O?.({...c,bundle:void 0}),D?.(l=>[...l,"bundle"])},canOperate:t?.bundle?.canOperate,status:!c?.bundle,bundleListItem:c?.bundle}),c?.gift&&e(H,{giftOperation:r=>{C?.({...t,gift:{value:r,canOperate:!0}}),O?.({...c,gift:void 0}),D?.(l=>[...l,"gift"])},canOperate:t?.gift?.canOperate,status:!c?.gift,gift:c?.gift})]})]})]}),o("div",{className:"text-right",children:[e(s,{className:"laptop:text-xl laptop-md:text-2xl text-right font-bold",html:`${re(a?.totalPrice||"",{amount:y({amount:parseFloat(x.toFixed(2)),currencyCode:n.price.currencyCode,locale:m})})}`}),I&&B>0&&e(s,{className:"laptop:text-xl laptop-md:text-2xl ml-1 text-base font-bold text-[#6D6D6F] line-through",html:y({amount:v,currencyCode:n.price.currencyCode,locale:m})}),e("div",{className:"mt-4 flex justify-end gap-3",children:e(pe,{mode:X,availableForSale:n.availableForSale,addToCartText:a?.addToCart,buyNowText:a?.shopNow,addToCartLoading:L,buyNowLoading:U,addToCartClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2",buyNowClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2",onAddToCart:w,onBuyNow:E,onNotifyMeClick:Y,notifyMeText:a?.notifyMe,notifyMeClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2"})})]})]})]})})}):null},me=()=>{const{bundle:m,variant:a,checkedBundle:g,freeGift:p,checkedGift:n,exchangePurchase:x,checkedExchangePurchase:v}=S();let k,d,i;const{bundleList:B}=m||{},{giftList:w=[]}=p||{},{giftList:E=[]}=x||{},f=B?.filter(P=>P.variants.slice(1,P.variants.length).every(L=>L.variant.availableForSale))||[],[N]=f;k=g||N;const[t]=w?.filter(P=>P.availableForSale)??[];d=n||t;const[C]=E?.filter(P=>P.availableForSale)??[];return i=v||C,{bundleVariant:k,giftVariant:d,exchangeVariant:i}},Q=({bundleOperation:m,bundleListItem:a,canOperate:g,status:p})=>{const{locale:n="us",copyWriting:x}=j(),{variant:v,setCheckedBundle:k}=S(),d=a?.variants.filter(i=>i.variant.sku!==v.sku);return e("div",{className:"",children:d?.map(i=>o("div",{className:"flex items-center justify-between gap-4",children:[o("div",{className:"flex items-center gap-4",children:[e(A,{source:i?.variant?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),e("div",{className:"tablet:max-w-none line-clamp-2 flex max-w-[178px] flex-col gap-[6px]",children:e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] text-[14px] font-bold",html:i.variant.product.title})})]}),o("div",{className:"flex flex-col items-end justify-center gap-1",children:[!!a&&o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:y({amount:i?.price||0,locale:n,currencyCode:i.variant?.price?.currencyCode||""})}),i.price<i.variant.price.amount&&e(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:y({amount:i.variant.price.amount||0,locale:n,currencyCode:i.variant?.price?.currencyCode||""})})]}),g&&e(_,{size:"icon",variant:"link",onClick:()=>{k?.(p?void 0:a),m?.(a)},className:"size-auto shrink-0 underline",children:p?x?.remove:x?.add})]})]},i.variant.id))})},H=({giftOperation:m,gift:a,status:g,canOperate:p})=>{const{locale:n="us",copyWriting:x}=j(),{freeGift:v,setCheckedGift:k}=S(),{freeLabel:d}=v||{},{options:i}=a||{},B=T(()=>{const w=i?.find(t=>t.name==="color"||t.name==="colour"||t.name==="couleur")||{},E=i?.find(t=>t.name==="quantity")||{},f=w?w.values?.[0]?.label:"",N=E?E.values?.[0]?.label:"";return`${f&&N?N+" | "+f:N||f} | ${d}`},[d,i]);return o("div",{className:"flex items-center justify-between gap-6",children:[o("div",{className:"flex items-center gap-4",children:[e(A,{source:a?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),o("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:a?.product?.title}),e(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]",html:B})]})]}),o("div",{className:"flex flex-col items-end justify-center gap-2",children:[!!a&&o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:d}),e(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:y({amount:a.price.amount,locale:n,currencyCode:a.price.currencyCode})})]}),p&&e(_,{size:"icon",variant:"link",onClick:()=>{k?.(g?void 0:a),m(a)},className:"size-auto shrink-0 underline",children:g?x?.remove:x?.add})]})]})},K=({exchangeOperation:m,exchange:a,canOperate:g,status:p})=>{const{locale:n="us",copyWriting:x}=j(),{setCheckedExchangePurchase:v}=S();return o("div",{className:"flex items-center justify-between gap-6",children:[o("div",{className:"flex items-center gap-4",children:[e(A,{source:a?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),o("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:a?.product?.title}),e(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]"})]})]}),o("div",{className:"flex flex-col items-end justify-center gap-2",children:[!!a&&o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:y({amount:a.finalPrice?.amount||0,locale:n,currencyCode:a.price.currencyCode})}),e(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:y({amount:a.price?.amount||0,locale:n,currencyCode:a.price.currencyCode})})]}),g&&e(_,{size:"icon",variant:"link",onClick:()=>{v?.(p?void 0:a),m(a)},className:"size-auto shrink-0 underline",children:p?x?.remove:x?.add})]})]})};var De=ce(ue);export{De as default};
|
|
1
|
+
import{jsx as t,jsxs as l}from"react/jsx-runtime";import{Text as s,Button as K,Grid as U,GridItem as M,Picture as T,Heading as X}from"../../../../../components/index.js";import{useBizProductContext as B}from"../../../BizProductProvider.js";import{useComponentData as Y}from"../../../hooks/useComponentData.js";import{useEffect as Z,useMemo as N,useState as tt}from"react";import{formatPrice as h}from"../../../utils/index.js";import{useAiuiContext as V}from"../../../../AiuiProvider/index.js";import et from"decimal.js";import{replaceTemplate as at}from"../../../utils/textFormat.js";import{withLayout as ot}from"../../../../../shared/Styles.js";import{ExposureDetector as lt}from"../../../../../components/index.js";import{gaTrack as it}from"../../../../../shared/track.js";import rt from"../../CartActionButtons/index.js";const nt=()=>{const{locale:p="us",copyWriting:r,trackingData:f}=V(),{product:m,variant:e,finalPrice:d,comparePrice:x,coupon:C,selectedOptions:n,selectedVariants:g,totalSavings:k,onAddToCart:P,onBuyNow:w,savingDetail:c,checkedBundle:v,joinedRecommendBuyProducts:a,setJoinedRecommendBuyProducts:$,setSavingDetail:ct,addToCartLoading:I,buyNowLoading:R,notifyMeMode:q,onNotifyMeClick:W,profile:A,addOrder:D,setAddOrder:S}=B(),_=f?.showComparePrice??!0,b=Y("ProductSummary")??{},[G]=g,j=N(()=>{let o=new et(G?.price?.amount||0);A?.email&&(o=o.minus(c?.member||0));const i=o.minus(c?.coupon).toNumber();return parseFloat(i.toFixed(2))},[G,v,A,c?.member,c?.coupon]),{giftVariant:z}=st()||{},[u,O]=tt();Z(()=>{O({gift:a.gift?.value?void 0:z})},[z,a]);const J=N(()=>{const o=[];return D&&D.forEach((i,y)=>{a[i]?.value&&o.push({type:i,key:`${i}-${y}`})}),o},[D,a]),Q=N(()=>{const o=n?.quantity||"",i=n?.color||n?.colour||n?.couleur||"";return`${o&&i?`${o} | ${i}`:o||i}`},[n?.quantity,n?.color,n?.colour,n?.couleur]),H=N(()=>{const{image_1920:o,image_1440:i,image_1024:y,image_768:E,image_390:F}=b?.thumbnail||{};return(b?.thumbnail?`${o} 1920, ${i} 1440, ${y} 1024, ${E} 768, ${F} 390`:e.image?.url)||e.image?.url},[b?.thumbnail,e.image?.url]);return e.availableForSale?t("div",{className:"ipc-product-summary laptop:px-16 laptop-md:px-0 laptop-md:mt-[96px] lg-desktop:mt-[128px] mt-16",children:t("div",{className:"laptop:rounded-2xl bg-[#F5F5F7]",children:l(U,{className:"tablet:p-8 tablet:!pb-0 px-4 pt-6",children:[l(M,{className:"laptop:col-start-1 laptop:col-span-5 col-span-12 flex flex-col justify-between gap-4",children:[t(X,{className:"lg-desktop:text-[48px] laptop:text-[32px] laptop-md:text-[40px] mb-4 text-[24px] font-bold leading-none [&>span]:text-[#D1D1D1]",html:b?.readyWant?.replace?.("{title}",m?.title)}),t("div",{className:"",children:t(T,{source:H,className:"lg-desktop:aspect-[644/320] laptop-md:aspect-[503/270] laptop:aspect-[332/190] tablet:aspect-[704/380] aspect-[358/190]",imgClassName:"object-cover h-full"})})]}),l(M,{className:"tablet:pb-8 laptop:col-start-7 laptop:mt-0 laptop:col-span-6 col-span-12 mt-8 flex flex-col justify-between gap-6 pb-6",children:[l("div",{children:[l("div",{className:"flex flex-col gap-4",children:[t(lt,{exposureKey:"listing_selector",onExposure:()=>{it({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:`Product Detail Page${e.sku}`,component_type:"image",component_name:"listing_selector",position:1}})},children:l("div",{className:"flex items-center justify-between gap-6",children:[l("div",{className:"flex items-center gap-4",children:[t(T,{source:e.image?.url||m?.images?.[0]?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),l("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[t(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:m.title}),t(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]",html:Q})]})]}),l("div",{className:"flex items-center gap-1",children:[t(s,{className:"laptop-md:text-2xl text-base font-bold",html:h({amount:j,currencyCode:e.price.currencyCode,locale:p})}),_&&j<e?.price?.amount&&t(s,{className:"laptop-md:text-2xl laptop:text-xl text-base font-bold text-[#6D6D6F] line-through",html:h({amount:e?.price?.amount,currencyCode:e.price.currencyCode,locale:p})})]})]})}),J.map(({type:o,key:i})=>o==="gift"&&a?.gift?.value?t(L,{giftOperation:y=>{$?.({...a,gift:{value:void 0,canOperate:!0}}),O?.({...u,gift:y}),S?.(E=>E.filter(F=>F!=="gift"))},status:!!a?.gift,gift:a?.gift?.value,canOperate:a?.gift?.canOperate},i):null)]}),u?.gift&&l("div",{className:"laptop-md:mt-8 mt-6",children:[t(s,{className:"laptop-md:text-[18px] text-sm font-bold",html:b?.recommendBuy}),t("div",{className:"laptop-md:gap-4 mt-4 flex flex-col gap-6",children:u?.gift&&t(L,{giftOperation:o=>{$?.({...a,gift:{value:o,canOperate:!0}}),O?.({...u,gift:void 0}),S?.(i=>[...i,"gift"])},canOperate:a?.gift?.canOperate,status:!u?.gift,gift:u?.gift})})]})]}),l("div",{className:"text-right",children:[t(s,{className:"laptop:text-xl laptop-md:text-2xl text-right font-bold",html:`${at(r?.totalPrice||"",{amount:h({amount:parseFloat(d.toFixed(2)),currencyCode:e.price.currencyCode,locale:p})})}`}),_&&k>0&&t(s,{className:"laptop:text-xl laptop-md:text-2xl ml-1 text-base font-bold text-[#6D6D6F] line-through",html:h({amount:x,currencyCode:e.price.currencyCode,locale:p})}),t("div",{className:"mt-4 flex justify-end gap-3",children:t(rt,{mode:q,availableForSale:e.availableForSale,addToCartText:r?.addToCart,buyNowText:r?.shopNow,addToCartLoading:I,buyNowLoading:R,addToCartClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2",buyNowClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2",onAddToCart:P,onBuyNow:w,onNotifyMeClick:W,notifyMeText:r?.notifyMe,notifyMeClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2"})})]})]})]})})}):null},st=()=>{const{bundle:p,variant:r,checkedBundle:f,freeGift:m,checkedGift:e}=B();let d;const{giftList:x=[]}=m||{},[C]=x?.filter(n=>n.availableForSale)??[];return d=e||C,{giftVariant:d}},L=({giftOperation:p,gift:r,status:f,canOperate:m})=>{const{locale:e="us",copyWriting:d}=V(),{freeGift:x,setCheckedGift:C}=B(),{freeLabel:n}=x||{},{options:g}=r||{},k=N(()=>{const P=g?.find(a=>a.name==="color"||a.name==="colour"||a.name==="couleur")||{},w=g?.find(a=>a.name==="quantity")||{},c=P?P.values?.[0]?.label:"",v=w?w.values?.[0]?.label:"";return`${c&&v?v+" | "+c:v||c} | ${n}`},[n,g]);return l("div",{className:"flex items-center justify-between gap-6",children:[l("div",{className:"flex items-center gap-4",children:[t(T,{source:r?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),l("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[t(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:r?.product?.title}),t(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]",html:k})]})]}),l("div",{className:"flex flex-col items-end justify-center gap-2",children:[!!r&&l("div",{className:"flex items-center gap-1",children:[t(s,{className:"laptop-md:text-2xl text-base font-bold",html:n}),t(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:h({amount:r.price.amount,locale:e,currencyCode:r.price.currencyCode})})]}),m&&t(K,{size:"icon",variant:"link",onClick:()=>{C?.(f?void 0:r),p(r)},className:"size-auto shrink-0 underline",children:f?d?.remove:d?.add})]})]})};var wt=ot(nt);export{wt as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|