@anker-in/headless-ui 1.1.9 → 1.1.11
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/Listing/BizProductProvider.d.ts +11 -2
- 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/PaidShipping/LearnMore.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PaidShipping/LearnMore.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingMethod.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingMethod.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/PaidShipping/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PaidShipping/index.js.map +2 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +6 -6
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefitsTabs/index.d.ts +2 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefitsTabs/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefitsTabs/index.js.map +3 -3
- 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 +2 -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 +2 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js.map +2 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.js +2 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.js.map +2 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductDetail/index.js.map +2 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/components/CompareModal.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/components/CompareModal.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/components/SpecsModal.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/components/SpecsModal.js.map +2 -2
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGallery/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGridBox.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/ProductGridBox.js.map +2 -2
- 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/ProductCard/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/ProductCard/index.js.map +2 -2
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +2 -2
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js.map +3 -3
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/useScrollSpy.d.ts +2 -0
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/useScrollSpy.js +2 -0
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/useScrollSpy.js.map +7 -0
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/index.js.map +2 -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/index.d.ts +0 -3
- package/dist/cjs/biz-components/Listing/index.js +1 -1
- package/dist/cjs/biz-components/Listing/index.js.map +4 -4
- package/dist/cjs/biz-components/MediaPlayerBase/index.js +1 -1
- package/dist/cjs/biz-components/MediaPlayerBase/index.js.map +3 -3
- package/dist/cjs/biz-components/MediaPlayerSticky/index.js +1 -1
- package/dist/cjs/biz-components/MediaPlayerSticky/index.js.map +2 -2
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.d.ts +4 -0
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js +4 -4
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js.map +3 -3
- package/dist/cjs/biz-components/index.d.ts +0 -1
- package/dist/cjs/biz-components/index.js +1 -1
- package/dist/cjs/biz-components/index.js.map +3 -3
- package/dist/cjs/components/ExposureDetector.js +1 -1
- package/dist/cjs/components/ExposureDetector.js.map +2 -2
- package/dist/cjs/components/avatar.js +1 -1
- package/dist/cjs/components/avatar.js.map +2 -2
- package/dist/cjs/components/link.d.ts +2 -2
- package/dist/cjs/components/link.js +1 -1
- package/dist/cjs/components/link.js.map +2 -2
- package/dist/cjs/helpers/ScrollLoadVideo.js +1 -1
- package/dist/cjs/helpers/ScrollLoadVideo.js.map +2 -2
- package/dist/cjs/stories/link.stories.d.ts +1 -1
- package/dist/cjs/stories/link.stories.js +1 -1
- package/dist/cjs/stories/link.stories.js.map +1 -1
- package/dist/esm/biz-components/Listing/BizProductProvider.d.ts +11 -2
- 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/PaidShipping/LearnMore.js +1 -1
- package/dist/esm/biz-components/Listing/components/PaidShipping/LearnMore.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingMethod.js +1 -1
- package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingMethod.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.js +1 -1
- package/dist/esm/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/PaidShipping/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/PaidShipping/index.js.map +2 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js +6 -6
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/BenefitsTab.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefitsTabs/index.d.ts +2 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefitsTabs/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductBenefitsTabs/index.js.map +3 -3
- 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 +2 -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 +2 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductFreeGift/index.js.map +2 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.js +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductHighlight/index.js.map +2 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/ProductOptions/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductDetail/index.js.map +2 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/components/CompareModal.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/components/CompareModal.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/components/SpecsModal.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/components/SpecsModal.js.map +2 -2
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGallery/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGridBox.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/ProductGridBox.js.map +2 -2
- 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/ProductCard/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/ProductCard/index.js.map +2 -2
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +2 -2
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/index.js.map +3 -3
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/useScrollSpy.d.ts +2 -0
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/useScrollSpy.js +2 -0
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ScrollSpyNav/useScrollSpy.js.map +7 -0
- package/dist/esm/biz-components/Listing/components/PurchaseBar/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/PurchaseBar/index.js.map +2 -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/index.d.ts +0 -3
- package/dist/esm/biz-components/Listing/index.js +1 -1
- package/dist/esm/biz-components/Listing/index.js.map +3 -3
- package/dist/esm/biz-components/MediaPlayerBase/index.js +1 -1
- package/dist/esm/biz-components/MediaPlayerBase/index.js.map +3 -3
- package/dist/esm/biz-components/MediaPlayerSticky/index.js +1 -1
- package/dist/esm/biz-components/MediaPlayerSticky/index.js.map +2 -2
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.d.ts +4 -0
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js +5 -5
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js.map +3 -3
- package/dist/esm/biz-components/index.d.ts +0 -1
- package/dist/esm/biz-components/index.js +1 -1
- package/dist/esm/biz-components/index.js.map +2 -2
- package/dist/esm/components/ExposureDetector.js +1 -1
- package/dist/esm/components/ExposureDetector.js.map +2 -2
- package/dist/esm/components/avatar.js +1 -1
- package/dist/esm/components/avatar.js.map +2 -2
- package/dist/esm/components/link.d.ts +2 -2
- package/dist/esm/components/link.js +1 -1
- package/dist/esm/components/link.js.map +2 -2
- package/dist/esm/helpers/ScrollLoadVideo.js +1 -1
- package/dist/esm/helpers/ScrollLoadVideo.js.map +2 -2
- package/dist/esm/stories/link.stories.d.ts +1 -1
- package/dist/esm/stories/link.stories.js +1 -1
- package/dist/esm/stories/link.stories.js.map +1 -1
- package/package.json +2 -2
- package/tailwind.config.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/link.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["'use client'\nimport React from 'react'\nimport type { ReactNode } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cn } from '../helpers/index.js'\nimport { type VariantProps, cva } from 'class-variance-authority'\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js'\n\n// \u5B9A\u4E49 link \u7684\u6837\u5F0F\u53D8\u4F53\nconst linkVariants = cva('tracking hover:text-brand-0 font-bold underline transition-colors', {\n variants: {\n size: {\n base: 'text-text-2', // \u4E2D\n lg: 'text-text-3', // \u5927\n },\n variant: {\n secondary: 'text-info-secondary hover:text-info-primary',\n primary: 'text-info-primary hover:text-brand-0',\n },\n },\n})\n// \u5B9A\u4E49\u7EC4\u4EF6\u7C7B\u578B\uFF0C\u7EE7\u627F a \u6807\u7B7E\u6807\u51C6\u5C5E\u6027\ntype LinkElement = React.ElementRef<'a'>\ntype LinkProps = {\n /** \u5B9A\u4E49\u5B50\u7EC4\u4EF6\u4F5C\u4E3A\u7236\u7EC4\u4EF6\u7684\u7C7B\u578B,\u8BE6\u7EC6\u4F7F\u7528\u65B9\u5F0F\u8BF7\u53C2\u8003radix-ui */\n asChild?: boolean\n /** \u7C7B\u540D*/\n className?: string\n /** \u7981\u7528\u94FE\u63A5 */\n disabled?: boolean\n /** \u540E\u7F6E\u56FE\u6807*/\n suffixIcon?: ReactNode\n /** \u8DF3\u8F6C\u94FE\u63A5*/\n href?: string\n /** \u6837\u5F0F*/\n style?: React.CSSProperties\n /** \u70B9\u51FB\u4E8B\u4EF6\uFF0C\u7981\u7528\u72B6\u6001\u65E0\u6CD5\u89E6\u53D1*/\n onClick?: Function\n} & VariantProps<typeof linkVariants> &\n ComponentPropsWithout<'a', RemovedProps>\n\nconst Link = React.forwardRef<LinkElement, LinkProps>(\n (\n {\n children,\n size = 'base',\n variant = 'primary',\n className,\n asChild = false,\n href,\n style,\n disabled = false,\n suffixIcon,\n onClick,\n ...props // \u8FD9\u91CC\u4F1A\u5305\u542B href\u3001target\u3001rel \u7B49\u6807\u51C6 anchor \u5C5E\u6027\n }: LinkProps,\n forwardedRef\n ) => {\n const Comp = asChild ? Slot : 'a'\n\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\n !disabled && onClick?.(event)\n if (disabled || !href) {\n event.preventDefault()\n return\n }\n }\n\n return (\n <Comp\n ref={forwardedRef}\n onClick={handleClick}\n href={disabled ? undefined : href}\n className={cn(linkVariants({ size, variant }), className, {\n 'flex items-center': suffixIcon,\n 'cursor-pointer': !disabled,\n 'text-info-quaternary cursor-not-allowed hover:text-info-quaternary': disabled,\n })}\n {...(style ? { style: style } : null)}\n {...props}\n >\n <>\n {children}\n {suffixIcon && <span className=\"svg\">{suffixIcon}</span>}\n </>\n </Comp>\n )\n }\n)\nLink.displayName = 'Link'\n\nexport default Link\nexport type { LinkProps }\n"],
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAiFQ,IAAAI,EAAA,6BAhFRC,EAAkB,oBAElBC,EAAqB,gCACrBC,EAAmB,+BACnBC,EAAuC,oCAIvC,MAAMC,KAAe,OAAI,qEAAsE,CAC7F,SAAU,CACR,KAAM,CACJ,KAAM,cACN,GAAI,aACN,EACA,QAAS,CACP,UAAW,8CACX,QAAS,sCACX,CACF,CACF,CAAC,EAqBKC,EAAO,EAAAC,QAAM,WACjB,CACE,CACE,SAAAC,EACA,KAAAC,EAAO,OACP,QAAAC,EAAU,UACV,UAAAC,EACA,QAAAC,EAAU,GACV,KAAAC,EACA,MAAAC,EACA,SAAAC,EAAW,GACX,WAAAC,EACA,QAAAC,EACA,GAAGC,CACL,EACAC,OAaE,OAXWP,EAAU,OAAO,IAW3B,CACC,IAAKO,EACL,QAXiBC,GAA+C,CAElE,GADA,CAACL,GAAYE,IAAUG,CAAK,EACxBL,GAAY,CAACF,EAAM,CACrBO,EAAM,eAAe,EACrB,MACF,CACF,EAMI,KAAML,EAAW,OAAYF,EAC7B,aAAW,MAAGR,EAAa,CAAE,KAAAI,EAAM,QAAAC,CAAQ,CAAC,EAAGC,EAAW,CACxD,oBAAqBK,EACrB,iBAAkB,CAACD,EACnB,qEAAsEA,CACxE,CAAC,EACA,GAAID,EAAQ,CAAE,MAAOA,CAAM,EAAI,KAC/B,GAAGI,EAEJ,gCACG,UAAAV,EACAQ,MAAc,OAAC,QAAK,UAAU,MAAO,SAAAA,EAAW,GACnD,EACF,CAGN,EACAV,EAAK,YAAc,OAEnB,IAAOR,EAAQQ",
|
|
6
6
|
"names": ["link_exports", "__export", "link_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_slot", "import_helpers", "import_class_variance_authority", "linkVariants", "Link", "React", "children", "size", "variant", "className", "asChild", "href", "style", "disabled", "suffixIcon", "onClick", "props", "forwardedRef", "event"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var j=(t,r)=>{for(var d in r)L(t,d,{get:r[d],enumerable:!0})},C=(t,r,d,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of M(r))!T.call(t,i)&&i!==d&&L(t,i,{get:()=>r[i],enumerable:!(u=H(r,i))||u.enumerable});return t};var D=t=>C(L({},"__esModule",{value:!0}),t);var R={};j(R,{default:()=>P});module.exports=D(R);var a=require("react/jsx-runtime"),o=require("react"),s=require("../helpers/utils.js"),E=require("lodash");const
|
|
1
|
+
"use strict";var L=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var j=(t,r)=>{for(var d in r)L(t,d,{get:r[d],enumerable:!0})},C=(t,r,d,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of M(r))!T.call(t,i)&&i!==d&&L(t,i,{get:()=>r[i],enumerable:!(u=H(r,i))||u.enumerable});return t};var D=t=>C(L({},"__esModule",{value:!0}),t);var R={};j(R,{default:()=>P});module.exports=D(R);var a=require("react/jsx-runtime"),o=require("react"),s=require("../helpers/utils.js"),E=require("lodash");const y=new Set,F=({src:t,poster:r,alt:d="Scroll Loaded Video",className:u="",videoWrapperClassName:i="",videoClassName:b="",autoplay:h=!1,muted:N=!0,loop:z=!0,controls:S=!1,playsInline:k=!0,videoRef:f=null,...I})=>{const[m,w]=(0,o.useState)(!1),[n,v]=(0,o.useState)(!1),g=(0,o.useRef)(null),p=(0,o.useRef)(null),l=(0,o.useRef)("");(0,o.useEffect)(()=>{y.has(t)&&(w(!0),v(!0),l.current=t)},[t]),(0,o.useEffect)(()=>{if(n&&m){const e=f?.current||p.current;e&&(e.muted=!0,e.play().catch(c=>{console.warn("\u89C6\u9891\u81EA\u52A8\u64AD\u653E\u5931\u8D25:",c)}))}},[n,m,f]);const V=(0,o.useCallback)(()=>{const e=t;if(!e||l.current===e&&n)return;if(y.has(e)){v(!0),l.current=e;return}l.current=e;const c=document.createElement("video");c.preload="metadata",c.onloadedmetadata=()=>{v(!0),y.add(e)},c.src=e},[n,t]);(0,o.useEffect)(()=>{if(!g.current||n)return;const e=(0,E.debounce)(()=>{if(window.scrollY>10)return w(!0),V(),window.removeEventListener("scroll",e)},100);return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[V,n]);const U=(0,o.useCallback)(()=>{v(!0),l.current&&y.add(l.current);const e=f?.current||p.current;e&&(e.muted=!0,e.play())},[]);return(0,a.jsxs)("div",{ref:g,className:(0,s.cn)("relative size-full",u),children:[r&&(0,a.jsx)("div",{className:(0,s.cn)("absolute inset-0 size-full overflow-hidden transition-opacity duration-500 ease-in-out",i,{"opacity-100":!n,"overflow-visible opacity-0":n}),children:(0,a.jsx)("img",{src:r,alt:d,style:{width:"100%",height:"100%",objectFit:"cover"},className:(0,s.cn)(b),loading:"lazy"})}),(0,a.jsx)("div",{className:(0,s.cn)("size-full transition-opacity duration-500 ease-in-out",{"opacity-100":n,"opacity-0":!n}),style:{visibility:m?"visible":"hidden"},children:m&&(0,a.jsx)("div",{className:(0,s.cn)("relative size-full",i),children:(0,a.jsx)("video",{ref:f||p,src:l.current||t,poster:r,className:(0,s.cn)("size-full object-cover",b),onLoadedMetadata:U,autoPlay:h,muted:N,loop:z,controls:S,playsInline:k,...I},l.current)})})]})};var P=F;
|
|
2
2
|
//# sourceMappingURL=ScrollLoadVideo.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/ScrollLoadVideo.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect, useState, useRef, useCallback } from 'react'\nimport { cn } from '../helpers/utils.js'\nimport { debounce } from 'lodash'\n\n// \u521B\u5EFA\u4E00\u4E2A\u5168\u5C40\u7F13\u5B58\u6765\u5B58\u50A8\u5DF2\u52A0\u8F7D\u7684\u89C6\u9891URL\nconst globalLoadedVideoUrls = new Set<string>()\n\nconst ScrollLoadVideo = ({\n src,\n poster,\n alt = 'Scroll Loaded Video',\n className = '',\n videoWrapperClassName = '',\n videoClassName = '',\n autoplay = false,\n muted = true,\n loop = true,\n controls = false,\n playsInline = true,\n videoRef = null,\n ...attr\n}: {\n src: string\n poster?: string\n alt?: string\n className?: string\n videoWrapperClassName?: string\n videoClassName?: string\n autoplay?: boolean\n muted?: boolean\n loop?: boolean\n controls?: boolean\n playsInline?: boolean\n [key: string]: any\n}) => {\n const [isVideoStartLoad, setIsVideoStartLoad] = useState(false)\n const [isVideoLoaded, setIsVideoLoaded] = useState(false)\n const ref = useRef<HTMLDivElement>(null)\n // \u5185\u90E8\u89C6\u9891\u5F15\u7528\uFF0C\u5982\u679C\u5916\u90E8\u6CA1\u6709\u4F20\u5165 videoRef\n const internalVideoRef = useRef<HTMLVideoElement>(null)\n // \u4FDD\u5B58\u5F53\u524D\u52A0\u8F7D\u7684\u89C6\u9891URL\n const currentVideoUrl = useRef<string>('')\n\n // \u5728\u7EC4\u4EF6\u6302\u8F7D\u65F6\u68C0\u67E5\u89C6\u9891\u662F\u5426\u5DF2\u7ECF\u88AB\u52A0\u8F7D\u8FC7\n useEffect(() => {\n // \u5982\u679C\u89C6\u9891\u5DF2\u7ECF\u88AB\u5168\u5C40\u7F13\u5B58\u8FC7\uFF0C\u76F4\u63A5\u8BBE\u7F6E\u4E3A\u5DF2\u52A0\u8F7D\u72B6\u6001\n if (globalLoadedVideoUrls.has(src)) {\n setIsVideoStartLoad(true)\n setIsVideoLoaded(true)\n currentVideoUrl.current = src\n }\n }, [src])\n\n // \u5F53\u89C6\u9891\u5DF2\u52A0\u8F7D\u4E14\u5DF2\u5F00\u59CB\u52A0\u8F7D\u65F6\uFF0C\u5C1D\u8BD5\u64AD\u653E\u89C6\u9891\n useEffect(() => {\n if (isVideoLoaded && isVideoStartLoad) {\n const videoElement = videoRef?.current || internalVideoRef.current\n if (videoElement) {\n // \u786E\u4FDD\u9759\u97F3\u4EE5\u5141\u8BB8\u81EA\u52A8\u64AD\u653E\n videoElement.muted = true\n // \u5C1D\u8BD5\u64AD\u653E\u89C6\u9891\n videoElement.play().catch((error: unknown) => {\n console.warn('\u89C6\u9891\u81EA\u52A8\u64AD\u653E\u5931\u8D25:', error)\n })\n }\n }\n }, [isVideoLoaded, isVideoStartLoad, videoRef])\n\n // \u9884\u52A0\u8F7D\u89C6\u9891\n const preloadVideo = useCallback(() => {\n const videoUrl = src\n\n if (!videoUrl) return\n\n // \u5982\u679C\u5F53\u524DURL\u5DF2\u7ECF\u662F\u89C6\u9891\u7248\u672C\uFF0C\u65E0\u9700\u91CD\u590D\u52A0\u8F7D\n if (currentVideoUrl.current === videoUrl && isVideoLoaded) {\n return\n }\n\n // \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u52A0\u8F7D\u8FC7\u8FD9\u4E2AURL\u7684\u89C6\u9891\u7248\u672C\n if (globalLoadedVideoUrls.has(videoUrl)) {\n setIsVideoLoaded(true)\n currentVideoUrl.current = videoUrl\n return\n }\n\n // \u66F4\u65B0\u5F53\u524D\u89C6\u9891URL\n currentVideoUrl.current = videoUrl\n\n // \u9884\u52A0\u8F7D\u89C6\u9891\n const videoElement = document.createElement('video')\n videoElement.preload = 'metadata'\n videoElement.onloadedmetadata = () => {\n setIsVideoLoaded(true)\n globalLoadedVideoUrls.add(videoUrl)\n }\n videoElement.src = videoUrl\n }, [isVideoLoaded, src])\n\n useEffect(() => {\n if (!ref.current || isVideoLoaded) return\n const scrollHandler = debounce(() => {\n if (window.scrollY > 10) {\n setIsVideoStartLoad(true)\n preloadVideo()\n return window.removeEventListener('scroll', scrollHandler)\n }\n }, 100)\n window.addEventListener('scroll', scrollHandler)\n return () => {\n window.removeEventListener('scroll', scrollHandler)\n }\n }, [preloadVideo, isVideoLoaded])\n\n const handleVideoLoad = useCallback(() => {\n setIsVideoLoaded(true)\n // \u8BB0\u5F55\u5F53\u524DURL\u5DF2\u52A0\u8F7D\u89C6\u9891\u7248\u672C\n if (currentVideoUrl.current) {\n globalLoadedVideoUrls.add(currentVideoUrl.current)\n }\n const videoElement = videoRef?.current || internalVideoRef.current\n if (videoElement) {\n videoElement.muted = true\n videoElement.play()\n }\n }, [])\n\n return (\n <div ref={ref} className={cn('relative size-full', className)}>\n {poster && (\n <div\n className={cn(\n 'absolute inset-0 size-full overflow-hidden transition-opacity duration-500 ease-in-out',\n videoWrapperClassName,\n {\n 'opacity-100': !isVideoLoaded,\n 'overflow-visible opacity-0': isVideoLoaded,\n }\n )}\n >\n <img\n src={poster}\n alt={alt}\n style={{ width: '100%', height: '100%', objectFit: 'cover' }}\n className={cn(videoClassName)}\n />\n </div>\n )}\n <div\n className={cn('size-full transition-opacity duration-500 ease-in-out', {\n 'opacity-100': isVideoLoaded,\n 'opacity-0': !isVideoLoaded,\n })}\n style={{ visibility: isVideoStartLoad ? 'visible' : 'hidden' }}\n >\n {isVideoStartLoad && (\n <div className={cn('relative size-full', videoWrapperClassName)}>\n <video\n ref={videoRef || internalVideoRef}\n key={currentVideoUrl.current} // \u6DFB\u52A0key\u786E\u4FDDURL\u53D8\u5316\u65F6\u91CD\u65B0\u6E32\u67D3\n src={currentVideoUrl.current || src}\n poster={poster}\n className={cn('size-full object-cover', videoClassName)}\n onLoadedMetadata={handleVideoLoad}\n autoPlay={autoplay}\n muted={muted}\n loop={loop}\n controls={controls}\n playsInline={playsInline}\n {...attr}\n />\n </div>\n )}\n </div>\n </div>\n )\n}\n\nexport default ScrollLoadVideo\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAgII,IAAAI,EAAA,6BAhIJC,EAAgE,iBAChEC,EAAmB,+BACnBC,EAAyB,kBAGzB,MAAMC,EAAwB,IAAI,IAE5BC,EAAkB,CAAC,CACvB,IAAAC,EACA,OAAAC,EACA,IAAAC,EAAM,sBACN,UAAAC,EAAY,GACZ,sBAAAC,EAAwB,GACxB,eAAAC,EAAiB,GACjB,SAAAC,EAAW,GACX,MAAAC,EAAQ,GACR,KAAAC,EAAO,GACP,SAAAC,EAAW,GACX,YAAAC,EAAc,GACd,SAAAC,EAAW,KACX,GAAGC,CACL,IAaM,CACJ,KAAM,CAACC,EAAkBC,CAAmB,KAAI,YAAS,EAAK,EACxD,CAACC,EAAeC,CAAgB,KAAI,YAAS,EAAK,EAClDC,KAAM,UAAuB,IAAI,EAEjCC,KAAmB,UAAyB,IAAI,EAEhDC,KAAkB,UAAe,EAAE,KAGzC,aAAU,IAAM,CAEVrB,EAAsB,IAAIE,CAAG,IAC/Bc,EAAoB,EAAI,EACxBE,EAAiB,EAAI,EACrBG,EAAgB,QAAUnB,EAE9B,EAAG,CAACA,CAAG,CAAC,KAGR,aAAU,IAAM,CACd,GAAIe,GAAiBF,EAAkB,CACrC,MAAMO,EAAeT,GAAU,SAAWO,EAAiB,QACvDE,IAEFA,EAAa,MAAQ,GAErBA,EAAa,KAAK,EAAE,MAAOC,GAAmB,CAC5C,QAAQ,KAAK,oDAAaA,CAAK,CACjC,CAAC,EAEL,CACF,EAAG,CAACN,EAAeF,EAAkBF,CAAQ,CAAC,EAG9C,MAAMW,KAAe,eAAY,IAAM,CACrC,MAAMC,EAAWvB,EAKjB,GAHI,CAACuB,GAGDJ,EAAgB,UAAYI,GAAYR,EAC1C,OAIF,GAAIjB,EAAsB,IAAIyB,CAAQ,EAAG,CACvCP,EAAiB,EAAI,EACrBG,EAAgB,QAAUI,EAC1B,MACF,CAGAJ,EAAgB,QAAUI,EAG1B,MAAMH,EAAe,SAAS,cAAc,OAAO,EACnDA,EAAa,QAAU,WACvBA,EAAa,iBAAmB,IAAM,CACpCJ,EAAiB,EAAI,EACrBlB,EAAsB,IAAIyB,CAAQ,CACpC,EACAH,EAAa,IAAMG,CACrB,EAAG,CAACR,EAAef,CAAG,CAAC,KAEvB,aAAU,IAAM,CACd,GAAI,CAACiB,EAAI,SAAWF,EAAe,OACnC,MAAMS,KAAgB,YAAS,IAAM,CACnC,GAAI,OAAO,QAAU,GACnB,OAAAV,EAAoB,EAAI,EACxBQ,EAAa,EACN,OAAO,oBAAoB,SAAUE,CAAa,CAE7D,EAAG,GAAG,EACN,cAAO,iBAAiB,SAAUA,CAAa,EACxC,IAAM,CACX,OAAO,oBAAoB,SAAUA,CAAa,CACpD,CACF,EAAG,CAACF,EAAcP,CAAa,CAAC,EAEhC,MAAMU,KAAkB,eAAY,IAAM,CACxCT,EAAiB,EAAI,EAEjBG,EAAgB,SAClBrB,EAAsB,IAAIqB,EAAgB,OAAO,EAEnD,MAAMC,EAAeT,GAAU,SAAWO,EAAiB,QACvDE,IACFA,EAAa,MAAQ,GACrBA,EAAa,KAAK,EAEtB,EAAG,CAAC,CAAC,EAEL,SACE,QAAC,OAAI,IAAKH,EAAK,aAAW,MAAG,qBAAsBd,CAAS,EACzD,UAAAF,MACC,OAAC,OACC,aAAW,MACT,yFACAG,EACA,CACE,cAAe,CAACW,EAChB,6BAA8BA,CAChC,CACF,EAEA,mBAAC,OACC,IAAKd,EACL,IAAKC,EACL,MAAO,CAAE,MAAO,OAAQ,OAAQ,OAAQ,UAAW,OAAQ,EAC3D,aAAW,MAAGG,CAAc,
|
|
4
|
+
"sourcesContent": ["import React, { useEffect, useState, useRef, useCallback } from 'react'\nimport { cn } from '../helpers/utils.js'\nimport { debounce } from 'lodash'\n\n// \u521B\u5EFA\u4E00\u4E2A\u5168\u5C40\u7F13\u5B58\u6765\u5B58\u50A8\u5DF2\u52A0\u8F7D\u7684\u89C6\u9891URL\nconst globalLoadedVideoUrls = new Set<string>()\n\nconst ScrollLoadVideo = ({\n src,\n poster,\n alt = 'Scroll Loaded Video',\n className = '',\n videoWrapperClassName = '',\n videoClassName = '',\n autoplay = false,\n muted = true,\n loop = true,\n controls = false,\n playsInline = true,\n videoRef = null,\n ...attr\n}: {\n src: string\n poster?: string\n alt?: string\n className?: string\n videoWrapperClassName?: string\n videoClassName?: string\n autoplay?: boolean\n muted?: boolean\n loop?: boolean\n controls?: boolean\n playsInline?: boolean\n [key: string]: any\n}) => {\n const [isVideoStartLoad, setIsVideoStartLoad] = useState(false)\n const [isVideoLoaded, setIsVideoLoaded] = useState(false)\n const ref = useRef<HTMLDivElement>(null)\n // \u5185\u90E8\u89C6\u9891\u5F15\u7528\uFF0C\u5982\u679C\u5916\u90E8\u6CA1\u6709\u4F20\u5165 videoRef\n const internalVideoRef = useRef<HTMLVideoElement>(null)\n // \u4FDD\u5B58\u5F53\u524D\u52A0\u8F7D\u7684\u89C6\u9891URL\n const currentVideoUrl = useRef<string>('')\n\n // \u5728\u7EC4\u4EF6\u6302\u8F7D\u65F6\u68C0\u67E5\u89C6\u9891\u662F\u5426\u5DF2\u7ECF\u88AB\u52A0\u8F7D\u8FC7\n useEffect(() => {\n // \u5982\u679C\u89C6\u9891\u5DF2\u7ECF\u88AB\u5168\u5C40\u7F13\u5B58\u8FC7\uFF0C\u76F4\u63A5\u8BBE\u7F6E\u4E3A\u5DF2\u52A0\u8F7D\u72B6\u6001\n if (globalLoadedVideoUrls.has(src)) {\n setIsVideoStartLoad(true)\n setIsVideoLoaded(true)\n currentVideoUrl.current = src\n }\n }, [src])\n\n // \u5F53\u89C6\u9891\u5DF2\u52A0\u8F7D\u4E14\u5DF2\u5F00\u59CB\u52A0\u8F7D\u65F6\uFF0C\u5C1D\u8BD5\u64AD\u653E\u89C6\u9891\n useEffect(() => {\n if (isVideoLoaded && isVideoStartLoad) {\n const videoElement = videoRef?.current || internalVideoRef.current\n if (videoElement) {\n // \u786E\u4FDD\u9759\u97F3\u4EE5\u5141\u8BB8\u81EA\u52A8\u64AD\u653E\n videoElement.muted = true\n // \u5C1D\u8BD5\u64AD\u653E\u89C6\u9891\n videoElement.play().catch((error: unknown) => {\n console.warn('\u89C6\u9891\u81EA\u52A8\u64AD\u653E\u5931\u8D25:', error)\n })\n }\n }\n }, [isVideoLoaded, isVideoStartLoad, videoRef])\n\n // \u9884\u52A0\u8F7D\u89C6\u9891\n const preloadVideo = useCallback(() => {\n const videoUrl = src\n\n if (!videoUrl) return\n\n // \u5982\u679C\u5F53\u524DURL\u5DF2\u7ECF\u662F\u89C6\u9891\u7248\u672C\uFF0C\u65E0\u9700\u91CD\u590D\u52A0\u8F7D\n if (currentVideoUrl.current === videoUrl && isVideoLoaded) {\n return\n }\n\n // \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u52A0\u8F7D\u8FC7\u8FD9\u4E2AURL\u7684\u89C6\u9891\u7248\u672C\n if (globalLoadedVideoUrls.has(videoUrl)) {\n setIsVideoLoaded(true)\n currentVideoUrl.current = videoUrl\n return\n }\n\n // \u66F4\u65B0\u5F53\u524D\u89C6\u9891URL\n currentVideoUrl.current = videoUrl\n\n // \u9884\u52A0\u8F7D\u89C6\u9891\n const videoElement = document.createElement('video')\n videoElement.preload = 'metadata'\n videoElement.onloadedmetadata = () => {\n setIsVideoLoaded(true)\n globalLoadedVideoUrls.add(videoUrl)\n }\n videoElement.src = videoUrl\n }, [isVideoLoaded, src])\n\n useEffect(() => {\n if (!ref.current || isVideoLoaded) return\n const scrollHandler = debounce(() => {\n if (window.scrollY > 10) {\n setIsVideoStartLoad(true)\n preloadVideo()\n return window.removeEventListener('scroll', scrollHandler)\n }\n }, 100)\n window.addEventListener('scroll', scrollHandler)\n return () => {\n window.removeEventListener('scroll', scrollHandler)\n }\n }, [preloadVideo, isVideoLoaded])\n\n const handleVideoLoad = useCallback(() => {\n setIsVideoLoaded(true)\n // \u8BB0\u5F55\u5F53\u524DURL\u5DF2\u52A0\u8F7D\u89C6\u9891\u7248\u672C\n if (currentVideoUrl.current) {\n globalLoadedVideoUrls.add(currentVideoUrl.current)\n }\n const videoElement = videoRef?.current || internalVideoRef.current\n if (videoElement) {\n videoElement.muted = true\n videoElement.play()\n }\n }, [])\n\n return (\n <div ref={ref} className={cn('relative size-full', className)}>\n {poster && (\n <div\n className={cn(\n 'absolute inset-0 size-full overflow-hidden transition-opacity duration-500 ease-in-out',\n videoWrapperClassName,\n {\n 'opacity-100': !isVideoLoaded,\n 'overflow-visible opacity-0': isVideoLoaded,\n }\n )}\n >\n <img\n src={poster}\n alt={alt}\n style={{ width: '100%', height: '100%', objectFit: 'cover' }}\n className={cn(videoClassName)}\n loading=\"lazy\"\n />\n </div>\n )}\n <div\n className={cn('size-full transition-opacity duration-500 ease-in-out', {\n 'opacity-100': isVideoLoaded,\n 'opacity-0': !isVideoLoaded,\n })}\n style={{ visibility: isVideoStartLoad ? 'visible' : 'hidden' }}\n >\n {isVideoStartLoad && (\n <div className={cn('relative size-full', videoWrapperClassName)}>\n <video\n ref={videoRef || internalVideoRef}\n key={currentVideoUrl.current} // \u6DFB\u52A0key\u786E\u4FDDURL\u53D8\u5316\u65F6\u91CD\u65B0\u6E32\u67D3\n src={currentVideoUrl.current || src}\n poster={poster}\n className={cn('size-full object-cover', videoClassName)}\n onLoadedMetadata={handleVideoLoad}\n autoPlay={autoplay}\n muted={muted}\n loop={loop}\n controls={controls}\n playsInline={playsInline}\n {...attr}\n />\n </div>\n )}\n </div>\n </div>\n )\n}\n\nexport default ScrollLoadVideo\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["ScrollLoadVideo_exports", "__export", "ScrollLoadVideo_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_utils", "import_lodash", "globalLoadedVideoUrls", "ScrollLoadVideo", "src", "poster", "alt", "className", "videoWrapperClassName", "videoClassName", "autoplay", "muted", "loop", "controls", "playsInline", "videoRef", "attr", "isVideoStartLoad", "setIsVideoStartLoad", "isVideoLoaded", "setIsVideoLoaded", "ref", "internalVideoRef", "currentVideoUrl", "videoElement", "error", "preloadVideo", "videoUrl", "scrollHandler", "handleVideoLoad"]
|
|
7
7
|
}
|
|
@@ -11,7 +11,7 @@ declare const meta: {
|
|
|
11
11
|
onClick?: Function;
|
|
12
12
|
} & import("class-variance-authority").VariantProps<(props?: ({
|
|
13
13
|
size?: "base" | "lg" | null | undefined;
|
|
14
|
-
variant?: "primary" | "
|
|
14
|
+
variant?: "primary" | "secondary" | null | undefined;
|
|
15
15
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & import("../helpers/component-props.js").ComponentPropsWithout<"a", import("../helpers/component-props.js").RemovedProps> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
16
16
|
parameters: {
|
|
17
17
|
layout: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var d=Object.create;var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var k=(i,a)=>{for(var s in a)o(i,s,{get:a[s],enumerable:!0})},r=(i,a,s,t)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of p(a))!m.call(i,l)&&l!==s&&o(i,l,{get:()=>a[l],enumerable:!(t=c(a,l))||t.enumerable});return i};var y=(i,a,s)=>(s=i!=null?d(f(i)):{},r(a||!i||!i.__esModule?o(s,"default",{value:i,enumerable:!0}):s,i)),L=i=>r(o({},"__esModule",{value:!0}),i);var z={};k(z,{Default:()=>b,Disabled:()=>
|
|
1
|
+
"use strict";var d=Object.create;var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var k=(i,a)=>{for(var s in a)o(i,s,{get:a[s],enumerable:!0})},r=(i,a,s,t)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of p(a))!m.call(i,l)&&l!==s&&o(i,l,{get:()=>a[l],enumerable:!(t=c(a,l))||t.enumerable});return i};var y=(i,a,s)=>(s=i!=null?d(f(i)):{},r(a||!i||!i.__esModule?o(s,"default",{value:i,enumerable:!0}):s,i)),L=i=>r(o({},"__esModule",{value:!0}),i);var z={};k(z,{Default:()=>b,Disabled:()=>u,LinkSize:()=>x,default:()=>g});module.exports=L(z);var e=require("react/jsx-runtime"),S=require("@storybook/icons"),n=y(require("../components/link.js"));const v={title:"Components/Link",component:n.default,parameters:{layout:"centered"},tags:["autodocs"],argTypes:{size:{description:"\u5C3A\u5BF8",control:{type:"select"},options:["base","lg"],table:{defaultValue:{summary:"base"}}},variant:{description:"\u94FE\u63A5\u60AC\u6D6E\u6587\u5B57\u6837\u5F0F",control:{type:"select"},options:["primary","secondary"],table:{defaultValue:{summary:"primary"}}},onClick:{control:!1},suffixIcon:{control:!1},style:{control:!1},className:{control:!1},children:{control:!1}},args:{onClick:void 0}};var g=v;const b={args:{children:"Link"}},x=()=>(0,e.jsxs)("div",{className:"inline-flex flex-col gap-4",children:[(0,e.jsx)("div",{className:"inline-flex gap-4",children:(0,e.jsx)(n.default,{size:"base",children:"Link"})}),(0,e.jsx)("div",{className:"inline-flex gap-4",children:(0,e.jsx)(n.default,{size:"lg",children:"Link"})}),(0,e.jsx)("div",{className:"inline-flex gap-4",children:(0,e.jsx)(n.default,{size:"base",variant:"secondary",children:"Link"})}),(0,e.jsx)("div",{className:"inline-flex gap-4",children:(0,e.jsx)(n.default,{size:"lg",variant:"secondary",children:"Link"})})]}),u=()=>(0,e.jsxs)("div",{className:"inline-flex flex-col gap-4",children:[(0,e.jsxs)("div",{className:"inline-flex gap-4",children:[(0,e.jsx)(n.default,{size:"base",disabled:!0,children:"Link"}),(0,e.jsx)(n.default,{size:"base",disabled:!0,children:"Link"})]}),(0,e.jsxs)("div",{className:"inline-flex gap-4",children:[(0,e.jsx)(n.default,{size:"lg",disabled:!0,children:"Link"}),(0,e.jsx)(n.default,{size:"lg",disabled:!0,children:"Link"})]})]});
|
|
2
2
|
//# sourceMappingURL=link.stories.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/stories/link.stories.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Meta, StoryObj } from '@storybook/react'\nimport { ChevronRightIcon } from '@storybook/icons'\nimport Link from '../components/link.js'\n\nconst meta = {\n // \u540C\u65F6\u5B9A\u4E49\u4E86\u9875\u9762\u5DE6\u4FA7\u83DC\u5355\n title: 'Components/Link',\n component: Link,\n parameters: {\n layout: 'centered',\n },\n // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs\n tags: ['autodocs'],\n // More on argTypes: https://storybook.js.org/docs/api/argtypes\n argTypes: {\n size: {\n description: '\u5C3A\u5BF8',\n control: {\n type: 'select',\n },\n options: ['base', 'lg'],\n table: {\n defaultValue: { summary: 'base' },\n },\n },\n variant: {\n description: '\u94FE\u63A5\u60AC\u6D6E\u6587\u5B57\u6837\u5F0F',\n control: {\n type: 'select',\n },\n options: ['primary', '
|
|
4
|
+
"sourcesContent": ["import type { Meta, StoryObj } from '@storybook/react'\nimport { ChevronRightIcon } from '@storybook/icons'\nimport Link from '../components/link.js'\n\nconst meta = {\n // \u540C\u65F6\u5B9A\u4E49\u4E86\u9875\u9762\u5DE6\u4FA7\u83DC\u5355\n title: 'Components/Link',\n component: Link,\n parameters: {\n layout: 'centered',\n },\n // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs\n tags: ['autodocs'],\n // More on argTypes: https://storybook.js.org/docs/api/argtypes\n argTypes: {\n size: {\n description: '\u5C3A\u5BF8',\n control: {\n type: 'select',\n },\n options: ['base', 'lg'],\n table: {\n defaultValue: { summary: 'base' },\n },\n },\n variant: {\n description: '\u94FE\u63A5\u60AC\u6D6E\u6587\u5B57\u6837\u5F0F',\n control: {\n type: 'select',\n },\n options: ['primary', 'secondary'],\n table: {\n defaultValue: { summary: 'primary' },\n },\n },\n onClick: {\n control: false,\n },\n suffixIcon: {\n control: false,\n },\n style: {\n control: false,\n },\n className: {\n control: false,\n },\n children: {\n control: false,\n },\n },\n args: {\n onClick: undefined,\n },\n} satisfies Meta<typeof Link>\n\nexport default meta\n\ntype Story = StoryObj<typeof meta>\n\nexport const Default: Story = {\n args: {\n children: 'Link',\n },\n}\n\nexport const LinkSize = () => (\n <div className=\"inline-flex flex-col gap-4\">\n <div className=\"inline-flex gap-4\">\n <Link size=\"base\">Link</Link>\n </div>\n <div className=\"inline-flex gap-4\">\n <Link size=\"lg\">Link</Link>\n </div>\n <div className=\"inline-flex gap-4\">\n <Link size=\"base\" variant=\"secondary\">\n Link\n </Link>\n </div>\n <div className=\"inline-flex gap-4\">\n <Link size=\"lg\" variant=\"secondary\">\n Link\n </Link>\n </div>\n </div>\n)\n\nexport const Disabled = () => (\n <div className=\"inline-flex flex-col gap-4\">\n <div className=\"inline-flex gap-4\">\n <Link size=\"base\" disabled>\n Link\n </Link>\n <Link size=\"base\" disabled>\n Link\n </Link>\n </div>\n <div className=\"inline-flex gap-4\">\n <Link size=\"lg\" disabled>\n Link\n </Link>\n <Link size=\"lg\" disabled>\n Link\n </Link>\n </div>\n </div>\n)\n"],
|
|
5
5
|
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,aAAAC,EAAA,aAAAC,EAAA,YAAAC,IAAA,eAAAC,EAAAN,GAmEE,IAAAO,EAAA,6BAlEFC,EAAiC,4BACjCC,EAAiB,oCAEjB,MAAMC,EAAO,CAEX,MAAO,kBACP,UAAW,EAAAC,QACX,WAAY,CACV,OAAQ,UACV,EAEA,KAAM,CAAC,UAAU,EAEjB,SAAU,CACR,KAAM,CACJ,YAAa,eACb,QAAS,CACP,KAAM,QACR,EACA,QAAS,CAAC,OAAQ,IAAI,EACtB,MAAO,CACL,aAAc,CAAE,QAAS,MAAO,CAClC,CACF,EACA,QAAS,CACP,YAAa,mDACb,QAAS,CACP,KAAM,QACR,EACA,QAAS,CAAC,UAAW,WAAW,EAChC,MAAO,CACL,aAAc,CAAE,QAAS,SAAU,CACrC,CACF,EACA,QAAS,CACP,QAAS,EACX,EACA,WAAY,CACV,QAAS,EACX,EACA,MAAO,CACL,QAAS,EACX,EACA,UAAW,CACT,QAAS,EACX,EACA,SAAU,CACR,QAAS,EACX,CACF,EACA,KAAM,CACJ,QAAS,MACX,CACF,EAEA,IAAON,EAAQK,EAIR,MAAMR,EAAiB,CAC5B,KAAM,CACJ,SAAU,MACZ,CACF,EAEaE,EAAW,OACtB,QAAC,OAAI,UAAU,6BACb,oBAAC,OAAI,UAAU,oBACb,mBAAC,EAAAO,QAAA,CAAK,KAAK,OAAO,gBAAI,EACxB,KACA,OAAC,OAAI,UAAU,oBACb,mBAAC,EAAAA,QAAA,CAAK,KAAK,KAAK,gBAAI,EACtB,KACA,OAAC,OAAI,UAAU,oBACb,mBAAC,EAAAA,QAAA,CAAK,KAAK,OAAO,QAAQ,YAAY,gBAEtC,EACF,KACA,OAAC,OAAI,UAAU,oBACb,mBAAC,EAAAA,QAAA,CAAK,KAAK,KAAK,QAAQ,YAAY,gBAEpC,EACF,GACF,EAGWR,EAAW,OACtB,QAAC,OAAI,UAAU,6BACb,qBAAC,OAAI,UAAU,oBACb,oBAAC,EAAAQ,QAAA,CAAK,KAAK,OAAO,SAAQ,GAAC,gBAE3B,KACA,OAAC,EAAAA,QAAA,CAAK,KAAK,OAAO,SAAQ,GAAC,gBAE3B,GACF,KACA,QAAC,OAAI,UAAU,oBACb,oBAAC,EAAAA,QAAA,CAAK,KAAK,KAAK,SAAQ,GAAC,gBAEzB,KACA,OAAC,EAAAA,QAAA,CAAK,KAAK,KAAK,SAAQ,GAAC,gBAEzB,GACF,GACF",
|
|
6
6
|
"names": ["link_stories_exports", "__export", "Default", "Disabled", "LinkSize", "link_stories_default", "__toCommonJS", "import_jsx_runtime", "import_icons", "import_link", "meta", "Link"]
|
|
7
7
|
}
|
|
@@ -72,6 +72,15 @@ export type JoinedRecommendBuyProducts = {
|
|
|
72
72
|
canOperate?: boolean;
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
|
+
export type CreditsRedemption = {
|
|
76
|
+
amount: number;
|
|
77
|
+
availablePoints: number;
|
|
78
|
+
usedPoints: number;
|
|
79
|
+
skuDetails?: {
|
|
80
|
+
sku: string;
|
|
81
|
+
is_eligible: boolean;
|
|
82
|
+
}[];
|
|
83
|
+
};
|
|
75
84
|
export interface ProductContextType {
|
|
76
85
|
isLogin?: boolean;
|
|
77
86
|
isMobile?: boolean;
|
|
@@ -105,7 +114,7 @@ export interface ProductContextType {
|
|
|
105
114
|
compareData?: CompareData['data'];
|
|
106
115
|
onAddToCart?: () => void;
|
|
107
116
|
onBuyNow?: () => void;
|
|
108
|
-
|
|
117
|
+
creditsRedemption?: CreditsRedemption;
|
|
109
118
|
memberFunctionResult?: FunctionMemberPriceResult;
|
|
110
119
|
openModal: ({ title, content, domContent }: ModalData) => void;
|
|
111
120
|
openSignInPopup?: () => void;
|
|
@@ -122,5 +131,5 @@ export interface ProductContextType {
|
|
|
122
131
|
}
|
|
123
132
|
export declare const BizProductContext: React.Context<ProductContextType>;
|
|
124
133
|
export declare const useBizProductContext: () => ProductContextType;
|
|
125
|
-
declare const ProductProvider: ({ product, isLogin, profile, isMobile, isDesktop, children, renderRating, freeGift, exchangePurchase, bundle, checkedBundle, checkedGift, setCheckedBundle, setCheckedGift, checkedExchangePurchase, setCheckedExchangePurchase, variant, selectedOptions, setSelectedOptions, compareData, coupon, finalPrice, comparePrice, totalSavings, savingDetail, setSavingDetail, selectedVariants, onAddToCart, onBuyNow,
|
|
134
|
+
declare const ProductProvider: ({ product, isLogin, profile, isMobile, isDesktop, children, renderRating, freeGift, exchangePurchase, bundle, checkedBundle, checkedGift, setCheckedBundle, setCheckedGift, checkedExchangePurchase, setCheckedExchangePurchase, variant, selectedOptions, setSelectedOptions, compareData, coupon, finalPrice, comparePrice, totalSavings, savingDetail, setSavingDetail, selectedVariants, onAddToCart, onBuyNow, creditsRedemption, memberFunctionResult, openModal, openSignInPopup, openAuthCodePopup, openSignUpPopup, renderInstallments, onUseCouponChange, onUseMemberDiscountChange, discount, buyNowLoading, addToCartLoading, }: PropsWithChildren<Omit<ProductContextType, "joinedRecommendBuyProducts" | "setJoinedRecommendBuyProducts" | "addOrder" | "setAddOrder">>) => import("react/jsx-runtime").JSX.Element;
|
|
126
135
|
export default ProductProvider;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as Y}from"react/jsx-runtime";import{createContext as K,useContext as a,useState as i,useEffect as Q}from"react";const t=K({}),te=()=>{if(!a(t))throw new Error("useProductContext must be used in <ProductProvider>");return a(t)},X=({product:n,isLogin:d,profile:c,isMobile:u,isDesktop:s,children:p,renderRating:l,freeGift:m,exchangePurchase:
|
|
1
|
+
import{jsx as Y}from"react/jsx-runtime";import{createContext as K,useContext as a,useState as i,useEffect as Q}from"react";const t=K({}),te=()=>{if(!a(t))throw new Error("useProductContext must be used in <ProductProvider>");return a(t)},X=({product:n,isLogin:d,profile:c,isMobile:u,isDesktop:s,children:p,renderRating:l,freeGift:m,exchangePurchase:b,bundle:P,checkedBundle:g,checkedGift:h,setCheckedBundle:y,setCheckedGift:C,checkedExchangePurchase:f,setCheckedExchangePurchase:v,variant:e,selectedOptions:x,setSelectedOptions:S,compareData:D,coupon:B,finalPrice:R,comparePrice:A,totalSavings:O,savingDetail:k,setSavingDetail:_,selectedVariants:V,onAddToCart:M,onBuyNow:w,creditsRedemption:F,memberFunctionResult:T,openModal:G,openSignInPopup:J,openAuthCodePopup:L,openSignUpPopup:I,renderInstallments:N,onUseCouponChange:U,onUseMemberDiscountChange:E,discount:W,buyNowLoading:j,addToCartLoading:z})=>{const[q,o]=i({}),[H,r]=i([]);return Q(()=>{e?.id&&(o({bundle:{value:void 0,canOperate:!0},gift:{value:void 0,canOperate:!0},exchange:{value:void 0,canOperate:!0}}),r([]))},[e?.id]),Y(t.Provider,{value:{product:n,variant:e,isMobile:u,isDesktop:s,isLogin:d,profile:c,coupon:B,renderRating:l,finalPrice:R,comparePrice:A,savingDetail:k,setSavingDetail:_,totalSavings:O,selectedOptions:x,setSelectedOptions:S,freeGift:m,exchangePurchase:b,checkedGift:h,setCheckedGift:C,checkedBundle:g,setCheckedBundle:y,bundle:P,compareData:D,selectedVariants:V,onAddToCart:M,onBuyNow:w,joinedRecommendBuyProducts:q,setJoinedRecommendBuyProducts:o,checkedExchangePurchase:f,setCheckedExchangePurchase:v,creditsRedemption:F,memberFunctionResult:T,openModal:G,openSignInPopup:J,openAuthCodePopup:L,openSignUpPopup:I,renderInstallments:N,onUseCouponChange:U,onUseMemberDiscountChange:E,discount:W,buyNowLoading:j,addToCartLoading:z,addOrder:H,setAddOrder:r},children:p})};var ne=X;export{t as BizProductContext,ne as default,te as useBizProductContext};
|
|
2
2
|
//# sourceMappingURL=BizProductProvider.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/Listing/BizProductProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, {\n createContext,\n useCallback,\n useContext,\n type Dispatch,\n type SetStateAction,\n type PropsWithChildren,\n useState,\n useEffect,\n} from 'react'\nimport type {\n Product,\n ProductPrice,\n ProductVariant,\n VariantCoupon,\n Options,\n FreeGift,\n BundleListItem,\n Bundle,\n} from './types/product'\nimport type { CompareData, DiscountData } from './types.js'\n\ntype Country = {\n id?: number\n name?: string\n code?: string\n}\n\nexport type UserProfile = {\n user_id: string\n email: string\n nick_name?: string\n full_name?: string\n first_name?: string\n last_name?: string\n dob?: string\n gender?: string\n phone_number?: string\n phone_account?: string\n country?: Country\n is_subscribe?: boolean\n avatar?: string\n can_change_password?: boolean\n invitation_code?: string\n phone_carrier?: string\n dob_programmed?: boolean\n activated?: boolean\n registed_at?: number\n activated_at?: number\n token?: string\n}\n\nexport type SavingDetail = {\n coupon: number\n bundle: number\n member: number\n freeGift: number\n compare: number\n exchangePurchase: number\n}\n\ntype variantWithFinalPrice = ProductVariant & { finalPrice?: ProductPrice }\n\nexport type FunctionMemberPriceResult = {\n hasMemberPrice: boolean\n originalPrice: number\n withCouponMemberTotalSave: number\n withoutCouponMaxMemberTotalSave?: number\n labels: {\n key: string\n value: string\n desc: string\n }[]\n}\n\nexport type ModalData = {\n needClickAway?: boolean\n className?: string\n title?: string\n content?: string\n domContent?: React.ReactNode\n}\n\nexport type JoinedRecommendBuyProducts = {\n bundle?: {\n value?: BundleListItem\n canOperate?: boolean\n }\n gift?: {\n value?: ProductVariant\n canOperate?: boolean\n }\n exchange?: {\n value?: ProductVariant\n canOperate?: boolean\n }\n}\nexport interface ProductContextType {\n isLogin?: boolean\n isMobile?: boolean\n isDesktop?: boolean\n product: Product\n profile?: UserProfile\n variant: ProductVariant\n selectedVariants: Array<variantWithFinalPrice>\n renderRating?: React.ReactNode\n coupon?: VariantCoupon\n savingDetail: SavingDetail\n setSavingDetail: Dispatch<SetStateAction<SavingDetail>>\n finalPrice: number\n comparePrice: number\n totalSavings: number\n selectedOptions: Options\n setSelectedOptions: Dispatch<SetStateAction<Options>>\n freeGift?: FreeGift\n checkedGift?: ProductVariant\n setCheckedGift?: Dispatch<SetStateAction<ProductVariant | undefined>>\n exchangePurchase?: FreeGift\n checkedExchangePurchase?: ProductVariant\n setCheckedExchangePurchase?: Dispatch<SetStateAction<ProductVariant | undefined>>\n checkedBundle?: BundleListItem\n setCheckedBundle: Dispatch<SetStateAction<BundleListItem | undefined>>\n joinedRecommendBuyProducts: JoinedRecommendBuyProducts\n setJoinedRecommendBuyProducts?: Dispatch<SetStateAction<JoinedRecommendBuyProducts>>\n checkedCareBundle?: ProductVariant\n setCheckedCareBundle?: Dispatch<SetStateAction<ProductVariant | undefined>>\n bundle?: Bundle\n compareData?: CompareData['data']\n onAddToCart?: () => void\n onBuyNow?: () => void\n
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "createContext", "useContext", "useState", "useEffect", "BizProductContext", "useBizProductContext", "ProductProvider", "product", "isLogin", "profile", "isMobile", "isDesktop", "children", "renderRating", "freeGift", "exchangePurchase", "bundle", "checkedBundle", "checkedGift", "setCheckedBundle", "setCheckedGift", "checkedExchangePurchase", "setCheckedExchangePurchase", "variant", "selectedOptions", "setSelectedOptions", "compareData", "coupon", "finalPrice", "comparePrice", "totalSavings", "savingDetail", "setSavingDetail", "selectedVariants", "onAddToCart", "onBuyNow", "
|
|
4
|
+
"sourcesContent": ["import React, {\n createContext,\n useCallback,\n useContext,\n type Dispatch,\n type SetStateAction,\n type PropsWithChildren,\n useState,\n useEffect,\n} from 'react'\nimport type {\n Product,\n ProductPrice,\n ProductVariant,\n VariantCoupon,\n Options,\n FreeGift,\n BundleListItem,\n Bundle,\n} from './types/product'\nimport type { CompareData, DiscountData } from './types.js'\n\ntype Country = {\n id?: number\n name?: string\n code?: string\n}\n\nexport type UserProfile = {\n user_id: string\n email: string\n nick_name?: string\n full_name?: string\n first_name?: string\n last_name?: string\n dob?: string\n gender?: string\n phone_number?: string\n phone_account?: string\n country?: Country\n is_subscribe?: boolean\n avatar?: string\n can_change_password?: boolean\n invitation_code?: string\n phone_carrier?: string\n dob_programmed?: boolean\n activated?: boolean\n registed_at?: number\n activated_at?: number\n token?: string\n}\n\nexport type SavingDetail = {\n coupon: number\n bundle: number\n member: number\n freeGift: number\n compare: number\n exchangePurchase: number\n}\n\ntype variantWithFinalPrice = ProductVariant & { finalPrice?: ProductPrice }\n\nexport type FunctionMemberPriceResult = {\n hasMemberPrice: boolean\n originalPrice: number\n withCouponMemberTotalSave: number\n withoutCouponMaxMemberTotalSave?: number\n labels: {\n key: string\n value: string\n desc: string\n }[]\n}\n\nexport type ModalData = {\n needClickAway?: boolean\n className?: string\n title?: string\n content?: string\n domContent?: React.ReactNode\n}\n\nexport type JoinedRecommendBuyProducts = {\n bundle?: {\n value?: BundleListItem\n canOperate?: boolean\n }\n gift?: {\n value?: ProductVariant\n canOperate?: boolean\n }\n exchange?: {\n value?: ProductVariant\n canOperate?: boolean\n }\n}\n\nexport type CreditsRedemption = {\n amount: number\n availablePoints: number\n usedPoints: number\n skuDetails?: {\n sku: string\n is_eligible: boolean\n }[]\n}\n\nexport interface ProductContextType {\n isLogin?: boolean\n isMobile?: boolean\n isDesktop?: boolean\n product: Product\n profile?: UserProfile\n variant: ProductVariant\n selectedVariants: Array<variantWithFinalPrice>\n renderRating?: React.ReactNode\n coupon?: VariantCoupon\n savingDetail: SavingDetail\n setSavingDetail: Dispatch<SetStateAction<SavingDetail>>\n finalPrice: number\n comparePrice: number\n totalSavings: number\n selectedOptions: Options\n setSelectedOptions: Dispatch<SetStateAction<Options>>\n freeGift?: FreeGift\n checkedGift?: ProductVariant\n setCheckedGift?: Dispatch<SetStateAction<ProductVariant | undefined>>\n exchangePurchase?: FreeGift\n checkedExchangePurchase?: ProductVariant\n setCheckedExchangePurchase?: Dispatch<SetStateAction<ProductVariant | undefined>>\n checkedBundle?: BundleListItem\n setCheckedBundle: Dispatch<SetStateAction<BundleListItem | undefined>>\n joinedRecommendBuyProducts: JoinedRecommendBuyProducts\n setJoinedRecommendBuyProducts?: Dispatch<SetStateAction<JoinedRecommendBuyProducts>>\n checkedCareBundle?: ProductVariant\n setCheckedCareBundle?: Dispatch<SetStateAction<ProductVariant | undefined>>\n bundle?: Bundle\n compareData?: CompareData['data']\n onAddToCart?: () => void\n onBuyNow?: () => void\n creditsRedemption?: CreditsRedemption\n memberFunctionResult?: FunctionMemberPriceResult\n openModal: ({ title, content, domContent }: ModalData) => void\n openSignInPopup?: () => void\n openAuthCodePopup?: () => void\n openSignUpPopup?: () => void\n renderInstallments?: React.ReactNode\n onUseCouponChange?: (couponSaving: number) => void\n onUseMemberDiscountChange?: (memberSaving: number) => void\n discount?: DiscountData\n buyNowLoading?: boolean\n addToCartLoading?: boolean\n addOrder?: Array<'bundle' | 'gift' | 'exchange'>\n setAddOrder?: Dispatch<SetStateAction<Array<'bundle' | 'gift' | 'exchange'>>>\n}\n\n// const initialState: ProductContextType = {\n// isLogin: false,\n// isMobile: false,\n// product: {} as Product,\n// variant: {} as ProductVariant,\n// savingDetail: { coupon: 0, bundle: 0, member: 0, freeGift: 0, compare: 0 },\n// finalPrice: 0,\n// comparePrice: 0,\n// totalSavings: 0,\n// renderRating: null,\n// selectedOptions: {} as Options,\n// setSelectedOptions: () => {},\n// checkedBundle: undefined,\n// checkedGift: undefined,\n// setCheckedBundle: () => {},\n// setCheckedGift: () => {},\n// checkedCareBundle: undefined,\n// setCheckedCareBundle: () => {},\n// }\n\nexport const BizProductContext = createContext<ProductContextType>({} as ProductContextType)\n\nexport const useBizProductContext = () => {\n const context = useContext(BizProductContext)\n if (!context) {\n throw new Error('useProductContext must be used in <ProductProvider>')\n }\n return useContext(BizProductContext)\n}\n\nconst ProductProvider = ({\n product,\n isLogin,\n profile,\n isMobile,\n isDesktop,\n children,\n renderRating,\n freeGift,\n exchangePurchase,\n bundle,\n checkedBundle,\n checkedGift,\n setCheckedBundle,\n setCheckedGift,\n checkedExchangePurchase,\n setCheckedExchangePurchase,\n variant,\n selectedOptions,\n setSelectedOptions,\n compareData,\n coupon,\n finalPrice,\n comparePrice,\n totalSavings,\n savingDetail,\n setSavingDetail,\n selectedVariants,\n onAddToCart,\n onBuyNow,\n creditsRedemption,\n memberFunctionResult,\n openModal,\n openSignInPopup,\n openAuthCodePopup,\n openSignUpPopup,\n renderInstallments,\n onUseCouponChange,\n onUseMemberDiscountChange,\n discount,\n buyNowLoading,\n addToCartLoading,\n}: PropsWithChildren<\n Omit<ProductContextType, 'joinedRecommendBuyProducts' | 'setJoinedRecommendBuyProducts' | 'addOrder' | 'setAddOrder'>\n>) => {\n const [joinedRecommendBuyProducts, setJoinedRecommendBuyProducts] = useState<JoinedRecommendBuyProducts>({})\n const [addOrder, setAddOrder] = useState<Array<'bundle' | 'gift' | 'exchange'>>([])\n\n useEffect(() => {\n if (variant?.id) {\n setJoinedRecommendBuyProducts({\n bundle: {\n value: undefined,\n canOperate: true,\n },\n gift: {\n value: undefined,\n canOperate: true,\n },\n exchange: {\n value: undefined,\n canOperate: true,\n },\n })\n setAddOrder([])\n }\n }, [variant?.id])\n\n return (\n <BizProductContext.Provider\n value={{\n product,\n variant,\n isMobile,\n isDesktop,\n isLogin,\n profile,\n coupon,\n renderRating,\n finalPrice,\n comparePrice,\n savingDetail,\n setSavingDetail,\n totalSavings,\n selectedOptions,\n setSelectedOptions,\n freeGift,\n exchangePurchase,\n checkedGift,\n setCheckedGift,\n checkedBundle,\n setCheckedBundle,\n bundle,\n compareData,\n selectedVariants,\n onAddToCart,\n onBuyNow,\n joinedRecommendBuyProducts,\n setJoinedRecommendBuyProducts,\n checkedExchangePurchase,\n setCheckedExchangePurchase,\n creditsRedemption,\n memberFunctionResult,\n openModal,\n openSignInPopup,\n openAuthCodePopup,\n openSignUpPopup,\n renderInstallments,\n onUseCouponChange,\n onUseMemberDiscountChange,\n discount,\n buyNowLoading,\n addToCartLoading,\n addOrder,\n setAddOrder,\n }}\n >\n {children}\n </BizProductContext.Provider>\n )\n}\n\nexport default ProductProvider\n"],
|
|
5
|
+
"mappings": "AAgQI,cAAAA,MAAA,oBAhQJ,OACE,iBAAAC,EAEA,cAAAC,EAIA,YAAAC,EACA,aAAAC,MACK,QAwKA,MAAMC,EAAoBJ,EAAkC,CAAC,CAAuB,EAE9EK,GAAuB,IAAM,CAExC,GAAI,CADYJ,EAAWG,CAAiB,EAE1C,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOH,EAAWG,CAAiB,CACrC,EAEME,EAAkB,CAAC,CACvB,QAAAC,EACA,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,UAAAC,EACA,SAAAC,EACA,aAAAC,EACA,SAAAC,EACA,iBAAAC,EACA,OAAAC,EACA,cAAAC,EACA,YAAAC,EACA,iBAAAC,EACA,eAAAC,EACA,wBAAAC,EACA,2BAAAC,EACA,QAAAC,EACA,gBAAAC,EACA,mBAAAC,EACA,YAAAC,EACA,OAAAC,EACA,WAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,YAAAC,EACA,SAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,UAAAC,EACA,gBAAAC,EACA,kBAAAC,EACA,gBAAAC,EACA,mBAAAC,EACA,kBAAAC,EACA,0BAAAC,EACA,SAAAC,EACA,cAAAC,EACA,iBAAAC,CACF,IAEM,CACJ,KAAM,CAACC,EAA4BC,CAA6B,EAAI/C,EAAqC,CAAC,CAAC,EACrG,CAACgD,EAAUC,CAAW,EAAIjD,EAAgD,CAAC,CAAC,EAElF,OAAAC,EAAU,IAAM,CACVoB,GAAS,KACX0B,EAA8B,CAC5B,OAAQ,CACN,MAAO,OACP,WAAY,EACd,EACA,KAAM,CACJ,MAAO,OACP,WAAY,EACd,EACA,SAAU,CACR,MAAO,OACP,WAAY,EACd,CACF,CAAC,EACDE,EAAY,CAAC,CAAC,EAElB,EAAG,CAAC5B,GAAS,EAAE,CAAC,EAGdxB,EAACK,EAAkB,SAAlB,CACC,MAAO,CACL,QAAAG,EACA,QAAAgB,EACA,SAAAb,EACA,UAAAC,EACA,QAAAH,EACA,QAAAC,EACA,OAAAkB,EACA,aAAAd,EACA,WAAAe,EACA,aAAAC,EACA,aAAAE,EACA,gBAAAC,EACA,aAAAF,EACA,gBAAAN,EACA,mBAAAC,EACA,SAAAX,EACA,iBAAAC,EACA,YAAAG,EACA,eAAAE,EACA,cAAAH,EACA,iBAAAE,EACA,OAAAH,EACA,YAAAU,EACA,iBAAAO,EACA,YAAAC,EACA,SAAAC,EACA,2BAAAa,EACA,8BAAAC,EACA,wBAAA5B,EACA,2BAAAC,EACA,kBAAAc,EACA,qBAAAC,EACA,UAAAC,EACA,gBAAAC,EACA,kBAAAC,EACA,gBAAAC,EACA,mBAAAC,EACA,kBAAAC,EACA,0BAAAC,EACA,SAAAC,EACA,cAAAC,EACA,iBAAAC,EACA,SAAAG,EACA,YAAAC,CACF,EAEC,SAAAvC,EACH,CAEJ,EAEA,IAAOwC,GAAQ9C",
|
|
6
|
+
"names": ["jsx", "createContext", "useContext", "useState", "useEffect", "BizProductContext", "useBizProductContext", "ProductProvider", "product", "isLogin", "profile", "isMobile", "isDesktop", "children", "renderRating", "freeGift", "exchangePurchase", "bundle", "checkedBundle", "checkedGift", "setCheckedBundle", "setCheckedGift", "checkedExchangePurchase", "setCheckedExchangePurchase", "variant", "selectedOptions", "setSelectedOptions", "compareData", "coupon", "finalPrice", "comparePrice", "totalSavings", "savingDetail", "setSavingDetail", "selectedVariants", "onAddToCart", "onBuyNow", "creditsRedemption", "memberFunctionResult", "openModal", "openSignInPopup", "openAuthCodePopup", "openSignUpPopup", "renderInstallments", "onUseCouponChange", "onUseMemberDiscountChange", "discount", "buyNowLoading", "addToCartLoading", "joinedRecommendBuyProducts", "setJoinedRecommendBuyProducts", "addOrder", "setAddOrder", "BizProductProvider_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Button as i,Picture as
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Button as i,Picture as r,Text as p}from"../../../../components/index.js";import{useAiuiContext as x}from"../../../AiuiProvider/index.js";import{cn as c}from"../../../../helpers/index.js";const d=s=>{const{className:n,setOpenShippingPolicyModal:a,metafields:t}=s,{copyWriting:l}=x();return o("div",{tabIndex:-1,className:c("from-4.29% to-101.05% laptop:rounded-2xl laptop:py-5 relative items-start gap-[16px] overflow-hidden rounded-xl bg-gradient-to-r from-[rgba(215,245,254,0.24)] to-[rgba(215,245,254,0.80)] p-4 text-[#1F2021] md:py-[16px]","flex flex-col",n),children:[e(r,{source:t?.shippingPolicyIcon,className:"absolute -bottom-10 -right-10 z-[1] size-[150px]"}),o("div",{className:"relative z-10 flex w-full items-start justify-between",children:[o("div",{className:"laptop:gap-2 lg-desktop:gap-4 flex flex-col gap-3",children:[e(p,{size:2,className:"laptop:text-[16px] lg-desktop:text-[18px] text-[14px]",children:t?.shippingPolicyTitle}),e(p,{size:1,as:"p",className:"laptop:text-[14px] text-[12px] text-[#6D6D6F]",children:t?.loginBeforeCheckoutNote})]}),e(i,{variant:"link",className:"laptop:inline-flex hidden whitespace-nowrap !p-0",onClick:()=>{a(!0)},children:l?.learnMore})]}),e(i,{variant:"link",className:"laptop:hidden inline-flex p-0",onClick:()=>{a(!0)},children:l?.learnMore})]})};var u=d;export{u as default};
|
|
2
2
|
//# sourceMappingURL=LearnMore.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/biz-components/Listing/components/PaidShipping/LearnMore.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Button, Picture, Text } from '../../../../components/index.js'\nimport { useAiuiContext } from '../../../AiuiProvider/index.js'\nimport { cn } from '../../../../helpers/index.js'\n\nconst LearnMore = (props: any) => {\n const { className, setOpenShippingPolicyModal, metafields } = props\n const {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "Button", "Picture", "Text", "useAiuiContext", "cn", "LearnMore", "props", "className", "setOpenShippingPolicyModal", "metafields", "
|
|
4
|
+
"sourcesContent": ["import { Button, Picture, Text } from '../../../../components/index.js'\nimport { useAiuiContext } from '../../../AiuiProvider/index.js'\nimport { cn } from '../../../../helpers/index.js'\n\nconst LearnMore = (props: any) => {\n const { className, setOpenShippingPolicyModal, metafields } = props\n const { copyWriting } = useAiuiContext()\n\n return (\n <div\n tabIndex={-1}\n className={cn(\n 'from-4.29% to-101.05% laptop:rounded-2xl laptop:py-5 relative items-start gap-[16px] overflow-hidden rounded-xl bg-gradient-to-r from-[rgba(215,245,254,0.24)] to-[rgba(215,245,254,0.80)] p-4 text-[#1F2021] md:py-[16px]',\n 'flex flex-col',\n className\n )}\n >\n <Picture source={metafields?.shippingPolicyIcon} className=\"absolute -bottom-10 -right-10 z-[1] size-[150px]\" />\n <div className=\"relative z-10 flex w-full items-start justify-between\">\n <div className=\"laptop:gap-2 lg-desktop:gap-4 flex flex-col gap-3\">\n <Text size={2} className=\"laptop:text-[16px] lg-desktop:text-[18px] text-[14px]\">\n {metafields?.shippingPolicyTitle}\n </Text>\n <Text size={1} as=\"p\" className=\"laptop:text-[14px] text-[12px] text-[#6D6D6F]\">\n {metafields?.loginBeforeCheckoutNote}\n </Text>\n </div>\n <Button\n variant=\"link\"\n className=\"laptop:inline-flex hidden whitespace-nowrap !p-0\"\n onClick={() => {\n setOpenShippingPolicyModal(true)\n }}\n >\n {copyWriting?.learnMore}\n </Button>\n </div>\n\n <Button\n variant=\"link\"\n className=\"laptop:hidden inline-flex p-0\"\n onClick={() => {\n setOpenShippingPolicyModal(true)\n }}\n >\n {copyWriting?.learnMore}\n </Button>\n </div>\n )\n}\n\nexport default LearnMore\n"],
|
|
5
|
+
"mappings": "AAiBM,cAAAA,EAEE,QAAAC,MAFF,oBAjBN,OAAS,UAAAC,EAAQ,WAAAC,EAAS,QAAAC,MAAY,kCACtC,OAAS,kBAAAC,MAAsB,iCAC/B,OAAS,MAAAC,MAAU,+BAEnB,MAAMC,EAAaC,GAAe,CAChC,KAAM,CAAE,UAAAC,EAAW,2BAAAC,EAA4B,WAAAC,CAAW,EAAIH,EACxD,CAAE,YAAAI,CAAY,EAAIP,EAAe,EAEvC,OACEJ,EAAC,OACC,SAAU,GACV,UAAWK,EACT,6NACA,gBACAG,CACF,EAEA,UAAAT,EAACG,EAAA,CAAQ,OAAQQ,GAAY,mBAAoB,UAAU,mDAAmD,EAC9GV,EAAC,OAAI,UAAU,wDACb,UAAAA,EAAC,OAAI,UAAU,oDACb,UAAAD,EAACI,EAAA,CAAK,KAAM,EAAG,UAAU,wDACtB,SAAAO,GAAY,oBACf,EACAX,EAACI,EAAA,CAAK,KAAM,EAAG,GAAG,IAAI,UAAU,gDAC7B,SAAAO,GAAY,wBACf,GACF,EACAX,EAACE,EAAA,CACC,QAAQ,OACR,UAAU,mDACV,QAAS,IAAM,CACbQ,EAA2B,EAAI,CACjC,EAEC,SAAAE,GAAa,UAChB,GACF,EAEAZ,EAACE,EAAA,CACC,QAAQ,OACR,UAAU,gCACV,QAAS,IAAM,CACbQ,EAA2B,EAAI,CACjC,EAEC,SAAAE,GAAa,UAChB,GACF,CAEJ,EAEA,IAAOC,EAAQN",
|
|
6
|
+
"names": ["jsx", "jsxs", "Button", "Picture", "Text", "useAiuiContext", "cn", "LearnMore", "props", "className", "setOpenShippingPolicyModal", "metafields", "copyWriting", "LearnMore_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as o,jsxs as
|
|
1
|
+
import{jsx as o,jsxs as n}from"react/jsx-runtime";import{formatPrice as c}from"../../utils/index.js";import{useAiuiContext as u}from"../../../AiuiProvider/index.js";import{Text as r}from"../../../../components/index.js";import{cn as t}from"../../../../helpers/index.js";import{ShippingMethodMode as f}from"./type.js";const y=({item:e,index:p,active:d,toggleShipping:a,currencyCode:i,metafields:x,className:s=""})=>{const{copyWriting:m,locale:b="us"}=u();return n("div",{role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&a(e,p)},className:t("laptop:rounded-2xl laptop:py-5 relative flex cursor-pointer justify-between gap-[16px] overflow-hidden rounded-xl border-2 border-[#E8E8E8] p-4 text-[#1F2021]",{"cursor-not-allowed opacity-60":e.disabled,"border-brand":d},s),onClick:()=>a(e,p),children:[n("div",{className:"relative",children:[o(r,{className:t("laptop:text-[16px] lg-desktop:text-[18px] text-[14px] font-bold leading-[1.4]",{}),as:"p",html:e.title}),o(r,{className:t("laptop:text-[14px] mt-[8px] text-[12px] font-bold leading-[1.4] text-[#6D6D6F]",{}),as:"p",html:e.subtitle})]}),o(r,{className:t("relative my-auto h-fit text-xl font-bold",{}),as:"p",html:e.price?c({amount:e.price,currencyCode:i,locale:b,removeTrailingZeros:!0}):m?.free}),e.mode!==f.FREE&&o("div",{className:t("bg-brand absolute -right-px -top-px rounded-bl-[8px] rounded-tr-[8px] px-[8px] py-[3px] text-[12px] font-bold leading-[1.4] text-white"),children:x?.memberOnly})]})};var w=y;export{w as default};
|
|
2
2
|
//# sourceMappingURL=ShippingMethod.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/biz-components/Listing/components/PaidShipping/ShippingMethod.tsx"],
|
|
4
|
-
"sourcesContent": ["import { formatPrice } from '../../utils/index.js'\nimport { useAiuiContext } from '../../../AiuiProvider/index.js'\nimport { Text } from '../../../../components/index.js'\nimport { cn } from '../../../../helpers/index.js'\nimport { ShippingMethodMode } from './type.js'\n\nconst ShippingMethod = ({\n item,\n index,\n active,\n toggleShipping,\n currencyCode,\n metafields,\n className = '',\n}: {\n item: any\n index: number\n active: boolean\n toggleShipping: (item: any, index: number) => void\n currencyCode: string\n metafields: any\n className?: string\n}) => {\n const {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "formatPrice", "useAiuiContext", "Text", "cn", "ShippingMethodMode", "ShippingMethod", "item", "index", "active", "toggleShipping", "currencyCode", "metafields", "className", "
|
|
4
|
+
"sourcesContent": ["import { formatPrice } from '../../utils/index.js'\nimport { useAiuiContext } from '../../../AiuiProvider/index.js'\nimport { Text } from '../../../../components/index.js'\nimport { cn } from '../../../../helpers/index.js'\nimport { ShippingMethodMode } from './type.js'\n\nconst ShippingMethod = ({\n item,\n index,\n active,\n toggleShipping,\n currencyCode,\n metafields,\n className = '',\n}: {\n item: any\n index: number\n active: boolean\n toggleShipping: (item: any, index: number) => void\n currencyCode: string\n metafields: any\n className?: string\n}) => {\n const { copyWriting, locale = 'us' } = useAiuiContext()\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n toggleShipping(item, index)\n }\n }}\n className={cn(\n 'laptop:rounded-2xl laptop:py-5 relative flex cursor-pointer justify-between gap-[16px] overflow-hidden rounded-xl border-2 border-[#E8E8E8] p-4 text-[#1F2021]',\n {\n 'cursor-not-allowed opacity-60': item.disabled,\n 'border-brand': active,\n },\n className\n )}\n onClick={() => toggleShipping(item, index)}\n >\n <div className=\"relative\">\n <Text\n className={cn('laptop:text-[16px] lg-desktop:text-[18px] text-[14px] font-bold leading-[1.4]', {})}\n as=\"p\"\n html={item.title}\n />\n <Text\n className={cn('laptop:text-[14px] mt-[8px] text-[12px] font-bold leading-[1.4] text-[#6D6D6F]', {})}\n as=\"p\"\n html={item.subtitle}\n />\n </div>\n\n <Text\n className={cn('relative my-auto h-fit text-xl font-bold', {})}\n as=\"p\"\n html={\n item.price\n ? formatPrice({\n amount: item.price,\n currencyCode,\n locale,\n removeTrailingZeros: true,\n })\n : copyWriting?.free\n }\n />\n {item.mode !== ShippingMethodMode.FREE && (\n <div\n className={cn(\n 'bg-brand absolute -right-px -top-px rounded-bl-[8px] rounded-tr-[8px] px-[8px] py-[3px] text-[12px] font-bold leading-[1.4] text-white'\n )}\n >\n {metafields?.memberOnly}\n </div>\n )}\n </div>\n )\n}\n\nexport default ShippingMethod\n"],
|
|
5
|
+
"mappings": "AA4CM,OACE,OAAAA,EADF,QAAAC,MAAA,oBA5CN,OAAS,eAAAC,MAAmB,uBAC5B,OAAS,kBAAAC,MAAsB,iCAC/B,OAAS,QAAAC,MAAY,kCACrB,OAAS,MAAAC,MAAU,+BACnB,OAAS,sBAAAC,MAA0B,YAEnC,MAAMC,EAAiB,CAAC,CACtB,KAAAC,EACA,MAAAC,EACA,OAAAC,EACA,eAAAC,EACA,aAAAC,EACA,WAAAC,EACA,UAAAC,EAAY,EACd,IAQM,CACJ,KAAM,CAAE,YAAAC,EAAa,OAAAC,EAAS,IAAK,EAAIb,EAAe,EAEtD,OACEF,EAAC,OACC,KAAK,SACL,SAAU,EACV,UAAWgB,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,MACjCN,EAAeH,EAAMC,CAAK,CAE9B,EACA,UAAWJ,EACT,kKACA,CACE,gCAAiCG,EAAK,SACtC,eAAgBE,CAClB,EACAI,CACF,EACA,QAAS,IAAMH,EAAeH,EAAMC,CAAK,EAEzC,UAAAR,EAAC,OAAI,UAAU,WACb,UAAAD,EAACI,EAAA,CACC,UAAWC,EAAG,gFAAiF,CAAC,CAAC,EACjG,GAAG,IACH,KAAMG,EAAK,MACb,EACAR,EAACI,EAAA,CACC,UAAWC,EAAG,iFAAkF,CAAC,CAAC,EAClG,GAAG,IACH,KAAMG,EAAK,SACb,GACF,EAEAR,EAACI,EAAA,CACC,UAAWC,EAAG,2CAA4C,CAAC,CAAC,EAC5D,GAAG,IACH,KACEG,EAAK,MACDN,EAAY,CACV,OAAQM,EAAK,MACb,aAAAI,EACA,OAAAI,EACA,oBAAqB,EACvB,CAAC,EACDD,GAAa,KAErB,EACCP,EAAK,OAASF,EAAmB,MAChCN,EAAC,OACC,UAAWK,EACT,wIACF,EAEC,SAAAQ,GAAY,WACf,GAEJ,CAEJ,EAEA,IAAOK,EAAQX",
|
|
6
|
+
"names": ["jsx", "jsxs", "formatPrice", "useAiuiContext", "Text", "cn", "ShippingMethodMode", "ShippingMethod", "item", "index", "active", "toggleShipping", "currencyCode", "metafields", "className", "copyWriting", "locale", "e", "ShippingMethod_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as l}from"react/jsx-runtime";import{Text as o,Link as m}from"../../../../components/index.js";import{Dialog as d,DialogContent as g,DialogHeader as x,DialogTitle as c}from"../../../../components/index.js";const h=({data:e,onClose:p,open:s})=>t(d,{open:s,onOpenChange:p,children:l(g,{overlayClassName:"z-[100]",className:"laptop:top-1/2 laptop:max-w-[90vw] laptop:bottom-auto laptop:-translate-y-1/2 laptop:h-auto laptop:w-[896px] laptop:px-8 bottom-0 top-auto z-[110] h-[calc(100vh-240px)] max-h-[80vh] translate-y-0 gap-0 overflow-hidden overflow-y-auto !py-0 px-4 [&_.dialog-close-button]:focus:!ring-0 [&_.dialog-close-icon]:!size-6 [&_.dialog-close-icon]:text-[#6D6D6F]",children:[t(x,{className:"laptop:pt-4 pb-2 pt-4",children:t(c,{className:"laptop:text-[24px] text-left text-[20px] font-bold",children:e?.title})}),l("div",{className:"laptop:gap-8 laptop:py-8 py-6",children:[t(o,{className:"text-[20px] font-bold leading-[1.2] text-[#1d1d1f] md:text-[16px]",html:e?.shippingCoupon?.title}),t("ul",{className:"mt-3 grid grid-flow-row gap-[4px] font-bold leading-[1.4]",children:e?.shippingCoupon?.list.map((i,a)=>l("li",{className:"flex text-[18px]",children:[l("span",{className:"text-[#86868C]",children:[a+1,"."]}),t("span",{className:"ml-[4px] font-bold text-[#86868C]",children:i})]},a))}),l("div",{className:"mt-[24px] md:mt-[16px]",children:[t(o,{className:"text-[18px] font-bold leading-[1.2] text-[#1d1d1f]",html:e?.shippingService?.title}),t("div",{className:"mt-1 grid w-full grid-cols-2 gap-[12px] md:grid-cols-1",children:e?.shippingService?.list.map((i,a)=>l("div",{className:"rounded-[12px] bg-[#EAEAEC] p-4",children:[t(o,{as:"p",className:"text-base font-bold !leading-[1.2] text-[#1d1d1f]",html:i.title}),t("div",{className:"mt-3 grid grid-flow-row",children:i.list.map((n,r)=>t(o,{as:"p",className:"text-base font-bold text-[#86868C]",children:n},r))})]},a))})]}),t(m,{className:"text-brand-0 mt-8 block text-[16px] font-medium leading-[1.2] underline",href:`${e?.terms?.url}`,children:e?.terms?.text})]})]})});export{h as ShippingPolicyModal};
|
|
2
2
|
//# sourceMappingURL=ShippingPolicyModal.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/biz-components/Listing/components/PaidShipping/ShippingPolicyModal.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Text, Link } from '../../../../components/index.js'\nimport { Dialog, DialogContent, DialogHeader, DialogTitle
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "Text", "Link", "Dialog", "DialogContent", "ShippingPolicyModal", "data", "onClose", "open", "item", "index", "subItem", "subIndex"]
|
|
4
|
+
"sourcesContent": ["import { Text, Link } from '../../../../components/index.js'\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../../../components/index.js'\n\ninterface Terms {\n text: string\n url: string\n}\n\ninterface List {\n title: string\n list: string[]\n}\n\ninterface ShippingService {\n title: string\n list: List[]\n}\n\ninterface Data {\n title: string\n shippingCoupon: List\n shippingService: ShippingService\n terms: Terms\n}\n\ninterface Props {\n data: Data\n onClose: () => void\n open: boolean\n}\n\nexport const ShippingPolicyModal = ({ data, onClose, open }: Props) => {\n return (\n <Dialog open={open} onOpenChange={onClose}>\n <DialogContent\n overlayClassName=\"z-[100]\"\n className=\"laptop:top-1/2 laptop:max-w-[90vw] laptop:bottom-auto laptop:-translate-y-1/2 laptop:h-auto laptop:w-[896px] laptop:px-8 bottom-0 top-auto z-[110] h-[calc(100vh-240px)] max-h-[80vh] translate-y-0 gap-0 overflow-hidden overflow-y-auto !py-0 px-4 [&_.dialog-close-button]:focus:!ring-0 [&_.dialog-close-icon]:!size-6 [&_.dialog-close-icon]:text-[#6D6D6F]\"\n >\n <DialogHeader className=\"laptop:pt-4 pb-2 pt-4\">\n <DialogTitle className=\"laptop:text-[24px] text-left text-[20px] font-bold\">{data?.title}</DialogTitle>\n </DialogHeader>\n <div className=\"laptop:gap-8 laptop:py-8 py-6\">\n <Text\n className=\"text-[20px] font-bold leading-[1.2] text-[#1d1d1f] md:text-[16px]\"\n html={data?.shippingCoupon?.title}\n />\n <ul className=\"mt-3 grid grid-flow-row gap-[4px] font-bold leading-[1.4]\">\n {data?.shippingCoupon?.list.map((item, index) => (\n <li className=\"flex text-[18px]\" key={index}>\n <span className=\"text-[#86868C]\">{index + 1}.</span>\n <span className=\"ml-[4px] font-bold text-[#86868C]\">{item}</span>\n </li>\n ))}\n </ul>\n <div className=\"mt-[24px] md:mt-[16px]\">\n <Text className=\"text-[18px] font-bold leading-[1.2] text-[#1d1d1f]\" html={data?.shippingService?.title} />\n <div className=\"mt-1 grid w-full grid-cols-2 gap-[12px] md:grid-cols-1\">\n {data?.shippingService?.list.map((item, index) => (\n <div className=\"rounded-[12px] bg-[#EAEAEC] p-4\" key={index}>\n <Text as=\"p\" className=\"text-base font-bold !leading-[1.2] text-[#1d1d1f]\" html={item.title} />\n <div className=\"mt-3 grid grid-flow-row\">\n {item.list.map((subItem, subIndex) => (\n <Text as=\"p\" className=\"text-base font-bold text-[#86868C]\" key={subIndex}>\n {subItem}\n </Text>\n ))}\n </div>\n </div>\n ))}\n </div>\n </div>\n\n <Link\n className=\"text-brand-0 mt-8 block text-[16px] font-medium leading-[1.2] underline\"\n href={`${data?.terms?.url}`}\n >\n {data?.terms?.text}\n </Link>\n </div>\n </DialogContent>\n </Dialog>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAuCU,cAAAA,EAUM,QAAAC,MAVN,oBAvCV,OAAS,QAAAC,EAAM,QAAAC,MAAY,kCAC3B,OAAS,UAAAC,EAAQ,iBAAAC,EAAe,gBAAAC,EAAc,eAAAC,MAAmB,kCA8B1D,MAAMC,EAAsB,CAAC,CAAE,KAAAC,EAAM,QAAAC,EAAS,KAAAC,CAAK,IAEtDX,EAACI,EAAA,CAAO,KAAMO,EAAM,aAAcD,EAChC,SAAAT,EAACI,EAAA,CACC,iBAAiB,UACjB,UAAU,oWAEV,UAAAL,EAACM,EAAA,CAAa,UAAU,wBACtB,SAAAN,EAACO,EAAA,CAAY,UAAU,qDAAsD,SAAAE,GAAM,MAAM,EAC3F,EACAR,EAAC,OAAI,UAAU,gCACb,UAAAD,EAACE,EAAA,CACC,UAAU,oEACV,KAAMO,GAAM,gBAAgB,MAC9B,EACAT,EAAC,MAAG,UAAU,4DACX,SAAAS,GAAM,gBAAgB,KAAK,IAAI,CAACG,EAAMC,IACrCZ,EAAC,MAAG,UAAU,mBACZ,UAAAA,EAAC,QAAK,UAAU,iBAAkB,UAAAY,EAAQ,EAAE,KAAC,EAC7Cb,EAAC,QAAK,UAAU,oCAAqC,SAAAY,EAAK,IAFtBC,CAGtC,CACD,EACH,EACAZ,EAAC,OAAI,UAAU,yBACb,UAAAD,EAACE,EAAA,CAAK,UAAU,sDAAsD,KAAMO,GAAM,iBAAiB,MAAO,EAC1GT,EAAC,OAAI,UAAU,yDACZ,SAAAS,GAAM,iBAAiB,KAAK,IAAI,CAACG,EAAMC,IACtCZ,EAAC,OAAI,UAAU,kCACb,UAAAD,EAACE,EAAA,CAAK,GAAG,IAAI,UAAU,oDAAoD,KAAMU,EAAK,MAAO,EAC7FZ,EAAC,OAAI,UAAU,0BACZ,SAAAY,EAAK,KAAK,IAAI,CAACE,EAASC,IACvBf,EAACE,EAAA,CAAK,GAAG,IAAI,UAAU,qCACpB,SAAAY,GAD8DC,CAEjE,CACD,EACH,IARoDF,CAStD,CACD,EACH,GACF,EAEAb,EAACG,EAAA,CACC,UAAU,0EACV,KAAM,GAAGM,GAAM,OAAO,GAAG,GAExB,SAAAA,GAAM,OAAO,KAChB,GACF,GACF,EACF",
|
|
6
|
+
"names": ["jsx", "jsxs", "Text", "Link", "Dialog", "DialogContent", "DialogHeader", "DialogTitle", "ShippingPolicyModal", "data", "onClose", "open", "item", "index", "subItem", "subIndex"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as o,jsxs as T}from"react/jsx-runtime";import{Text as c}from"../../../../components/index.js";import{useCallback as h,useEffect as D,useMemo as b,useState as g}from"react";import{cn as L}from"../../../../helpers/index.js";import O from"./ShippingMethod.js";import{ShippingPolicyModal as z}from"./ShippingPolicyModal.js";import{isWeightAvailable as v}from"./utils.js";import E from"./LearnMore.js";import{useBizProductContext as I}from"../../BizProductProvider.js";import{withLayout as V}from"../../../../shared/Styles.js";const W=({metafields:
|
|
1
|
+
import{jsx as o,jsxs as T}from"react/jsx-runtime";import{Text as c}from"../../../../components/index.js";import{useCallback as h,useEffect as D,useMemo as b,useState as g}from"react";import{cn as L}from"../../../../helpers/index.js";import O from"./ShippingMethod.js";import{ShippingPolicyModal as z}from"./ShippingPolicyModal.js";import{isWeightAvailable as v}from"./utils.js";import E from"./LearnMore.js";import{useBizProductContext as I}from"../../BizProductProvider.js";import{withLayout as V}from"../../../../shared/Styles.js";const W=({metafields:p,productList:m,onShippingInfoChange:u,variant:y,className:P})=>{const{isLogin:w,openSignInPopup:_}=I(),[C,M]=g(!1),[x,N]=g(!1),[k,f]=g(null),S=b(()=>m.reduce((e,i)=>e+(i?.variant?.weight||0),0),[m]),r=h((e,i,n)=>({id:`${e.__code}__${e.price}`,code:e.__code,mode:e.__mode,title:e.title,disabled:!v(i,e),price:e.price,subtitle:e.subtitle,tag:n!==0?p?.memberOnly:"",error:v(i,e)?"":p.overWeightError}),[p?.memberOnly,p.overWeightError]),l=b(()=>{const e=p?.list?.map((i,n)=>r(i,S,n));return e?.reduce((i,n)=>{const d=e.filter(t=>t.code==n.code);let s;return d.every(t=>t.disabled)?s=d[d.length-1]:s=d.find(t=>!t.disabled),i.find(t=>s.id===t.id)?i:[...i,s]},[])},[r,p?.list,S]),a=h(e=>{u({selected_delivery_code:e.code,selected_delivery_mode:e.mode})},[u]);D(()=>{if(p?.list?.length>0&&!x){const e=r(p?.list[0],0,0);f(e),a(e),N(!0)}},[r,p?.list,a,x]);const A=h(e=>{e.disabled||(f(e),a(e))},[w,l,y.sku,a,_]);return T("div",{id:"ipc-product-paid-shipping",className:L(" laptop-md:mt-[96px] lg-desktop:mt-[128px] tablet:px-8 laptop:px-16 laptop-md:px-0 mt-16 px-4",P),children:[o("div",{className:"flex flex-wrap justify-between space-x-2 md:space-x-1",children:o(c,{className:"text-[16px] font-bold leading-[1.2] text-[#1F2021]",html:p?.title})}),T("div",{className:"lg-desktop:mt-[16px] laptop-md:flex-nowrap mt-[12px] flex flex-wrap gap-[12px] overflow-hidden",children:[l.map((e,i)=>o(O,{index:i,item:e,active:k?.code===e.code,toggleShipping:()=>A(e),currencyCode:y.price.currencyCode,metafields:p,className:"laptop:w-[calc(50%-6px)] laptop-md:flex-1 w-full"},i)),o(E,{setOpenShippingPolicyModal:M,metafields:p,className:"laptop:w-[calc(50%-6px)] laptop-md:w-[calc(33.33%-16px)] lg-desktop:w-[calc(33.33%-24px)] w-full"})]}),l.find(e=>e?.error)&&o(c,{className:"laptop-md:mt-[16px] mt-[12px] font-bold leading-[1.4] text-[#D41435]",html:l.find(e=>e.error)?.error,as:"p"}),p?.seeAvailableArea&&o(c,{as:"div",className:"mt-[16px] font-bold leading-[1.4] text-[#1D1D1F] [&_a]:underline",html:p?.seeAvailableArea}),p?.shippingPolicy&&o(z,{data:p?.shippingPolicy,onClose:()=>M(!1),open:C})]})};var U=V(W);export{U 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/PaidShipping/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Container, Text } from '../../../../components/index.js'\nimport type { Product, ProductVariant } from '../../types/product'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { cn } from '../../../../helpers/index.js'\n\nimport ShippingMethod from './ShippingMethod.js'\nimport { ShippingPolicyModal } from './ShippingPolicyModal.js'\nimport type { DeliveryCustom, shippingMetafields, ShippingMethodType } from './type'\nimport { isWeightAvailable } from './utils.js'\nimport LearnMore from './LearnMore.js'\nimport { useBizProductContext } from '../../BizProductProvider.js'\nimport { withLayout } from '../../../../shared/Styles.js'\n\nconst PaidShipping = ({\n metafields,\n productList,\n onShippingInfoChange,\n variant,\n className,\n}: {\n metafields: any\n productList: Array<Product & { variant: ProductVariant }>\n variant: ProductVariant\n onShippingInfoChange: (deliveryCustom: DeliveryCustom) => void\n className?: string\n}) => {\n const { isLogin, openSignInPopup } = useBizProductContext()\n const [openShippingPolicyModal, setOpenShippingPolicyModal] = useState(false)\n const [init, setInit] = useState(false)\n\n const [selectedMethod, setSelectedMethod] = useState<ShippingMethodType | null>(null)\n\n const weight = useMemo(() => {\n return productList.reduce((acc, product) => acc + (product?.variant?.weight || 0), 0)\n }, [productList])\n\n const normalizedMethod = useCallback(\n (method: shippingMetafields, weight: number, index: number) => {\n return {\n id: `${method.__code}__${method.price}`,\n code: method.__code,\n mode: method.__mode,\n title: method.title,\n disabled: !isWeightAvailable(weight, method),\n price: method.price,\n subtitle: method.subtitle,\n tag: index !== 0 ? metafields?.memberOnly : '',\n error: !isWeightAvailable(weight, method) ? metafields.overWeightError : '',\n }\n },\n [metafields?.memberOnly, metafields.overWeightError]\n )\n\n const list = useMemo(() => {\n const normalizedList: ShippingMethodType[] = metafields?.list?.map((method: shippingMetafields, index: number) =>\n normalizedMethod(method, weight, index)\n )\n\n return normalizedList?.reduce((prev: ShippingMethodType[], method: ShippingMethodType) => {\n // \u5982\u679C\u8D85\u91CD\uFF0C\u540C\u4E00\u4E2A\u7269\u6D41\u9009\u9879\u7C7B\u578B\u4E0B\uFF0C\u5C55\u793A\u5176\u4E2D\u4E00\u4E2A\u4E14\u4E0D\u53EF\u9009\n const sameTypeMethod = normalizedList.filter((m: ShippingMethodType) => m.code == method.code)\n let availableMethod: ShippingMethodType\n // \u6240\u6709\u7269\u6D41\u9009\u9879\u90FD\u4E0D\u53EF\u9009\n if (sameTypeMethod.every((m: ShippingMethodType) => m.disabled)) {\n availableMethod = sameTypeMethod[sameTypeMethod.length - 1]\n } else {\n // \u53EF\u9009\u7269\u6D41\u9009\u9879\n availableMethod = sameTypeMethod.find((m: ShippingMethodType) => !m.disabled)!\n }\n // \u5F53\u524D\u7269\u6D41\u9009\u9879\u5DF2\u5B58\u5728\n const hasSameMethod = prev.find((m: ShippingMethodType) => availableMethod.id === m.id)\n if (!hasSameMethod) {\n return [...prev, availableMethod]\n } else {\n return prev\n }\n }, [] as ShippingMethodType[])\n }, [normalizedMethod, metafields?.list, weight])\n\n const handleChangeShippingInfo = useCallback(\n (selectedMethod: ShippingMethodType) => {\n onShippingInfoChange({\n selected_delivery_code: selectedMethod.code,\n selected_delivery_mode: selectedMethod.mode,\n })\n },\n [onShippingInfoChange]\n )\n\n useEffect(() => {\n // \u9ED8\u8BA4\u9009\u4E2D\u7B2C\u4E00\u4E2A\u7269\u6D41\u9009\u9879\n if (metafields?.list?.length > 0 && !init) {\n const standardShippingMethod = normalizedMethod(metafields?.list[0], 0, 0)\n setSelectedMethod(standardShippingMethod)\n handleChangeShippingInfo(standardShippingMethod)\n setInit(true)\n }\n }, [normalizedMethod, metafields?.list, handleChangeShippingInfo, init])\n\n const toggleShipping = useCallback(\n (method: ShippingMethodType) => {\n if (method.disabled) {\n return\n }\n setSelectedMethod(method)\n handleChangeShippingInfo(method)\n // gaTrack({\n // event: 'ga4Event',\n // event_name: 'lp_button',\n // member_active_status: isLogin ? 'active' : 'not active', //\u7528\u4E8E\u8F93\u5165code\u6FC0\u6D3B\u4F1A\u5458\u5F39'\u7A97\u7684\u6309\u94AE\uFF0C\u533A\u5206\u4F1A\u5458\u6FC0\u6D3B\u72B6\u6001\uFF0C\u4F20active\u6216not active\n // event_parameters: {\n // page_group: 'Product Detail Page' + variant.sku, //\u5982\u679C\u662F\u9996\u9875\uFF0C\u5219\u4F20\"Home Page\";\u5982\u679C\u662Flisting\u7684\u9996\u5C4F\u6309\u94AE\uFF0C\u4F20Product Detail Page+$SKU\n // position: 'masterbanner1', //\u4F4D\u7F6E\u6807\u8BB0\u3002\u9996\u9875\u9996\u5C4F\u8F6E\u64AD\u4F4D\u7F6E\u4F20masterbanner1\u3001masterbanner2\u3001masterbanner3\uFF0C\u7B2C\u4E8C\u5C4F\u4F202nd_banner\uFF0C\u7B2C\u4E09\u5C4F\u4F203rd_banner\uFF0C\u6216\u8005\u53D6\u8BE5\u6A21\u5757\u5C0F\u6807\u9898\uFF0C\u6216\u80FD\u8BC6\u522B\u51FA\u662F\u54EA\u4E2A\u6A21\u5757\u4F4D\u7F6E\u7684\u6587\u6848\uFF0C\u5F39\u7A97\u4F20pop;\u5982\u679C\u662F\u8D2D\u7269\u8F66\u4FA7\u8FB9\u680F\uFF0C\u5219\u4F20\"Cart Pop Up\"\n // button_name: method.title, //\u53D6\u6309\u94AE\u6587\u6848\uFF0C\u6216\u80FD\u8BC6\u522B\u51FA\u662F\u54EA\u4E2A\u6309\u94AE\u7684\u6587\u6848,\u6BD4\u5982\u53F3\u4E0A\u89D2\u5173\u95ED\u4F20close,\u793E\u5A92\u5206\u4EAB\u56FE\u6807\u4F20\u5BF9\u5E94\u5E73\u53F0\u540D\u5B57\u5982Facebook,\u56FE\u7247\u5207\u6362\u5219\u4F20\u5BF9\u5E94\u5C55\u793A\u56FE\u7247\u7684\u540D\u5B57\n // info: '', //\u9ED8\u8BA4\u7A7A\u503C\uFF0C\u4E00\u822C\u4F20\u590D\u9009\u6846\u7684\u6587\u6848\u5185\u5BB9\uFF0C\u7279\u6B8A\u60C5\u51B5\u53EF\u6307\u5B9Ainfo\u503C\n // },\n // })\n },\n\n [isLogin, list, variant.sku, handleChangeShippingInfo, openSignInPopup]\n )\n\n return (\n <div\n id=\"ipc-product-paid-shipping\"\n className={cn(\n '
|
|
5
|
-
"mappings": "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
|
|
4
|
+
"sourcesContent": ["import { Container, Text } from '../../../../components/index.js'\nimport type { Product, ProductVariant } from '../../types/product'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { cn } from '../../../../helpers/index.js'\n\nimport ShippingMethod from './ShippingMethod.js'\nimport { ShippingPolicyModal } from './ShippingPolicyModal.js'\nimport type { DeliveryCustom, shippingMetafields, ShippingMethodType } from './type'\nimport { isWeightAvailable } from './utils.js'\nimport LearnMore from './LearnMore.js'\nimport { useBizProductContext } from '../../BizProductProvider.js'\nimport { withLayout } from '../../../../shared/Styles.js'\n\nconst PaidShipping = ({\n metafields,\n productList,\n onShippingInfoChange,\n variant,\n className,\n}: {\n metafields: any\n productList: Array<Product & { variant: ProductVariant }>\n variant: ProductVariant\n onShippingInfoChange: (deliveryCustom: DeliveryCustom) => void\n className?: string\n}) => {\n const { isLogin, openSignInPopup } = useBizProductContext()\n const [openShippingPolicyModal, setOpenShippingPolicyModal] = useState(false)\n const [init, setInit] = useState(false)\n\n const [selectedMethod, setSelectedMethod] = useState<ShippingMethodType | null>(null)\n\n const weight = useMemo(() => {\n return productList.reduce((acc, product) => acc + (product?.variant?.weight || 0), 0)\n }, [productList])\n\n const normalizedMethod = useCallback(\n (method: shippingMetafields, weight: number, index: number) => {\n return {\n id: `${method.__code}__${method.price}`,\n code: method.__code,\n mode: method.__mode,\n title: method.title,\n disabled: !isWeightAvailable(weight, method),\n price: method.price,\n subtitle: method.subtitle,\n tag: index !== 0 ? metafields?.memberOnly : '',\n error: !isWeightAvailable(weight, method) ? metafields.overWeightError : '',\n }\n },\n [metafields?.memberOnly, metafields.overWeightError]\n )\n\n const list = useMemo(() => {\n const normalizedList: ShippingMethodType[] = metafields?.list?.map((method: shippingMetafields, index: number) =>\n normalizedMethod(method, weight, index)\n )\n\n return normalizedList?.reduce((prev: ShippingMethodType[], method: ShippingMethodType) => {\n // \u5982\u679C\u8D85\u91CD\uFF0C\u540C\u4E00\u4E2A\u7269\u6D41\u9009\u9879\u7C7B\u578B\u4E0B\uFF0C\u5C55\u793A\u5176\u4E2D\u4E00\u4E2A\u4E14\u4E0D\u53EF\u9009\n const sameTypeMethod = normalizedList.filter((m: ShippingMethodType) => m.code == method.code)\n let availableMethod: ShippingMethodType\n // \u6240\u6709\u7269\u6D41\u9009\u9879\u90FD\u4E0D\u53EF\u9009\n if (sameTypeMethod.every((m: ShippingMethodType) => m.disabled)) {\n availableMethod = sameTypeMethod[sameTypeMethod.length - 1]\n } else {\n // \u53EF\u9009\u7269\u6D41\u9009\u9879\n availableMethod = sameTypeMethod.find((m: ShippingMethodType) => !m.disabled)!\n }\n // \u5F53\u524D\u7269\u6D41\u9009\u9879\u5DF2\u5B58\u5728\n const hasSameMethod = prev.find((m: ShippingMethodType) => availableMethod.id === m.id)\n if (!hasSameMethod) {\n return [...prev, availableMethod]\n } else {\n return prev\n }\n }, [] as ShippingMethodType[])\n }, [normalizedMethod, metafields?.list, weight])\n\n const handleChangeShippingInfo = useCallback(\n (selectedMethod: ShippingMethodType) => {\n onShippingInfoChange({\n selected_delivery_code: selectedMethod.code,\n selected_delivery_mode: selectedMethod.mode,\n })\n },\n [onShippingInfoChange]\n )\n\n useEffect(() => {\n // \u9ED8\u8BA4\u9009\u4E2D\u7B2C\u4E00\u4E2A\u7269\u6D41\u9009\u9879\n if (metafields?.list?.length > 0 && !init) {\n const standardShippingMethod = normalizedMethod(metafields?.list[0], 0, 0)\n setSelectedMethod(standardShippingMethod)\n handleChangeShippingInfo(standardShippingMethod)\n setInit(true)\n }\n }, [normalizedMethod, metafields?.list, handleChangeShippingInfo, init])\n\n const toggleShipping = useCallback(\n (method: ShippingMethodType) => {\n if (method.disabled) {\n return\n }\n setSelectedMethod(method)\n handleChangeShippingInfo(method)\n // gaTrack({\n // event: 'ga4Event',\n // event_name: 'lp_button',\n // member_active_status: isLogin ? 'active' : 'not active', //\u7528\u4E8E\u8F93\u5165code\u6FC0\u6D3B\u4F1A\u5458\u5F39'\u7A97\u7684\u6309\u94AE\uFF0C\u533A\u5206\u4F1A\u5458\u6FC0\u6D3B\u72B6\u6001\uFF0C\u4F20active\u6216not active\n // event_parameters: {\n // page_group: 'Product Detail Page' + variant.sku, //\u5982\u679C\u662F\u9996\u9875\uFF0C\u5219\u4F20\"Home Page\";\u5982\u679C\u662Flisting\u7684\u9996\u5C4F\u6309\u94AE\uFF0C\u4F20Product Detail Page+$SKU\n // position: 'masterbanner1', //\u4F4D\u7F6E\u6807\u8BB0\u3002\u9996\u9875\u9996\u5C4F\u8F6E\u64AD\u4F4D\u7F6E\u4F20masterbanner1\u3001masterbanner2\u3001masterbanner3\uFF0C\u7B2C\u4E8C\u5C4F\u4F202nd_banner\uFF0C\u7B2C\u4E09\u5C4F\u4F203rd_banner\uFF0C\u6216\u8005\u53D6\u8BE5\u6A21\u5757\u5C0F\u6807\u9898\uFF0C\u6216\u80FD\u8BC6\u522B\u51FA\u662F\u54EA\u4E2A\u6A21\u5757\u4F4D\u7F6E\u7684\u6587\u6848\uFF0C\u5F39\u7A97\u4F20pop;\u5982\u679C\u662F\u8D2D\u7269\u8F66\u4FA7\u8FB9\u680F\uFF0C\u5219\u4F20\"Cart Pop Up\"\n // button_name: method.title, //\u53D6\u6309\u94AE\u6587\u6848\uFF0C\u6216\u80FD\u8BC6\u522B\u51FA\u662F\u54EA\u4E2A\u6309\u94AE\u7684\u6587\u6848,\u6BD4\u5982\u53F3\u4E0A\u89D2\u5173\u95ED\u4F20close,\u793E\u5A92\u5206\u4EAB\u56FE\u6807\u4F20\u5BF9\u5E94\u5E73\u53F0\u540D\u5B57\u5982Facebook,\u56FE\u7247\u5207\u6362\u5219\u4F20\u5BF9\u5E94\u5C55\u793A\u56FE\u7247\u7684\u540D\u5B57\n // info: '', //\u9ED8\u8BA4\u7A7A\u503C\uFF0C\u4E00\u822C\u4F20\u590D\u9009\u6846\u7684\u6587\u6848\u5185\u5BB9\uFF0C\u7279\u6B8A\u60C5\u51B5\u53EF\u6307\u5B9Ainfo\u503C\n // },\n // })\n },\n\n [isLogin, list, variant.sku, handleChangeShippingInfo, openSignInPopup]\n )\n\n return (\n <div\n id=\"ipc-product-paid-shipping\"\n className={cn(\n ' laptop-md:mt-[96px] lg-desktop:mt-[128px] tablet:px-8 laptop:px-16 laptop-md:px-0 mt-16 px-4',\n className\n )}\n >\n <div className=\"flex flex-wrap justify-between space-x-2 md:space-x-1\">\n <Text className=\"text-[16px] font-bold leading-[1.2] text-[#1F2021]\" html={metafields?.title}></Text>\n {/* <button\n onClick={() => {\n setOpenShippingPolicyModal(true)\n }}\n className='text-brand-color text-[16px] font-semibold text-[#595959] underline md:text-[14px]'\n >\n {metafields?.policy}\n </button> */}\n </div>\n <div className=\"lg-desktop:mt-[16px] laptop-md:flex-nowrap mt-[12px] flex flex-wrap gap-[12px] overflow-hidden\">\n {list.map((method: ShippingMethodType, index: number) => (\n <ShippingMethod\n key={index}\n index={index}\n item={method}\n active={selectedMethod?.code === method.code}\n toggleShipping={() => toggleShipping(method)}\n currencyCode={variant.price.currencyCode}\n metafields={metafields}\n className=\"laptop:w-[calc(50%-6px)] laptop-md:flex-1 w-full\"\n />\n ))}\n {/* learn more \u5361\u7247 */}\n <LearnMore\n setOpenShippingPolicyModal={setOpenShippingPolicyModal}\n metafields={metafields}\n className=\"laptop:w-[calc(50%-6px)] laptop-md:w-[calc(33.33%-16px)] lg-desktop:w-[calc(33.33%-24px)] w-full\"\n />\n </div>\n {list.find((method: ShippingMethodType) => method?.error) && (\n <Text\n className=\"laptop-md:mt-[16px] mt-[12px] font-bold leading-[1.4] text-[#D41435]\"\n html={list.find((method: ShippingMethodType) => method.error)?.error as string}\n as=\"p\"\n />\n )}\n\n {metafields?.seeAvailableArea && (\n <Text\n as=\"div\"\n className=\"mt-[16px] font-bold leading-[1.4] text-[#1D1D1F] [&_a]:underline\"\n html={metafields?.seeAvailableArea}\n />\n )}\n {metafields?.shippingPolicy && (\n <ShippingPolicyModal\n data={metafields?.shippingPolicy}\n onClose={() => setOpenShippingPolicyModal(false)}\n open={openShippingPolicyModal}\n />\n )}\n </div>\n )\n}\n\nexport default withLayout(PaidShipping)\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["jsx", "jsxs", "Text", "useCallback", "useEffect", "useMemo", "useState", "cn", "ShippingMethod", "ShippingPolicyModal", "isWeightAvailable", "LearnMore", "useBizProductContext", "withLayout", "PaidShipping", "metafields", "productList", "onShippingInfoChange", "variant", "className", "isLogin", "openSignInPopup", "openShippingPolicyModal", "setOpenShippingPolicyModal", "init", "setInit", "selectedMethod", "setSelectedMethod", "weight", "acc", "product", "normalizedMethod", "method", "index", "list", "normalizedList", "prev", "sameTypeMethod", "m", "availableMethod", "handleChangeShippingInfo", "standardShippingMethod", "toggleShipping", "PaidShipping_default"]
|
|
7
7
|
}
|