@anker-in/headless-ui 1.3.20 → 1.3.21
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/EventSchedule/index.d.ts +2 -2
- package/dist/cjs/biz-components/EventSchedule/index.js +1 -1
- package/dist/cjs/biz-components/EventSchedule/index.js.map +3 -3
- 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/PurchaseBar/ProductActions/index.js +1 -1
- package/dist/cjs/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
- package/dist/cjs/biz-components/Specs/index.js +1 -1
- package/dist/cjs/biz-components/Specs/index.js.map +3 -3
- package/dist/esm/biz-components/EventSchedule/index.d.ts +2 -2
- package/dist/esm/biz-components/EventSchedule/index.js +1 -1
- package/dist/esm/biz-components/EventSchedule/index.js.map +3 -3
- 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/PurchaseBar/ProductActions/index.js +1 -1
- package/dist/esm/biz-components/Listing/components/PurchaseBar/ProductActions/index.js.map +3 -3
- package/dist/esm/biz-components/Specs/index.js +1 -1
- package/dist/esm/biz-components/Specs/index.js.map +3 -3
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var Y=Object.create;var h=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ne=(o,a)=>{for(var p in a)h(o,p,{get:a[p],enumerable:!0})},A=(o,a,p,k)=>{if(a&&typeof a=="object"||typeof a=="function")for(let x of ee(a))!se.call(o,x)&&x!==p&&h(o,x,{get:()=>a[x],enumerable:!(k=Z(a,x))||k.enumerable});return o};var F=(o,a,p)=>(p=o!=null?Y(te(o)):{},A(a||!o||!o.__esModule?h(p,"default",{value:o,enumerable:!0}):p,o)),oe=o=>A(h({},"__esModule",{value:!0}),o);var le={};ne(le,{default:()=>ae});module.exports=oe(le);var e=require("react/jsx-runtime"),H=F(require("./dropdown.js")),P=require("../AiuiProvider/index.js"),R=require("react-responsive"),m=require("react"),I=require("../../shared/Styles.js"),_=require("../ShelfDisplay/shelfDisplay.js"),r=require("../../components/index.js"),$=require("../../helpers/index.js"),b=F(require("react"));const j=b.default.forwardRef(({data:o,buildData:a,onChange:p,onSecondaryChange:k,className:x,...O},U)=>{const g=(0,R.useMediaQuery)({query:"(max-width: 768px)"}),[d,w]=(0,m.useState)({}),[y,V]=(0,m.useState)([]),[S,L]=(0,m.useState)(!1),[N,M]=(0,m.useState)({}),D=(0,b.useRef)(null),{locale:B="us",currencyDisplay:z,trackingData:q}=(0,P.useAiuiContext)(),Q=q?.showComparePrice??!0,{LeftMenu:C,RightMenu:E,DefaultSelectMenu:v}=(0,m.useMemo)(()=>o?.data||{},[o?.data]),W=t=>{try{const n=new URL(t).pathname.toLowerCase();return/\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/.test(n)}catch{return/\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/i.test(t)}},G=(t,s)=>{const n=t?.variants?.find?.(f=>f?.sku===t?.sku),l=n?.coupons?.[0],{price:u,basePrice:i}=(0,_.formatVariantPrice)({locale:B||"us",amount:l?l?.variant_price4wscode:n?.price,baseAmount:l?n?.price:0,currencyDisplay:z,currencyCode:t?.price?.currencyCode||"USD"}),c=typeof v?.buttonText=="string"?v?.buttonText:v?.buttonText?.[String(s)]||"";return(0,e.jsxs)("div",{className:"specs-sku-node-wrap box-border",children:[(0,e.jsxs)(r.Text,{className:"md-tablet:p-2 l-tablet:mb-4 l-tablet:text-sm desktop:px-6 lg-desktop:mb-8 lg-desktop:text-lg openDropDown specs-sku-node-text relative mb-6 box-border block rounded-[50px] border border-[#E4E5E6] bg-[#F5F5F7] px-6 py-4 text-base font-bold",onClick:()=>{if(y?.length<=1)return null;M({...N,[s]:!N?.[s]})},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between overflow-hidden",children:[(0,e.jsx)("div",{className:"openDropDown md-tablet:text-sm lg-desktop:text-lg specs-sku-node-title flex-1 truncate text-base",title:d?.[s]?.name||"",children:d?.[s]?.name||""}),y?.length>1?(0,e.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",className:"openDropDown",children:(0,e.jsx)("path",{d:"M6 9.5L12 15.5L18 9.5",stroke:"#1D1D1F",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):null]}),(0,e.jsx)(H.default,{index:s,list:y,active:d,setActive:w,visible:N,setVisible:M})]}),(0,e.jsx)("div",{className:"lg-desktop:max-h-[196px] lg-desktop:max-w-[196px] max-h-[138px] max-w-[138px]",children:(0,e.jsx)(r.Picture,{source:n?.image?.url||"",className:"aspect-h-[280] aspect-w-[280]",imgClassName:"w-full h-full object-cover hover:scale-105 transition-all duration-300"})}),(0,e.jsx)("div",{className:"lg-desktop:text-2xl mb-2 mt-6 text-xl font-bold",children:(0,e.jsx)("div",{className:"lg-desktop:min-h-[32px] flex min-h-[28px] items-center",children:n?.availableForSale?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"specs-sku-node-price text-[#080A0F]",children:u||""}),Q&&i&&(0,e.jsx)("div",{className:"lg-desktop:text-2xl specs-sku-node-base-price ml-1 text-xl text-[#86868C] line-through",children:i})]}):null})}),c?(0,e.jsx)(r.Button,{onClick:()=>{p?.(t,s)},className:"specs-sku-node-button",children:c}):null]})},J=t=>t&&typeof t!="string"?(0,e.jsxs)("div",{className:"size-full",children:[(0,e.jsx)("p",{className:"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm",dangerouslySetInnerHTML:{__html:t?.text||""}}),(0,e.jsx)(r.Picture,{source:t?.imgUrl,className:"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]",imgClassName:"w-full h-full object-cover"})]}):(0,e.jsx)("div",{className:"break-all",children:W(t)?(0,e.jsx)(r.Picture,{source:t,className:"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]",imgClassName:"w-full h-full object-cover"}):(0,e.jsx)("p",{className:"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm",dangerouslySetInnerHTML:{__html:t||""}})}),T=t=>t.map((s,n)=>{const l=n===0;return(0,e.jsxs)("div",{className:"l-tablet:flex l-tablet:flex-col box-border grid w-full cursor-pointer grid-cols-3 overflow-hidden border-t border-t-[#E4E5E6] specs-product-node-wrap",children:[(0,e.jsx)(r.Heading,{as:"h3",html:s||"",className:"tablet:py-6 l-tablet:text-[#86868C] desktop:p-6 lg-desktop:text-lg specs-product-node-title mr-4 flex-1 pt-4 text-base font-bold md:text-sm"}),(0,e.jsx)("div",{className:`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:p-6 lg-desktop:gap-16 grid-cols-${S?3:2} specs-product-node-body col-span-2 grid flex-1 py-6`,children:Object.keys(d)?.map?.(u=>{const i=d?.[u],c=E?.menus?.find?.(f=>f?.handle===i?.handle)?.subTitle;return J(c?.[s])})})]},s)}),K=t=>{if(!d)return;const{subTitle:s,isProduct:n}=t;return n?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"l-tablet:flex l-tablet:flex-col specs-content-item-product box-border grid w-full cursor-pointer grid-cols-3 border-t-0 border-t-[#E4E5E6]",children:[t?.title&&(0,e.jsx)(r.Heading,{as:"h3",html:t?.title||"",className:"l:hidden specs-item-product-title"}),(0,e.jsx)("div",{className:`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:px-6 desktop:pb-6 lg-desktop:gap-16 grid-cols-${S?3:2} specs-item-product-body col-span-2 grid flex-1 pb-4 pr-0`,children:Object.keys(d)?.map((l,u)=>{const i=d?.[l],c=a?.products?.find?.(f=>f?.handle===i?.handle);return(0,e.jsx)("div",{children:G({...c,item:l,sku:i?.sku},u)},l)})})]}),t?.categoryLabel&&(0,e.jsx)(r.Heading,{size:2,as:"h4",html:t?.categoryLabel||"",className:"desktop:p-6 specs-item-product-category py-6"}),s?.length?T(s):null]}):T(s)};return(0,b.useImperativeHandle)(U,()=>D.current),(0,m.useEffect)(()=>{if(!a?.products?.length)return;const t=v?.sku?.split?.(",")||[],s=g&&t?.length>2?t?.slice(0,2):t;let n={};s?.forEach?.((u,i)=>{const c=a?.products?.find?.(f=>{if(f?.variants?.find?.(X=>X?.sku===u))return!0});c&&(n={...n,[i]:{sku:u,name:c?.name||c?.title,handle:c?.handle}})});const l=a?.products?.filter(u=>E?.menus?.find(i=>i?.handle===u?.handle));w(n),V(l),L(t?.length>2&&!g)},[a,g]),(0,m.useEffect)(()=>{if(g){const t=Object.keys(d||{});if(t?.length>2){const s=t?.slice?.(0,2);let n={};s?.forEach?.(l=>{n={...n,[l]:d?.[l]}}),L(!1),w(n)}}},[g]),(0,e.jsx)("div",{...O,className:(0,$.cn)("specs-wrapper w-full overflow-hidden bg-[#F5F5F7]",x),ref:D,children:C?.data?(0,e.jsx)("div",{className:"specs-wrapper-content box-border w-full overflow-hidden",children:C?.data?.map?.((t,s)=>(0,e.jsx)("div",{className:"specs-wrapper-content-item w-full overflow-hidden pt-10 [&:first-child]:pt-0",children:K(t)},s))}):null})});j.displayName="Specs";var ae=(0,I.withLayout)(j);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/Specs/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport DropDown from './dropdown.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { useMediaQuery } from 'react-responsive'\nimport { useMemo, useState, useEffect } from 'react'\nimport { withLayout } from '../../shared/Styles.js'\nimport { formatVariantPrice } from '../ShelfDisplay/shelfDisplay.js'\nimport { Picture, Text, Button, Heading } from '../../components/index.js'\nimport { cn } from '../../helpers/index.js'\nimport React, { useImperativeHandle, useRef } from 'react'\n\nexport interface SpecsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n data?: any\n buildData?: any\n onChange?: (product: any, index: number) => void\n onSecondaryChange?: (data: any) => void\n}\n\nconst Specs = React.forwardRef<HTMLDivElement, SpecsProps>(\n ({ data, buildData, onChange, onSecondaryChange, className, ...rest }, ref) => {\n const isMobile = useMediaQuery({ query: '(max-width: 768px)' })\n\n const [active, setActive] = useState<any>({})\n const [menuList, setMenuList] = useState<any[]>([])\n const [isShowMax, setIsShowMax] = useState<boolean>(false)\n const [visibleActive, setVisibleActive] = useState<{ [key: number]: boolean }>({})\n\n const innerRef = useRef<HTMLDivElement>(null)\n\n const { locale = 'us', currencyDisplay } = useAiuiContext()\n\n const { LeftMenu, RightMenu, DefaultSelectMenu } = useMemo(() => data?.data || {}, [data?.data])\n\n const isImageUrl = (urlPath: string) => {\n try {\n const url = new URL(urlPath)\n const path = url.pathname.toLowerCase()\n return /\\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/.test(path)\n } catch (e) {\n // \u5982\u679C\u4F20\u5165\u7684\u4E0D\u662F\u6709\u6548URL\uFF08\u5982\u76F8\u5BF9\u8DEF\u5F84\uFF09\uFF0C\u76F4\u63A5\u68C0\u67E5\u8DEF\u5F84\n return /\\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/i.test(urlPath)\n }\n }\n\n const skuNode = (product: any, index: number) => {\n const findSku = product?.variants?.find?.((item: any) => item?.sku === product?.sku)\n const coupon = findSku?.coupons?.[0]\n const { price, basePrice } = formatVariantPrice({\n locale: locale || 'us',\n amount: coupon ? coupon?.variant_price4wscode : findSku?.price,\n baseAmount: coupon ? findSku?.price : 0,\n currencyDisplay,\n currencyCode: product?.price?.currencyCode || 'USD',\n })\n const buttonTextValue =\n typeof DefaultSelectMenu?.buttonText === 'string'\n ? DefaultSelectMenu?.buttonText\n : DefaultSelectMenu?.buttonText?.[String(index)] || ''\n return (\n <div className=\"specs-sku-node-wrap box-border\">\n <Text\n className={`md-tablet:p-2 l-tablet:mb-4 l-tablet:text-sm desktop:px-6 lg-desktop:mb-8 lg-desktop:text-lg openDropDown specs-sku-node-text relative mb-6 box-border block rounded-[50px] border border-[#E4E5E6] bg-[#F5F5F7] px-6 py-4 text-base font-bold`}\n onClick={() => {\n if (menuList?.length <= 1) return null\n\n setVisibleActive({\n ...visibleActive,\n [index]: !visibleActive?.[index],\n })\n }}\n >\n <div className=\"flex items-center justify-between overflow-hidden\">\n <div\n className=\"openDropDown md-tablet:text-sm lg-desktop:text-lg specs-sku-node-title flex-1 truncate text-base\"\n title={active?.[index]?.name || ''}\n >\n {active?.[index]?.name || ''}\n </div>\n {menuList?.length > 1 ? (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"25\"\n viewBox=\"0 0 24 25\"\n fill=\"none\"\n className=\"openDropDown\"\n >\n <path\n d=\"M6 9.5L12 15.5L18 9.5\"\n stroke=\"#1D1D1F\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n ) : null}\n </div>\n <DropDown\n index={index}\n list={menuList}\n active={active}\n setActive={setActive}\n visible={visibleActive}\n setVisible={setVisibleActive}\n />\n </Text>\n <div className=\"lg-desktop:max-h-[196px] lg-desktop:max-w-[196px] max-h-[138px] max-w-[138px]\">\n <Picture\n source={findSku?.image?.url || ''}\n className=\"aspect-h-[280] aspect-w-[280]\"\n imgClassName=\"w-full h-full object-cover hover:scale-105 transition-all duration-300\"\n />\n </div>\n <div className=\"lg-desktop:text-2xl mb-2 mt-6 text-xl font-bold\">\n <div className=\"lg-desktop:min-h-[32px] flex min-h-[28px] items-center\">\n {findSku?.availableForSale ? (\n <>\n <div className=\"specs-sku-node-price text-[#080A0F]\">{price || ''}</div>\n {basePrice && (\n <div className=\"lg-desktop:text-2xl specs-sku-node-base-price ml-1 text-xl text-[#86868C] line-through\">\n {basePrice}\n </div>\n )}\n </>\n ) : null}\n </div>\n </div>\n {buttonTextValue ? (\n <Button\n onClick={() => {\n onChange?.(product, index)\n }}\n className=\"specs-sku-node-button\"\n >\n {buttonTextValue}\n </Button>\n ) : null}\n </div>\n )\n }\n\n const normalNode = (v: any) => {\n if (v && typeof v !== 'string') {\n return (\n <div className=\"size-full\">\n <p\n className=\"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm\"\n dangerouslySetInnerHTML={{\n __html: v?.text || '',\n }}\n />\n <Picture\n source={v?.imgUrl}\n className=\"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]\"\n imgClassName=\"w-full h-full object-cover\"\n />\n </div>\n )\n }\n return (\n <div className=\"break-all\">\n {isImageUrl(v) ? (\n <Picture\n source={v}\n className=\"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]\"\n imgClassName=\"w-full h-full object-cover\"\n />\n ) : (\n <p\n className=\"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm\"\n dangerouslySetInnerHTML={{\n __html: v || '',\n }}\n />\n )}\n </div>\n )\n }\n\n const productNode = (data: any) => {\n return data.map((st: any, idx: number) => {\n const isFirstParameter = idx === 0\n return (\n <div\n key={st}\n className={`l-tablet:flex l-tablet:flex-col box-border grid w-full cursor-pointer grid-cols-3 overflow-hidden border-t border-t-[#E4E5E6] ${isFirstParameter ? '' : ''} specs-product-node-wrap`}\n >\n <Heading\n as=\"h3\"\n html={st || ''}\n className=\"tablet:py-6 l-tablet:text-[#86868C] desktop:p-6 lg-desktop:text-lg specs-product-node-title mr-4 flex-1 pt-4 text-base font-bold md:text-sm\"\n />\n <div\n className={`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:p-6 lg-desktop:gap-16 grid-cols-${isShowMax ? 3 : 2} specs-product-node-body col-span-2 grid flex-1 py-6`}\n >\n {Object.keys(active)?.map?.((item: string) => {\n const currentData = active?.[item]\n const currentMenus = RightMenu?.menus?.find?.(\n (item: any) => item?.handle === currentData?.handle\n )?.subTitle\n return normalNode(currentMenus?.[st])\n })}\n </div>\n </div>\n )\n })\n }\n\n // \u5DE6\u4FA7\u6807\u9898\u83DC\u5355\n const childrenNode = (node: any) => {\n if (!active) return\n const { subTitle, isProduct } = node\n // \u5982\u679C\u662F\u4EA7\u54C1\n if (isProduct) {\n return (\n <>\n <div\n className={`l-tablet:flex l-tablet:flex-col specs-content-item-product box-border grid w-full cursor-pointer grid-cols-3 border-t-0 border-t-[#E4E5E6]`}\n >\n {node?.title && (\n <Heading as=\"h3\" html={node?.title || ''} className=\"l:hidden specs-item-product-title\" />\n )}\n <div\n className={`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:px-6 desktop:pb-6 lg-desktop:gap-16 grid-cols-${isShowMax ? 3 : 2} specs-item-product-body col-span-2 grid flex-1 pb-4 pr-0`}\n >\n {Object.keys(active)?.map((item: string, index: number) => {\n const currentData = active?.[item]\n const currentProduct = buildData?.products?.find?.(\n (item: any) => item?.handle === currentData?.handle\n )\n return (\n <div key={item}>{skuNode({ ...currentProduct, item: item, sku: currentData?.sku }, index)}</div>\n )\n })}\n </div>\n </div>\n {node?.categoryLabel && (\n <Heading\n size={2}\n as=\"h4\"\n html={node?.categoryLabel || ''}\n className=\"desktop:p-6 specs-item-product-category py-6\"\n />\n )}\n {subTitle?.length ? productNode(subTitle) : null}\n </>\n )\n }\n return productNode(subTitle)\n }\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n useEffect(() => {\n if (!buildData?.products?.length) return\n const skus = DefaultSelectMenu?.sku?.split?.(',') || []\n const limitedSkus = isMobile && skus?.length > 2 ? skus?.slice(0, 2) : skus\n let currentActive = {}\n limitedSkus?.forEach?.((sku: string, index: number) => {\n const findData = buildData?.products?.find?.((item: any) => {\n const findSku = item?.variants?.find?.((v: any) => v?.sku === sku)\n if (findSku) return true\n })\n if (findData) {\n currentActive = {\n ...currentActive,\n [index]: {\n sku: sku,\n name: findData?.name || findData?.title,\n handle: findData?.handle,\n },\n }\n }\n })\n const currentMenu = buildData?.products?.filter((item: any) => {\n return RightMenu?.menus?.find((params: any) => params?.handle === item?.handle)\n })\n setActive(currentActive)\n setMenuList(currentMenu)\n setIsShowMax(skus?.length > 2 && !isMobile)\n }, [buildData, isMobile])\n\n useEffect(() => {\n if (isMobile) {\n const currentActive = Object.keys(active || {})\n if (currentActive?.length > 2) {\n const newActive = currentActive?.slice?.(0, 2)\n let newShowActive = {}\n newActive?.forEach?.((item: string) => {\n newShowActive = { ...newShowActive, [item]: active?.[item] }\n })\n setIsShowMax(false)\n setActive(newShowActive)\n }\n }\n }, [isMobile])\n\n return (\n <div {...rest} className={cn('specs-wrapper w-full overflow-hidden bg-[#F5F5F7]', className)} ref={innerRef}>\n {LeftMenu?.data ? (\n <div className=\"specs-wrapper-content box-border w-full overflow-hidden\">\n {LeftMenu?.data?.map?.((item: any, index: number) => {\n return (\n <div\n key={index}\n className=\"specs-wrapper-content-item w-full overflow-hidden pt-10 [&:first-child]:pt-0\"\n >\n {childrenNode(item)}\n </div>\n )\n })}\n </div>\n ) : null}\n </div>\n )\n }\n)\n\nSpecs.displayName = 'Specs'\n\nexport default withLayout(Specs)\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Specs_exports", "__export", "Specs_default", "__toCommonJS", "import_jsx_runtime", "import_dropdown", "import_AiuiProvider", "import_react_responsive", "import_react", "import_Styles", "import_shelfDisplay", "import_components", "import_helpers", "Specs", "React", "data", "buildData", "onChange", "onSecondaryChange", "className", "rest", "ref", "isMobile", "active", "setActive", "menuList", "setMenuList", "isShowMax", "setIsShowMax", "visibleActive", "setVisibleActive", "innerRef", "locale", "currencyDisplay", "LeftMenu", "RightMenu", "DefaultSelectMenu", "isImageUrl", "urlPath", "path", "skuNode", "product", "index", "findSku", "item", "coupon", "price", "basePrice", "buttonTextValue", "DropDown", "normalNode", "v", "productNode", "st", "idx", "isFirstParameter", "currentData", "currentMenus", "childrenNode", "node", "subTitle", "isProduct", "currentProduct", "skus", "limitedSkus", "currentActive", "sku", "findData", "currentMenu", "params", "newActive", "newShowActive"]
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport DropDown from './dropdown.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { useMediaQuery } from 'react-responsive'\nimport { useMemo, useState, useEffect } from 'react'\nimport { withLayout } from '../../shared/Styles.js'\nimport { formatVariantPrice } from '../ShelfDisplay/shelfDisplay.js'\nimport { Picture, Text, Button, Heading } from '../../components/index.js'\nimport { cn } from '../../helpers/index.js'\nimport React, { useImperativeHandle, useRef } from 'react'\n\nexport interface SpecsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n data?: any\n buildData?: any\n onChange?: (product: any, index: number) => void\n onSecondaryChange?: (data: any) => void\n}\n\nconst Specs = React.forwardRef<HTMLDivElement, SpecsProps>(\n ({ data, buildData, onChange, onSecondaryChange, className, ...rest }, ref) => {\n const isMobile = useMediaQuery({ query: '(max-width: 768px)' })\n\n const [active, setActive] = useState<any>({})\n const [menuList, setMenuList] = useState<any[]>([])\n const [isShowMax, setIsShowMax] = useState<boolean>(false)\n const [visibleActive, setVisibleActive] = useState<{ [key: number]: boolean }>({})\n\n const innerRef = useRef<HTMLDivElement>(null)\n\n const { locale = 'us', currencyDisplay, trackingData } = useAiuiContext()\n\n /** \u662F\u5426\u663E\u793A\u539F\u4EF7\uFF08\u5212\u7EBF\u4EF7\uFF09\uFF0C\u9ED8\u8BA4\u663E\u793A */\n const showComparePrice = trackingData?.showComparePrice ?? true\n\n const { LeftMenu, RightMenu, DefaultSelectMenu } = useMemo(() => data?.data || {}, [data?.data])\n\n const isImageUrl = (urlPath: string) => {\n try {\n const url = new URL(urlPath)\n const path = url.pathname.toLowerCase()\n return /\\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/.test(path)\n } catch (e) {\n // \u5982\u679C\u4F20\u5165\u7684\u4E0D\u662F\u6709\u6548URL\uFF08\u5982\u76F8\u5BF9\u8DEF\u5F84\uFF09\uFF0C\u76F4\u63A5\u68C0\u67E5\u8DEF\u5F84\n return /\\.(jpeg|jpg|gif|png|webp|bmp|svg|tiff)$/i.test(urlPath)\n }\n }\n\n const skuNode = (product: any, index: number) => {\n const findSku = product?.variants?.find?.((item: any) => item?.sku === product?.sku)\n const coupon = findSku?.coupons?.[0]\n const { price, basePrice } = formatVariantPrice({\n locale: locale || 'us',\n amount: coupon ? coupon?.variant_price4wscode : findSku?.price,\n baseAmount: coupon ? findSku?.price : 0,\n currencyDisplay,\n currencyCode: product?.price?.currencyCode || 'USD',\n })\n const buttonTextValue =\n typeof DefaultSelectMenu?.buttonText === 'string'\n ? DefaultSelectMenu?.buttonText\n : DefaultSelectMenu?.buttonText?.[String(index)] || ''\n return (\n <div className=\"specs-sku-node-wrap box-border\">\n <Text\n className={`md-tablet:p-2 l-tablet:mb-4 l-tablet:text-sm desktop:px-6 lg-desktop:mb-8 lg-desktop:text-lg openDropDown specs-sku-node-text relative mb-6 box-border block rounded-[50px] border border-[#E4E5E6] bg-[#F5F5F7] px-6 py-4 text-base font-bold`}\n onClick={() => {\n if (menuList?.length <= 1) return null\n\n setVisibleActive({\n ...visibleActive,\n [index]: !visibleActive?.[index],\n })\n }}\n >\n <div className=\"flex items-center justify-between overflow-hidden\">\n <div\n className=\"openDropDown md-tablet:text-sm lg-desktop:text-lg specs-sku-node-title flex-1 truncate text-base\"\n title={active?.[index]?.name || ''}\n >\n {active?.[index]?.name || ''}\n </div>\n {menuList?.length > 1 ? (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"25\"\n viewBox=\"0 0 24 25\"\n fill=\"none\"\n className=\"openDropDown\"\n >\n <path\n d=\"M6 9.5L12 15.5L18 9.5\"\n stroke=\"#1D1D1F\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n ) : null}\n </div>\n <DropDown\n index={index}\n list={menuList}\n active={active}\n setActive={setActive}\n visible={visibleActive}\n setVisible={setVisibleActive}\n />\n </Text>\n <div className=\"lg-desktop:max-h-[196px] lg-desktop:max-w-[196px] max-h-[138px] max-w-[138px]\">\n <Picture\n source={findSku?.image?.url || ''}\n className=\"aspect-h-[280] aspect-w-[280]\"\n imgClassName=\"w-full h-full object-cover hover:scale-105 transition-all duration-300\"\n />\n </div>\n <div className=\"lg-desktop:text-2xl mb-2 mt-6 text-xl font-bold\">\n <div className=\"lg-desktop:min-h-[32px] flex min-h-[28px] items-center\">\n {findSku?.availableForSale ? (\n <>\n <div className=\"specs-sku-node-price text-[#080A0F]\">{price || ''}</div>\n {showComparePrice && basePrice && (\n <div className=\"lg-desktop:text-2xl specs-sku-node-base-price ml-1 text-xl text-[#86868C] line-through\">\n {basePrice}\n </div>\n )}\n </>\n ) : null}\n </div>\n </div>\n {buttonTextValue ? (\n <Button\n onClick={() => {\n onChange?.(product, index)\n }}\n className=\"specs-sku-node-button\"\n >\n {buttonTextValue}\n </Button>\n ) : null}\n </div>\n )\n }\n\n const normalNode = (v: any) => {\n if (v && typeof v !== 'string') {\n return (\n <div className=\"size-full\">\n <p\n className=\"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm\"\n dangerouslySetInnerHTML={{\n __html: v?.text || '',\n }}\n />\n <Picture\n source={v?.imgUrl}\n className=\"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]\"\n imgClassName=\"w-full h-full object-cover\"\n />\n </div>\n )\n }\n return (\n <div className=\"break-all\">\n {isImageUrl(v) ? (\n <Picture\n source={v}\n className=\"l:max-h-[174px] l:max-w-[174px] m-auto max-h-[360px] max-w-[360px]\"\n imgClassName=\"w-full h-full object-cover\"\n />\n ) : (\n <p\n className=\"min-xxl:text-lg specs-normal-node-text text-base font-bold text-[#080A0F] md:text-sm\"\n dangerouslySetInnerHTML={{\n __html: v || '',\n }}\n />\n )}\n </div>\n )\n }\n\n const productNode = (data: any) => {\n return data.map((st: any, idx: number) => {\n const isFirstParameter = idx === 0\n return (\n <div\n key={st}\n className={`l-tablet:flex l-tablet:flex-col box-border grid w-full cursor-pointer grid-cols-3 overflow-hidden border-t border-t-[#E4E5E6] ${isFirstParameter ? '' : ''} specs-product-node-wrap`}\n >\n <Heading\n as=\"h3\"\n html={st || ''}\n className=\"tablet:py-6 l-tablet:text-[#86868C] desktop:p-6 lg-desktop:text-lg specs-product-node-title mr-4 flex-1 pt-4 text-base font-bold md:text-sm\"\n />\n <div\n className={`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:p-6 lg-desktop:gap-16 grid-cols-${isShowMax ? 3 : 2} specs-product-node-body col-span-2 grid flex-1 py-6`}\n >\n {Object.keys(active)?.map?.((item: string) => {\n const currentData = active?.[item]\n const currentMenus = RightMenu?.menus?.find?.(\n (item: any) => item?.handle === currentData?.handle\n )?.subTitle\n return normalNode(currentMenus?.[st])\n })}\n </div>\n </div>\n )\n })\n }\n\n // \u5DE6\u4FA7\u6807\u9898\u83DC\u5355\n const childrenNode = (node: any) => {\n if (!active) return\n const { subTitle, isProduct } = node\n // \u5982\u679C\u662F\u4EA7\u54C1\n if (isProduct) {\n return (\n <>\n <div\n className={`l-tablet:flex l-tablet:flex-col specs-content-item-product box-border grid w-full cursor-pointer grid-cols-3 border-t-0 border-t-[#E4E5E6]`}\n >\n {node?.title && (\n <Heading as=\"h3\" html={node?.title || ''} className=\"l:hidden specs-item-product-title\" />\n )}\n <div\n className={`l-tablet:w-full l-tablet:gap-4 laptop:gap-8 desktop:gap-12 desktop:px-6 desktop:pb-6 lg-desktop:gap-16 grid-cols-${isShowMax ? 3 : 2} specs-item-product-body col-span-2 grid flex-1 pb-4 pr-0`}\n >\n {Object.keys(active)?.map((item: string, index: number) => {\n const currentData = active?.[item]\n const currentProduct = buildData?.products?.find?.(\n (item: any) => item?.handle === currentData?.handle\n )\n return (\n <div key={item}>{skuNode({ ...currentProduct, item: item, sku: currentData?.sku }, index)}</div>\n )\n })}\n </div>\n </div>\n {node?.categoryLabel && (\n <Heading\n size={2}\n as=\"h4\"\n html={node?.categoryLabel || ''}\n className=\"desktop:p-6 specs-item-product-category py-6\"\n />\n )}\n {subTitle?.length ? productNode(subTitle) : null}\n </>\n )\n }\n return productNode(subTitle)\n }\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n useEffect(() => {\n if (!buildData?.products?.length) return\n const skus = DefaultSelectMenu?.sku?.split?.(',') || []\n const limitedSkus = isMobile && skus?.length > 2 ? skus?.slice(0, 2) : skus\n let currentActive = {}\n limitedSkus?.forEach?.((sku: string, index: number) => {\n const findData = buildData?.products?.find?.((item: any) => {\n const findSku = item?.variants?.find?.((v: any) => v?.sku === sku)\n if (findSku) return true\n })\n if (findData) {\n currentActive = {\n ...currentActive,\n [index]: {\n sku: sku,\n name: findData?.name || findData?.title,\n handle: findData?.handle,\n },\n }\n }\n })\n const currentMenu = buildData?.products?.filter((item: any) => {\n return RightMenu?.menus?.find((params: any) => params?.handle === item?.handle)\n })\n setActive(currentActive)\n setMenuList(currentMenu)\n setIsShowMax(skus?.length > 2 && !isMobile)\n }, [buildData, isMobile])\n\n useEffect(() => {\n if (isMobile) {\n const currentActive = Object.keys(active || {})\n if (currentActive?.length > 2) {\n const newActive = currentActive?.slice?.(0, 2)\n let newShowActive = {}\n newActive?.forEach?.((item: string) => {\n newShowActive = { ...newShowActive, [item]: active?.[item] }\n })\n setIsShowMax(false)\n setActive(newShowActive)\n }\n }\n }, [isMobile])\n\n return (\n <div {...rest} className={cn('specs-wrapper w-full overflow-hidden bg-[#F5F5F7]', className)} ref={innerRef}>\n {LeftMenu?.data ? (\n <div className=\"specs-wrapper-content box-border w-full overflow-hidden\">\n {LeftMenu?.data?.map?.((item: any, index: number) => {\n return (\n <div\n key={index}\n className=\"specs-wrapper-content-item w-full overflow-hidden pt-10 [&:first-child]:pt-0\"\n >\n {childrenNode(item)}\n </div>\n )\n })}\n </div>\n ) : null}\n </div>\n )\n }\n)\n\nSpecs.displayName = 'Specs'\n\nexport default withLayout(Specs)\n"],
|
|
5
|
+
"mappings": "+kBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,IA2EY,IAAAI,EAAA,6BAzEZC,EAAqB,4BACrBC,EAA+B,oCAC/BC,EAA8B,4BAC9BC,EAA6C,iBAC7CC,EAA2B,kCAC3BC,EAAmC,2CACnCC,EAA+C,qCAC/CC,EAAmB,kCACnBJ,EAAmD,oBASnD,MAAMK,EAAQ,EAAAC,QAAM,WAClB,CAAC,CAAE,KAAAC,EAAM,UAAAC,EAAW,SAAAC,EAAU,kBAAAC,EAAmB,UAAAC,EAAW,GAAGC,CAAK,EAAGC,IAAQ,CAC7E,MAAMC,KAAW,iBAAc,CAAE,MAAO,oBAAqB,CAAC,EAExD,CAACC,EAAQC,CAAS,KAAI,YAAc,CAAC,CAAC,EACtC,CAACC,EAAUC,CAAW,KAAI,YAAgB,CAAC,CAAC,EAC5C,CAACC,EAAWC,CAAY,KAAI,YAAkB,EAAK,EACnD,CAACC,EAAeC,CAAgB,KAAI,YAAqC,CAAC,CAAC,EAE3EC,KAAW,UAAuB,IAAI,EAEtC,CAAE,OAAAC,EAAS,KAAM,gBAAAC,EAAiB,aAAAC,CAAa,KAAI,kBAAe,EAGlEC,EAAmBD,GAAc,kBAAoB,GAErD,CAAE,SAAAE,EAAU,UAAAC,EAAW,kBAAAC,CAAkB,KAAI,WAAQ,IAAMvB,GAAM,MAAQ,CAAC,EAAG,CAACA,GAAM,IAAI,CAAC,EAEzFwB,EAAcC,GAAo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AAO,EACtB,CAAC,EACGC,IACFF,EAAgB,CACd,GAAGA,EACH,CAACvB,CAAK,EAAG,CACP,IAAKwB,EACL,KAAMC,GAAU,MAAQA,GAAU,MAClC,OAAQA,GAAU,MACpB,CACF,EAEJ,CAAC,EACD,MAAMC,EAActD,GAAW,UAAU,OAAQ8B,GACxCT,GAAW,OAAO,KAAMkC,GAAgBA,GAAQ,SAAWzB,GAAM,MAAM,CAC/E,EACDtB,EAAU2C,CAAa,EACvBzC,EAAY4C,CAAW,EACvB1C,EAAaqC,GAAM,OAAS,GAAK,CAAC3C,CAAQ,CAC5C,EAAG,CAACN,EAAWM,CAAQ,CAAC,KAExB,aAAU,IAAM,CACd,GAAIA,EAAU,CACZ,MAAM6C,EAAgB,OAAO,KAAK5C,GAAU,CAAC,CAAC,EAC9C,GAAI4C,GAAe,OAAS,EAAG,CAC7B,MAAMK,EAAYL,GAAe,QAAQ,EAAG,CAAC,EAC7C,IAAIM,EAAgB,CAAC,EACrBD,GAAW,UAAW1B,GAAiB,CACrC2B,EAAgB,CAAE,GAAGA,EAAe,CAAC3B,CAAI,EAAGvB,IAASuB,CAAI,CAAE,CAC7D,CAAC,EACDlB,EAAa,EAAK,EAClBJ,EAAUiD,CAAa,CACzB,CACF,CACF,EAAG,CAACnD,CAAQ,CAAC,KAGX,OAAC,OAAK,GAAGF,EAAM,aAAW,MAAG,oDAAqDD,CAAS,EAAG,IAAKY,EAChG,SAAAK,GAAU,QACT,OAAC,OAAI,UAAU,0DACZ,SAAAA,GAAU,MAAM,MAAM,CAACU,EAAWF,OAE/B,OAAC,OAEC,UAAU,+EAET,SAAAgB,EAAad,CAAI,GAHbF,CAIP,CAEH,EACH,EACE,KACN,CAEJ,CACF,EAEA/B,EAAM,YAAc,QAEpB,IAAOX,MAAQ,cAAWW,CAAK",
|
|
6
|
+
"names": ["Specs_exports", "__export", "Specs_default", "__toCommonJS", "import_jsx_runtime", "import_dropdown", "import_AiuiProvider", "import_react_responsive", "import_react", "import_Styles", "import_shelfDisplay", "import_components", "import_helpers", "Specs", "React", "data", "buildData", "onChange", "onSecondaryChange", "className", "rest", "ref", "isMobile", "active", "setActive", "menuList", "setMenuList", "isShowMax", "setIsShowMax", "visibleActive", "setVisibleActive", "innerRef", "locale", "currencyDisplay", "trackingData", "showComparePrice", "LeftMenu", "RightMenu", "DefaultSelectMenu", "isImageUrl", "urlPath", "path", "skuNode", "product", "index", "findSku", "item", "coupon", "price", "basePrice", "buttonTextValue", "DropDown", "normalNode", "v", "productNode", "st", "idx", "isFirstParameter", "currentData", "currentMenus", "childrenNode", "node", "subTitle", "isProduct", "currentProduct", "skus", "limitedSkus", "currentActive", "sku", "findData", "currentMenu", "params", "newActive", "newShowActive"]
|
|
7
7
|
}
|
|
@@ -22,9 +22,9 @@ export interface StateIcon {
|
|
|
22
22
|
export interface EventScheduleItem {
|
|
23
23
|
/** 标题 */
|
|
24
24
|
title: string;
|
|
25
|
-
/** 开始日期(ISO 8601
|
|
25
|
+
/** 开始日期(ISO 8601 格式,如 '2024-12-01T00:00:00Z') */
|
|
26
26
|
startDate: string;
|
|
27
|
-
/** 结束日期(ISO 8601
|
|
27
|
+
/** 结束日期(ISO 8601 格式,如 '2024-12-31T23:59:59Z') */
|
|
28
28
|
endDate: string;
|
|
29
29
|
/**
|
|
30
30
|
* 卡片背景图标配置,状态化图标(必须包含 active 和 inactive)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as s,jsxs as g}from"react/jsx-runtime";import*as n from"react";import{cn as d}from"../../helpers/index.js";import{withLayout as
|
|
1
|
+
"use client";import{jsx as s,jsxs as g}from"react/jsx-runtime";import*as n from"react";import{cn as d}from"../../helpers/index.js";import{withLayout as A}from"../../shared/Styles.js";import{Text as _,Picture as B,Heading as P,Container as R}from"../../components/index.js";import{Swiper as D,SwiperSlide as y}from"swiper/react";import{cva as b}from"class-variance-authority";const x=(e,r)=>{const c=Date.now(),u=new Date(e).getTime(),m=new Date(r).getTime();return c>m?"completed":c<u?"not-started":"in-progress"},z=b("h-1 w-full overflow-hidden",{variants:{state:{"in-progress-light":"bg-[#F6CD4E]","in-progress-dark":"bg-[#D79941]","not-started-light":"bg-[#EAEAEC]","not-started-dark":"bg-[#1E2024]","completed-light":"bg-[#F6CD4E]","completed-dark":"bg-[#D79941]"}},defaultVariants:{state:"not-started-light"}}),H=b("size-4 rounded-full transition-colors",{variants:{state:{"in-progress-light":"bg-[#F6CD4E]","in-progress-dark":"bg-[#D79941]","not-started-light":"bg-[#EAEAEC]","not-started-dark":"bg-[#1E2024]","completed-light":"bg-[#F6CD4E]","completed-dark":"bg-[#D79941]"}},defaultVariants:{state:"not-started-light"}}),S=b("font-bold leading-[1.2]",{variants:{state:{"in-progress-light":"text-[#080A0F]","in-progress-dark":"text-white","not-started-light":"text-[#080A0F]","not-started-dark":"text-[#F5F6F7]","completed-light":"text-[#4A4C56]/60","completed-dark":"text-[#F5F6F7]/60"}},defaultVariants:{state:"not-started-light"}}),j=b("laptop:h-[160px] rounded-box relative flex h-[120px] min-w-0 flex-col justify-between gap-2 overflow-hidden",{variants:{state:{"in-progress-light":"bg-[#F4E8BC]","in-progress-dark":"bg-[#D79941]","not-started-light":"bg-[#EAEAEC]","not-started-dark":"bg-[#1E2024]","completed-light":"bg-[#F4E8BC]","completed-dark":"bg-[#D79941]"}},defaultVariants:{state:"not-started-light"}}),q=({timeStatus:e,theme:r="light",className:c,index:u,nodeLength:m})=>{const o=`${e}-${r}`,i=u===0,l=u===m-1;return g("div",{className:d(`event-schedule-timeline-node event-schedule-timeline-node--${e} relative my-2 flex h-1 w-full items-center justify-center`,c),children:[s("div",{className:d(`event-schedule-timeline-progress event-schedule-timeline-progress--${e}`,z({state:o}),i&&"rounded-l-full",l&&"rounded-r-full")}),s("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:s("div",{className:d(`event-schedule-timeline-dot event-schedule-timeline-dot--${e}`,H({state:o}))})})]})},G=(e,r)=>{if(e)return r==="in-progress"?e.active:r==="completed"&&e.completed||e.inactive},J=({timeStatus:e,item:r,theme:c="light",className:u,scheduleCount:m})=>{const o=n.useMemo(()=>G(r.icon,e),[r.icon,e]),i=`${e}-${c}`;return g("div",{className:d(`event-schedule-card event-schedule-card--${e}`,j({state:i}),u),children:[o&&s("div",{className:`event-schedule-card__background-icon event-schedule-card__background-icon--${e} laptop:w-[128px] desktop:w-[160px] absolute bottom-0 right-0 z-10 w-[120px]`,children:s(B,{source:o.url,alt:o.alt,className:"aspect-square"})}),g("div",{className:`event-schedule-card__content event-schedule-card__content--${e} tablet:px-4 tablet:py-3 desktop:pl-6 desktop:pr-16 relative z-20 flex h-full flex-col justify-between p-4 pr-8`,children:[s(P,{html:r.title,className:d(`event-schedule-card__title event-schedule-card__title--${e}`,m>=4?"desktop:text-[24px]":"desktop:text-[32px]","laptop:text-[24px] line-clamp-1 text-[20px]",S({state:i}))}),s("div",{className:`event-schedule-card__details event-schedule-card__details--${e} flex flex-col gap-0.5`,children:r.items.map((l,a)=>g("div",{className:`event-schedule-card__detail-item event-schedule-card__detail-item--${e} flex items-center gap-2`,children:[l.icon&&s(_,{className:d(`event-schedule-card__detail-icon event-schedule-card__detail-icon--${e} desktop:size-6 size-5 shrink-0`,S({state:i})),html:l.icon}),s(_,{html:l.label,className:d(`event-schedule-card__detail-text event-schedule-card__detail-text--${e} lg-desktop:text-[18px] desktop:text-[16px] line-clamp-1 flex-1 text-[14px] leading-[1.4]`,S({state:i}))})]},a))})]})]})},L=n.forwardRef(({classNames:e={},data:r,className:c,...u},m)=>{const o=r.theme||"light",i=n.useRef(null),l=n.useRef(null),a=n.useRef(!1),f=n.useMemo(()=>r?.scheduleList?.length||2,[r?.scheduleList]),v=n.useMemo(()=>r.scheduleList.findIndex(t=>x(t.startDate,t.endDate)==="in-progress"),[r.scheduleList]),w=n.useCallback((t,h=!1)=>{const p=M=>{switch(M){case"mobile":return{slidesPerView:1.17};case"tablet":return t===2?{slidesPerView:2}:{slidesPerView:2.4};case"laptop":return t===2?{}:t===4?{slidesPerView:3.2}:{slidesPerView:t};case"desktop":return t===2?{slidesPerView:2}:{slidesPerView:t}}},T=p("mobile"),E=p("tablet"),C=p("laptop"),N=p("desktop");return h?{0:{...T,spaceBetween:12},768:{...E,spaceBetween:12},1024:{...C,spaceBetween:16},1440:{...N,spaceBetween:16}}:{0:T,768:E,1024:C,1440:N}},[]),F=n.useMemo(()=>w(f,!0),[f,w]),V=n.useMemo(()=>w(f,!1),[f,w]),k=r.showTimeline!==!1,$=n.useCallback(t=>{a.current||!l.current||(a.current=!0,l.current.slideTo(t.activeIndex,t.params.speed),setTimeout(()=>{a.current=!1},50))},[]),I=n.useCallback(t=>{a.current||!i.current||(a.current=!0,i.current.slideTo(t.activeIndex,t.params.speed),setTimeout(()=>{a.current=!1},50))},[]);return n.useEffect(()=>{i.current&&l.current&&v>=0&&setTimeout(()=>{a.current=!0,i.current?.slideTo(v,500),l.current?.slideTo(v,500),setTimeout(()=>{a.current=!1},600)},100)},[v]),g(R,{...u,ref:m,className:d("event-schedule-root overflow-hidden",e?.root,c),children:[k&&s(D,{breakpoints:V,className:"event-schedule-timeline h-4 w-full !overflow-visible",onSwiper:t=>{l.current=t},onSlideChange:I,children:r.scheduleList.map((t,h)=>{const p=x(t.startDate,t.endDate);return s(y,{className:"",children:s(q,{className:e?.timeline,timeStatus:p,theme:o,index:h,nodeLength:r.scheduleList.length})},"timelineNode"+h)})}),s(D,{breakpoints:F,className:"event-schedule-cards w-full !overflow-visible",onSwiper:t=>{i.current=t},onSlideChange:$,children:r.scheduleList.map((t,h)=>{const p=x(t.startDate,t.endDate);return s(y,{children:s(J,{timeStatus:p,className:d(k?"laptop:mt-4 mt-2":"",e?.eventScheduleCard),item:t,theme:o,scheduleCount:r.scheduleList.length})},"SwiperSlideItem"+h)})})]})});L.displayName="EventSchedule";var X=A(L);export{X as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/EventSchedule/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { Text, Picture, Heading, Container } from '../../components/index.js'\nimport { Swiper, SwiperSlide } from 'swiper/react'\nimport type { Swiper as SwiperType } from 'swiper'\nimport dayjs from 'dayjs'\nimport { cva } from 'class-variance-authority'\nimport type { Media } from '../../types/props.js'\nexport type EventScheduleSemanticName = 'root' | 'timeline' | 'eventScheduleCard'\n\n/**\n * \u65F6\u95F4\u72B6\u6001\u7C7B\u578B\n */\nexport type TimeStatus = 'completed' | 'in-progress' | 'not-started'\n\n/**\n * \u72B6\u6001\u5316\u56FE\u6807\u914D\u7F6E\n */\nexport interface StateIcon {\n /** \u6FC0\u6D3B\u72B6\u6001\u7684\u56FE\u6807\uFF08\u8FDB\u884C\u4E2D\uFF09 */\n active: Media\n /** \u975E\u6FC0\u6D3B\u72B6\u6001\u7684\u56FE\u6807\uFF08\u672A\u5F00\u59CB\uFF09 */\n inactive: Media\n /** \u5DF2\u5B8C\u6210\u72B6\u6001\u7684\u56FE\u6807\uFF08\u53EF\u9009\uFF0C\u4E0D\u63D0\u4F9B\u5219\u4F7F\u7528 inactive\uFF09 */\n completed?: Media\n}\n\n/**\n * \u6D3B\u52A8\u65E5\u7A0B\u9879\u6570\u636E\u63A5\u53E3\n */\nexport interface EventScheduleItem {\n /** \u6807\u9898 */\n title: string\n /** \u5F00\u59CB\u65E5\u671F\uFF08ISO 8601 \u683C\u5F0F\u6216\u4EFB\u4F55 dayjs \u652F\u6301\u7684\u683C\u5F0F\uFF0C\u5982 '2024-12-01'\uFF09 */\n startDate: string\n /** \u7ED3\u675F\u65E5\u671F\uFF08ISO 8601 \u683C\u5F0F\u6216\u4EFB\u4F55 dayjs \u652F\u6301\u7684\u683C\u5F0F\uFF0C\u5982 '2024-12-31'\uFF09 */\n endDate: string\n /**\n * \u5361\u7247\u80CC\u666F\u56FE\u6807\u914D\u7F6E\uFF0C\u72B6\u6001\u5316\u56FE\u6807\uFF08\u5FC5\u987B\u5305\u542B active \u548C inactive\uFF09\n *\n * @example\n * icon: {\n * active: { url: \"https://example.com/active-icon.svg\", alt: \"Active Icon\" },\n * inactive: { url: \"https://example.com/inactive-icon.svg\", alt: \"Inactive Icon\" }\n * }\n */\n icon?: StateIcon\n /** \u8BE6\u7EC6\u4FE1\u606F\u5217\u8868 */\n items: {\n /** \u56FE\u6807 (SVG \u5B57\u7B26\u4E32\u6216 URL) */\n icon?: string\n /** \u6587\u672C\u5185\u5BB9 */\n label: string\n }[]\n}\n\n/**\n * EventSchedule \u4E1A\u52A1\u7EC4\u4EF6\u6570\u636E\u63A5\u53E3\n */\nexport interface EventScheduleData {\n /** \u65E5\u7A0B\u5217\u8868 */\n scheduleList: EventScheduleItem[]\n /** \u662F\u5426\u663E\u793A\u65F6\u95F4\u8F74\uFF0C\u9ED8\u8BA4\u4E3A true */\n showTimeline?: boolean\n /** \u4E3B\u9898\u6A21\u5F0F */\n theme?: 'light' | 'dark'\n}\n\nexport interface EventScheduleProps extends React.HTMLAttributes<HTMLDivElement> {\n /** \u4E1A\u52A1\u6570\u636E */\n data: EventScheduleData\n classNames?: Partial<Record<EventScheduleSemanticName, string>>\n}\n\n/**\n * \u83B7\u53D6\u65F6\u95F4\u72B6\u6001\n * @param startDate \u5F00\u59CB\u65E5\u671F\n * @param endDate \u7ED3\u675F\u65E5\u671F\n * @returns \u65F6\u95F4\u72B6\u6001\uFF1Acompleted\uFF08\u5DF2\u5B8C\u6210\uFF09\u3001in-progress\uFF08\u8FDB\u884C\u4E2D\uFF09\u3001not-started\uFF08\u672A\u5F00\u59CB\uFF09\n */\nconst getTimeStatus = (startDate: string, endDate: string): TimeStatus => {\n const now = dayjs()\n const start = dayjs(startDate).startOf('day')\n const end = dayjs(endDate).endOf('day')\n\n // \u5F53\u524D\u65F6\u95F4\u5728\u7ED3\u675F\u65F6\u95F4\u4E4B\u540E - \u5DF2\u5B8C\u6210\n if (now.isAfter(end)) {\n return 'completed'\n }\n\n // \u5F53\u524D\u65F6\u95F4\u5728\u5F00\u59CB\u65F6\u95F4\u4E4B\u524D - \u672A\u5F00\u59CB\n if (now.isBefore(start)) {\n return 'not-started'\n }\n\n // \u5F53\u524D\u65F6\u95F4\u5728\u5F00\u59CB\u548C\u7ED3\u675F\u4E4B\u95F4 - \u8FDB\u884C\u4E2D\n return 'in-progress'\n}\n\n/**\n * \u65F6\u95F4\u8F74\u8FDB\u5EA6\u6761\u6837\u5F0F\u53D8\u4F53\uFF08\u652F\u6301\u4E09\u79CD\u65F6\u95F4\u72B6\u6001\uFF09\n */\nconst timelineProgressActiveVariants = cva('h-1 w-full overflow-hidden', {\n variants: {\n state: {\n // \u8FDB\u884C\u4E2D\n 'in-progress-light': 'bg-[#F6CD4E]',\n 'in-progress-dark': 'bg-[#D79941]',\n // \u672A\u5F00\u59CB\n 'not-started-light': 'bg-[#EAEAEC]',\n 'not-started-dark': 'bg-[#1E2024]',\n // \u5DF2\u5B8C\u6210\n 'completed-light': 'bg-[#F6CD4E]',\n 'completed-dark': 'bg-[#D79941]',\n },\n },\n defaultVariants: {\n state: 'not-started-light',\n },\n})\n\n/**\n * \u65F6\u95F4\u8F74\u8282\u70B9\u6837\u5F0F\u53D8\u4F53\uFF08\u652F\u6301\u4E09\u79CD\u65F6\u95F4\u72B6\u6001\uFF09\n */\nconst timelineNodeActiveVariants = cva('size-4 rounded-full transition-colors', {\n variants: {\n state: {\n // \u8FDB\u884C\u4E2D\n 'in-progress-light': 'bg-[#F6CD4E]',\n 'in-progress-dark': 'bg-[#D79941]',\n // \u672A\u5F00\u59CB\n 'not-started-light': 'bg-[#EAEAEC]',\n 'not-started-dark': 'bg-[#1E2024]',\n // \u5DF2\u5B8C\u6210\uFF08\u4E0E\u8FDB\u884C\u4E2D\u989C\u8272\u4E00\u81F4\uFF09\n 'completed-light': 'bg-[#F6CD4E]',\n 'completed-dark': 'bg-[#D79941]',\n },\n },\n defaultVariants: {\n state: 'not-started-light',\n },\n})\n\n/**\n * \u5361\u7247\u6587\u672C\u6837\u5F0F\u53D8\u4F53\uFF08\u652F\u6301\u4E09\u79CD\u65F6\u95F4\u72B6\u6001\uFF09\n */\nconst cardTextVariants = cva('font-bold leading-[1.2]', {\n variants: {\n state: {\n // \u8FDB\u884C\u4E2D\uFF08\u4FDD\u6301\u539F\u6709\u989C\u8272\uFF09\n 'in-progress-light': 'text-[#080A0F]',\n 'in-progress-dark': 'text-white',\n // \u672A\u5F00\u59CB\uFF0860% \u900F\u660E\u5EA6\uFF09\n 'not-started-light': 'text-[#080A0F]',\n 'not-started-dark': 'text-[#F5F6F7]',\n // \u5DF2\u5B8C\u6210\uFF0860% \u900F\u660E\u5EA6\uFF09\n 'completed-light': 'text-[#4A4C56]/60',\n 'completed-dark': 'text-[#F5F6F7]/60',\n },\n },\n defaultVariants: {\n state: 'not-started-light',\n },\n})\n\n/**\n * \u5361\u7247\u5BB9\u5668\u6837\u5F0F\u53D8\u4F53\uFF08\u652F\u6301\u4E09\u79CD\u65F6\u95F4\u72B6\u6001\uFF09\n */\nconst eventScheduleCardVariants = cva(\n 'laptop:h-[160px] rounded-box relative flex h-[120px] min-w-0 flex-col justify-between gap-2 overflow-hidden',\n {\n variants: {\n state: {\n // \u8FDB\u884C\u4E2D\n 'in-progress-light': 'bg-[#F4E8BC]',\n 'in-progress-dark': 'bg-[#D79941]',\n // \u672A\u5F00\u59CB\n 'not-started-light': 'bg-[#EAEAEC]',\n 'not-started-dark': 'bg-[#1E2024]',\n // \u5DF2\u5B8C\u6210\n 'completed-light': 'bg-[#F4E8BC]',\n 'completed-dark': 'bg-[#D79941]',\n },\n },\n defaultVariants: {\n state: 'not-started-light',\n },\n }\n)\n\n/**\n * \u65F6\u95F4\u8F74\u8282\u70B9\u7EC4\u4EF6 Props\n */\ninterface TimelineNodeProps {\n /** \u65F6\u95F4\u72B6\u6001 */\n timeStatus: TimeStatus\n /** \u4E3B\u9898\u6A21\u5F0F */\n theme?: 'light' | 'dark'\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n /** \u5F53\u524D\u8282\u70B9\u7D22\u5F15 */\n index: number\n /** \u8282\u70B9\u603B\u6570 */\n nodeLength: number\n}\n\n/**\n * \u65F6\u95F4\u8F74\u8282\u70B9\u7EC4\u4EF6\n */\nconst TimelineNode = ({ timeStatus, theme = 'light', className, index, nodeLength }: TimelineNodeProps) => {\n // \u8BA1\u7B97\u7EC4\u5408\u72B6\u6001\n const state = `${timeStatus}-${theme}` as\n | 'in-progress-light'\n | 'in-progress-dark'\n | 'not-started-light'\n | 'not-started-dark'\n | 'completed-light'\n | 'completed-dark'\n\n // \u5224\u65AD\u9996\u5C3E\u4F4D\u7F6E\n const isFirst = index === 0\n const isLast = index === nodeLength - 1\n\n return (\n <div\n className={cn(\n `event-schedule-timeline-node event-schedule-timeline-node--${timeStatus} relative my-2 flex h-1 w-full items-center justify-center`,\n className\n )}\n >\n {/* \u8FDB\u5EA6\u6761\u80CC\u666F */}\n <div\n className={cn(\n `event-schedule-timeline-progress event-schedule-timeline-progress--${timeStatus}`,\n timelineProgressActiveVariants({ state }),\n isFirst && 'rounded-l-full',\n isLast && 'rounded-r-full'\n )}\n />\n {/* \u65F6\u95F4\u8282\u70B9\u5706\u70B9 */}\n <div className=\"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2\">\n <div\n className={cn(\n `event-schedule-timeline-dot event-schedule-timeline-dot--${timeStatus}`,\n timelineNodeActiveVariants({ state })\n )}\n />\n </div>\n </div>\n )\n}\n\n/**\n * \u6839\u636E\u65F6\u95F4\u72B6\u6001\u83B7\u53D6\u5BF9\u5E94\u7684\u56FE\u6807\n * @param icon \u72B6\u6001\u5316\u56FE\u6807\u914D\u7F6E\n * @param timeStatus \u65F6\u95F4\u72B6\u6001\n * @returns \u56FE\u6807 Media \u5BF9\u8C61\n */\nconst getIconByTimeStatus = (icon: StateIcon | undefined, timeStatus: TimeStatus): Media | undefined => {\n if (!icon) return undefined\n // \u8FDB\u884C\u4E2D\u4F7F\u7528 active \u56FE\u6807\n if (timeStatus === 'in-progress') return icon.active\n // \u5DF2\u5B8C\u6210\u4F7F\u7528 completed \u56FE\u6807\uFF08\u5982\u679C\u6709\uFF09\uFF0C\u5426\u5219\u4F7F\u7528 inactive\n if (timeStatus === 'completed') return icon.completed || icon.inactive\n // \u672A\u5F00\u59CB\u4F7F\u7528 inactive \u56FE\u6807\n return icon.inactive\n}\n\n/**\n * \u6D3B\u52A8\u65E5\u7A0B\u5361\u7247\u7EC4\u4EF6\n */\nconst EventScheduleCard = ({\n timeStatus,\n item,\n theme = 'light',\n className,\n scheduleCount,\n}: {\n timeStatus: TimeStatus\n item: EventScheduleItem\n theme?: 'light' | 'dark'\n className?: string\n scheduleCount: number\n}) => {\n const currentIcon = React.useMemo(() => {\n return getIconByTimeStatus(item.icon, timeStatus)\n }, [item.icon, timeStatus])\n\n // \u8BA1\u7B97\u7EC4\u5408\u72B6\u6001\n const cardState = `${timeStatus}-${theme}` as\n | 'in-progress-light'\n | 'in-progress-dark'\n | 'not-started-light'\n | 'not-started-dark'\n | 'completed-light'\n | 'completed-dark'\n\n return (\n <div\n className={cn(\n `event-schedule-card event-schedule-card--${timeStatus}`,\n eventScheduleCardVariants({ state: cardState }),\n className\n )}\n >\n {/* \u80CC\u666F\u56FE\u6807 */}\n {currentIcon && (\n <div\n className={`event-schedule-card__background-icon event-schedule-card__background-icon--${timeStatus} laptop:w-[128px] desktop:w-[160px] absolute bottom-0 right-0 z-10 w-[120px]`}\n >\n <Picture source={currentIcon.url} alt={currentIcon.alt} className=\"aspect-square\" />\n </div>\n )}\n {/* \u5185\u5BB9\u533A\u57DF */}\n <div\n className={`event-schedule-card__content event-schedule-card__content--${timeStatus} tablet:px-4 tablet:py-3 desktop:pl-6 desktop:pr-16 relative z-20 flex h-full flex-col justify-between p-4 pr-8`}\n >\n <Heading\n html={item.title}\n className={cn(\n `event-schedule-card__title event-schedule-card__title--${timeStatus}`,\n scheduleCount >= 4 ? 'desktop:text-[24px]' : 'desktop:text-[32px]',\n 'laptop:text-[24px] line-clamp-1 text-[20px]',\n cardTextVariants({ state: cardState })\n )}\n />\n {/* \u8BE6\u7EC6\u4FE1\u606F\u5217\u8868 */}\n <div\n className={`event-schedule-card__details event-schedule-card__details--${timeStatus} flex flex-col gap-0.5`}\n >\n {item.items.map((detail, index) => (\n <div\n key={index}\n className={`event-schedule-card__detail-item event-schedule-card__detail-item--${timeStatus} flex items-center gap-2`}\n >\n {/* \u56FE\u6807 */}\n {detail.icon && (\n <Text\n className={cn(\n `event-schedule-card__detail-icon event-schedule-card__detail-icon--${timeStatus} desktop:size-6 size-5 shrink-0`,\n cardTextVariants({ state: cardState })\n )}\n html={detail.icon}\n />\n )}\n {/* \u6587\u672C */}\n <Text\n html={detail.label}\n className={cn(\n `event-schedule-card__detail-text event-schedule-card__detail-text--${timeStatus} lg-desktop:text-[18px] desktop:text-[16px] line-clamp-1 flex-1 text-[14px] leading-[1.4]`,\n cardTextVariants({ state: cardState })\n )}\n />\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n\n/**\n * EventSchedule - \u6D3B\u52A8\u65E5\u7A0B\u7EC4\u4EF6\n *\n * @description \u663E\u793A\u6D3B\u52A8\u65E5\u7A0B\u65F6\u95F4\u8F74\u548C\u6D3B\u52A8\u5361\u7247\u5217\u8868\n */\nconst EventSchedule = React.forwardRef<HTMLDivElement, EventScheduleProps>(\n ({ classNames = {}, data, className, ...rest }, ref) => {\n const theme = data.theme || 'light'\n const swiperRef = React.useRef<SwiperType | null>(null)\n const timelineSwiperRef = React.useRef<SwiperType | null>(null)\n const isSyncingRef = React.useRef(false) // \u9632\u6B62\u5FAA\u73AF\u89E6\u53D1\n const itemsPerRow = React.useMemo(() => {\n return data?.scheduleList?.length || 2\n }, [data?.scheduleList])\n\n // \u8BA1\u7B97\u8FDB\u884C\u4E2D item \u7684\u7D22\u5F15\uFF08\u7528\u4E8E\u81EA\u52A8\u6EDA\u52A8\uFF09\n const activeIndex = React.useMemo(() => {\n return data.scheduleList.findIndex(item => {\n const timeStatus = getTimeStatus(item.startDate, item.endDate)\n return timeStatus === 'in-progress'\n })\n }, [data.scheduleList])\n\n /**\n * \u751F\u6210\u7EDF\u4E00\u7684 Swiper \u65AD\u70B9\u914D\u7F6E\n * @param itemsPerRow \u6BCF\u884C\u663E\u793A\u7684\u9879\u76EE\u6570\n * @param withSpaceBetween \u662F\u5426\u5305\u542B\u95F4\u8DDD\u914D\u7F6E\n * @returns Swiper \u65AD\u70B9\u914D\u7F6E\u5BF9\u8C61\n */\n const generateSwiperBreakpoints = React.useCallback((itemsPerRow: number, withSpaceBetween: boolean = false) => {\n // \u6839\u636E itemsPerRow \u786E\u5B9A\u4E0D\u540C\u65AD\u70B9\u4E0B\u7684 slidesPerView\n const getBreakpointConfig = (breakpoint: 'mobile' | 'tablet' | 'laptop' | 'desktop') => {\n switch (breakpoint) {\n case 'mobile':\n return { slidesPerView: 1.17 }\n case 'tablet':\n if (itemsPerRow === 2) return { slidesPerView: 2 }\n return { slidesPerView: 2.4 }\n case 'laptop':\n if (itemsPerRow === 2) return {}\n if (itemsPerRow === 4) return { slidesPerView: 3.2 }\n return { slidesPerView: itemsPerRow }\n case 'desktop':\n if (itemsPerRow === 2) return { slidesPerView: 2 }\n return { slidesPerView: itemsPerRow }\n }\n }\n\n const mobileConfig = getBreakpointConfig('mobile')\n const tabletConfig = getBreakpointConfig('tablet')\n const laptopConfig = getBreakpointConfig('laptop')\n const desktopConfig = getBreakpointConfig('desktop')\n\n // \u5982\u679C\u9700\u8981 spaceBetween\uFF0C\u5219\u6DFB\u52A0\u5230\u914D\u7F6E\u4E2D\n if (withSpaceBetween) {\n return {\n 0: { ...mobileConfig, spaceBetween: 12 },\n 768: { ...tabletConfig, spaceBetween: 12 },\n 1024: { ...laptopConfig, spaceBetween: 16 },\n 1440: { ...desktopConfig, spaceBetween: 16 },\n }\n }\n\n return {\n 0: mobileConfig,\n 768: tabletConfig,\n 1024: laptopConfig,\n 1440: desktopConfig,\n }\n }, [])\n\n // \u6839\u636E itemsPerRow \u914D\u7F6E\u54CD\u5E94\u5F0F\u65AD\u70B9\uFF08\u5361\u7247 Swiper - \u5305\u542B\u95F4\u8DDD\uFF09\n const swiperBreakpoints = React.useMemo(() => {\n return generateSwiperBreakpoints(itemsPerRow, true)\n }, [itemsPerRow, generateSwiperBreakpoints])\n\n // \u65F6\u95F4\u8F74 Swiper \u65AD\u70B9\u914D\u7F6E\uFF08\u4E0D\u5305\u542B\u95F4\u8DDD\uFF09\n const timeNodeSwiperBreakpoints = React.useMemo(() => {\n return generateSwiperBreakpoints(itemsPerRow, false)\n }, [itemsPerRow, generateSwiperBreakpoints])\n\n const showTimeline = data.showTimeline !== false // \u9ED8\u8BA4\u4E3A true\n\n // \u540C\u6B65\u4E24\u4E2A Swiper \u7684\u6ED1\u52A8\n const handleCardSwiperSlideChange = React.useCallback((swiper: SwiperType) => {\n if (isSyncingRef.current || !timelineSwiperRef.current) return\n isSyncingRef.current = true\n timelineSwiperRef.current.slideTo(swiper.activeIndex, swiper.params.speed)\n // \u5EF6\u8FDF\u91CD\u7F6E\u6807\u5FD7\uFF0C\u786E\u4FDD\u540C\u6B65\u5B8C\u6210\n setTimeout(() => {\n isSyncingRef.current = false\n }, 50)\n }, [])\n\n const handleTimelineSwiperSlideChange = React.useCallback((swiper: SwiperType) => {\n if (isSyncingRef.current || !swiperRef.current) return\n isSyncingRef.current = true\n swiperRef.current.slideTo(swiper.activeIndex, swiper.params.speed)\n // \u5EF6\u8FDF\u91CD\u7F6E\u6807\u5FD7\uFF0C\u786E\u4FDD\u540C\u6B65\u5B8C\u6210\n setTimeout(() => {\n isSyncingRef.current = false\n }, 50)\n }, [])\n\n // \u81EA\u52A8\u6EDA\u52A8\u5230 active item\n React.useEffect(() => {\n if (swiperRef.current && timelineSwiperRef.current && activeIndex >= 0) {\n // \u5EF6\u8FDF\u6267\u884C\uFF0C\u786E\u4FDD Swiper \u5DF2\u7ECF\u5B8C\u5168\u521D\u59CB\u5316\n setTimeout(() => {\n isSyncingRef.current = true\n swiperRef.current?.slideTo(activeIndex, 500)\n timelineSwiperRef.current?.slideTo(activeIndex, 500)\n setTimeout(() => {\n isSyncingRef.current = false\n }, 600)\n }, 100)\n }\n }, [activeIndex])\n\n return (\n <Container {...rest} ref={ref} className={cn('event-schedule-root overflow-hidden', classNames?.root, className)}>\n {showTimeline && (\n <Swiper\n breakpoints={timeNodeSwiperBreakpoints}\n className=\"event-schedule-timeline h-4 w-full !overflow-visible\"\n onSwiper={swiper => {\n timelineSwiperRef.current = swiper\n }}\n onSlideChange={handleTimelineSwiperSlideChange}\n >\n {data.scheduleList.map((item, index) => {\n const timeStatus = getTimeStatus(item.startDate, item.endDate)\n return (\n <SwiperSlide key={'timelineNode' + index} className=\"\">\n <TimelineNode\n className={classNames?.timeline}\n timeStatus={timeStatus}\n theme={theme}\n index={index}\n nodeLength={data.scheduleList.length}\n />\n </SwiperSlide>\n )\n })}\n </Swiper>\n )}\n <Swiper\n breakpoints={swiperBreakpoints}\n className=\"event-schedule-cards w-full !overflow-visible\"\n onSwiper={swiper => {\n swiperRef.current = swiper\n }}\n onSlideChange={handleCardSwiperSlideChange}\n >\n {data.scheduleList.map((item, index) => {\n const timeStatus = getTimeStatus(item.startDate, item.endDate)\n return (\n <SwiperSlide key={'SwiperSlideItem' + index}>\n <EventScheduleCard\n timeStatus={timeStatus}\n className={cn(showTimeline ? 'laptop:mt-4 mt-2' : '', classNames?.eventScheduleCard)}\n item={item}\n theme={theme}\n scheduleCount={data.scheduleList.length}\n />\n </SwiperSlide>\n )\n })}\n </Swiper>\n </Container>\n )\n }\n)\n\nEventSchedule.displayName = 'EventSchedule'\nexport default withLayout(EventSchedule)\n\n// \u5BFC\u51FA\u7C7B\u578B\u4F9B\u5916\u90E8\u4F7F\u7528\n// export type { StateIcon, EventScheduleItem, EventScheduleData, EventScheduleProps }\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "React", "cn", "withLayout", "Text", "Picture", "Heading", "Container", "Swiper", "SwiperSlide", "
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { Text, Picture, Heading, Container } from '../../components/index.js'\nimport { Swiper, SwiperSlide } from 'swiper/react'\nimport type { Swiper as SwiperType } from 'swiper'\nimport { cva } from 'class-variance-authority'\nimport type { Media } from '../../types/props.js'\nexport type EventScheduleSemanticName = 'root' | 'timeline' | 'eventScheduleCard'\n\n/**\n * \u65F6\u95F4\u72B6\u6001\u7C7B\u578B\n */\nexport type TimeStatus = 'completed' | 'in-progress' | 'not-started'\n\n/**\n * \u72B6\u6001\u5316\u56FE\u6807\u914D\u7F6E\n */\nexport interface StateIcon {\n /** \u6FC0\u6D3B\u72B6\u6001\u7684\u56FE\u6807\uFF08\u8FDB\u884C\u4E2D\uFF09 */\n active: Media\n /** \u975E\u6FC0\u6D3B\u72B6\u6001\u7684\u56FE\u6807\uFF08\u672A\u5F00\u59CB\uFF09 */\n inactive: Media\n /** \u5DF2\u5B8C\u6210\u72B6\u6001\u7684\u56FE\u6807\uFF08\u53EF\u9009\uFF0C\u4E0D\u63D0\u4F9B\u5219\u4F7F\u7528 inactive\uFF09 */\n completed?: Media\n}\n\n/**\n * \u6D3B\u52A8\u65E5\u7A0B\u9879\u6570\u636E\u63A5\u53E3\n */\nexport interface EventScheduleItem {\n /** \u6807\u9898 */\n title: string\n /** \u5F00\u59CB\u65E5\u671F\uFF08ISO 8601 \u683C\u5F0F\uFF0C\u5982 '2024-12-01T00:00:00Z'\uFF09 */\n startDate: string\n /** \u7ED3\u675F\u65E5\u671F\uFF08ISO 8601 \u683C\u5F0F\uFF0C\u5982 '2024-12-31T23:59:59Z'\uFF09 */\n endDate: string\n /**\n * \u5361\u7247\u80CC\u666F\u56FE\u6807\u914D\u7F6E\uFF0C\u72B6\u6001\u5316\u56FE\u6807\uFF08\u5FC5\u987B\u5305\u542B active \u548C inactive\uFF09\n *\n * @example\n * icon: {\n * active: { url: \"https://example.com/active-icon.svg\", alt: \"Active Icon\" },\n * inactive: { url: \"https://example.com/inactive-icon.svg\", alt: \"Inactive Icon\" }\n * }\n */\n icon?: StateIcon\n /** \u8BE6\u7EC6\u4FE1\u606F\u5217\u8868 */\n items: {\n /** \u56FE\u6807 (SVG \u5B57\u7B26\u4E32\u6216 URL) */\n icon?: string\n /** \u6587\u672C\u5185\u5BB9 */\n label: string\n }[]\n}\n\n/**\n * EventSchedule \u4E1A\u52A1\u7EC4\u4EF6\u6570\u636E\u63A5\u53E3\n */\nexport interface EventScheduleData {\n /** \u65E5\u7A0B\u5217\u8868 */\n scheduleList: EventScheduleItem[]\n /** \u662F\u5426\u663E\u793A\u65F6\u95F4\u8F74\uFF0C\u9ED8\u8BA4\u4E3A true */\n showTimeline?: boolean\n /** \u4E3B\u9898\u6A21\u5F0F */\n theme?: 'light' | 'dark'\n}\n\nexport interface EventScheduleProps extends React.HTMLAttributes<HTMLDivElement> {\n /** \u4E1A\u52A1\u6570\u636E */\n data: EventScheduleData\n classNames?: Partial<Record<EventScheduleSemanticName, string>>\n}\n\n/**\n * \u83B7\u53D6\u65F6\u95F4\u72B6\u6001\n * @param startDate \u5F00\u59CB\u65E5\u671F\n * @param endDate \u7ED3\u675F\u65E5\u671F\n * @returns \u65F6\u95F4\u72B6\u6001\uFF1Acompleted\uFF08\u5DF2\u5B8C\u6210\uFF09\u3001in-progress\uFF08\u8FDB\u884C\u4E2D\uFF09\u3001not-started\uFF08\u672A\u5F00\u59CB\uFF09\n */\nconst getTimeStatus = (startDate: string, endDate: string): TimeStatus => {\n const now = Date.now()\n const start = new Date(startDate).getTime()\n const end = new Date(endDate).getTime()\n\n // \u5F53\u524D\u65F6\u95F4\u5728\u7ED3\u675F\u65F6\u95F4\u4E4B\u540E - \u5DF2\u5B8C\u6210\n if (now > end) {\n return 'completed'\n }\n\n // \u5F53\u524D\u65F6\u95F4\u5728\u5F00\u59CB\u65F6\u95F4\u4E4B\u524D - \u672A\u5F00\u59CB\n if (now < start) {\n return 'not-started'\n }\n\n // \u5F53\u524D\u65F6\u95F4\u5728\u5F00\u59CB\u548C\u7ED3\u675F\u4E4B\u95F4 - \u8FDB\u884C\u4E2D\n return 'in-progress'\n}\n\n/**\n * \u65F6\u95F4\u8F74\u8FDB\u5EA6\u6761\u6837\u5F0F\u53D8\u4F53\uFF08\u652F\u6301\u4E09\u79CD\u65F6\u95F4\u72B6\u6001\uFF09\n */\nconst timelineProgressActiveVariants = cva('h-1 w-full overflow-hidden', {\n variants: {\n state: {\n // \u8FDB\u884C\u4E2D\n 'in-progress-light': 'bg-[#F6CD4E]',\n 'in-progress-dark': 'bg-[#D79941]',\n // \u672A\u5F00\u59CB\n 'not-started-light': 'bg-[#EAEAEC]',\n 'not-started-dark': 'bg-[#1E2024]',\n // \u5DF2\u5B8C\u6210\n 'completed-light': 'bg-[#F6CD4E]',\n 'completed-dark': 'bg-[#D79941]',\n },\n },\n defaultVariants: {\n state: 'not-started-light',\n },\n})\n\n/**\n * \u65F6\u95F4\u8F74\u8282\u70B9\u6837\u5F0F\u53D8\u4F53\uFF08\u652F\u6301\u4E09\u79CD\u65F6\u95F4\u72B6\u6001\uFF09\n */\nconst timelineNodeActiveVariants = cva('size-4 rounded-full transition-colors', {\n variants: {\n state: {\n // \u8FDB\u884C\u4E2D\n 'in-progress-light': 'bg-[#F6CD4E]',\n 'in-progress-dark': 'bg-[#D79941]',\n // \u672A\u5F00\u59CB\n 'not-started-light': 'bg-[#EAEAEC]',\n 'not-started-dark': 'bg-[#1E2024]',\n // \u5DF2\u5B8C\u6210\uFF08\u4E0E\u8FDB\u884C\u4E2D\u989C\u8272\u4E00\u81F4\uFF09\n 'completed-light': 'bg-[#F6CD4E]',\n 'completed-dark': 'bg-[#D79941]',\n },\n },\n defaultVariants: {\n state: 'not-started-light',\n },\n})\n\n/**\n * \u5361\u7247\u6587\u672C\u6837\u5F0F\u53D8\u4F53\uFF08\u652F\u6301\u4E09\u79CD\u65F6\u95F4\u72B6\u6001\uFF09\n */\nconst cardTextVariants = cva('font-bold leading-[1.2]', {\n variants: {\n state: {\n // \u8FDB\u884C\u4E2D\uFF08\u4FDD\u6301\u539F\u6709\u989C\u8272\uFF09\n 'in-progress-light': 'text-[#080A0F]',\n 'in-progress-dark': 'text-white',\n // \u672A\u5F00\u59CB\uFF0860% \u900F\u660E\u5EA6\uFF09\n 'not-started-light': 'text-[#080A0F]',\n 'not-started-dark': 'text-[#F5F6F7]',\n // \u5DF2\u5B8C\u6210\uFF0860% \u900F\u660E\u5EA6\uFF09\n 'completed-light': 'text-[#4A4C56]/60',\n 'completed-dark': 'text-[#F5F6F7]/60',\n },\n },\n defaultVariants: {\n state: 'not-started-light',\n },\n})\n\n/**\n * \u5361\u7247\u5BB9\u5668\u6837\u5F0F\u53D8\u4F53\uFF08\u652F\u6301\u4E09\u79CD\u65F6\u95F4\u72B6\u6001\uFF09\n */\nconst eventScheduleCardVariants = cva(\n 'laptop:h-[160px] rounded-box relative flex h-[120px] min-w-0 flex-col justify-between gap-2 overflow-hidden',\n {\n variants: {\n state: {\n // \u8FDB\u884C\u4E2D\n 'in-progress-light': 'bg-[#F4E8BC]',\n 'in-progress-dark': 'bg-[#D79941]',\n // \u672A\u5F00\u59CB\n 'not-started-light': 'bg-[#EAEAEC]',\n 'not-started-dark': 'bg-[#1E2024]',\n // \u5DF2\u5B8C\u6210\n 'completed-light': 'bg-[#F4E8BC]',\n 'completed-dark': 'bg-[#D79941]',\n },\n },\n defaultVariants: {\n state: 'not-started-light',\n },\n }\n)\n\n/**\n * \u65F6\u95F4\u8F74\u8282\u70B9\u7EC4\u4EF6 Props\n */\ninterface TimelineNodeProps {\n /** \u65F6\u95F4\u72B6\u6001 */\n timeStatus: TimeStatus\n /** \u4E3B\u9898\u6A21\u5F0F */\n theme?: 'light' | 'dark'\n /** \u81EA\u5B9A\u4E49\u7C7B\u540D */\n className?: string\n /** \u5F53\u524D\u8282\u70B9\u7D22\u5F15 */\n index: number\n /** \u8282\u70B9\u603B\u6570 */\n nodeLength: number\n}\n\n/**\n * \u65F6\u95F4\u8F74\u8282\u70B9\u7EC4\u4EF6\n */\nconst TimelineNode = ({ timeStatus, theme = 'light', className, index, nodeLength }: TimelineNodeProps) => {\n // \u8BA1\u7B97\u7EC4\u5408\u72B6\u6001\n const state = `${timeStatus}-${theme}` as\n | 'in-progress-light'\n | 'in-progress-dark'\n | 'not-started-light'\n | 'not-started-dark'\n | 'completed-light'\n | 'completed-dark'\n\n // \u5224\u65AD\u9996\u5C3E\u4F4D\u7F6E\n const isFirst = index === 0\n const isLast = index === nodeLength - 1\n\n return (\n <div\n className={cn(\n `event-schedule-timeline-node event-schedule-timeline-node--${timeStatus} relative my-2 flex h-1 w-full items-center justify-center`,\n className\n )}\n >\n {/* \u8FDB\u5EA6\u6761\u80CC\u666F */}\n <div\n className={cn(\n `event-schedule-timeline-progress event-schedule-timeline-progress--${timeStatus}`,\n timelineProgressActiveVariants({ state }),\n isFirst && 'rounded-l-full',\n isLast && 'rounded-r-full'\n )}\n />\n {/* \u65F6\u95F4\u8282\u70B9\u5706\u70B9 */}\n <div className=\"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2\">\n <div\n className={cn(\n `event-schedule-timeline-dot event-schedule-timeline-dot--${timeStatus}`,\n timelineNodeActiveVariants({ state })\n )}\n />\n </div>\n </div>\n )\n}\n\n/**\n * \u6839\u636E\u65F6\u95F4\u72B6\u6001\u83B7\u53D6\u5BF9\u5E94\u7684\u56FE\u6807\n * @param icon \u72B6\u6001\u5316\u56FE\u6807\u914D\u7F6E\n * @param timeStatus \u65F6\u95F4\u72B6\u6001\n * @returns \u56FE\u6807 Media \u5BF9\u8C61\n */\nconst getIconByTimeStatus = (icon: StateIcon | undefined, timeStatus: TimeStatus): Media | undefined => {\n if (!icon) return undefined\n // \u8FDB\u884C\u4E2D\u4F7F\u7528 active \u56FE\u6807\n if (timeStatus === 'in-progress') return icon.active\n // \u5DF2\u5B8C\u6210\u4F7F\u7528 completed \u56FE\u6807\uFF08\u5982\u679C\u6709\uFF09\uFF0C\u5426\u5219\u4F7F\u7528 inactive\n if (timeStatus === 'completed') return icon.completed || icon.inactive\n // \u672A\u5F00\u59CB\u4F7F\u7528 inactive \u56FE\u6807\n return icon.inactive\n}\n\n/**\n * \u6D3B\u52A8\u65E5\u7A0B\u5361\u7247\u7EC4\u4EF6\n */\nconst EventScheduleCard = ({\n timeStatus,\n item,\n theme = 'light',\n className,\n scheduleCount,\n}: {\n timeStatus: TimeStatus\n item: EventScheduleItem\n theme?: 'light' | 'dark'\n className?: string\n scheduleCount: number\n}) => {\n const currentIcon = React.useMemo(() => {\n return getIconByTimeStatus(item.icon, timeStatus)\n }, [item.icon, timeStatus])\n\n // \u8BA1\u7B97\u7EC4\u5408\u72B6\u6001\n const cardState = `${timeStatus}-${theme}` as\n | 'in-progress-light'\n | 'in-progress-dark'\n | 'not-started-light'\n | 'not-started-dark'\n | 'completed-light'\n | 'completed-dark'\n\n return (\n <div\n className={cn(\n `event-schedule-card event-schedule-card--${timeStatus}`,\n eventScheduleCardVariants({ state: cardState }),\n className\n )}\n >\n {/* \u80CC\u666F\u56FE\u6807 */}\n {currentIcon && (\n <div\n className={`event-schedule-card__background-icon event-schedule-card__background-icon--${timeStatus} laptop:w-[128px] desktop:w-[160px] absolute bottom-0 right-0 z-10 w-[120px]`}\n >\n <Picture source={currentIcon.url} alt={currentIcon.alt} className=\"aspect-square\" />\n </div>\n )}\n {/* \u5185\u5BB9\u533A\u57DF */}\n <div\n className={`event-schedule-card__content event-schedule-card__content--${timeStatus} tablet:px-4 tablet:py-3 desktop:pl-6 desktop:pr-16 relative z-20 flex h-full flex-col justify-between p-4 pr-8`}\n >\n <Heading\n html={item.title}\n className={cn(\n `event-schedule-card__title event-schedule-card__title--${timeStatus}`,\n scheduleCount >= 4 ? 'desktop:text-[24px]' : 'desktop:text-[32px]',\n 'laptop:text-[24px] line-clamp-1 text-[20px]',\n cardTextVariants({ state: cardState })\n )}\n />\n {/* \u8BE6\u7EC6\u4FE1\u606F\u5217\u8868 */}\n <div\n className={`event-schedule-card__details event-schedule-card__details--${timeStatus} flex flex-col gap-0.5`}\n >\n {item.items.map((detail, index) => (\n <div\n key={index}\n className={`event-schedule-card__detail-item event-schedule-card__detail-item--${timeStatus} flex items-center gap-2`}\n >\n {/* \u56FE\u6807 */}\n {detail.icon && (\n <Text\n className={cn(\n `event-schedule-card__detail-icon event-schedule-card__detail-icon--${timeStatus} desktop:size-6 size-5 shrink-0`,\n cardTextVariants({ state: cardState })\n )}\n html={detail.icon}\n />\n )}\n {/* \u6587\u672C */}\n <Text\n html={detail.label}\n className={cn(\n `event-schedule-card__detail-text event-schedule-card__detail-text--${timeStatus} lg-desktop:text-[18px] desktop:text-[16px] line-clamp-1 flex-1 text-[14px] leading-[1.4]`,\n cardTextVariants({ state: cardState })\n )}\n />\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n\n/**\n * EventSchedule - \u6D3B\u52A8\u65E5\u7A0B\u7EC4\u4EF6\n *\n * @description \u663E\u793A\u6D3B\u52A8\u65E5\u7A0B\u65F6\u95F4\u8F74\u548C\u6D3B\u52A8\u5361\u7247\u5217\u8868\n */\nconst EventSchedule = React.forwardRef<HTMLDivElement, EventScheduleProps>(\n ({ classNames = {}, data, className, ...rest }, ref) => {\n const theme = data.theme || 'light'\n const swiperRef = React.useRef<SwiperType | null>(null)\n const timelineSwiperRef = React.useRef<SwiperType | null>(null)\n const isSyncingRef = React.useRef(false) // \u9632\u6B62\u5FAA\u73AF\u89E6\u53D1\n const itemsPerRow = React.useMemo(() => {\n return data?.scheduleList?.length || 2\n }, [data?.scheduleList])\n\n // \u8BA1\u7B97\u8FDB\u884C\u4E2D item \u7684\u7D22\u5F15\uFF08\u7528\u4E8E\u81EA\u52A8\u6EDA\u52A8\uFF09\n const activeIndex = React.useMemo(() => {\n return data.scheduleList.findIndex(item => {\n const timeStatus = getTimeStatus(item.startDate, item.endDate)\n return timeStatus === 'in-progress'\n })\n }, [data.scheduleList])\n\n /**\n * \u751F\u6210\u7EDF\u4E00\u7684 Swiper \u65AD\u70B9\u914D\u7F6E\n * @param itemsPerRow \u6BCF\u884C\u663E\u793A\u7684\u9879\u76EE\u6570\n * @param withSpaceBetween \u662F\u5426\u5305\u542B\u95F4\u8DDD\u914D\u7F6E\n * @returns Swiper \u65AD\u70B9\u914D\u7F6E\u5BF9\u8C61\n */\n const generateSwiperBreakpoints = React.useCallback((itemsPerRow: number, withSpaceBetween: boolean = false) => {\n // \u6839\u636E itemsPerRow \u786E\u5B9A\u4E0D\u540C\u65AD\u70B9\u4E0B\u7684 slidesPerView\n const getBreakpointConfig = (breakpoint: 'mobile' | 'tablet' | 'laptop' | 'desktop') => {\n switch (breakpoint) {\n case 'mobile':\n return { slidesPerView: 1.17 }\n case 'tablet':\n if (itemsPerRow === 2) return { slidesPerView: 2 }\n return { slidesPerView: 2.4 }\n case 'laptop':\n if (itemsPerRow === 2) return {}\n if (itemsPerRow === 4) return { slidesPerView: 3.2 }\n return { slidesPerView: itemsPerRow }\n case 'desktop':\n if (itemsPerRow === 2) return { slidesPerView: 2 }\n return { slidesPerView: itemsPerRow }\n }\n }\n\n const mobileConfig = getBreakpointConfig('mobile')\n const tabletConfig = getBreakpointConfig('tablet')\n const laptopConfig = getBreakpointConfig('laptop')\n const desktopConfig = getBreakpointConfig('desktop')\n\n // \u5982\u679C\u9700\u8981 spaceBetween\uFF0C\u5219\u6DFB\u52A0\u5230\u914D\u7F6E\u4E2D\n if (withSpaceBetween) {\n return {\n 0: { ...mobileConfig, spaceBetween: 12 },\n 768: { ...tabletConfig, spaceBetween: 12 },\n 1024: { ...laptopConfig, spaceBetween: 16 },\n 1440: { ...desktopConfig, spaceBetween: 16 },\n }\n }\n\n return {\n 0: mobileConfig,\n 768: tabletConfig,\n 1024: laptopConfig,\n 1440: desktopConfig,\n }\n }, [])\n\n // \u6839\u636E itemsPerRow \u914D\u7F6E\u54CD\u5E94\u5F0F\u65AD\u70B9\uFF08\u5361\u7247 Swiper - \u5305\u542B\u95F4\u8DDD\uFF09\n const swiperBreakpoints = React.useMemo(() => {\n return generateSwiperBreakpoints(itemsPerRow, true)\n }, [itemsPerRow, generateSwiperBreakpoints])\n\n // \u65F6\u95F4\u8F74 Swiper \u65AD\u70B9\u914D\u7F6E\uFF08\u4E0D\u5305\u542B\u95F4\u8DDD\uFF09\n const timeNodeSwiperBreakpoints = React.useMemo(() => {\n return generateSwiperBreakpoints(itemsPerRow, false)\n }, [itemsPerRow, generateSwiperBreakpoints])\n\n const showTimeline = data.showTimeline !== false // \u9ED8\u8BA4\u4E3A true\n\n // \u540C\u6B65\u4E24\u4E2A Swiper \u7684\u6ED1\u52A8\n const handleCardSwiperSlideChange = React.useCallback((swiper: SwiperType) => {\n if (isSyncingRef.current || !timelineSwiperRef.current) return\n isSyncingRef.current = true\n timelineSwiperRef.current.slideTo(swiper.activeIndex, swiper.params.speed)\n // \u5EF6\u8FDF\u91CD\u7F6E\u6807\u5FD7\uFF0C\u786E\u4FDD\u540C\u6B65\u5B8C\u6210\n setTimeout(() => {\n isSyncingRef.current = false\n }, 50)\n }, [])\n\n const handleTimelineSwiperSlideChange = React.useCallback((swiper: SwiperType) => {\n if (isSyncingRef.current || !swiperRef.current) return\n isSyncingRef.current = true\n swiperRef.current.slideTo(swiper.activeIndex, swiper.params.speed)\n // \u5EF6\u8FDF\u91CD\u7F6E\u6807\u5FD7\uFF0C\u786E\u4FDD\u540C\u6B65\u5B8C\u6210\n setTimeout(() => {\n isSyncingRef.current = false\n }, 50)\n }, [])\n\n // \u81EA\u52A8\u6EDA\u52A8\u5230 active item\n React.useEffect(() => {\n if (swiperRef.current && timelineSwiperRef.current && activeIndex >= 0) {\n // \u5EF6\u8FDF\u6267\u884C\uFF0C\u786E\u4FDD Swiper \u5DF2\u7ECF\u5B8C\u5168\u521D\u59CB\u5316\n setTimeout(() => {\n isSyncingRef.current = true\n swiperRef.current?.slideTo(activeIndex, 500)\n timelineSwiperRef.current?.slideTo(activeIndex, 500)\n setTimeout(() => {\n isSyncingRef.current = false\n }, 600)\n }, 100)\n }\n }, [activeIndex])\n\n return (\n <Container {...rest} ref={ref} className={cn('event-schedule-root overflow-hidden', classNames?.root, className)}>\n {showTimeline && (\n <Swiper\n breakpoints={timeNodeSwiperBreakpoints}\n className=\"event-schedule-timeline h-4 w-full !overflow-visible\"\n onSwiper={swiper => {\n timelineSwiperRef.current = swiper\n }}\n onSlideChange={handleTimelineSwiperSlideChange}\n >\n {data.scheduleList.map((item, index) => {\n const timeStatus = getTimeStatus(item.startDate, item.endDate)\n return (\n <SwiperSlide key={'timelineNode' + index} className=\"\">\n <TimelineNode\n className={classNames?.timeline}\n timeStatus={timeStatus}\n theme={theme}\n index={index}\n nodeLength={data.scheduleList.length}\n />\n </SwiperSlide>\n )\n })}\n </Swiper>\n )}\n <Swiper\n breakpoints={swiperBreakpoints}\n className=\"event-schedule-cards w-full !overflow-visible\"\n onSwiper={swiper => {\n swiperRef.current = swiper\n }}\n onSlideChange={handleCardSwiperSlideChange}\n >\n {data.scheduleList.map((item, index) => {\n const timeStatus = getTimeStatus(item.startDate, item.endDate)\n return (\n <SwiperSlide key={'SwiperSlideItem' + index}>\n <EventScheduleCard\n timeStatus={timeStatus}\n className={cn(showTimeline ? 'laptop:mt-4 mt-2' : '', classNames?.eventScheduleCard)}\n item={item}\n theme={theme}\n scheduleCount={data.scheduleList.length}\n />\n </SwiperSlide>\n )\n })}\n </Swiper>\n </Container>\n )\n }\n)\n\nEventSchedule.displayName = 'EventSchedule'\nexport default withLayout(EventSchedule)\n\n// \u5BFC\u51FA\u7C7B\u578B\u4F9B\u5916\u90E8\u4F7F\u7528\n// export type { StateIcon, EventSche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AAK,UAAWA,EAAK,OAAO,EAC7D,OACElC,EAACU,EAAA,CACC,SAAAV,EAACiC,EAAA,CACC,WAAYV,EACZ,UAAWpB,EAAGwD,EAAe,mBAAqB,GAAInB,GAAY,iBAAiB,EACnF,KAAMN,EACN,MAAOV,EACP,cAAeiB,EAAK,aAAa,OACnC,GAPgB,kBAAoBf,CAQtC,CAEJ,CAAC,EACH,GACF,CAEJ,CACF,EAEAa,EAAc,YAAc,gBAC5B,IAAOwB,EAAQ3D,EAAWmC,CAAa",
|
|
6
|
+
"names": ["jsx", "jsxs", "React", "cn", "withLayout", "Text", "Picture", "Heading", "Container", "Swiper", "SwiperSlide", "cva", "getTimeStatus", "startDate", "endDate", "now", "start", "end", "timelineProgressActiveVariants", "timelineNodeActiveVariants", "cardTextVariants", "eventScheduleCardVariants", "TimelineNode", "timeStatus", "theme", "className", "index", "nodeLength", "state", "isFirst", "isLast", "getIconByTimeStatus", "icon", "EventScheduleCard", "item", "scheduleCount", "currentIcon", "cardState", "detail", "EventSchedule", "classNames", "data", "rest", "ref", "swiperRef", "timelineSwiperRef", "isSyncingRef", "itemsPerRow", "activeIndex", "generateSwiperBreakpoints", "withSpaceBetween", "getBreakpointConfig", "breakpoint", "mobileConfig", "tabletConfig", "laptopConfig", "desktopConfig", "swiperBreakpoints", "timeNodeSwiperBreakpoints", "showTimeline", "handleCardSwiperSlideChange", "swiper", "handleTimelineSwiperSlideChange", "EventSchedule_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Text as s,Button as _,Grid as Y,GridItem as q,Picture as z,Heading as Z}from"../../../../../components/index.js";import{useBizProductContext as A}from"../../../BizProductProvider.js";import{useComponentData as ee}from"../../../hooks/useComponentData.js";import{useEffect as te,useMemo as S,useState as ae}from"react";import{formatPrice as y}from"../../../utils/index.js";import{useAiuiContext as T}from"../../../../AiuiProvider/index.js";import J from"decimal.js";import{replaceTemplate as oe}from"../../../utils/textFormat.js";import{withLayout as ne}from"../../../../../shared/Styles.js";import{ExposureDetector as le}from"../../../../../components/index.js";import{gaTrack as ie}from"../../../../../shared/track.js";import re from"../../CartActionButtons/index.js";const ce=()=>{const{locale:m="us",copyWriting:a}=T(),{product:x,variant:n,finalPrice:g,comparePrice:f,coupon:P,selectedOptions:d,selectedVariants:v,totalSavings:i,onAddToCart:D,onBuyNow:E,savingDetail:b,checkedBundle:C,joinedRecommendBuyProducts:t,setJoinedRecommendBuyProducts:p,setSavingDetail:j,addToCartLoading:O,buyNowLoading:L,profile:G,addOrder:$,setAddOrder:w}=A(),B=ee("ProductSummary")??{},[F]=v,I=S(()=>{const r=C?.variants.find(N=>N.variant.sku===F?.sku),l=new J(F?.price?.amount||0).minus(r?.price||F?.price?.amount).toNumber();let u=new J(F?.price?.amount||0);G?.email&&(u=u.minus(b?.member||0));const h=u.minus(b?.coupon).minus(l).toNumber();return parseFloat(h.toFixed(2))},[F,C,G,b?.member,b?.coupon]),{bundleVariant:V,giftVariant:R,exchangeVariant:W}=se()||{},[c,k]=ae();te(()=>{k({bundle:t.bundle?.value?void 0:V,gift:t.gift?.value?void 0:R,exchange:t.exchange?.value?void 0:W})},[V,R,W,t]);const M=S(()=>{const r=[];return $&&$.forEach((l,u)=>{t[l]?.value&&r.push({type:l,key:`${l}-${u}`})}),r},[$,t]),U=S(()=>{const r=d?.quantity||"",l=d?.color||d?.colour||d?.couleur||"";return`${r&&l?`${r} | ${l}`:r||l}`},[d?.quantity,d?.color,d?.colour,d?.couleur]),X=S(()=>{const{image_1920:r,image_1440:l,image_1024:u,image_768:h,image_390:N}=B?.thumbnail||{};return(B?.thumbnail?`${r} 1920, ${l} 1440, ${u} 1024, ${h} 768, ${N} 390`:n.image?.url)||n.image?.url},[B?.thumbnail,n.image?.url]);return n.availableForSale?e("div",{className:"ipc-product-summary laptop:px-16 laptop-md:px-0 laptop-md:mt-[96px] lg-desktop:mt-[128px] mt-16",children:e("div",{className:"laptop:rounded-2xl bg-[#F5F5F7]",children:o(Y,{className:"tablet:p-8 tablet:!pb-0 px-4 pt-6",children:[o(q,{className:"laptop:col-start-1 laptop:col-span-5 col-span-12 flex flex-col justify-between gap-4",children:[e(Z,{className:"lg-desktop:text-[48px] laptop:text-[32px] laptop-md:text-[40px] mb-4 text-[24px] font-bold leading-none [&>span]:text-[#D1D1D1]",html:B?.readyWant?.replace?.("{title}",x?.title)}),e("div",{className:"",children:e(z,{source:X,className:"lg-desktop:aspect-[644/320] laptop-md:aspect-[503/270] laptop:aspect-[332/190] tablet:aspect-[704/380] aspect-[358/190]",imgClassName:"object-cover h-full"})})]}),o(q,{className:"tablet:pb-8 laptop:col-start-7 laptop:mt-0 laptop:col-span-6 col-span-12 mt-8 flex flex-col justify-between gap-6 pb-6",children:[o("div",{children:[o("div",{className:"flex flex-col gap-4",children:[e(le,{exposureKey:"listing_selector",onExposure:()=>{ie({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:`Product Detail Page${n.sku}`,component_type:"image",component_name:"listing_selector",position:1}})},children:o("div",{className:"flex items-center justify-between gap-6",children:[o("div",{className:"flex items-center gap-4",children:[e(z,{source:n.image?.url||x?.images?.[0]?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),o("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:x.title}),e(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]",html:U})]})]}),o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:y({amount:I,currencyCode:n.price.currencyCode,locale:m})}),I<n?.price?.amount&&e(s,{className:"laptop-md:text-2xl laptop:text-xl text-base font-bold text-[#6D6D6F] line-through",html:y({amount:n?.price?.amount,currencyCode:n.price.currencyCode,locale:m})})]})]})}),M.map(({type:r,key:l})=>r==="gift"&&t?.gift?.value?e(H,{giftOperation:u=>{p?.({...t,gift:{value:void 0,canOperate:!0}}),k?.({...c,gift:u}),w?.(h=>h.filter(N=>N!=="gift"))},status:!!t?.gift,gift:t?.gift?.value,canOperate:t?.gift?.canOperate},l):r==="bundle"&&t?.bundle?.value?e(Q,{bundleOperation:u=>{p?.({...t,bundle:{value:void 0,canOperate:!0}}),k?.({...c,bundle:u}),w?.(h=>h.filter(N=>N!=="bundle"))},status:!!t?.bundle,bundleListItem:t?.bundle?.value,canOperate:t?.bundle?.canOperate},l):r==="exchange"&&t?.exchange?.value?e(K,{exchangeOperation:u=>{p?.({...t,exchange:{value:void 0,canOperate:!0}}),k?.({...c,exchange:u}),w?.(h=>h.filter(N=>N!=="exchange"))},status:!!t?.exchange,canOperate:t?.exchange?.canOperate,exchange:t?.exchange?.value},l):null)]}),(c?.bundle||c?.gift||c?.exchange)&&o("div",{className:"laptop-md:mt-8 mt-6",children:[e(s,{className:"laptop-md:text-[18px] text-sm font-bold",html:B?.recommendBuy}),o("div",{className:"laptop-md:gap-4 mt-4 flex flex-col gap-6",children:[c?.exchange&&e(K,{exchangeOperation:r=>{p?.({...t,exchange:{value:r,canOperate:!0}}),k?.({...c,exchange:void 0}),w?.(l=>[...l,"exchange"])},canOperate:t?.exchange?.canOperate,status:!c?.exchange,exchange:c?.exchange}),c?.bundle&&e(Q,{bundleOperation:r=>{j?.({...b,exchangePurchase:0}),p?.({...t,bundle:{value:r,canOperate:!0}}),k?.({...c,bundle:void 0}),w?.(l=>[...l,"bundle"])},canOperate:t?.bundle?.canOperate,status:!c?.bundle,bundleListItem:c?.bundle}),c?.gift&&e(H,{giftOperation:r=>{p?.({...t,gift:{value:r,canOperate:!0}}),k?.({...c,gift:void 0}),w?.(l=>[...l,"gift"])},canOperate:t?.gift?.canOperate,status:!c?.gift,gift:c?.gift})]})]})]}),o("div",{className:"text-right",children:[e(s,{className:"laptop:text-xl laptop-md:text-2xl text-right font-bold",html:`${oe(a?.totalPrice||"",{amount:y({amount:parseFloat(g.toFixed(2)),currencyCode:n.price.currencyCode,locale:m})})}`}),i>0&&e(s,{className:"laptop:text-xl laptop-md:text-2xl ml-1 text-base font-bold text-[#6D6D6F] line-through",html:y({amount:f,currencyCode:n.price.currencyCode,locale:m})}),e("div",{className:"mt-4 flex justify-end gap-3",children:e(re,{availableForSale:n.availableForSale,addToCartText:a?.addToCart,buyNowText:a?.shopNow,addToCartLoading:O,buyNowLoading:L,addToCartClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2",buyNowClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2",onAddToCart:D,onBuyNow:E})})]})]})]})})}):null},se=()=>{const{bundle:m,variant:a,checkedBundle:x,freeGift:n,checkedGift:g,exchangePurchase:f,checkedExchangePurchase:P}=A();let d,v,i;const{bundleList:D}=m||{},{giftList:E=[]}=n||{},{giftList:b=[]}=f||{},C=D?.filter(O=>O.variants.slice(1,O.variants.length).every(L=>L.variant.availableForSale))||[],[t]=C;d=x||t;const[p]=E?.filter(O=>O.availableForSale)??[];v=g||p;const[j]=b?.filter(O=>O.availableForSale)??[];return i=P||j,{bundleVariant:d,giftVariant:v,exchangeVariant:i}},Q=({bundleOperation:m,bundleListItem:a,canOperate:x,status:n})=>{const{locale:g="us",copyWriting:f}=T(),{variant:P,setCheckedBundle:d}=A(),v=a?.variants.filter(i=>i.variant.sku!==P.sku);return e("div",{className:"",children:v?.map(i=>o("div",{className:"flex items-center justify-between gap-4",children:[o("div",{className:"flex items-center gap-4",children:[e(z,{source:i?.variant?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),e("div",{className:"tablet:max-w-none line-clamp-2 flex max-w-[178px] flex-col gap-[6px]",children:e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] text-[14px] font-bold",html:i.variant.product.title})})]}),o("div",{className:"flex flex-col items-end justify-center gap-1",children:[!!a&&o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:y({amount:i?.price||0,locale:g,currencyCode:i.variant?.price?.currencyCode||""})}),i.price<i.variant.price.amount&&e(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:y({amount:i.variant.price.amount||0,locale:g,currencyCode:i.variant?.price?.currencyCode||""})})]}),x&&e(_,{size:"icon",variant:"link",onClick:()=>{d?.(n?void 0:a),m?.(a)},className:"size-auto shrink-0 underline",children:n?f?.remove:f?.add})]})]},i.variant.id))})},H=({giftOperation:m,gift:a,status:x,canOperate:n})=>{const{locale:g="us",copyWriting:f}=T(),{freeGift:P,setCheckedGift:d}=A(),{freeLabel:v}=P||{},{options:i}=a||{},D=S(()=>{const E=i?.find(p=>p.name==="color"||p.name==="colour"||p.name==="couleur")||{},b=i?.find(p=>p.name==="quantity")||{},C=E?E.values?.[0]?.label:"",t=b?b.values?.[0]?.label:"";return`${C&&t?t+" | "+C:t||C} | ${v}`},[v,i]);return o("div",{className:"flex items-center justify-between gap-6",children:[o("div",{className:"flex items-center gap-4",children:[e(z,{source:a?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),o("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:a?.product?.title}),e(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]",html:D})]})]}),o("div",{className:"flex flex-col items-end justify-center gap-2",children:[!!a&&o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:v}),e(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:y({amount:a.price.amount,locale:g,currencyCode:a.price.currencyCode})})]}),n&&e(_,{size:"icon",variant:"link",onClick:()=>{d?.(x?void 0:a),m(a)},className:"size-auto shrink-0 underline",children:x?f?.remove:f?.add})]})]})},K=({exchangeOperation:m,exchange:a,canOperate:x,status:n})=>{const{locale:g="us",copyWriting:f}=T(),{setCheckedExchangePurchase:P}=A();return o("div",{className:"flex items-center justify-between gap-6",children:[o("div",{className:"flex items-center gap-4",children:[e(z,{source:a?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),o("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:a?.product?.title}),e(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]"})]})]}),o("div",{className:"flex flex-col items-end justify-center gap-2",children:[!!a&&o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:y({amount:a.finalPrice?.amount||0,locale:g,currencyCode:a.price.currencyCode})}),e(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:y({amount:a.price?.amount||0,locale:g,currencyCode:a.price.currencyCode})})]}),x&&e(_,{size:"icon",variant:"link",onClick:()=>{P?.(n?void 0:a),m(a)},className:"size-auto shrink-0 underline",children:n?f?.remove:f?.add})]})]})};var Oe=ne(ce);export{Oe as default};
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Text as s,Button as _,Grid as ee,GridItem as J,Picture as A,Heading as te}from"../../../../../components/index.js";import{useBizProductContext as S}from"../../../BizProductProvider.js";import{useComponentData as ae}from"../../../hooks/useComponentData.js";import{useEffect as oe,useMemo as T,useState as ne}from"react";import{formatPrice as N}from"../../../utils/index.js";import{useAiuiContext as j}from"../../../../AiuiProvider/index.js";import Q from"decimal.js";import{replaceTemplate as le}from"../../../utils/textFormat.js";import{withLayout as re}from"../../../../../shared/Styles.js";import{ExposureDetector as ie}from"../../../../../components/index.js";import{gaTrack as ce}from"../../../../../shared/track.js";import se from"../../CartActionButtons/index.js";const de=()=>{const{locale:m="us",copyWriting:a,trackingData:g}=j(),{product:p,variant:n,finalPrice:x,comparePrice:v,coupon:k,selectedOptions:d,selectedVariants:r,totalSavings:B,onAddToCart:w,onBuyNow:E,savingDetail:f,checkedBundle:y,joinedRecommendBuyProducts:t,setJoinedRecommendBuyProducts:P,setSavingDetail:C,addToCartLoading:L,buyNowLoading:U,profile:G,addOrder:$,setAddOrder:D}=S(),I=g?.showComparePrice??!0,F=ae("ProductSummary")??{},[z]=r,V=T(()=>{const i=y?.variants.find(h=>h.variant.sku===z?.sku),l=new Q(z?.price?.amount||0).minus(i?.price||z?.price?.amount).toNumber();let u=new Q(z?.price?.amount||0);G?.email&&(u=u.minus(f?.member||0));const b=u.minus(f?.coupon).minus(l).toNumber();return parseFloat(b.toFixed(2))},[z,y,G,f?.member,f?.coupon]),{bundleVariant:R,giftVariant:W,exchangeVariant:q}=pe()||{},[c,O]=ne();oe(()=>{O({bundle:t.bundle?.value?void 0:R,gift:t.gift?.value?void 0:W,exchange:t.exchange?.value?void 0:q})},[R,W,q,t]);const X=T(()=>{const i=[];return $&&$.forEach((l,u)=>{t[l]?.value&&i.push({type:l,key:`${l}-${u}`})}),i},[$,t]),Y=T(()=>{const i=d?.quantity||"",l=d?.color||d?.colour||d?.couleur||"";return`${i&&l?`${i} | ${l}`:i||l}`},[d?.quantity,d?.color,d?.colour,d?.couleur]),Z=T(()=>{const{image_1920:i,image_1440:l,image_1024:u,image_768:b,image_390:h}=F?.thumbnail||{};return(F?.thumbnail?`${i} 1920, ${l} 1440, ${u} 1024, ${b} 768, ${h} 390`:n.image?.url)||n.image?.url},[F?.thumbnail,n.image?.url]);return n.availableForSale?e("div",{className:"ipc-product-summary laptop:px-16 laptop-md:px-0 laptop-md:mt-[96px] lg-desktop:mt-[128px] mt-16",children:e("div",{className:"laptop:rounded-2xl bg-[#F5F5F7]",children:o(ee,{className:"tablet:p-8 tablet:!pb-0 px-4 pt-6",children:[o(J,{className:"laptop:col-start-1 laptop:col-span-5 col-span-12 flex flex-col justify-between gap-4",children:[e(te,{className:"lg-desktop:text-[48px] laptop:text-[32px] laptop-md:text-[40px] mb-4 text-[24px] font-bold leading-none [&>span]:text-[#D1D1D1]",html:F?.readyWant?.replace?.("{title}",p?.title)}),e("div",{className:"",children:e(A,{source:Z,className:"lg-desktop:aspect-[644/320] laptop-md:aspect-[503/270] laptop:aspect-[332/190] tablet:aspect-[704/380] aspect-[358/190]",imgClassName:"object-cover h-full"})})]}),o(J,{className:"tablet:pb-8 laptop:col-start-7 laptop:mt-0 laptop:col-span-6 col-span-12 mt-8 flex flex-col justify-between gap-6 pb-6",children:[o("div",{children:[o("div",{className:"flex flex-col gap-4",children:[e(ie,{exposureKey:"listing_selector",onExposure:()=>{ce({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:`Product Detail Page${n.sku}`,component_type:"image",component_name:"listing_selector",position:1}})},children:o("div",{className:"flex items-center justify-between gap-6",children:[o("div",{className:"flex items-center gap-4",children:[e(A,{source:n.image?.url||p?.images?.[0]?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),o("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:p.title}),e(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]",html:Y})]})]}),o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:N({amount:V,currencyCode:n.price.currencyCode,locale:m})}),I&&V<n?.price?.amount&&e(s,{className:"laptop-md:text-2xl laptop:text-xl text-base font-bold text-[#6D6D6F] line-through",html:N({amount:n?.price?.amount,currencyCode:n.price.currencyCode,locale:m})})]})]})}),X.map(({type:i,key:l})=>i==="gift"&&t?.gift?.value?e(K,{giftOperation:u=>{P?.({...t,gift:{value:void 0,canOperate:!0}}),O?.({...c,gift:u}),D?.(b=>b.filter(h=>h!=="gift"))},status:!!t?.gift,gift:t?.gift?.value,canOperate:t?.gift?.canOperate},l):i==="bundle"&&t?.bundle?.value?e(H,{bundleOperation:u=>{P?.({...t,bundle:{value:void 0,canOperate:!0}}),O?.({...c,bundle:u}),D?.(b=>b.filter(h=>h!=="bundle"))},status:!!t?.bundle,bundleListItem:t?.bundle?.value,canOperate:t?.bundle?.canOperate},l):i==="exchange"&&t?.exchange?.value?e(M,{exchangeOperation:u=>{P?.({...t,exchange:{value:void 0,canOperate:!0}}),O?.({...c,exchange:u}),D?.(b=>b.filter(h=>h!=="exchange"))},status:!!t?.exchange,canOperate:t?.exchange?.canOperate,exchange:t?.exchange?.value},l):null)]}),(c?.bundle||c?.gift||c?.exchange)&&o("div",{className:"laptop-md:mt-8 mt-6",children:[e(s,{className:"laptop-md:text-[18px] text-sm font-bold",html:F?.recommendBuy}),o("div",{className:"laptop-md:gap-4 mt-4 flex flex-col gap-6",children:[c?.exchange&&e(M,{exchangeOperation:i=>{P?.({...t,exchange:{value:i,canOperate:!0}}),O?.({...c,exchange:void 0}),D?.(l=>[...l,"exchange"])},canOperate:t?.exchange?.canOperate,status:!c?.exchange,exchange:c?.exchange}),c?.bundle&&e(H,{bundleOperation:i=>{C?.({...f,exchangePurchase:0}),P?.({...t,bundle:{value:i,canOperate:!0}}),O?.({...c,bundle:void 0}),D?.(l=>[...l,"bundle"])},canOperate:t?.bundle?.canOperate,status:!c?.bundle,bundleListItem:c?.bundle}),c?.gift&&e(K,{giftOperation:i=>{P?.({...t,gift:{value:i,canOperate:!0}}),O?.({...c,gift:void 0}),D?.(l=>[...l,"gift"])},canOperate:t?.gift?.canOperate,status:!c?.gift,gift:c?.gift})]})]})]}),o("div",{className:"text-right",children:[e(s,{className:"laptop:text-xl laptop-md:text-2xl text-right font-bold",html:`${le(a?.totalPrice||"",{amount:N({amount:parseFloat(x.toFixed(2)),currencyCode:n.price.currencyCode,locale:m})})}`}),I&&B>0&&e(s,{className:"laptop:text-xl laptop-md:text-2xl ml-1 text-base font-bold text-[#6D6D6F] line-through",html:N({amount:v,currencyCode:n.price.currencyCode,locale:m})}),e("div",{className:"mt-4 flex justify-end gap-3",children:e(se,{availableForSale:n.availableForSale,addToCartText:a?.addToCart,buyNowText:a?.shopNow,addToCartLoading:L,buyNowLoading:U,addToCartClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2",buyNowClassName:"tablet:w-auto laptop:w-1/2 laptop-md:w-auto w-1/2",onAddToCart:w,onBuyNow:E})})]})]})]})})}):null},pe=()=>{const{bundle:m,variant:a,checkedBundle:g,freeGift:p,checkedGift:n,exchangePurchase:x,checkedExchangePurchase:v}=S();let k,d,r;const{bundleList:B}=m||{},{giftList:w=[]}=p||{},{giftList:E=[]}=x||{},f=B?.filter(C=>C.variants.slice(1,C.variants.length).every(L=>L.variant.availableForSale))||[],[y]=f;k=g||y;const[t]=w?.filter(C=>C.availableForSale)??[];d=n||t;const[P]=E?.filter(C=>C.availableForSale)??[];return r=v||P,{bundleVariant:k,giftVariant:d,exchangeVariant:r}},H=({bundleOperation:m,bundleListItem:a,canOperate:g,status:p})=>{const{locale:n="us",copyWriting:x}=j(),{variant:v,setCheckedBundle:k}=S(),d=a?.variants.filter(r=>r.variant.sku!==v.sku);return e("div",{className:"",children:d?.map(r=>o("div",{className:"flex items-center justify-between gap-4",children:[o("div",{className:"flex items-center gap-4",children:[e(A,{source:r?.variant?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),e("div",{className:"tablet:max-w-none line-clamp-2 flex max-w-[178px] flex-col gap-[6px]",children:e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] text-[14px] font-bold",html:r.variant.product.title})})]}),o("div",{className:"flex flex-col items-end justify-center gap-1",children:[!!a&&o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:N({amount:r?.price||0,locale:n,currencyCode:r.variant?.price?.currencyCode||""})}),r.price<r.variant.price.amount&&e(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:N({amount:r.variant.price.amount||0,locale:n,currencyCode:r.variant?.price?.currencyCode||""})})]}),g&&e(_,{size:"icon",variant:"link",onClick:()=>{k?.(p?void 0:a),m?.(a)},className:"size-auto shrink-0 underline",children:p?x?.remove:x?.add})]})]},r.variant.id))})},K=({giftOperation:m,gift:a,status:g,canOperate:p})=>{const{locale:n="us",copyWriting:x}=j(),{freeGift:v,setCheckedGift:k}=S(),{freeLabel:d}=v||{},{options:r}=a||{},B=T(()=>{const w=r?.find(t=>t.name==="color"||t.name==="colour"||t.name==="couleur")||{},E=r?.find(t=>t.name==="quantity")||{},f=w?w.values?.[0]?.label:"",y=E?E.values?.[0]?.label:"";return`${f&&y?y+" | "+f:y||f} | ${d}`},[d,r]);return o("div",{className:"flex items-center justify-between gap-6",children:[o("div",{className:"flex items-center gap-4",children:[e(A,{source:a?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),o("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:a?.product?.title}),e(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]",html:B})]})]}),o("div",{className:"flex flex-col items-end justify-center gap-2",children:[!!a&&o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:d}),e(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:N({amount:a.price.amount,locale:n,currencyCode:a.price.currencyCode})})]}),p&&e(_,{size:"icon",variant:"link",onClick:()=>{k?.(g?void 0:a),m(a)},className:"size-auto shrink-0 underline",children:g?x?.remove:x?.add})]})]})},M=({exchangeOperation:m,exchange:a,canOperate:g,status:p})=>{const{locale:n="us",copyWriting:x}=j(),{setCheckedExchangePurchase:v}=S();return o("div",{className:"flex items-center justify-between gap-6",children:[o("div",{className:"flex items-center gap-4",children:[e(A,{source:a?.image?.url,className:"laptop:size-12 lg-desktop:size-16 border-1 size-10 shrink-0 rounded-lg border-[#E4E5E6] bg-[#EAEAEC] object-cover p-2"}),o("div",{className:"tablet:max-w-none flex max-w-[178px] flex-col gap-[6px]",children:[e(s,{className:"laptop-md:text-[16px] lg-desktop:text-[18px] line-clamp-2 text-[14px] font-bold",html:a?.product?.title}),e(s,{className:"laptop:text-[14px] laptop-md:text-[18px] text-[12px] font-bold text-[#6D6D6F]"})]})]}),o("div",{className:"flex flex-col items-end justify-center gap-2",children:[!!a&&o("div",{className:"flex items-center gap-1",children:[e(s,{className:"laptop-md:text-2xl text-base font-bold",html:N({amount:a.finalPrice?.amount||0,locale:n,currencyCode:a.price.currencyCode})}),e(s,{className:"laptop-md:text-2xl text-base font-bold text-[#6D6D6F] line-through",html:N({amount:a.price?.amount||0,locale:n,currencyCode:a.price.currencyCode})})]}),g&&e(_,{size:"icon",variant:"link",onClick:()=>{v?.(p?void 0:a),m(a)},className:"size-auto shrink-0 underline",children:p?x?.remove:x?.add})]})]})};var we=re(de);export{we as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|