@anker-in/headless-ui 1.1.30 → 1.1.32
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/ShelfDisplay/index.js +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/index.js.map +2 -2
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplay.d.ts +2 -0
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplay.js +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplay.js.map +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js +1 -9
- package/dist/cjs/biz-components/ShelfDisplay/shelfDisplayItem.js.map +2 -2
- package/dist/cjs/components/badge.d.ts +5 -2
- package/dist/cjs/components/badge.js +1 -1
- package/dist/cjs/components/badge.js.map +3 -3
- package/dist/cjs/stories/badge.stories.d.ts +66 -1
- package/dist/cjs/stories/badge.stories.js +1 -1
- package/dist/cjs/stories/badge.stories.js.map +3 -3
- package/dist/esm/biz-components/ShelfDisplay/index.js +1 -1
- package/dist/esm/biz-components/ShelfDisplay/index.js.map +2 -2
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplay.d.ts +2 -0
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplay.js +1 -1
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplay.js.map +1 -1
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js +1 -9
- package/dist/esm/biz-components/ShelfDisplay/shelfDisplayItem.js.map +2 -2
- package/dist/esm/components/badge.d.ts +5 -2
- package/dist/esm/components/badge.js +1 -1
- package/dist/esm/components/badge.js.map +3 -3
- package/dist/esm/stories/badge.stories.d.ts +66 -1
- package/dist/esm/stories/badge.stories.js +1 -1
- package/dist/esm/stories/badge.stories.js.map +3 -3
- package/package.json +1 -1
- package/style.css +45 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var oe=Object.create;var y=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var pe=(t,n)=>{for(var
|
|
1
|
+
"use strict";"use client";var oe=Object.create;var y=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var pe=(t,n)=>{for(var i in n)y(t,i,{get:n[i],enumerable:!0})},z=(t,n,i,p)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of ce(n))!fe.call(t,l)&&l!==i&&y(t,l,{get:()=>n[l],enumerable:!(p=le(n,l))||p.enumerable});return t};var S=(t,n,i)=>(i=t!=null?oe(me(t)):{},z(n||!t||!t.__esModule?y(i,"default",{value:t,enumerable:!0}):i,t)),de=t=>z(y({},"__esModule",{value:!0}),t);var be={};pe(be,{default:()=>_e});module.exports=de(be);var o=require("react/jsx-runtime"),s=S(require("react")),$=require("../../helpers/utils.js"),q=S(require("./tabSwitch.js")),O=S(require("../Title/index.js")),K=S(require("../SwiperBox/index.js")),Q=require("../../shared/Styles.js"),R=require("../../shared/track.js"),W=require("react-responsive"),Z=require("../../hooks/useRollout.js"),v=require("./shelfDisplayItem.js");const ue="image",he="product_shelf",we=t=>t==null?"default":String(t).replace(/[^a-zA-Z0-9_-]/g,"")||"default",ge=()=>`shelf-display-${Math.random().toString(36).slice(2,9)}`,A=s.default.forwardRef(({key:t,data:n,event:i,buildData:p,breakpoints:l,className:j="",recommendedData:f,target:F="_self",metafields:G,isDisplayGudgments:D=!1,isDisplayBackImage:J=!1},U)=>{const{productsTab:d=[],productsCard:M=[],title:P,isShowTab:w=!0,tabShape:X="square",isShowTag:Y=!1,isShowOriginalPrice:ee=!0,isShowRecommendedCard:x=!1,...te}=n,[g,C]=(0,s.useState)(""),[c,k]=(0,s.useState)([]),H=(0,s.useRef)(!1),T=(0,s.useRef)(!1),B=(0,s.useRef)(null),ne=(0,s.useRef)(ge()),se=(0,W.useMediaQuery)({query:"(max-width: 768px)"}),[ae,E]=(0,Z.useRollout)({threshold:0}),_=c?.length<=1&&D,u=!se&&c?.length<=2&&D,I=e=>{switch(e){case 1440:return u?c?.length:4;case 1024:return u?c?.length:3;default:return u?c?.length:2.3}},V=()=>{(0,R.gaTrack)({event:"ga4Event",event_name:"view_item_list",event_parameters:{page_group:"Home Page",item_list_name:"Home_Page_Bundle",items:f?.map((e,m)=>{const r=e?.variants?.find(a=>a?.sku===e?.sku)||e?.variants?.[0];return{item_id:e?.sku||r?.sku,item_name:e?.name,item_variant:r?.name,price:r?.price,index:m+1}})}})},h=(e,m)=>{if(m){const b=f?.map?.(r=>({...r,isShowRecommended:!0}));k(b?.length?b||[]:[])}else if(Array.isArray(e)){const r=e?.map?.(a=>{const N=p?.products?.find(re=>re?.handle===a?.handle);if(N)return{sku:a.sku,isShowRecommended:!1,custom_name:a.custom_name,custom_description:a.custom_description,custom_image:a.custom_image,custom_theme:a.custom_theme,custom_primary_link:a?.custom_primary_link||"",custom_secondary_link:a?.custom_secondary_link||"",...N}})?.filter(a=>a);k(r?.length?r||[]:[])}else k([])};(0,s.useImperativeHandle)(U,()=>B.current),(0,s.useEffect)(()=>{E&&f?.length&&!H.current&&(H.current=!0,V())},[E,f]),(0,s.useEffect)(()=>{if(!T.current){if(!T.current&&f?.length&&(T.current=!0),w){const e=d?.find(m=>m?.tab===g)||d?.[0];C(e?.tab||""),h(e?.data||[],e?.isShowRecommendedTab);return}h(M,x)}},[f]),(0,s.useEffect)(()=>{if(w){const e=d?.find(m=>m?.tab===g)||d?.[0];h(e?.data||[],e?.isShowRecommendedTab);return}h(M,x)},[p]);const ie=we(g),L=`${ne.current}-${ie}`;return(0,o.jsxs)("div",{ref:B,className:(0,$.cn)("shelf-display-wrap w-full",j,{"aiui-dark":n?.theme==="dark"}),children:[P&&(0,o.jsx)(O.default,{data:{title:P}}),w&&(0,o.jsx)("div",{className:"md-tablet:w-full md-tablet:overflow-hidden",children:(0,o.jsx)(q.default,{value:g,tabs:d,tabShape:X,onTabClick:e=>{if(C(e?.tab),h(e?.data||[],e?.isShowRecommendedTab),!e?.isShowRecommendedTab){(0,R.gaTrack)({event:"ga4Event",event_name:"component_click",event_parameters:{page_group:"Home Page",component_type:ue,component_name:he,component_title:n?.title,component_position:1,navigation:e?.tab}});return}V()}})}),(0,o.jsx)("div",{ref:ae,className:"tablet:min-h-[393px] laptop:min-h-[425px] desktop:min-h-[405px] lg-desktop:min-h-[409px]",children:(0,o.jsx)(K.default,{data:{list:c,configuration:{...te,event:i,isShowTag:Y,isShowOriginalPrice:ee,target:F,metafields:G,itemLength:c?.length,isDisplayBackImage:J}},id:L,className:`${w?"mt-6":""} shelf-display-swiper-box !overflow-visible`,itemClassName:u?"flex-1":"",Slide:u?v.ShelfDisplayHorizontalItem:v.ShelfDisplayWrapItem,breakpoints:l||{0:{spaceBetween:12,freeMode:!1,slidesPerView:1},374:{spaceBetween:12,freeMode:!1,slidesPerView:_?1:1.2},768:{spaceBetween:_?0:16,freeMode:!1,slidesPerView:I()},1024:{spaceBetween:_?0:16,freeMode:!1,slidesPerView:I(1024)},1440:{spaceBetween:_?0:16,freeMode:!1,slidesPerView:I(1440)}}},L)})]})});A.displayName="ShelfDisplay";var _e=(0,Q.withLayout)(A);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/ShelfDisplay/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\nimport React, { useState, useEffect, useRef, useImperativeHandle } from 'react'\nimport { cn } from '../../helpers/utils.js'\nimport TabSwitch from './tabSwitch.js'\nimport Title from '../Title/index.js'\nimport SwiperBox from '../SwiperBox/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { useMediaQuery } from 'react-responsive'\nimport { useRollout } from '../../hooks/useRollout.js'\nimport { ShelfDisplayWrapItem, ShelfDisplayHorizontalItem } from './shelfDisplayItem.js'\nimport type { ShelfDisplayProps, ShelfDisplayItem } from './shelfDisplay.js'\n\nconst componentType = 'image'\nconst componentName = 'product_shelf'\n\nconst sanitizeCssSelector = (value?: string | number) => {\n if (value === undefined || value === null) return 'default'\n const sanitized = String(value).replace(/[^a-zA-Z0-9_-]/g, '')\n return sanitized || 'default'\n}\n\nconst createInstanceId = () => `shelf-display-${Math.random().toString(36).slice(2, 9)}`\n\nconst ShelfDisplay = React.forwardRef<HTMLDivElement, ShelfDisplayProps>(\n (\n {\n key,\n data,\n event,\n buildData,\n breakpoints,\n className = '',\n recommendedData,\n target = '_self',\n metafields,\n isDisplayGudgments = false,\n isDisplayBackImage = false,\n },\n ref\n ) => {\n const {\n productsTab = [],\n productsCard = [],\n title,\n isShowTab = true,\n tabShape = 'square',\n isShowTag = false,\n isShowOriginalPrice = true,\n isShowRecommendedCard = false,\n ...other\n } = data\n\n const [tabId, setTabId] = useState<string>('')\n const [currentItems, setCurrentItems] = useState<ShelfDisplayItem[]>([])\n\n const isView = useRef<boolean>(false)\n const isRecommend = useRef<boolean>(false)\n const innerRef = useRef<HTMLDivElement>(null)\n const instanceIdRef = useRef<string>(createInstanceId())\n\n const isMobile = useMediaQuery({ query: '(max-width: 768px)' })\n const [viewRef, inView] = useRollout<HTMLDivElement>({ threshold: 0 })\n\n const isOnce = currentItems?.length <= 1 && isDisplayGudgments\n const isShowGudgments = !isMobile && currentItems?.length <= 2 && isDisplayGudgments\n\n const showItemLength = (size?: number) => {\n switch (size) {\n case 1440:\n return isShowGudgments ? currentItems?.length : 4\n case 1024:\n return isShowGudgments ? currentItems?.length : 3\n default:\n return isShowGudgments ? currentItems?.length : 2.3\n }\n }\n\n const gackViewEvent = () => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'view_item_list',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: recommendedData?.map((item, index) => {\n const findData = item?.variants?.find((v: any) => v?.sku === item?.sku)\n const variant = findData || item?.variants?.[0]\n return {\n item_id: item?.sku || variant?.sku,\n item_name: item?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: index + 1,\n }\n }),\n },\n })\n }\n\n const handleCurrentTab = (currentData: ShelfDisplayItem[], flag: boolean) => {\n if (flag) {\n const newCurrentData = recommendedData?.map?.(item => {\n return {\n ...item,\n isShowRecommended: true,\n }\n })\n setCurrentItems(newCurrentData?.length ? newCurrentData || [] : [])\n } else {\n const isArray = Array.isArray(currentData)\n if (isArray) {\n const newCurrentData = currentData\n ?.map?.(item => {\n const findData = buildData?.products?.find(params => params?.handle === item?.handle)\n if (findData) {\n return {\n sku: item.sku,\n isShowRecommended: false,\n custom_name: item.custom_name,\n custom_description: item.custom_description,\n custom_image: item.custom_image,\n custom_theme: item.custom_theme,\n ...findData,\n }\n }\n })\n ?.filter(item => item)\n setCurrentItems(newCurrentData?.length ? newCurrentData || [] : [])\n } else {\n setCurrentItems([])\n }\n }\n }\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n useEffect(() => {\n if (inView && recommendedData?.length && !isView.current) {\n isView.current = true\n gackViewEvent()\n }\n }, [inView, recommendedData])\n\n // \u7B97\u6CD5\u6570\u636E\u4F1A\u7A0D\u5FAE\u5EF6\u8FDF\uFF0C\u6240\u4EE5\u9700\u76D1\u542CrecommendedData\uFF0C\u4E3A\u4E86\u9632\u6B62\u5728\u6709\u7B97\u6CD5\u6570\u636E\u4E14\u5BF9\u9ED8\u8BA4\u6E32\u67D3\u7B2C\u4E00\u4E2A\u540E\u53CD\u590D\u89E6\u53D1\uFF0C\u7528isRecommend\u5173\u95ED\n useEffect(() => {\n if (isRecommend.current) return\n if (!isRecommend.current && recommendedData?.length) {\n isRecommend.current = true\n }\n if (isShowTab) {\n const currentTab = productsTab?.find(item => item?.tab === tabId) || productsTab?.[0]\n setTabId(currentTab?.tab || '')\n handleCurrentTab(currentTab?.data || [], currentTab?.isShowRecommendedTab)\n return\n }\n handleCurrentTab(productsCard, isShowRecommendedCard)\n }, [recommendedData])\n\n useEffect(() => {\n if (isShowTab) {\n const currentTab = productsTab?.find(item => item?.tab === tabId) || productsTab?.[0]\n handleCurrentTab(currentTab?.data || [], currentTab?.isShowRecommendedTab)\n return\n }\n handleCurrentTab(productsCard, isShowRecommendedCard)\n // buildData \u66F4\u65B0\u65F6\u9700\u8981\u91CD\u65B0\u8BA1\u7B97\u5F53\u524D\u5217\u8868\n }, [buildData])\n\n const safeTabKey = sanitizeCssSelector(tabId)\n const swiperInstanceId = `${instanceIdRef.current}-${safeTabKey}`\n\n return (\n <div\n ref={innerRef}\n className={cn('shelf-display-wrap w-full', className, { 'aiui-dark': data?.theme === 'dark' })}\n >\n {title && <Title data={{ title: title }} />}\n {isShowTab && (\n <div className=\"md-tablet:w-full md-tablet:overflow-hidden\">\n <TabSwitch\n value={tabId}\n tabs={productsTab}\n tabShape={tabShape}\n onTabClick={v => {\n setTabId(v?.tab)\n handleCurrentTab(v?.data || [], v?.isShowRecommendedTab)\n if (!v?.isShowRecommendedTab) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_click',\n event_parameters: {\n page_group: 'Home Page',\n component_type: componentType,\n component_name: componentName,\n component_title: data?.title,\n component_position: 1,\n navigation: v?.tab,\n },\n })\n return\n }\n gackViewEvent()\n }}\n />\n </div>\n )}\n <div\n ref={viewRef as any}\n className=\"tablet:min-h-[393px] laptop:min-h-[425px] desktop:min-h-[405px] lg-desktop:min-h-[409px]\"\n >\n <SwiperBox\n key={swiperInstanceId}\n data={{\n list: currentItems,\n configuration: {\n ...other,\n event: event,\n isShowTag,\n isShowOriginalPrice,\n target: target,\n metafields: metafields,\n itemLength: currentItems?.length,\n isDisplayBackImage: isDisplayBackImage,\n },\n }}\n id={swiperInstanceId}\n className={`${isShowTab ? 'mt-6' : ''} shelf-display-swiper-box !overflow-visible`}\n itemClassName={isShowGudgments ? 'flex-1' : ''}\n Slide={isShowGudgments ? ShelfDisplayHorizontalItem : ShelfDisplayWrapItem}\n breakpoints={\n breakpoints || {\n 0: {\n spaceBetween: 12,\n freeMode: false,\n slidesPerView: 1,\n },\n 374: {\n spaceBetween: 12,\n freeMode: false,\n slidesPerView: isOnce ? 1 : 1.2,\n },\n 768: {\n spaceBetween: isOnce ? 0 : 16,\n freeMode: false,\n slidesPerView: showItemLength(),\n },\n 1024: {\n spaceBetween: isOnce ? 0 : 16,\n freeMode: false,\n slidesPerView: showItemLength(1024),\n },\n 1440: {\n spaceBetween: isOnce ? 0 : 16,\n freeMode: false,\n slidesPerView: showItemLength(1440),\n },\n }\n }\n />\n </div>\n </div>\n )\n }\n)\n\nShelfDisplay.displayName = 'ShelfDisplay'\nexport default withLayout(ShelfDisplay)\n"],
|
|
5
|
-
"mappings": "mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,
|
|
4
|
+
"sourcesContent": ["'use client'\nimport React, { useState, useEffect, useRef, useImperativeHandle } from 'react'\nimport { cn } from '../../helpers/utils.js'\nimport TabSwitch from './tabSwitch.js'\nimport Title from '../Title/index.js'\nimport SwiperBox from '../SwiperBox/index.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { useMediaQuery } from 'react-responsive'\nimport { useRollout } from '../../hooks/useRollout.js'\nimport { ShelfDisplayWrapItem, ShelfDisplayHorizontalItem } from './shelfDisplayItem.js'\nimport type { ShelfDisplayProps, ShelfDisplayItem } from './shelfDisplay.js'\n\nconst componentType = 'image'\nconst componentName = 'product_shelf'\n\nconst sanitizeCssSelector = (value?: string | number) => {\n if (value === undefined || value === null) return 'default'\n const sanitized = String(value).replace(/[^a-zA-Z0-9_-]/g, '')\n return sanitized || 'default'\n}\n\nconst createInstanceId = () => `shelf-display-${Math.random().toString(36).slice(2, 9)}`\n\nconst ShelfDisplay = React.forwardRef<HTMLDivElement, ShelfDisplayProps>(\n (\n {\n key,\n data,\n event,\n buildData,\n breakpoints,\n className = '',\n recommendedData,\n target = '_self',\n metafields,\n isDisplayGudgments = false,\n isDisplayBackImage = false,\n },\n ref\n ) => {\n const {\n productsTab = [],\n productsCard = [],\n title,\n isShowTab = true,\n tabShape = 'square',\n isShowTag = false,\n isShowOriginalPrice = true,\n isShowRecommendedCard = false,\n ...other\n } = data\n\n const [tabId, setTabId] = useState<string>('')\n const [currentItems, setCurrentItems] = useState<ShelfDisplayItem[]>([])\n\n const isView = useRef<boolean>(false)\n const isRecommend = useRef<boolean>(false)\n const innerRef = useRef<HTMLDivElement>(null)\n const instanceIdRef = useRef<string>(createInstanceId())\n\n const isMobile = useMediaQuery({ query: '(max-width: 768px)' })\n const [viewRef, inView] = useRollout<HTMLDivElement>({ threshold: 0 })\n\n const isOnce = currentItems?.length <= 1 && isDisplayGudgments\n const isShowGudgments = !isMobile && currentItems?.length <= 2 && isDisplayGudgments\n\n const showItemLength = (size?: number) => {\n switch (size) {\n case 1440:\n return isShowGudgments ? currentItems?.length : 4\n case 1024:\n return isShowGudgments ? currentItems?.length : 3\n default:\n return isShowGudgments ? currentItems?.length : 2.3\n }\n }\n\n const gackViewEvent = () => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'view_item_list',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: recommendedData?.map((item, index) => {\n const findData = item?.variants?.find((v: any) => v?.sku === item?.sku)\n const variant = findData || item?.variants?.[0]\n return {\n item_id: item?.sku || variant?.sku,\n item_name: item?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: index + 1,\n }\n }),\n },\n })\n }\n\n const handleCurrentTab = (currentData: ShelfDisplayItem[], flag: boolean) => {\n if (flag) {\n const newCurrentData = recommendedData?.map?.(item => {\n return {\n ...item,\n isShowRecommended: true,\n }\n })\n setCurrentItems(newCurrentData?.length ? newCurrentData || [] : [])\n } else {\n const isArray = Array.isArray(currentData)\n if (isArray) {\n const newCurrentData = currentData\n ?.map?.(item => {\n const findData = buildData?.products?.find(params => params?.handle === item?.handle)\n if (findData) {\n return {\n sku: item.sku,\n isShowRecommended: false,\n custom_name: item.custom_name,\n custom_description: item.custom_description,\n custom_image: item.custom_image,\n custom_theme: item.custom_theme,\n custom_primary_link: item?.custom_primary_link || '',\n custom_secondary_link: item?.custom_secondary_link || '',\n ...findData,\n }\n }\n })\n ?.filter(item => item)\n setCurrentItems(newCurrentData?.length ? newCurrentData || [] : [])\n } else {\n setCurrentItems([])\n }\n }\n }\n\n useImperativeHandle(ref, () => innerRef.current as HTMLDivElement)\n\n useEffect(() => {\n if (inView && recommendedData?.length && !isView.current) {\n isView.current = true\n gackViewEvent()\n }\n }, [inView, recommendedData])\n\n // \u7B97\u6CD5\u6570\u636E\u4F1A\u7A0D\u5FAE\u5EF6\u8FDF\uFF0C\u6240\u4EE5\u9700\u76D1\u542CrecommendedData\uFF0C\u4E3A\u4E86\u9632\u6B62\u5728\u6709\u7B97\u6CD5\u6570\u636E\u4E14\u5BF9\u9ED8\u8BA4\u6E32\u67D3\u7B2C\u4E00\u4E2A\u540E\u53CD\u590D\u89E6\u53D1\uFF0C\u7528isRecommend\u5173\u95ED\n useEffect(() => {\n if (isRecommend.current) return\n if (!isRecommend.current && recommendedData?.length) {\n isRecommend.current = true\n }\n if (isShowTab) {\n const currentTab = productsTab?.find(item => item?.tab === tabId) || productsTab?.[0]\n setTabId(currentTab?.tab || '')\n handleCurrentTab(currentTab?.data || [], currentTab?.isShowRecommendedTab)\n return\n }\n handleCurrentTab(productsCard, isShowRecommendedCard)\n }, [recommendedData])\n\n useEffect(() => {\n if (isShowTab) {\n const currentTab = productsTab?.find(item => item?.tab === tabId) || productsTab?.[0]\n handleCurrentTab(currentTab?.data || [], currentTab?.isShowRecommendedTab)\n return\n }\n handleCurrentTab(productsCard, isShowRecommendedCard)\n // buildData \u66F4\u65B0\u65F6\u9700\u8981\u91CD\u65B0\u8BA1\u7B97\u5F53\u524D\u5217\u8868\n }, [buildData])\n\n const safeTabKey = sanitizeCssSelector(tabId)\n const swiperInstanceId = `${instanceIdRef.current}-${safeTabKey}`\n\n return (\n <div\n ref={innerRef}\n className={cn('shelf-display-wrap w-full', className, { 'aiui-dark': data?.theme === 'dark' })}\n >\n {title && <Title data={{ title: title }} />}\n {isShowTab && (\n <div className=\"md-tablet:w-full md-tablet:overflow-hidden\">\n <TabSwitch\n value={tabId}\n tabs={productsTab}\n tabShape={tabShape}\n onTabClick={v => {\n setTabId(v?.tab)\n handleCurrentTab(v?.data || [], v?.isShowRecommendedTab)\n if (!v?.isShowRecommendedTab) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_click',\n event_parameters: {\n page_group: 'Home Page',\n component_type: componentType,\n component_name: componentName,\n component_title: data?.title,\n component_position: 1,\n navigation: v?.tab,\n },\n })\n return\n }\n gackViewEvent()\n }}\n />\n </div>\n )}\n <div\n ref={viewRef as any}\n className=\"tablet:min-h-[393px] laptop:min-h-[425px] desktop:min-h-[405px] lg-desktop:min-h-[409px]\"\n >\n <SwiperBox\n key={swiperInstanceId}\n data={{\n list: currentItems,\n configuration: {\n ...other,\n event: event,\n isShowTag,\n isShowOriginalPrice,\n target: target,\n metafields: metafields,\n itemLength: currentItems?.length,\n isDisplayBackImage: isDisplayBackImage,\n },\n }}\n id={swiperInstanceId}\n className={`${isShowTab ? 'mt-6' : ''} shelf-display-swiper-box !overflow-visible`}\n itemClassName={isShowGudgments ? 'flex-1' : ''}\n Slide={isShowGudgments ? ShelfDisplayHorizontalItem : ShelfDisplayWrapItem}\n breakpoints={\n breakpoints || {\n 0: {\n spaceBetween: 12,\n freeMode: false,\n slidesPerView: 1,\n },\n 374: {\n spaceBetween: 12,\n freeMode: false,\n slidesPerView: isOnce ? 1 : 1.2,\n },\n 768: {\n spaceBetween: isOnce ? 0 : 16,\n freeMode: false,\n slidesPerView: showItemLength(),\n },\n 1024: {\n spaceBetween: isOnce ? 0 : 16,\n freeMode: false,\n slidesPerView: showItemLength(1024),\n },\n 1440: {\n spaceBetween: isOnce ? 0 : 16,\n freeMode: false,\n slidesPerView: showItemLength(1440),\n },\n }\n }\n />\n </div>\n </div>\n )\n }\n)\n\nShelfDisplay.displayName = 'ShelfDisplay'\nexport default withLayout(ShelfDisplay)\n"],
|
|
5
|
+
"mappings": "mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,IA+KM,IAAAI,EAAA,6BA9KNC,EAAwE,oBACxEC,EAAmB,kCACnBC,EAAsB,6BACtBC,EAAkB,gCAClBC,EAAsB,oCACtBC,EAA2B,kCAC3BC,EAAwB,iCACxBC,EAA8B,4BAC9BC,EAA2B,qCAC3BC,EAAiE,iCAGjE,MAAMC,GAAgB,QAChBC,GAAgB,gBAEhBC,GAAuBC,GACAA,GAAU,KAAa,UAChC,OAAOA,CAAK,EAAE,QAAQ,kBAAmB,EAAE,GACzC,UAGhBC,GAAmB,IAAM,iBAAiB,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,CAAC,GAEhFC,EAAe,EAAAC,QAAM,WACzB,CACE,CACE,IAAAC,EACA,KAAAC,EACA,MAAAC,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EAAY,GACZ,gBAAAC,EACA,OAAAC,EAAS,QACT,WAAAC,EACA,mBAAAC,EAAqB,GACrB,mBAAAC,EAAqB,EACvB,EACAC,IACG,CACH,KAAM,CACJ,YAAAC,EAAc,CAAC,EACf,aAAAC,EAAe,CAAC,EAChB,MAAAC,EACA,UAAAC,EAAY,GACZ,SAAAC,EAAW,SACX,UAAAC,EAAY,GACZ,oBAAAC,GAAsB,GACtB,sBAAAC,EAAwB,GACxB,GAAGC,EACL,EAAInB,EAEE,CAACoB,EAAOC,CAAQ,KAAI,YAAiB,EAAE,EACvC,CAACC,EAAcC,CAAe,KAAI,YAA6B,CAAC,CAAC,EAEjEC,KAAS,UAAgB,EAAK,EAC9BC,KAAc,UAAgB,EAAK,EACnCC,KAAW,UAAuB,IAAI,EACt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,EAAe,IAAI,CACpC,CACF,GA7CGe,CA+CP,EACF,GACF,CAEJ,CACF,EAEAnD,EAAa,YAAc,eAC3B,IAAOlB,MAAQ,cAAWkB,CAAY",
|
|
6
6
|
"names": ["ShelfDisplay_exports", "__export", "ShelfDisplay_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_utils", "import_tabSwitch", "import_Title", "import_SwiperBox", "import_Styles", "import_track", "import_react_responsive", "import_useRollout", "import_shelfDisplayItem", "componentType", "componentName", "sanitizeCssSelector", "value", "createInstanceId", "ShelfDisplay", "React", "key", "data", "event", "buildData", "breakpoints", "className", "recommendedData", "target", "metafields", "isDisplayGudgments", "isDisplayBackImage", "ref", "productsTab", "productsCard", "title", "isShowTab", "tabShape", "isShowTag", "isShowOriginalPrice", "isShowRecommendedCard", "other", "tabId", "setTabId", "currentItems", "setCurrentItems", "isView", "isRecommend", "innerRef", "instanceIdRef", "isMobile", "viewRef", "inView", "isOnce", "isShowGudgments", "showItemLength", "size", "gackViewEvent", "item", "index", "variant", "v", "handleCurrentTab", "currentData", "flag", "newCurrentData", "findData", "params", "currentTab", "safeTabKey", "swiperInstanceId", "Title", "TabSwitch", "SwiperBox"]
|
|
7
7
|
}
|
|
@@ -35,6 +35,8 @@ type EventType = {
|
|
|
35
35
|
secondaryButton?: (v: any, index: number, data: ShelfDisplayType, coupon: any) => void;
|
|
36
36
|
};
|
|
37
37
|
export interface ShelfDisplayItem {
|
|
38
|
+
custom_primary_link?: string;
|
|
39
|
+
custom_secondary_link?: string;
|
|
38
40
|
id?: string;
|
|
39
41
|
/** 产品图片*/
|
|
40
42
|
img?: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var v=Object.create;var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,
|
|
1
|
+
"use strict";var v=Object.create;var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var E=(e,n)=>{for(var t in n)u(e,t,{get:n[t],enumerable:!0})},b=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of P(n))!k.call(e,r)&&r!==t&&u(e,r,{get:()=>n[r],enumerable:!(i=T(n,r))||i.enumerable});return e};var w=(e,n,t)=>(t=e!=null?v(C(e)):{},b(n||!e||!e.__esModule?u(t,"default",{value:e,enumerable:!0}):t,e)),$=e=>b(u({},"__esModule",{value:!0}),e);var F={};E(F,{PRICE_SYMBOL:()=>c,formatPrice:()=>l,formatVariantPrice:()=>x,languageTerritory:()=>g});module.exports=$(F);var D=w(require("decimal.js"));const c={us:"$",uk:"\xA3",ca:"$",eu:"\u20AC",fr:"\u20AC",de:"\u20AC",nl:"\u20AC",vn:"\u20AB",cl:"$",sg:"$",ae:"AED"},g=e=>({us:"en-US",uk:"en-GB",ca:"en-CA",eu:"en",fr:"fr-FR",au:"en-AU",my:"en-my","eu-es":"de-DE","eu-fr":"de-DE","eu-it":"de-DE","eu-de":"de-DE","eu-en":"en-US","cz-en":"de-DE","ca-fr":"fr-FR",nl:"de-DE",de:"de-DE",vn:"vi-vn",sg:"en-sg","ae-en":"ae-en",plus:"en-us",cl:"es-cl",dk:"en-dk",fi:"en-fi",no:"en-no",is:"en-is",se:"en-se","eu-pl":"pl-PL",es:"es-es",pl:"pl-PL",nz:"en-NZ","sg-en":"en-SG","sa-en":"en-SA","vn-vi":"vi-VN",ie:"en-IE",tw:"zh-TW"})[e]||"";function l({amount:e,currencyCode:n,currencyDisplay:t,locale:i,maximumFractionDigits:r,minimumFractionDigits:m,removeTrailingZeros:p=!1}){const o=i==="nl"?"EUR":n||"USD",a=g(i);if(!a)return null;let s=new Intl.NumberFormat(a,{style:"currency",currency:o,currencyDisplay:t||"symbol",minimumFractionDigits:r===0?0:m,maximumFractionDigits:r})?.format?.(e);return["eu-de","eu-en","de","eu"].includes(i)&&(s=s?.toString()?.replace?.(/[\s]/g,"")),p&&(s=s?.replace?.(/(\.\d*?[1-9])0+\b/,"$1")?.replace?.(/\.0+\b/,"")?.replace?.(/(\,\d*?[1-9])0+\b/,"$1")?.replace?.(/\,0+\b/,"")),s}function x({amount:e,baseAmount:n,currencyCode:t,currencyDisplay:i,locale:r,maximumFractionDigits:m,minimumFractionDigits:p,removeTrailingZeros:o}){if(typeof Intl>"u")return{price:`${c[r]}${e}`,basePrice:`${c[r]}${n}`,discount:`${c[r]}${n-e||0}`};const a=n>e;let d=null;const s=g(r);if(s){const y=new Intl.NumberFormat(s,{style:"percent"});d=a?y.format((n-e)/n):null}let f;if(a){const y=new D.default(n).sub(e||0).toNumber();f=l({amount:y,currencyDisplay:i,currencyCode:t||"USD",locale:r,maximumFractionDigits:2})}const h=l({amount:e,currencyCode:t,currencyDisplay:i,locale:r,removeTrailingZeros:o}),S=a?l({amount:n,currencyCode:t,currencyDisplay:i,locale:r,maximumFractionDigits:m,minimumFractionDigits:p,removeTrailingZeros:o}):void 0;return{price:h,basePrice:S,discount:d,discountAmount:f}}
|
|
2
2
|
//# sourceMappingURL=shelfDisplay.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/ShelfDisplay/shelfDisplay.ts"],
|
|
4
|
-
"sourcesContent": ["import Decimal from 'decimal.js'\nimport type { ContainerProps, CurrencyDisplayType } from '../../types/props.js'\n/* eslint-disable no-useless-escape */\nexport const PRICE_SYMBOL = {\n us: '$',\n uk: '\u00A3',\n ca: '$',\n eu: '\u20AC',\n fr: '\u20AC',\n de: '\u20AC',\n nl: '\u20AC',\n vn: '\u20AB',\n cl: '$',\n sg: '$',\n ae: 'AED',\n} as any\n\nexport const languageTerritory = (locale: string) =>\n // https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_territory_information.html\n ({\n us: 'en-US',\n uk: 'en-GB',\n ca: 'en-CA',\n eu: 'en',\n fr: 'fr-FR',\n au: 'en-AU',\n my: 'en-my',\n 'eu-es': 'de-DE',\n 'eu-fr': 'de-DE',\n 'eu-it': 'de-DE',\n 'eu-de': 'de-DE',\n 'eu-en': 'en-US',\n 'cz-en': 'de-DE',\n 'ca-fr': 'fr-FR',\n nl: 'de-DE',\n de: 'de-DE',\n vn: 'vi-vn',\n sg: 'en-sg',\n 'ae-en': 'ae-en',\n plus: 'en-us',\n cl: 'es-cl',\n dk: 'en-dk',\n fi: 'en-fi',\n no: 'en-no',\n is: 'en-is',\n se: 'en-se',\n 'eu-pl': 'pl-PL',\n es: 'es-es',\n pl: 'pl-PL',\n nz: 'en-NZ',\n 'sg-en': 'en-SG',\n 'sa-en': 'en-SA',\n 'vn-vi': 'vi-VN',\n ie: 'en-IE',\n tw: 'zh-TW',\n })[locale] || ''\n\nexport function formatPrice({\n amount,\n currencyCode,\n currencyDisplay,\n locale,\n maximumFractionDigits,\n minimumFractionDigits,\n removeTrailingZeros = false,\n}: {\n amount: number\n currencyCode: string\n currencyDisplay?: CurrencyDisplayType\n locale: string\n maximumFractionDigits?: number\n minimumFractionDigits?: number\n removeTrailingZeros?: boolean\n}) {\n const code = locale === 'nl' ? 'EUR' : currencyCode || 'USD'\n const localeLanguage = languageTerritory(locale)\n if (!localeLanguage) {\n return null\n }\n const formatCurrency = new Intl.NumberFormat(localeLanguage, {\n style: 'currency',\n currency: code,\n currencyDisplay: currencyDisplay || 'symbol',\n minimumFractionDigits: maximumFractionDigits === 0 ? 0 : minimumFractionDigits,\n maximumFractionDigits,\n })\n\n let formattedValue = formatCurrency?.format?.(amount)\n\n if (['eu-de', 'eu-en', 'de', 'eu'].includes(locale)) {\n formattedValue = formattedValue?.toString()?.replace?.(/[\\s]/g, '')\n }\n\n if (removeTrailingZeros) {\n formattedValue = formattedValue\n ?.replace?.(/(\\.\\d*?[1-9])0+\\b/, '$1')\n ?.replace?.(/\\.0+\\b/, '')\n ?.replace?.(/(\\,\\d*?[1-9])0+\\b/, '$1')\n ?.replace?.(/\\,0+\\b/, '')\n }\n\n return formattedValue\n}\n\nexport function formatVariantPrice({\n amount,\n baseAmount,\n currencyCode,\n currencyDisplay,\n locale,\n maximumFractionDigits,\n minimumFractionDigits,\n removeTrailingZeros,\n}: {\n baseAmount: number\n amount: number\n currencyCode: string\n currencyDisplay?: CurrencyDisplayType\n locale: string\n maximumFractionDigits?: number\n minimumFractionDigits?: number\n removeTrailingZeros?: boolean\n}) {\n if (typeof Intl === 'undefined') {\n return {\n price: `${PRICE_SYMBOL[locale]}${amount}`,\n basePrice: `${PRICE_SYMBOL[locale]}${baseAmount}`,\n discount: `${PRICE_SYMBOL[locale]}${baseAmount - amount || 0}`,\n }\n }\n\n const hasDiscount = baseAmount > amount\n let discount = null\n const currentLocale = languageTerritory(locale)\n if (currentLocale) {\n const formatDiscount = new Intl.NumberFormat(currentLocale, {\n style: 'percent',\n })\n discount = hasDiscount ? formatDiscount.format((baseAmount - amount) / baseAmount) : null\n }\n // \u6298\u6263\u91D1\u989D\n let discountAmount\n if (hasDiscount) {\n const savePriceAmount = new Decimal(baseAmount).sub(amount || 0).toNumber()\n discountAmount = formatPrice({\n amount: savePriceAmount,\n currencyDisplay,\n currencyCode: currencyCode || 'USD',\n locale,\n maximumFractionDigits: 2,\n })\n }\n\n const price = formatPrice({ amount, currencyCode, currencyDisplay, locale, removeTrailingZeros })\n const basePrice = hasDiscount\n ? formatPrice({\n amount: baseAmount,\n currencyCode,\n currencyDisplay,\n locale,\n maximumFractionDigits,\n minimumFractionDigits,\n removeTrailingZeros,\n })\n : undefined\n\n return { price, basePrice, discount, discountAmount }\n}\n\ntype EventType = {\n primaryButton?: (v: any, index: number, data: ShelfDisplayType, coupon: any) => void\n secondaryButton?: (v: any, index: number, data: ShelfDisplayType, coupon: any) => void\n}\n\nexport interface ShelfDisplayItem {\n id?: string\n /** \u4EA7\u54C1\u56FE\u7247*/\n img?: {\n url: string\n }\n handle?: string\n sku?: string\n /** \u6298\u6263\u540E\u4EF7\u683C*/\n price?: string\n title?: string\n /** \u6298\u6263\u524D\u4EF7\u683C*/\n basePrice?: string\n subTitle?: string\n /** \u6807\u7B7E*/\n tagItems?: string[]\n tab?: string\n data?: ShelfDisplayItem[]\n custom_name?: string\n custom_description?: string\n custom_image?: string\n custom_theme?: string\n}\n\nexport type ShelfDisplayType = {\n title?: string\n isShowTab?: boolean\n isShowTag?: boolean\n isShowRecommendedCard?: boolean\n isShowOriginalPrice?: boolean\n direction?: 'horizontal' | 'vertical'\n align?: 'left' | 'center' | 'right'\n productsTab?: any[]\n productsCard?: any[]\n /** \u5361\u7247\u5F62\u72B6 */\n itemShape?: 'round' | 'square'\n /** \u6309\u94AE\u5F62\u72B6 */\n shape?: 'round' | 'square'\n /** \u6807\u7B7E\u9875\u5F62\u72B6*/\n tabShape?: 'rounded' | 'square'\n /** \u4E3B\u6309\u94AE\u914D\u7F6E */\n primaryButton?: string\n primaryFun?: 'AddCart' | 'BuyNow' | 'LearnMore'\n /** \u526F\u6309\u94AE\u914D\u7F6E */\n secondaryButton?: string\n secondaryFun?: 'AddCart' | 'BuyNow' | 'LearnMore'\n theme?: 'light' | 'dark'\n containerProps?: ContainerProps\n}\n\nexport interface ShelfDisplayProps {\n data: ShelfDisplayType\n buildData?: {\n categories: any[]\n products: any[]\n }\n recommendedData?: any[]\n /** \u6309\u94AE\u4E8B\u4EF6*/\n event?: EventType\n className?: string\n key?: string\n target?: '_self' | '_blank'\n breakpoints?: {\n [key: number]: {\n spaceBetween: number\n freeMode: boolean\n slidesPerView: number\n }\n }\n metafields?: any\n isDisplayGudgments?: boolean\n isDisplayBackImage?: boolean\n}\n"],
|
|
4
|
+
"sourcesContent": ["import Decimal from 'decimal.js'\nimport type { ContainerProps, CurrencyDisplayType } from '../../types/props.js'\n/* eslint-disable no-useless-escape */\nexport const PRICE_SYMBOL = {\n us: '$',\n uk: '\u00A3',\n ca: '$',\n eu: '\u20AC',\n fr: '\u20AC',\n de: '\u20AC',\n nl: '\u20AC',\n vn: '\u20AB',\n cl: '$',\n sg: '$',\n ae: 'AED',\n} as any\n\nexport const languageTerritory = (locale: string) =>\n // https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_territory_information.html\n ({\n us: 'en-US',\n uk: 'en-GB',\n ca: 'en-CA',\n eu: 'en',\n fr: 'fr-FR',\n au: 'en-AU',\n my: 'en-my',\n 'eu-es': 'de-DE',\n 'eu-fr': 'de-DE',\n 'eu-it': 'de-DE',\n 'eu-de': 'de-DE',\n 'eu-en': 'en-US',\n 'cz-en': 'de-DE',\n 'ca-fr': 'fr-FR',\n nl: 'de-DE',\n de: 'de-DE',\n vn: 'vi-vn',\n sg: 'en-sg',\n 'ae-en': 'ae-en',\n plus: 'en-us',\n cl: 'es-cl',\n dk: 'en-dk',\n fi: 'en-fi',\n no: 'en-no',\n is: 'en-is',\n se: 'en-se',\n 'eu-pl': 'pl-PL',\n es: 'es-es',\n pl: 'pl-PL',\n nz: 'en-NZ',\n 'sg-en': 'en-SG',\n 'sa-en': 'en-SA',\n 'vn-vi': 'vi-VN',\n ie: 'en-IE',\n tw: 'zh-TW',\n })[locale] || ''\n\nexport function formatPrice({\n amount,\n currencyCode,\n currencyDisplay,\n locale,\n maximumFractionDigits,\n minimumFractionDigits,\n removeTrailingZeros = false,\n}: {\n amount: number\n currencyCode: string\n currencyDisplay?: CurrencyDisplayType\n locale: string\n maximumFractionDigits?: number\n minimumFractionDigits?: number\n removeTrailingZeros?: boolean\n}) {\n const code = locale === 'nl' ? 'EUR' : currencyCode || 'USD'\n const localeLanguage = languageTerritory(locale)\n if (!localeLanguage) {\n return null\n }\n const formatCurrency = new Intl.NumberFormat(localeLanguage, {\n style: 'currency',\n currency: code,\n currencyDisplay: currencyDisplay || 'symbol',\n minimumFractionDigits: maximumFractionDigits === 0 ? 0 : minimumFractionDigits,\n maximumFractionDigits,\n })\n\n let formattedValue = formatCurrency?.format?.(amount)\n\n if (['eu-de', 'eu-en', 'de', 'eu'].includes(locale)) {\n formattedValue = formattedValue?.toString()?.replace?.(/[\\s]/g, '')\n }\n\n if (removeTrailingZeros) {\n formattedValue = formattedValue\n ?.replace?.(/(\\.\\d*?[1-9])0+\\b/, '$1')\n ?.replace?.(/\\.0+\\b/, '')\n ?.replace?.(/(\\,\\d*?[1-9])0+\\b/, '$1')\n ?.replace?.(/\\,0+\\b/, '')\n }\n\n return formattedValue\n}\n\nexport function formatVariantPrice({\n amount,\n baseAmount,\n currencyCode,\n currencyDisplay,\n locale,\n maximumFractionDigits,\n minimumFractionDigits,\n removeTrailingZeros,\n}: {\n baseAmount: number\n amount: number\n currencyCode: string\n currencyDisplay?: CurrencyDisplayType\n locale: string\n maximumFractionDigits?: number\n minimumFractionDigits?: number\n removeTrailingZeros?: boolean\n}) {\n if (typeof Intl === 'undefined') {\n return {\n price: `${PRICE_SYMBOL[locale]}${amount}`,\n basePrice: `${PRICE_SYMBOL[locale]}${baseAmount}`,\n discount: `${PRICE_SYMBOL[locale]}${baseAmount - amount || 0}`,\n }\n }\n\n const hasDiscount = baseAmount > amount\n let discount = null\n const currentLocale = languageTerritory(locale)\n if (currentLocale) {\n const formatDiscount = new Intl.NumberFormat(currentLocale, {\n style: 'percent',\n })\n discount = hasDiscount ? formatDiscount.format((baseAmount - amount) / baseAmount) : null\n }\n // \u6298\u6263\u91D1\u989D\n let discountAmount\n if (hasDiscount) {\n const savePriceAmount = new Decimal(baseAmount).sub(amount || 0).toNumber()\n discountAmount = formatPrice({\n amount: savePriceAmount,\n currencyDisplay,\n currencyCode: currencyCode || 'USD',\n locale,\n maximumFractionDigits: 2,\n })\n }\n\n const price = formatPrice({ amount, currencyCode, currencyDisplay, locale, removeTrailingZeros })\n const basePrice = hasDiscount\n ? formatPrice({\n amount: baseAmount,\n currencyCode,\n currencyDisplay,\n locale,\n maximumFractionDigits,\n minimumFractionDigits,\n removeTrailingZeros,\n })\n : undefined\n\n return { price, basePrice, discount, discountAmount }\n}\n\ntype EventType = {\n primaryButton?: (v: any, index: number, data: ShelfDisplayType, coupon: any) => void\n secondaryButton?: (v: any, index: number, data: ShelfDisplayType, coupon: any) => void\n}\n\nexport interface ShelfDisplayItem {\n custom_primary_link?: string\n custom_secondary_link?: string\n id?: string\n /** \u4EA7\u54C1\u56FE\u7247*/\n img?: {\n url: string\n }\n handle?: string\n sku?: string\n /** \u6298\u6263\u540E\u4EF7\u683C*/\n price?: string\n title?: string\n /** \u6298\u6263\u524D\u4EF7\u683C*/\n basePrice?: string\n subTitle?: string\n /** \u6807\u7B7E*/\n tagItems?: string[]\n tab?: string\n data?: ShelfDisplayItem[]\n custom_name?: string\n custom_description?: string\n custom_image?: string\n custom_theme?: string\n}\n\nexport type ShelfDisplayType = {\n title?: string\n isShowTab?: boolean\n isShowTag?: boolean\n isShowRecommendedCard?: boolean\n isShowOriginalPrice?: boolean\n direction?: 'horizontal' | 'vertical'\n align?: 'left' | 'center' | 'right'\n productsTab?: any[]\n productsCard?: any[]\n /** \u5361\u7247\u5F62\u72B6 */\n itemShape?: 'round' | 'square'\n /** \u6309\u94AE\u5F62\u72B6 */\n shape?: 'round' | 'square'\n /** \u6807\u7B7E\u9875\u5F62\u72B6*/\n tabShape?: 'rounded' | 'square'\n /** \u4E3B\u6309\u94AE\u914D\u7F6E */\n primaryButton?: string\n primaryFun?: 'AddCart' | 'BuyNow' | 'LearnMore'\n /** \u526F\u6309\u94AE\u914D\u7F6E */\n secondaryButton?: string\n secondaryFun?: 'AddCart' | 'BuyNow' | 'LearnMore'\n theme?: 'light' | 'dark'\n containerProps?: ContainerProps\n}\n\nexport interface ShelfDisplayProps {\n data: ShelfDisplayType\n buildData?: {\n categories: any[]\n products: any[]\n }\n recommendedData?: any[]\n /** \u6309\u94AE\u4E8B\u4EF6*/\n event?: EventType\n className?: string\n key?: string\n target?: '_self' | '_blank'\n breakpoints?: {\n [key: number]: {\n spaceBetween: number\n freeMode: boolean\n slidesPerView: number\n }\n }\n metafields?: any\n isDisplayGudgments?: boolean\n isDisplayBackImage?: boolean\n}\n"],
|
|
5
5
|
"mappings": "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C,EACD,OAEJ,MAAO,CAAE,MAAAY,EAAO,UAAAC,EAAW,SAAAP,EAAU,eAAAG,CAAe,CACtD",
|
|
6
6
|
"names": ["shelfDisplay_exports", "__export", "PRICE_SYMBOL", "formatPrice", "formatVariantPrice", "languageTerritory", "__toCommonJS", "import_decimal", "locale", "amount", "currencyCode", "currencyDisplay", "maximumFractionDigits", "minimumFractionDigits", "removeTrailingZeros", "code", "localeLanguage", "formattedValue", "baseAmount", "hasDiscount", "discount", "currentLocale", "formatDiscount", "discountAmount", "savePriceAmount", "Decimal", "price", "basePrice"]
|
|
7
7
|
}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
"use strict";var de=Object.create;var R=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var xe=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var a in t)R(e,a,{get:t[a],enumerable:!0})},pe=(e,t,a,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of fe(t))!he.call(e,u)&&u!==a&&R(e,u,{get:()=>t[u],enumerable:!(f=ue(t,u))||f.enumerable});return e};var te=(e,t,a)=>(a=e!=null?de(xe(e)):{},pe(t||!e||!e.__esModule?R(a,"default",{value:e,enumerable:!0}):a,e)),ge=e=>pe(R({},"__esModule",{value:!0}),e);var we={};ve(we,{ShelfDisplayHorizontalItem:()=>be,ShelfDisplayWrapItem:()=>ye,getProductImage:()=>ce});module.exports=ge(we);var s=require("react/jsx-runtime"),se=require("../AiuiProvider/index.js"),le=require("./shelfDisplay.js"),J=te(require("../../components/picture.js")),K=te(require("../../components/badge.js")),h=require("../../helpers/utils.js"),oe=require("../../components/text.js"),U=te(require("../../components/button.js")),ie=require("../../shared/track.js"),ae=require("../../shared/trackUrlRef.js"),ne=require("../../components/heading.js"),re=require("../../hooks/useExposure.js"),p=require("react");const V="image",q="product_shelf",G=999999999e-2,ce=e=>{const t=e?.sku,a=e?.variants,f=a?.find(k=>k?.sku===t),u=f?.image?.url||a?.[0]?.image?.url||"",$=f?.image?.altText||a?.[0]?.image?.altText||e?.custom_name||e?.title||"";return{imageUrl:u,altText:$}},ye=({data:e,configuration:t})=>{const{isDisplayBackImage:a=!1,itemShape:f,metafields:u,isTopTag:$=!1,isShowTag:k,isShowOriginalPrice:z,isShowShortTitle:b=!1}=t||{},{locale:w="es",copyWriting:Q,currencyDisplay:A}=(0,se.useAiuiContext)(),{discounts:H,discountsCopy:B}=u||{},L=(0,p.useRef)(null),[E,n]=(0,p.useState)([]),[D,X]=(0,p.useState)(""),F=(l,o,m,d)=>t?.event?.primaryButton?.(l,o+1,m,d),Y=(l,o,m,d)=>t?.event?.secondaryButton?.(l,o+1,m,d),r=(0,p.useMemo)(()=>{const l=e?.variants||[];if(l.length)return e?.sku?l?.find?.(o=>o?.sku===e?.sku)||l[0]:l?.[0]},[e?.sku,e?.variants]),x=r?.id?.split?.("/")||[],C=x?.[x?.length-1],I=!r?.availableForSale||r?.price?.amount===G||r?.price===G,v=r?.coupons?.[0],P=!!(z&&v),M=e?.price?.currencyCode||"USD",_=(0,p.useMemo)(()=>(0,le.formatVariantPrice)({locale:w,amount:P?v?.variant_price4wscode:r?.price,baseAmount:P?r?.price:0,currencyCode:M,currencyDisplay:A}),[M,w,P,v?.variant_price4wscode,r]),{price:j,basePrice:Z,discount:S,discountAmount:g}=_,{imageUrl:T,altText:N}=ce(e),y=e?.custom_name||e?.title,W=b&&r?.metafields?.infos?.page_short_title||y,O=e?.custom_description||e?.description,i=()=>{if(v?.value_type==="fixed_amount"){const l=g||"",o=l.match(/^(.*?)(\d[\d.,]*)(.*)$/);if(o){const[,m,d,me]=o;let ee=d;return d.endsWith(".00")?ee=d.replace(/\.00$/,""):d.endsWith(",00")&&(ee=d.replace(/,00$/,"")),`${m}${ee}${me}`}return l}return S||""};(0,p.useEffect)(()=>{let l=[];if(S||g){const m=`${i()} ${H?.off||B?.off||""}`;X(m),l.push(m)}const o=e?.tags?.filter?.(m=>m?.startsWith?.("CLtag"))?.map?.(m=>m?.replace?.("CLtag:",""))?.slice?.(0,S?1:2);n(l.concat(o))},[e?.tags,S,g,H?.off,B?.off]),(0,re.useExposure)(L,{componentType:V,componentName:q,componentTitle:y,componentDescription:O,position:t?.index+1});const c=()=>(0,s.jsxs)(s.Fragment,{children:[k&&E?.length>0?(0,s.jsx)("div",{className:"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden",children:E?.map?.((l,o)=>(0,s.jsx)(K.default,{className:"shelf-items-tag",children:l},o))}):null,W?(0,s.jsx)(ne.Heading,{as:"h3",title:W||"",size:2,className:"shelf-display-product-title lg-desktop:h-[58px] line-clamp-2 h-12",html:W||""}):null,O?(0,s.jsx)(oe.Text,{size:2,className:"lg-desktop:text-lg desktop:text-base shelf-display-product-description line-clamp-1 text-sm",html:O||""}):null,(0,s.jsx)("div",{className:"mb-2 mt-4 flex items-center",children:I?(0,s.jsx)("div",{className:"tablet:text-2xl text-info-primary text-xl font-bold",children:Q?.soldOutText}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"final-price tablet:text-2xl text-info-primary text-xl font-bold",children:r?.availableForSale&&j||""}),(0,s.jsx)("div",{className:"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through",children:r?.availableForSale&&Z||""})]})}),(0,s.jsxs)("div",{className:(0,h.cn)("shelf-flex-button-group","lg-desktop:gap-3 flex items-center gap-2",t.direction==="vertical"?"flex-col":""),children:[t?.secondaryButton?(0,s.jsx)(U.default,{variant:"secondary",onClick:()=>Y(e,t?.index,t,v),className:`
|
|
2
|
-
${t.direction==="vertical"?"w-full":""}
|
|
3
|
-
`,children:t?.secondaryButton||""}):null,t?.primaryButton?(0,s.jsx)(U.default,{disabled:I,variant:"primary",onClick:()=>F(e,t?.index,t,v),className:`
|
|
4
|
-
${t.direction==="vertical"?"w-full":""}
|
|
5
|
-
`,children:t?.primaryButton||""}):null]})]});return(0,s.jsx)("div",{ref:L,className:(0,h.cn)("bg-container-secondary-1 tablet:hover:bg-info-white box-border w-full cursor-pointer overflow-hidden duration-300",f==="round"?"rounded-2xl":"rounded-none","lg-desktop:aspect-w-[404] lg-desktop:aspect-h-[480] desktop:aspect-w-[316] desktop:aspect-h-[384]","laptop:aspect-w-[288] laptop:aspect-h-[360] aspect-w-[296] aspect-h-[360] relative","md-tablet:h-[360px] shelf-display-item"),children:a?(0,s.jsx)("div",{className:"absolute inset-0 box-border overflow-hidden",children:(0,s.jsxs)("div",{className:"relative inset-0 size-full",children:[(0,s.jsx)(J.default,{source:T,alt:N,className:"flex h-full justify-center object-cover [&_img]:w-auto"}),(0,s.jsx)("div",{className:"desktop:p-6 absolute inset-x-0 bottom-0 box-border overflow-hidden p-4",children:c()})]})}):(0,s.jsxs)("div",{className:"desktop:p-6 absolute inset-0 box-border flex flex-col justify-between overflow-hidden p-4",children:[D&&$&&(0,s.jsx)(K.default,{className:"shelf-prices-tag absolute left-4 top-4 z-10",children:D||""}),(0,s.jsx)("div",{className:(0,h.cn)("lg-desktop:h-[195px] shelf-display-item-image relative mb-2 inline-block h-[140px] w-full flex-1 overflow-hidden"),children:(0,s.jsx)("a",{"aria-label":y,target:t?.target,href:(0,ae.trackUrlRef)(`${w==="us"||!w?"":`/${w}`}/products/${e?.handle}?variant=${C}`,`${V}_${q}`),onClick:()=>{(0,ie.gaTrack)({event:"ga4Event",event_name:"select_item",event_parameters:{page_group:"Home Page",item_list_name:"Home_Page_Bundle",items:[{item_id:e?.sku||r?.sku,item_name:e?.name,item_variant:r?.name,price:r?.price,index:t?.index+1}]}})},children:(0,s.jsx)(J.default,{source:T,alt:N,className:"flex h-full justify-center object-cover [&_img]:w-auto"})})}),c()]})},e?.id||e?.handle)},be=({data:e,configuration:t})=>{const{itemShape:a,itemLength:f,metafields:u,isShowShortTitle:$}=t||{},{discounts:k,discountsCopy:z}=u||{},{locale:b="us",copyWriting:w,currencyDisplay:Q}=(0,se.useAiuiContext)(),[A,H]=(0,p.useState)([]),B=(0,p.useRef)(null),L=(i,c,l,o)=>t?.event?.primaryButton?.(i,c+1,l,o),E=(i,c,l,o)=>t?.event?.secondaryButton?.(i,c+1,l,o),n=(0,p.useMemo)(()=>{const i=e?.variants||[];if(i.length)return e?.sku&&i.find(c=>c?.sku===e?.sku)||i[0]},[e?.sku,e?.variants]),D=n?.id?.split?.("/")||[],X=D?.[D?.length-1],F=!n?.availableForSale||n?.price?.amount===G||n?.price===G,Y=t?.isShowTag,r=t?.isShowOriginalPrice,x=n?.coupons?.[0],C=!!(r&&x),I=e?.price?.currencyCode||"USD",v=(0,p.useMemo)(()=>(0,le.formatVariantPrice)({locale:b,amount:C?x?.variant_price4wscode:n?.price,baseAmount:C?n?.price:0,currencyCode:I,currencyDisplay:Q}),[I,b,C,x?.variant_price4wscode,n]),{price:P,basePrice:M,discount:_,discountAmount:j}=v,{imageUrl:Z,altText:S}=ce(e),g=e?.custom_name||e?.title,T=$&&n?.metafields?.infos?.page_short_title||g,N=e?.custom_description||e?.description;(0,re.useExposure)(B,{componentType:V,componentName:q,componentTitle:g,componentDescription:N,position:t?.index+1});const y=()=>f>=2?{boxItem:"lg-desktop:max-w-[401px] desktop:max-w-[292px] max-w-full",imgItem:"m-tablet:m-auto lg-desktop:max-w-[330px] lg-desktop:max-h-[330px] desktop:max-w-[260px] desktop:max-h-[260px] max-w-[138px] max-h-[138px]",wrap:"lg-desktop:aspect-w-[824] lg-desktop:aspect-h-[480] desktop:aspect-w-[648] desktop:aspect-h-[380] laptop:aspect-w-[440] laptop:aspect-h-[356] tablet:aspect-w-[346] tablet:aspect-h-[360] md-tablet:w-full"}:{boxItem:"lg-desktop:max-w-[401px] desktop:max-w-[292px] laptop:max-w-[289px] max-w-[262px]",imgItem:"md-tablet:m-auto lg-desktop:max-w-[450px] lg-desktop:max-h-[450px] desktop:max-w-[332px] desktop:max-h-[332px] max-w-[312px] max-h-[312px]",wrap:"lg-desktop:aspect-w-[1664] lg-desktop:aspect-h-[480] desktop:aspect-w-[1312] desktop:aspect-h-[380] laptop:aspect-w-[896] laptop:aspect-h-[356] tablet:aspect-w-[704] tablet:aspect-h-[360] md-tablet:w-full"},W=()=>f>=2?"flex flex-col justify-between desktop:gap-12 desktop:flex-row desktop:justify-center desktop:items-center":"flex justify-center items-center gap-6 md-tablet:flex-col",O=()=>{if(x?.value_type==="fixed_amount"){const i=j||"",c=i.match(/^(.*?)(\d[\d.,]*)(.*)$/);if(c){const[,l,o,m]=c;let d=o;return o.endsWith(".00")?d=o.replace(/\.00$/,""):o.endsWith(",00")&&(d=o.replace(/,00$/,"")),`${l}${d}${m}`}return i}return _||""};return(0,p.useEffect)(()=>{let i=[];if(_||j){const l=`${O()} ${k?.off||z?.off||""}`;i.push(l)}const c=e?.tags?.filter?.(l=>l?.startsWith?.("CLtag"))?.map?.(l=>l?.replace?.("CLtag:",""))?.slice?.(0,_?1:2);H(i.concat(c))},[e?.tags,_,j,k?.off,z?.off]),(0,s.jsx)("div",{ref:B,className:(0,h.cn)(y().wrap,a==="round"?"rounded-2xl":"rounded-none","shelf-display-item","bg-container-secondary-1 tablet:hover:bg-info-white gap-6 duration-300","md-tablet:h-[360px] relative box-border w-full cursor-pointer overflow-hidden"),children:(0,s.jsxs)("div",{className:(0,h.cn)(W(),"desktop:p-6 absolute inset-0 box-border overflow-hidden p-4"),children:[(0,s.jsx)("div",{className:(0,h.cn)(y().imgItem,"desktop:mb-0 relative mb-1 overflow-hidden"),children:(0,s.jsx)("a",{"aria-label":g,target:t?.target,href:(0,ae.trackUrlRef)(`${b==="us"||!b?"":`/${b}`}/products/${e?.handle}?variant=${X}`,`${V}_${q}`),onClick:()=>{(0,ie.gaTrack)({event:"ga4Event",event_name:"select_item",event_parameters:{page_group:"Home Page",item_list_name:"Home_Page_Bundle",items:[{item_id:e?.sku||n?.sku,item_name:e?.name,item_variant:n?.name,price:n?.price,index:t?.index+1}]}})},children:(0,s.jsx)(J.default,{source:Z,alt:S,className:"flex h-full justify-center object-cover [&_img]:w-auto"})})}),(0,s.jsxs)("div",{className:(0,h.cn)("flex flex-col items-start justify-center",y().boxItem),children:[Y&&(0,s.jsx)("div",{className:"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden",children:A?.length>0&&A?.map?.((i,c)=>(0,s.jsx)(K.default,{className:"shelf-items-tag",children:i},c))}),T?(0,s.jsx)(ne.Heading,{as:"h3",title:T||"",size:2,className:"shelf-display-product-title lg-desktop:h-[58px] mb-1 line-clamp-2 h-[48px]",html:T||""}):null,N?(0,s.jsx)(oe.Text,{size:2,className:"lg-desktop:text-lg lg-desktop:h-[26px] desktop:text-base desktop:h-6 shelf-display-product-description line-clamp-1 h-5 text-sm",html:N||""}):null,(0,s.jsx)("div",{className:"mb-2 mt-5 flex items-center",children:F?(0,s.jsx)("div",{className:"tablet:text-2xl text-info-primary text-xl font-bold",children:w?.soldOutText}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"final-price tablet:text-2xl text-info-primary text-xl font-bold",children:n?.availableForSale&&P||""}),(0,s.jsx)("div",{className:"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through",children:n?.availableForSale&&M||""})]})}),(0,s.jsxs)("div",{className:(0,h.cn)("shelf-flex-button-group","lg-desktop:gap-3 flex items-center gap-2",t.direction==="vertical"?"flex-col":""),children:[t?.secondaryButton?(0,s.jsx)(U.default,{variant:"secondary",onClick:()=>E(e,t?.index,t,x),className:`
|
|
6
|
-
${t.direction==="vertical"?"w-full":""}
|
|
7
|
-
`,children:t?.secondaryButton||""}):null,t?.primaryButton?(0,s.jsx)(U.default,{disabled:F,variant:"primary",onClick:()=>L(e,t?.index,t,x),className:`
|
|
8
|
-
${t.direction==="vertical"?"w-full":""}
|
|
9
|
-
`,children:t?.primaryButton||""}):null]})]})]})},e?.id||e?.handle)};
|
|
1
|
+
"use strict";var de=Object.create;var R=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var xe=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var n in t)R(e,n,{get:t[n],enumerable:!0})},pe=(e,t,n,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of fe(t))!he.call(e,u)&&u!==n&&R(e,u,{get:()=>t[u],enumerable:!(f=ue(t,u))||f.enumerable});return e};var te=(e,t,n)=>(n=e!=null?de(xe(e)):{},pe(t||!e||!e.__esModule?R(n,"default",{value:e,enumerable:!0}):n,e)),ye=e=>pe(R({},"__esModule",{value:!0}),e);var ke={};ve(ke,{ShelfDisplayHorizontalItem:()=>be,ShelfDisplayWrapItem:()=>ge,getProductImage:()=>ce});module.exports=ye(ke);var s=require("react/jsx-runtime"),se=require("../AiuiProvider/index.js"),oe=require("./shelfDisplay.js"),J=te(require("../../components/picture.js")),K=te(require("../../components/badge.js")),h=require("../../helpers/utils.js"),le=require("../../components/text.js"),U=te(require("../../components/button.js")),ie=require("../../shared/track.js"),ne=require("../../shared/trackUrlRef.js"),ae=require("../../components/heading.js"),re=require("../../hooks/useExposure.js"),p=require("react");const V="image",q="product_shelf",G=999999999e-2,ce=e=>{const t=e?.sku,n=e?.variants,f=n?.find(w=>w?.sku===t),u=f?.image?.url||n?.[0]?.image?.url||"",B=f?.image?.altText||n?.[0]?.image?.altText||e?.custom_name||e?.title||"";return{imageUrl:u,altText:B}},ge=({data:e,configuration:t})=>{const{isDisplayBackImage:n=!1,itemShape:f,metafields:u,isTopTag:B=!1,isShowTag:w,isShowOriginalPrice:z,isShowShortTitle:b=!1}=t||{},{locale:k="es",copyWriting:Q,currencyDisplay:A}=(0,se.useAiuiContext)(),{discounts:H,discountsCopy:$}=u||{},L=(0,p.useRef)(null),[E,a]=(0,p.useState)([]),[D,X]=(0,p.useState)(""),F=(o,l,m,d)=>t?.event?.primaryButton?.(o,l+1,m,d),Y=(o,l,m,d)=>t?.event?.secondaryButton?.(o,l+1,m,d),r=(0,p.useMemo)(()=>{const o=e?.variants||[];if(o.length)return e?.sku?o?.find?.(l=>l?.sku===e?.sku)||o[0]:o?.[0]},[e?.sku,e?.variants]),x=r?.id?.split?.("/")||[],C=x?.[x?.length-1],I=!r?.availableForSale||r?.price?.amount===G||r?.price===G,v=r?.coupons?.[0],P=!!(z&&v),M=e?.price?.currencyCode||"USD",_=(0,p.useMemo)(()=>(0,oe.formatVariantPrice)({locale:k,amount:P?v?.variant_price4wscode:r?.price,baseAmount:P?r?.price:0,currencyCode:M,currencyDisplay:A}),[M,k,P,v?.variant_price4wscode,r]),{price:j,basePrice:Z,discount:S,discountAmount:y}=_,{imageUrl:T,altText:N}=ce(e),g=e?.custom_name||e?.title,W=b&&r?.metafields?.infos?.page_short_title||g,O=e?.custom_description||e?.description,i=()=>{if(v?.value_type==="fixed_amount"){const o=y||"",l=o.match(/^(.*?)(\d[\d.,]*)(.*)$/);if(l){const[,m,d,me]=l;let ee=d;return d.endsWith(".00")?ee=d.replace(/\.00$/,""):d.endsWith(",00")&&(ee=d.replace(/,00$/,"")),`${m}${ee}${me}`}return o}return S||""};(0,p.useEffect)(()=>{let o=[];if(S||y){const m=`${i()} ${H?.off||$?.off||""}`;X(m),o.push(m)}const l=e?.tags?.filter?.(m=>m?.startsWith?.("CLtag"))?.map?.(m=>m?.replace?.("CLtag:",""))?.slice?.(0,S?1:2);a(o.concat(l))},[e?.tags,S,y,H?.off,$?.off]),(0,re.useExposure)(L,{componentType:V,componentName:q,componentTitle:g,componentDescription:O,position:t?.index+1});const c=()=>(0,s.jsxs)(s.Fragment,{children:[w&&E?.length>0?(0,s.jsx)("div",{className:"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden",children:E?.map?.((o,l)=>(0,s.jsx)(K.default,{className:"shelf-items-tag",children:o},l))}):null,W?(0,s.jsx)(ae.Heading,{as:"h3",title:W||"",size:2,className:"shelf-display-product-title lg-desktop:h-[58px] line-clamp-2 h-12",html:W||""}):null,O?(0,s.jsx)(le.Text,{size:2,className:"lg-desktop:text-lg desktop:text-base shelf-display-product-description line-clamp-1 text-sm",html:O||""}):null,(0,s.jsx)("div",{className:"mb-2 mt-4 flex items-center",children:I?(0,s.jsx)("div",{className:"tablet:text-2xl text-info-primary text-xl font-bold",children:Q?.soldOutText}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"final-price tablet:text-2xl text-info-primary text-xl font-bold",children:r?.availableForSale&&j||""}),(0,s.jsx)("div",{className:"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through",children:r?.availableForSale&&Z||""})]})}),(0,s.jsxs)("div",{className:(0,h.cn)("shelf-flex-button-group","lg-desktop:gap-3 flex items-center gap-2",t.direction==="vertical"?"flex-col":""),children:[t?.secondaryButton?(0,s.jsx)(U.default,{variant:"secondary",href:e?.custom_secondary_link,as:e?.custom_secondary_link?"a":"button",onClick:()=>!e?.custom_secondary_link&&Y(e,t?.index,t,v),className:t.direction==="vertical"?"w-full":"",children:t?.secondaryButton||""}):null,t?.primaryButton?(0,s.jsx)(U.default,{disabled:I,variant:"primary",href:e?.custom_primary_link,as:e?.custom_primary_link?"a":"button",onClick:()=>!e?.custom_primary_link&&F(e,t?.index,t,v),className:t.direction==="vertical"?"w-full":"",children:t?.primaryButton||""}):null]})]});return(0,s.jsx)("div",{ref:L,className:(0,h.cn)("bg-container-secondary-1 tablet:hover:bg-info-white box-border w-full cursor-pointer overflow-hidden duration-300",f==="round"?"rounded-2xl":"rounded-none","lg-desktop:aspect-w-[404] lg-desktop:aspect-h-[480] desktop:aspect-w-[316] desktop:aspect-h-[384]","laptop:aspect-w-[288] laptop:aspect-h-[360] aspect-w-[296] aspect-h-[360] relative","md-tablet:h-[360px] shelf-display-item"),children:n?(0,s.jsx)("div",{className:"absolute inset-0 box-border overflow-hidden",children:(0,s.jsxs)("div",{className:"relative inset-0 size-full",children:[(0,s.jsx)(J.default,{source:T,alt:N,className:"flex h-full justify-center object-cover [&_img]:w-auto"}),(0,s.jsx)("div",{className:"desktop:p-6 absolute inset-x-0 bottom-0 box-border overflow-hidden p-4",children:c()})]})}):(0,s.jsxs)("div",{className:"desktop:p-6 absolute inset-0 box-border flex flex-col justify-between overflow-hidden p-4",children:[D&&B&&(0,s.jsx)(K.default,{className:"shelf-prices-tag absolute left-4 top-4 z-10",children:D||""}),(0,s.jsx)("div",{className:(0,h.cn)("lg-desktop:h-[195px] shelf-display-item-image relative mb-2 inline-block h-[140px] w-full flex-1 overflow-hidden"),children:(0,s.jsx)("a",{"aria-label":g,target:t?.target,href:(0,ne.trackUrlRef)(`${k==="us"||!k?"":`/${k}`}/products/${e?.handle}?variant=${C}`,`${V}_${q}`),onClick:()=>{(0,ie.gaTrack)({event:"ga4Event",event_name:"select_item",event_parameters:{page_group:"Home Page",item_list_name:"Home_Page_Bundle",items:[{item_id:e?.sku||r?.sku,item_name:e?.name,item_variant:r?.name,price:r?.price,index:t?.index+1}]}})},children:(0,s.jsx)(J.default,{source:T,alt:N,className:"flex h-full justify-center object-cover [&_img]:w-auto"})})}),c()]})},e?.id||e?.handle)},be=({data:e,configuration:t})=>{const{itemShape:n,itemLength:f,metafields:u,isShowShortTitle:B}=t||{},{discounts:w,discountsCopy:z}=u||{},{locale:b="us",copyWriting:k,currencyDisplay:Q}=(0,se.useAiuiContext)(),[A,H]=(0,p.useState)([]),$=(0,p.useRef)(null),L=(i,c,o,l)=>t?.event?.primaryButton?.(i,c+1,o,l),E=(i,c,o,l)=>t?.event?.secondaryButton?.(i,c+1,o,l),a=(0,p.useMemo)(()=>{const i=e?.variants||[];if(i.length)return e?.sku&&i.find(c=>c?.sku===e?.sku)||i[0]},[e?.sku,e?.variants]),D=a?.id?.split?.("/")||[],X=D?.[D?.length-1],F=!a?.availableForSale||a?.price?.amount===G||a?.price===G,Y=t?.isShowTag,r=t?.isShowOriginalPrice,x=a?.coupons?.[0],C=!!(r&&x),I=e?.price?.currencyCode||"USD",v=(0,p.useMemo)(()=>(0,oe.formatVariantPrice)({locale:b,amount:C?x?.variant_price4wscode:a?.price,baseAmount:C?a?.price:0,currencyCode:I,currencyDisplay:Q}),[I,b,C,x?.variant_price4wscode,a]),{price:P,basePrice:M,discount:_,discountAmount:j}=v,{imageUrl:Z,altText:S}=ce(e),y=e?.custom_name||e?.title,T=B&&a?.metafields?.infos?.page_short_title||y,N=e?.custom_description||e?.description;(0,re.useExposure)($,{componentType:V,componentName:q,componentTitle:y,componentDescription:N,position:t?.index+1});const g=()=>f>=2?{boxItem:"lg-desktop:max-w-[401px] desktop:max-w-[292px] max-w-full",imgItem:"m-tablet:m-auto lg-desktop:max-w-[330px] lg-desktop:max-h-[330px] desktop:max-w-[260px] desktop:max-h-[260px] max-w-[138px] max-h-[138px]",wrap:"lg-desktop:aspect-w-[824] lg-desktop:aspect-h-[480] desktop:aspect-w-[648] desktop:aspect-h-[380] laptop:aspect-w-[440] laptop:aspect-h-[356] tablet:aspect-w-[346] tablet:aspect-h-[360] md-tablet:w-full"}:{boxItem:"lg-desktop:max-w-[401px] desktop:max-w-[292px] laptop:max-w-[289px] max-w-[262px]",imgItem:"md-tablet:m-auto lg-desktop:max-w-[450px] lg-desktop:max-h-[450px] desktop:max-w-[332px] desktop:max-h-[332px] max-w-[312px] max-h-[312px]",wrap:"lg-desktop:aspect-w-[1664] lg-desktop:aspect-h-[480] desktop:aspect-w-[1312] desktop:aspect-h-[380] laptop:aspect-w-[896] laptop:aspect-h-[356] tablet:aspect-w-[704] tablet:aspect-h-[360] md-tablet:w-full"},W=()=>f>=2?"flex flex-col justify-between desktop:gap-12 desktop:flex-row desktop:justify-center desktop:items-center":"flex justify-center items-center gap-6 md-tablet:flex-col",O=()=>{if(x?.value_type==="fixed_amount"){const i=j||"",c=i.match(/^(.*?)(\d[\d.,]*)(.*)$/);if(c){const[,o,l,m]=c;let d=l;return l.endsWith(".00")?d=l.replace(/\.00$/,""):l.endsWith(",00")&&(d=l.replace(/,00$/,"")),`${o}${d}${m}`}return i}return _||""};return(0,p.useEffect)(()=>{let i=[];if(_||j){const o=`${O()} ${w?.off||z?.off||""}`;i.push(o)}const c=e?.tags?.filter?.(o=>o?.startsWith?.("CLtag"))?.map?.(o=>o?.replace?.("CLtag:",""))?.slice?.(0,_?1:2);H(i.concat(c))},[e?.tags,_,j,w?.off,z?.off]),(0,s.jsx)("div",{ref:$,className:(0,h.cn)(g().wrap,n==="round"?"rounded-2xl":"rounded-none","shelf-display-item","bg-container-secondary-1 tablet:hover:bg-info-white gap-6 duration-300","md-tablet:h-[360px] relative box-border w-full cursor-pointer overflow-hidden"),children:(0,s.jsxs)("div",{className:(0,h.cn)(W(),"desktop:p-6 absolute inset-0 box-border overflow-hidden p-4"),children:[(0,s.jsx)("div",{className:(0,h.cn)(g().imgItem,"desktop:mb-0 relative mb-1 overflow-hidden"),children:(0,s.jsx)("a",{"aria-label":y,target:t?.target,href:(0,ne.trackUrlRef)(`${b==="us"||!b?"":`/${b}`}/products/${e?.handle}?variant=${X}`,`${V}_${q}`),onClick:()=>{(0,ie.gaTrack)({event:"ga4Event",event_name:"select_item",event_parameters:{page_group:"Home Page",item_list_name:"Home_Page_Bundle",items:[{item_id:e?.sku||a?.sku,item_name:e?.name,item_variant:a?.name,price:a?.price,index:t?.index+1}]}})},children:(0,s.jsx)(J.default,{source:Z,alt:S,className:"flex h-full justify-center object-cover [&_img]:w-auto"})})}),(0,s.jsxs)("div",{className:(0,h.cn)("flex flex-col items-start justify-center",g().boxItem),children:[Y&&(0,s.jsx)("div",{className:"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden",children:A?.length>0&&A?.map?.((i,c)=>(0,s.jsx)(K.default,{className:"shelf-items-tag",children:i},c))}),T?(0,s.jsx)(ae.Heading,{as:"h3",title:T||"",size:2,className:"shelf-display-product-title lg-desktop:h-[58px] mb-1 line-clamp-2 h-[48px]",html:T||""}):null,N?(0,s.jsx)(le.Text,{size:2,className:"lg-desktop:text-lg lg-desktop:h-[26px] desktop:text-base desktop:h-6 shelf-display-product-description line-clamp-1 h-5 text-sm",html:N||""}):null,(0,s.jsx)("div",{className:"mb-2 mt-5 flex items-center",children:F?(0,s.jsx)("div",{className:"tablet:text-2xl text-info-primary text-xl font-bold",children:k?.soldOutText}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"final-price tablet:text-2xl text-info-primary text-xl font-bold",children:a?.availableForSale&&P||""}),(0,s.jsx)("div",{className:"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through",children:a?.availableForSale&&M||""})]})}),(0,s.jsxs)("div",{className:(0,h.cn)("shelf-flex-button-group","lg-desktop:gap-3 flex items-center gap-2",t.direction==="vertical"?"flex-col":""),children:[t?.secondaryButton?(0,s.jsx)(U.default,{variant:"secondary",href:e?.custom_secondary_link,as:e?.custom_secondary_link?"a":"button",onClick:()=>!e?.custom_secondary_link&&E(e,t?.index,t,x),className:t.direction==="vertical"?"w-full":"",children:t?.secondaryButton||""}):null,t?.primaryButton?(0,s.jsx)(U.default,{disabled:F,variant:"primary",href:e?.custom_primary_link,as:e?.custom_primary_link?"a":"button",onClick:()=>!e?.custom_primary_link&&L(e,t?.index,t,x),className:t.direction==="vertical"?"w-full":"",children:t?.primaryButton||""}):null]})]})]})},e?.id||e?.handle)};
|
|
10
2
|
//# sourceMappingURL=shelfDisplayItem.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/ShelfDisplay/shelfDisplayItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useAiuiContext } from '../AiuiProvider/index.js'\nimport { formatVariantPrice } from './shelfDisplay.js'\nimport Picture from '../../components/picture.js'\nimport Badge from '../../components/badge.js'\nimport { cn } from '../../helpers/utils.js'\nimport { Text } from '../../components/text.js'\nimport Button from '../../components/button.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport { Heading } from '../../components/heading.js'\nimport type { ShelfDisplayItem, ShelfDisplayType } from './shelfDisplay.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { useRef, useEffect, useMemo, useState } from 'react'\n\nconst componentType = 'image'\nconst componentName = 'product_shelf'\n\nconst SOLD_OUT_PRICE = 9999999.99\n\n// \u516C\u5171\u51FD\u6570\uFF1A\u83B7\u53D6\u4EA7\u54C1\u56FE\u7247URL\u548CaltText\nexport const getProductImage = (data: any) => {\n const sku = data?.sku\n const skuArray = data?.variants\n const findSku = skuArray?.find((item: any) => item?.sku === sku)\n const imageUrl = findSku?.image?.url || skuArray?.[0]?.image?.url || ''\n const altText = findSku?.image?.altText || skuArray?.[0]?.image?.altText || data?.custom_name || data?.title || ''\n\n return {\n imageUrl,\n altText,\n }\n}\n\nexport const ShelfDisplayWrapItem = ({ data, configuration }: { data: any; configuration?: any }) => {\n const {\n isDisplayBackImage = false,\n itemShape,\n metafields,\n isTopTag = false,\n isShowTag,\n isShowOriginalPrice,\n isShowShortTitle = false,\n } = configuration || {}\n const { locale = 'es', copyWriting, currencyDisplay } = useAiuiContext()\n const { discounts, discountsCopy } = metafields || {}\n const ref = useRef<HTMLDivElement>(null)\n const [showTags, setShowTags] = useState<string[]>([])\n const [currentPriceTag, setCurrentPriceTag] = useState<string>('')\n\n const onPrimaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType, coupon: any) =>\n configuration?.event?.primaryButton?.(params, index + 1, data, coupon)\n\n const onSecondaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType, coupon: any) =>\n configuration?.event?.secondaryButton?.(params, index + 1, data, coupon)\n\n const variant = useMemo(() => {\n const variants = data?.variants || []\n if (!variants.length) {\n return undefined\n }\n if (!data?.sku) {\n return variants?.[0]\n }\n return variants?.find?.((item: any) => item?.sku === data?.sku) || variants[0]\n }, [data?.sku, data?.variants])\n\n const variantArr = variant?.id?.split?.('/') || []\n const variantId = variantArr?.[variantArr?.length - 1]\n\n const isSoldOut =\n !variant?.availableForSale || variant?.price?.amount === SOLD_OUT_PRICE || variant?.price === SOLD_OUT_PRICE\n\n // active \u7684 \u901A\u7528\u6298\u6263\n const coupon = variant?.coupons?.[0]\n\n const shouldUseCouponPrice = Boolean(isShowOriginalPrice && coupon)\n const currencyCode = data?.price?.currencyCode || 'USD'\n\n const priceInfo = useMemo(\n () =>\n formatVariantPrice({\n locale,\n amount: shouldUseCouponPrice ? coupon?.variant_price4wscode : variant?.price,\n baseAmount: shouldUseCouponPrice ? variant?.price : 0,\n currencyCode,\n currencyDisplay,\n }),\n [currencyCode, locale, shouldUseCouponPrice, coupon?.variant_price4wscode, variant]\n )\n\n const { price, basePrice, discount, discountAmount } = priceInfo\n\n const { imageUrl, altText } = getProductImage(data)\n\n const displayTitle = data?.custom_name || data?.title\n const currentDisplayTitle = isShowShortTitle\n ? variant?.metafields?.infos?.page_short_title || displayTitle\n : displayTitle\n const displayDescription = data?.custom_description || data?.description\n\n const showPrice = () => {\n if (coupon?.value_type === 'fixed_amount') {\n const amountStr = discountAmount || ''\n const match = amountStr.match(/^(.*?)(\\d[\\d.,]*)(.*)$/)\n if (match) {\n const [, prefix, numeric, suffix] = match\n let updatedNumeric = numeric\n if (numeric.endsWith('.00')) {\n updatedNumeric = numeric.replace(/\\.00$/, '')\n } else if (numeric.endsWith(',00')) {\n updatedNumeric = numeric.replace(/,00$/, '')\n }\n return `${prefix}${updatedNumeric}${suffix}`\n }\n return amountStr\n }\n return discount || ''\n }\n\n // \u5904\u7406\u6807\u7B7E\n useEffect(() => {\n let handleTags: string[] = []\n if (discount || discountAmount) {\n const discountTag = `${showPrice()} ${discounts?.off || discountsCopy?.off || ''}`\n setCurrentPriceTag(discountTag)\n handleTags.push(discountTag)\n }\n const newTags = data?.tags\n ?.filter?.((item: string) => item?.startsWith?.('CLtag'))\n ?.map?.((item: string) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, discount ? 1 : 2)\n setShowTags(handleTags.concat(newTags))\n }, [data?.tags, discount, discountAmount, discounts?.off, discountsCopy?.off])\n\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: displayTitle,\n componentDescription: displayDescription,\n position: configuration?.index + 1,\n })\n\n const bottomContent = () => {\n return (\n <>\n {isShowTag && showTags?.length > 0 ? (\n <div className=\"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden\">\n {showTags?.map?.((item: any, index: number) => (\n <Badge key={index} className=\"shelf-items-tag\">\n {item}\n </Badge>\n ))}\n </div>\n ) : null}\n {currentDisplayTitle ? (\n <Heading\n as=\"h3\"\n title={currentDisplayTitle || ''}\n size={2}\n className=\"shelf-display-product-title lg-desktop:h-[58px] line-clamp-2 h-12\"\n html={currentDisplayTitle || ''}\n />\n ) : null}\n {displayDescription ? (\n <Text\n size={2}\n className=\"lg-desktop:text-lg desktop:text-base shelf-display-product-description line-clamp-1 text-sm\"\n html={displayDescription || ''}\n />\n ) : null}\n <div className=\"mb-2 mt-4 flex items-center\">\n {isSoldOut ? (\n <div className=\"tablet:text-2xl text-info-primary text-xl font-bold\">{copyWriting?.soldOutText}</div>\n ) : (\n <>\n <div className=\"final-price tablet:text-2xl text-info-primary text-xl font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n {/* \u6309\u94AE\u7EC4 */}\n <div\n className={cn(\n 'shelf-flex-button-group',\n 'lg-desktop:gap-3 flex items-center gap-2',\n configuration.direction === 'vertical' ? 'flex-col' : ''\n )}\n >\n {configuration?.secondaryButton ? (\n <Button\n variant=\"secondary\"\n onClick={() => onSecondaryButton(data, configuration?.index, configuration, coupon)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.secondaryButton || ''}\n </Button>\n ) : null}\n {configuration?.primaryButton ? (\n <Button\n disabled={isSoldOut}\n variant=\"primary\"\n onClick={() => onPrimaryButton(data, configuration?.index, configuration, coupon)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.primaryButton || ''}\n </Button>\n ) : null}\n </div>\n </>\n )\n }\n\n return (\n <div\n ref={ref}\n key={data?.id || data?.handle}\n className={cn(\n 'bg-container-secondary-1 tablet:hover:bg-info-white box-border w-full cursor-pointer overflow-hidden duration-300',\n itemShape === 'round' ? 'rounded-2xl' : 'rounded-none',\n 'lg-desktop:aspect-w-[404] lg-desktop:aspect-h-[480] desktop:aspect-w-[316] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[288] laptop:aspect-h-[360] aspect-w-[296] aspect-h-[360] relative',\n 'md-tablet:h-[360px] shelf-display-item'\n )}\n >\n {isDisplayBackImage ? (\n <div className=\"absolute inset-0 box-border overflow-hidden\">\n <div className=\"relative inset-0 size-full\">\n <Picture\n source={imageUrl}\n alt={altText}\n className=\"flex h-full justify-center object-cover [&_img]:w-auto\"\n />\n <div className=\"desktop:p-6 absolute inset-x-0 bottom-0 box-border overflow-hidden p-4\">\n {bottomContent()}\n </div>\n </div>\n </div>\n ) : (\n <div className=\"desktop:p-6 absolute inset-0 box-border flex flex-col justify-between overflow-hidden p-4\">\n {currentPriceTag && isTopTag && (\n <Badge className=\"shelf-prices-tag absolute left-4 top-4 z-10\">{currentPriceTag || ''}</Badge>\n )}\n <div\n className={cn(\n 'lg-desktop:h-[195px] shelf-display-item-image relative mb-2 inline-block h-[140px] w-full flex-1 overflow-hidden'\n )}\n >\n <a\n aria-label={displayTitle}\n target={configuration?.target}\n href={trackUrlRef(\n `${locale === 'us' || !locale ? '' : `/${locale}`}/products/${data?.handle}?variant=${variantId}`,\n `${componentType}_${componentName}`\n )}\n onClick={() => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'select_item',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: [\n {\n item_id: data?.sku || variant?.sku,\n item_name: data?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: configuration?.index + 1,\n },\n ],\n },\n })\n }}\n >\n <Picture\n source={imageUrl}\n alt={altText}\n className=\"flex h-full justify-center object-cover [&_img]:w-auto\"\n />\n </a>\n </div>\n {bottomContent()}\n </div>\n )}\n </div>\n )\n}\n\nexport const ShelfDisplayHorizontalItem = ({ data, configuration }: { data: any; configuration?: any }) => {\n const { itemShape, itemLength, metafields, isShowShortTitle } = configuration || {}\n const { discounts, discountsCopy } = metafields || {}\n const { locale = 'us', copyWriting, currencyDisplay } = useAiuiContext()\n const [showTags, setShowTags] = useState<string[]>([])\n const ref = useRef<HTMLDivElement>(null)\n\n const onPrimaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType, coupon: any) =>\n configuration?.event?.primaryButton?.(params, index + 1, data, coupon)\n\n const onSecondaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType, coupon: any) =>\n configuration?.event?.secondaryButton?.(params, index + 1, data, coupon)\n\n const variant = useMemo(() => {\n const variants = data?.variants || []\n if (!variants.length) {\n return undefined\n }\n if (!data?.sku) {\n return variants[0]\n }\n return variants.find((item: any) => item?.sku === data?.sku) || variants[0]\n }, [data?.sku, data?.variants])\n\n const variantArr = variant?.id?.split?.('/') || []\n const variantId = variantArr?.[variantArr?.length - 1]\n\n const isSoldOut =\n !variant?.availableForSale || variant?.price?.amount === SOLD_OUT_PRICE || variant?.price === SOLD_OUT_PRICE\n const isShowTag = configuration?.isShowTag\n const isShowOriginalPrice = configuration?.isShowOriginalPrice\n\n // active \u7684 \u901A\u7528\u6298\u6263\n const coupon = variant?.coupons?.[0]\n\n const shouldUseCouponPrice = Boolean(isShowOriginalPrice && coupon)\n const currencyCode = data?.price?.currencyCode || 'USD'\n\n const priceInfo = useMemo(\n () =>\n formatVariantPrice({\n locale,\n amount: shouldUseCouponPrice ? coupon?.variant_price4wscode : variant?.price,\n baseAmount: shouldUseCouponPrice ? variant?.price : 0,\n currencyCode,\n currencyDisplay,\n }),\n [currencyCode, locale, shouldUseCouponPrice, coupon?.variant_price4wscode, variant]\n )\n\n const { price, basePrice, discount, discountAmount } = priceInfo\n\n const { imageUrl, altText } = getProductImage(data)\n\n const displayTitle = data?.custom_name || data?.title\n const currentDisplayTitle = isShowShortTitle\n ? variant?.metafields?.infos?.page_short_title || displayTitle\n : displayTitle\n const displayDescription = data?.custom_description || data?.description\n\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: displayTitle,\n componentDescription: displayDescription,\n position: configuration?.index + 1,\n })\n\n const showSizeClass = (): {\n boxItem: string\n imgItem: string\n wrap: string\n } => {\n if (itemLength >= 2) {\n return {\n boxItem: 'lg-desktop:max-w-[401px] desktop:max-w-[292px] max-w-full',\n imgItem:\n 'm-tablet:m-auto lg-desktop:max-w-[330px] lg-desktop:max-h-[330px] desktop:max-w-[260px] desktop:max-h-[260px] max-w-[138px] max-h-[138px]',\n wrap: 'lg-desktop:aspect-w-[824] lg-desktop:aspect-h-[480] desktop:aspect-w-[648] desktop:aspect-h-[380] laptop:aspect-w-[440] laptop:aspect-h-[356] tablet:aspect-w-[346] tablet:aspect-h-[360] md-tablet:w-full',\n }\n }\n return {\n boxItem: 'lg-desktop:max-w-[401px] desktop:max-w-[292px] laptop:max-w-[289px] max-w-[262px]',\n imgItem:\n 'md-tablet:m-auto lg-desktop:max-w-[450px] lg-desktop:max-h-[450px] desktop:max-w-[332px] desktop:max-h-[332px] max-w-[312px] max-h-[312px]',\n wrap: 'lg-desktop:aspect-w-[1664] lg-desktop:aspect-h-[480] desktop:aspect-w-[1312] desktop:aspect-h-[380] laptop:aspect-w-[896] laptop:aspect-h-[356] tablet:aspect-w-[704] tablet:aspect-h-[360] md-tablet:w-full',\n }\n }\n\n const handleWrapClass = () => {\n if (itemLength >= 2) {\n return 'flex flex-col justify-between desktop:gap-12 desktop:flex-row desktop:justify-center desktop:items-center'\n }\n return 'flex justify-center items-center gap-6 md-tablet:flex-col'\n }\n\n const showPrice = () => {\n if (coupon?.value_type === 'fixed_amount') {\n const amountStr = discountAmount || ''\n const match = amountStr.match(/^(.*?)(\\d[\\d.,]*)(.*)$/)\n if (match) {\n const [, prefix, numeric, suffix] = match\n let updatedNumeric = numeric\n if (numeric.endsWith('.00')) {\n updatedNumeric = numeric.replace(/\\.00$/, '')\n } else if (numeric.endsWith(',00')) {\n updatedNumeric = numeric.replace(/,00$/, '')\n }\n return `${prefix}${updatedNumeric}${suffix}`\n }\n return amountStr\n }\n return discount || ''\n }\n\n // \u5904\u7406\u6807\u7B7E\n useEffect(() => {\n let handleTags: string[] = []\n if (discount || discountAmount) {\n const discountTag = `${showPrice()} ${discounts?.off || discountsCopy?.off || ''}`\n handleTags.push(discountTag)\n }\n const newTags = data?.tags\n ?.filter?.((item: string) => item?.startsWith?.('CLtag'))\n ?.map?.((item: string) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, discount ? 1 : 2)\n setShowTags(handleTags.concat(newTags))\n }, [data?.tags, discount, discountAmount, discounts?.off, discountsCopy?.off])\n\n return (\n <div\n ref={ref}\n key={data?.id || data?.handle}\n className={cn(\n showSizeClass().wrap,\n itemShape === 'round' ? 'rounded-2xl' : 'rounded-none',\n 'shelf-display-item',\n 'bg-container-secondary-1 tablet:hover:bg-info-white gap-6 duration-300',\n 'md-tablet:h-[360px] relative box-border w-full cursor-pointer overflow-hidden'\n )}\n >\n <div className={cn(handleWrapClass(), 'desktop:p-6 absolute inset-0 box-border overflow-hidden p-4')}>\n <div className={cn(showSizeClass().imgItem, 'desktop:mb-0 relative mb-1 overflow-hidden')}>\n <a\n aria-label={displayTitle}\n target={configuration?.target}\n href={trackUrlRef(\n `${locale === 'us' || !locale ? '' : `/${locale}`}/products/${data?.handle}?variant=${variantId}`,\n `${componentType}_${componentName}`\n )}\n onClick={() => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'select_item',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: [\n {\n item_id: data?.sku || variant?.sku,\n item_name: data?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: configuration?.index + 1,\n },\n ],\n },\n })\n }}\n >\n <Picture\n source={imageUrl}\n alt={altText}\n className=\"flex h-full justify-center object-cover [&_img]:w-auto\"\n />\n </a>\n </div>\n <div className={cn('flex flex-col items-start justify-center', showSizeClass().boxItem)}>\n {isShowTag && (\n <div className=\"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden\">\n {showTags?.length > 0 &&\n showTags?.map?.((item: any, index: number) => (\n <Badge key={index} className=\"shelf-items-tag\">\n {item}\n </Badge>\n ))}\n </div>\n )}\n {currentDisplayTitle ? (\n <Heading\n as=\"h3\"\n title={currentDisplayTitle || ''}\n size={2}\n className=\"shelf-display-product-title lg-desktop:h-[58px] mb-1 line-clamp-2 h-[48px]\"\n html={currentDisplayTitle || ''}\n />\n ) : null}\n {displayDescription ? (\n <Text\n size={2}\n className=\"lg-desktop:text-lg lg-desktop:h-[26px] desktop:text-base desktop:h-6 shelf-display-product-description line-clamp-1 h-5 text-sm\"\n html={displayDescription || ''}\n />\n ) : null}\n <div className=\"mb-2 mt-5 flex items-center\">\n {isSoldOut ? (\n <div className=\"tablet:text-2xl text-info-primary text-xl font-bold\">{copyWriting?.soldOutText}</div>\n ) : (\n <>\n <div className=\"final-price tablet:text-2xl text-info-primary text-xl font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n {/* \u6309\u94AE\u7EC4 */}\n <div\n className={cn(\n 'shelf-flex-button-group',\n 'lg-desktop:gap-3 flex items-center gap-2',\n configuration.direction === 'vertical' ? 'flex-col' : ''\n )}\n >\n {configuration?.secondaryButton ? (\n <Button\n variant=\"secondary\"\n onClick={() => onSecondaryButton(data, configuration?.index, configuration, coupon)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.secondaryButton || ''}\n </Button>\n ) : null}\n {configuration?.primaryButton ? (\n <Button\n disabled={isSoldOut}\n variant=\"primary\"\n onClick={() => onPrimaryButton(data, configuration?.index, configuration, coupon)}\n className={`\n ${configuration.direction === 'vertical' ? 'w-full' : ''}\n `}\n >\n {configuration?.primaryButton || ''}\n </Button>\n ) : null}\n </div>\n </div>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": "0kBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,gCAAAE,GAAA,yBAAAC,GAAA,oBAAAC,KAAA,eAAAC,GAAAL,IAoJc,IAAAM,EAAA,6BApJdC,GAA+B,oCAC/BC,GAAmC,6BACnCC,EAAoB,2CACpBC,EAAkB,yCAClBC,EAAmB,kCACnBC,GAAqB,oCACrBC,EAAmB,0CACnBC,GAAwB,iCACxBC,GAA4B,uCAC5BC,GAAwB,uCAExBC,GAA4B,sCAC5BC,EAAqD,iBAErD,MAAMC,EAAgB,QAChBC,EAAgB,gBAEhBC,EAAiB,aAGVjB,GAAmBkB,GAAc,CAC5C,MAAMC,EAAMD,GAAM,IACZE,EAAWF,GAAM,SACjBG,EAAUD,GAAU,KAAME,GAAcA,GAAM,MAAQH,CAAG,EACzDI,EAAWF,GAAS,OAAO,KAAOD,IAAW,CAAC,GAAG,OAAO,KAAO,GAC/DI,EAAUH,GAAS,OAAO,SAAWD,IAAW,CAAC,GAAG,OAAO,SAAWF,GAAM,aAAeA,GAAM,OAAS,GAEhH,MAAO,CACL,SAAAK,EACA,QAAAC,CACF,CACF,EAEazB,GAAuB,CAAC,CAAE,KAAAmB,EAAM,cAAAO,CAAc,IAA0C,CACnG,KAAM,CACJ,mBAAAC,EAAqB,GACrB,UAAAC,EACA,WAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EACA,oBAAAC,EACA,iBAAAC,EAAmB,EACrB,EAAIP,GAAiB,CAAC,EAChB,CAAE,OAAAQ,EAAS,KAAM,YAAAC,EAAa,gBAAAC,CAAgB,KAAI,mBAAe,EACjE,CAAE,UAAAC,EAAW,cAAAC,CAAc,EAAIT,GAAc,CAAC,EAC9CU,KAAM,UAAuB,IAAI,EACjC,CAACC,E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ACG,UAAA3C,GAAaS,GAAU,OAAS,KAC/B,OAAC,OAAI,UAAU,2DACZ,SAAAA,GAAU,MAAM,CAACjB,EAAWuB,OAC3B,OAAC,EAAA6B,QAAA,CAAkB,UAAU,kBAC1B,SAAApD,GADSuB,CAEZ,CACD,EACH,EACE,KACHgB,KACC,OAAC,YACC,GAAG,KACH,MAAOA,GAAuB,GAC9B,KAAM,EACN,UAAU,oEACV,KAAMA,GAAuB,GAC/B,EACE,KACHC,KACC,OAAC,SACC,KAAM,EACN,UAAU,8FACV,KAAMA,GAAsB,GAC9B,EACE,QACJ,OAAC,OAAI,UAAU,8BACZ,SAAAV,KACC,OAAC,OAAI,UAAU,sDAAuD,SAAAlB,GAAa,YAAY,KAE/F,oBACE,oBAAC,OAAI,UAAU,kEACZ,SAAAc,GAAS,kBAAmBQ,GAAS,GACxC,KACA,OAAC,OAAI,UAAU,sFACZ,SAAAR,GAAS,kBAAmBS,GAAa,GAC5C,GACF,EAEJ,KAEA,QAAC,OACC,aAAW,MACT,0BACA,2CACAhC,EAAc,YAAc,WAAa,WAAa,EACxD,EAEC,UAAAA,GAAe,mBACd,OAAC,EAAAkD,QAAA,CACC,QAAQ,YACR,QAAS,
|
|
4
|
+
"sourcesContent": ["import { useAiuiContext } from '../AiuiProvider/index.js'\nimport { formatVariantPrice } from './shelfDisplay.js'\nimport Picture from '../../components/picture.js'\nimport Badge from '../../components/badge.js'\nimport { cn } from '../../helpers/utils.js'\nimport { Text } from '../../components/text.js'\nimport Button from '../../components/button.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { trackUrlRef } from '../../shared/trackUrlRef.js'\nimport { Heading } from '../../components/heading.js'\nimport type { ShelfDisplayItem, ShelfDisplayType } from './shelfDisplay.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { useRef, useEffect, useMemo, useState } from 'react'\n\nconst componentType = 'image'\nconst componentName = 'product_shelf'\n\nconst SOLD_OUT_PRICE = 9999999.99\n\n// \u516C\u5171\u51FD\u6570\uFF1A\u83B7\u53D6\u4EA7\u54C1\u56FE\u7247URL\u548CaltText\nexport const getProductImage = (data: any) => {\n const sku = data?.sku\n const skuArray = data?.variants\n const findSku = skuArray?.find((item: any) => item?.sku === sku)\n const imageUrl = findSku?.image?.url || skuArray?.[0]?.image?.url || ''\n const altText = findSku?.image?.altText || skuArray?.[0]?.image?.altText || data?.custom_name || data?.title || ''\n\n return {\n imageUrl,\n altText,\n }\n}\n\nexport const ShelfDisplayWrapItem = ({ data, configuration }: { data: any; configuration?: any }) => {\n const {\n isDisplayBackImage = false,\n itemShape,\n metafields,\n isTopTag = false,\n isShowTag,\n isShowOriginalPrice,\n isShowShortTitle = false,\n } = configuration || {}\n const { locale = 'es', copyWriting, currencyDisplay } = useAiuiContext()\n const { discounts, discountsCopy } = metafields || {}\n const ref = useRef<HTMLDivElement>(null)\n const [showTags, setShowTags] = useState<string[]>([])\n const [currentPriceTag, setCurrentPriceTag] = useState<string>('')\n\n const onPrimaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType, coupon: any) =>\n configuration?.event?.primaryButton?.(params, index + 1, data, coupon)\n\n const onSecondaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType, coupon: any) =>\n configuration?.event?.secondaryButton?.(params, index + 1, data, coupon)\n\n const variant = useMemo(() => {\n const variants = data?.variants || []\n if (!variants.length) {\n return undefined\n }\n if (!data?.sku) {\n return variants?.[0]\n }\n return variants?.find?.((item: any) => item?.sku === data?.sku) || variants[0]\n }, [data?.sku, data?.variants])\n\n const variantArr = variant?.id?.split?.('/') || []\n const variantId = variantArr?.[variantArr?.length - 1]\n\n const isSoldOut =\n !variant?.availableForSale || variant?.price?.amount === SOLD_OUT_PRICE || variant?.price === SOLD_OUT_PRICE\n\n // active \u7684 \u901A\u7528\u6298\u6263\n const coupon = variant?.coupons?.[0]\n\n const shouldUseCouponPrice = Boolean(isShowOriginalPrice && coupon)\n const currencyCode = data?.price?.currencyCode || 'USD'\n\n const priceInfo = useMemo(\n () =>\n formatVariantPrice({\n locale,\n amount: shouldUseCouponPrice ? coupon?.variant_price4wscode : variant?.price,\n baseAmount: shouldUseCouponPrice ? variant?.price : 0,\n currencyCode,\n currencyDisplay,\n }),\n [currencyCode, locale, shouldUseCouponPrice, coupon?.variant_price4wscode, variant]\n )\n\n const { price, basePrice, discount, discountAmount } = priceInfo\n\n const { imageUrl, altText } = getProductImage(data)\n\n const displayTitle = data?.custom_name || data?.title\n const currentDisplayTitle = isShowShortTitle\n ? variant?.metafields?.infos?.page_short_title || displayTitle\n : displayTitle\n const displayDescription = data?.custom_description || data?.description\n\n const showPrice = () => {\n if (coupon?.value_type === 'fixed_amount') {\n const amountStr = discountAmount || ''\n const match = amountStr.match(/^(.*?)(\\d[\\d.,]*)(.*)$/)\n if (match) {\n const [, prefix, numeric, suffix] = match\n let updatedNumeric = numeric\n if (numeric.endsWith('.00')) {\n updatedNumeric = numeric.replace(/\\.00$/, '')\n } else if (numeric.endsWith(',00')) {\n updatedNumeric = numeric.replace(/,00$/, '')\n }\n return `${prefix}${updatedNumeric}${suffix}`\n }\n return amountStr\n }\n return discount || ''\n }\n\n // \u5904\u7406\u6807\u7B7E\n useEffect(() => {\n let handleTags: string[] = []\n if (discount || discountAmount) {\n const discountTag = `${showPrice()} ${discounts?.off || discountsCopy?.off || ''}`\n setCurrentPriceTag(discountTag)\n handleTags.push(discountTag)\n }\n const newTags = data?.tags\n ?.filter?.((item: string) => item?.startsWith?.('CLtag'))\n ?.map?.((item: string) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, discount ? 1 : 2)\n setShowTags(handleTags.concat(newTags))\n }, [data?.tags, discount, discountAmount, discounts?.off, discountsCopy?.off])\n\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: displayTitle,\n componentDescription: displayDescription,\n position: configuration?.index + 1,\n })\n\n const bottomContent = () => {\n return (\n <>\n {isShowTag && showTags?.length > 0 ? (\n <div className=\"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden\">\n {showTags?.map?.((item: any, index: number) => (\n <Badge key={index} className=\"shelf-items-tag\">\n {item}\n </Badge>\n ))}\n </div>\n ) : null}\n {currentDisplayTitle ? (\n <Heading\n as=\"h3\"\n title={currentDisplayTitle || ''}\n size={2}\n className=\"shelf-display-product-title lg-desktop:h-[58px] line-clamp-2 h-12\"\n html={currentDisplayTitle || ''}\n />\n ) : null}\n {displayDescription ? (\n <Text\n size={2}\n className=\"lg-desktop:text-lg desktop:text-base shelf-display-product-description line-clamp-1 text-sm\"\n html={displayDescription || ''}\n />\n ) : null}\n <div className=\"mb-2 mt-4 flex items-center\">\n {isSoldOut ? (\n <div className=\"tablet:text-2xl text-info-primary text-xl font-bold\">{copyWriting?.soldOutText}</div>\n ) : (\n <>\n <div className=\"final-price tablet:text-2xl text-info-primary text-xl font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n {/* \u6309\u94AE\u7EC4 */}\n <div\n className={cn(\n 'shelf-flex-button-group',\n 'lg-desktop:gap-3 flex items-center gap-2',\n configuration.direction === 'vertical' ? 'flex-col' : ''\n )}\n >\n {configuration?.secondaryButton ? (\n <Button\n variant=\"secondary\"\n href={data?.custom_secondary_link}\n as={data?.custom_secondary_link ? 'a' : 'button'}\n onClick={() =>\n !data?.custom_secondary_link && onSecondaryButton(data, configuration?.index, configuration, coupon)\n }\n className={configuration.direction === 'vertical' ? 'w-full' : ''}\n >\n {configuration?.secondaryButton || ''}\n </Button>\n ) : null}\n {configuration?.primaryButton ? (\n <Button\n disabled={isSoldOut}\n variant=\"primary\"\n href={data?.custom_primary_link}\n as={data?.custom_primary_link ? 'a' : 'button'}\n onClick={() =>\n !data?.custom_primary_link && onPrimaryButton(data, configuration?.index, configuration, coupon)\n }\n className={configuration.direction === 'vertical' ? 'w-full' : ''}\n >\n {configuration?.primaryButton || ''}\n </Button>\n ) : null}\n </div>\n </>\n )\n }\n\n return (\n <div\n ref={ref}\n key={data?.id || data?.handle}\n className={cn(\n 'bg-container-secondary-1 tablet:hover:bg-info-white box-border w-full cursor-pointer overflow-hidden duration-300',\n itemShape === 'round' ? 'rounded-2xl' : 'rounded-none',\n 'lg-desktop:aspect-w-[404] lg-desktop:aspect-h-[480] desktop:aspect-w-[316] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[288] laptop:aspect-h-[360] aspect-w-[296] aspect-h-[360] relative',\n 'md-tablet:h-[360px] shelf-display-item'\n )}\n >\n {isDisplayBackImage ? (\n <div className=\"absolute inset-0 box-border overflow-hidden\">\n <div className=\"relative inset-0 size-full\">\n <Picture\n source={imageUrl}\n alt={altText}\n className=\"flex h-full justify-center object-cover [&_img]:w-auto\"\n />\n <div className=\"desktop:p-6 absolute inset-x-0 bottom-0 box-border overflow-hidden p-4\">\n {bottomContent()}\n </div>\n </div>\n </div>\n ) : (\n <div className=\"desktop:p-6 absolute inset-0 box-border flex flex-col justify-between overflow-hidden p-4\">\n {currentPriceTag && isTopTag && (\n <Badge className=\"shelf-prices-tag absolute left-4 top-4 z-10\">{currentPriceTag || ''}</Badge>\n )}\n <div\n className={cn(\n 'lg-desktop:h-[195px] shelf-display-item-image relative mb-2 inline-block h-[140px] w-full flex-1 overflow-hidden'\n )}\n >\n <a\n aria-label={displayTitle}\n target={configuration?.target}\n href={trackUrlRef(\n `${locale === 'us' || !locale ? '' : `/${locale}`}/products/${data?.handle}?variant=${variantId}`,\n `${componentType}_${componentName}`\n )}\n onClick={() => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'select_item',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: [\n {\n item_id: data?.sku || variant?.sku,\n item_name: data?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: configuration?.index + 1,\n },\n ],\n },\n })\n }}\n >\n <Picture\n source={imageUrl}\n alt={altText}\n className=\"flex h-full justify-center object-cover [&_img]:w-auto\"\n />\n </a>\n </div>\n {bottomContent()}\n </div>\n )}\n </div>\n )\n}\n\nexport const ShelfDisplayHorizontalItem = ({ data, configuration }: { data: any; configuration?: any }) => {\n const { itemShape, itemLength, metafields, isShowShortTitle } = configuration || {}\n const { discounts, discountsCopy } = metafields || {}\n const { locale = 'us', copyWriting, currencyDisplay } = useAiuiContext()\n const [showTags, setShowTags] = useState<string[]>([])\n const ref = useRef<HTMLDivElement>(null)\n\n const onPrimaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType, coupon: any) =>\n configuration?.event?.primaryButton?.(params, index + 1, data, coupon)\n\n const onSecondaryButton = (params: ShelfDisplayItem, index: number, data: ShelfDisplayType, coupon: any) =>\n configuration?.event?.secondaryButton?.(params, index + 1, data, coupon)\n\n const variant = useMemo(() => {\n const variants = data?.variants || []\n if (!variants.length) {\n return undefined\n }\n if (!data?.sku) {\n return variants[0]\n }\n return variants.find((item: any) => item?.sku === data?.sku) || variants[0]\n }, [data?.sku, data?.variants])\n\n const variantArr = variant?.id?.split?.('/') || []\n const variantId = variantArr?.[variantArr?.length - 1]\n\n const isSoldOut =\n !variant?.availableForSale || variant?.price?.amount === SOLD_OUT_PRICE || variant?.price === SOLD_OUT_PRICE\n const isShowTag = configuration?.isShowTag\n const isShowOriginalPrice = configuration?.isShowOriginalPrice\n\n // active \u7684 \u901A\u7528\u6298\u6263\n const coupon = variant?.coupons?.[0]\n\n const shouldUseCouponPrice = Boolean(isShowOriginalPrice && coupon)\n const currencyCode = data?.price?.currencyCode || 'USD'\n\n const priceInfo = useMemo(\n () =>\n formatVariantPrice({\n locale,\n amount: shouldUseCouponPrice ? coupon?.variant_price4wscode : variant?.price,\n baseAmount: shouldUseCouponPrice ? variant?.price : 0,\n currencyCode,\n currencyDisplay,\n }),\n [currencyCode, locale, shouldUseCouponPrice, coupon?.variant_price4wscode, variant]\n )\n\n const { price, basePrice, discount, discountAmount } = priceInfo\n\n const { imageUrl, altText } = getProductImage(data)\n\n const displayTitle = data?.custom_name || data?.title\n const currentDisplayTitle = isShowShortTitle\n ? variant?.metafields?.infos?.page_short_title || displayTitle\n : displayTitle\n const displayDescription = data?.custom_description || data?.description\n\n useExposure(ref, {\n componentType,\n componentName,\n componentTitle: displayTitle,\n componentDescription: displayDescription,\n position: configuration?.index + 1,\n })\n\n const showSizeClass = (): {\n boxItem: string\n imgItem: string\n wrap: string\n } => {\n if (itemLength >= 2) {\n return {\n boxItem: 'lg-desktop:max-w-[401px] desktop:max-w-[292px] max-w-full',\n imgItem:\n 'm-tablet:m-auto lg-desktop:max-w-[330px] lg-desktop:max-h-[330px] desktop:max-w-[260px] desktop:max-h-[260px] max-w-[138px] max-h-[138px]',\n wrap: 'lg-desktop:aspect-w-[824] lg-desktop:aspect-h-[480] desktop:aspect-w-[648] desktop:aspect-h-[380] laptop:aspect-w-[440] laptop:aspect-h-[356] tablet:aspect-w-[346] tablet:aspect-h-[360] md-tablet:w-full',\n }\n }\n return {\n boxItem: 'lg-desktop:max-w-[401px] desktop:max-w-[292px] laptop:max-w-[289px] max-w-[262px]',\n imgItem:\n 'md-tablet:m-auto lg-desktop:max-w-[450px] lg-desktop:max-h-[450px] desktop:max-w-[332px] desktop:max-h-[332px] max-w-[312px] max-h-[312px]',\n wrap: 'lg-desktop:aspect-w-[1664] lg-desktop:aspect-h-[480] desktop:aspect-w-[1312] desktop:aspect-h-[380] laptop:aspect-w-[896] laptop:aspect-h-[356] tablet:aspect-w-[704] tablet:aspect-h-[360] md-tablet:w-full',\n }\n }\n\n const handleWrapClass = () => {\n if (itemLength >= 2) {\n return 'flex flex-col justify-between desktop:gap-12 desktop:flex-row desktop:justify-center desktop:items-center'\n }\n return 'flex justify-center items-center gap-6 md-tablet:flex-col'\n }\n\n const showPrice = () => {\n if (coupon?.value_type === 'fixed_amount') {\n const amountStr = discountAmount || ''\n const match = amountStr.match(/^(.*?)(\\d[\\d.,]*)(.*)$/)\n if (match) {\n const [, prefix, numeric, suffix] = match\n let updatedNumeric = numeric\n if (numeric.endsWith('.00')) {\n updatedNumeric = numeric.replace(/\\.00$/, '')\n } else if (numeric.endsWith(',00')) {\n updatedNumeric = numeric.replace(/,00$/, '')\n }\n return `${prefix}${updatedNumeric}${suffix}`\n }\n return amountStr\n }\n return discount || ''\n }\n\n // \u5904\u7406\u6807\u7B7E\n useEffect(() => {\n let handleTags: string[] = []\n if (discount || discountAmount) {\n const discountTag = `${showPrice()} ${discounts?.off || discountsCopy?.off || ''}`\n handleTags.push(discountTag)\n }\n const newTags = data?.tags\n ?.filter?.((item: string) => item?.startsWith?.('CLtag'))\n ?.map?.((item: string) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, discount ? 1 : 2)\n setShowTags(handleTags.concat(newTags))\n }, [data?.tags, discount, discountAmount, discounts?.off, discountsCopy?.off])\n\n return (\n <div\n ref={ref}\n key={data?.id || data?.handle}\n className={cn(\n showSizeClass().wrap,\n itemShape === 'round' ? 'rounded-2xl' : 'rounded-none',\n 'shelf-display-item',\n 'bg-container-secondary-1 tablet:hover:bg-info-white gap-6 duration-300',\n 'md-tablet:h-[360px] relative box-border w-full cursor-pointer overflow-hidden'\n )}\n >\n <div className={cn(handleWrapClass(), 'desktop:p-6 absolute inset-0 box-border overflow-hidden p-4')}>\n <div className={cn(showSizeClass().imgItem, 'desktop:mb-0 relative mb-1 overflow-hidden')}>\n <a\n aria-label={displayTitle}\n target={configuration?.target}\n href={trackUrlRef(\n `${locale === 'us' || !locale ? '' : `/${locale}`}/products/${data?.handle}?variant=${variantId}`,\n `${componentType}_${componentName}`\n )}\n onClick={() => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'select_item',\n event_parameters: {\n page_group: 'Home Page',\n item_list_name: 'Home_Page_Bundle',\n items: [\n {\n item_id: data?.sku || variant?.sku,\n item_name: data?.name,\n item_variant: variant?.name,\n price: variant?.price,\n index: configuration?.index + 1,\n },\n ],\n },\n })\n }}\n >\n <Picture\n source={imageUrl}\n alt={altText}\n className=\"flex h-full justify-center object-cover [&_img]:w-auto\"\n />\n </a>\n </div>\n <div className={cn('flex flex-col items-start justify-center', showSizeClass().boxItem)}>\n {isShowTag && (\n <div className=\"mb-1 box-border flex h-8 flex-wrap gap-1 overflow-hidden\">\n {showTags?.length > 0 &&\n showTags?.map?.((item: any, index: number) => (\n <Badge key={index} className=\"shelf-items-tag\">\n {item}\n </Badge>\n ))}\n </div>\n )}\n {currentDisplayTitle ? (\n <Heading\n as=\"h3\"\n title={currentDisplayTitle || ''}\n size={2}\n className=\"shelf-display-product-title lg-desktop:h-[58px] mb-1 line-clamp-2 h-[48px]\"\n html={currentDisplayTitle || ''}\n />\n ) : null}\n {displayDescription ? (\n <Text\n size={2}\n className=\"lg-desktop:text-lg lg-desktop:h-[26px] desktop:text-base desktop:h-6 shelf-display-product-description line-clamp-1 h-5 text-sm\"\n html={displayDescription || ''}\n />\n ) : null}\n <div className=\"mb-2 mt-5 flex items-center\">\n {isSoldOut ? (\n <div className=\"tablet:text-2xl text-info-primary text-xl font-bold\">{copyWriting?.soldOutText}</div>\n ) : (\n <>\n <div className=\"final-price tablet:text-2xl text-info-primary text-xl font-bold\">\n {variant?.availableForSale ? price || '' : ''}\n </div>\n <div className=\"origin-price tablet:text-xl text-info-secondary ml-1 text-lg font-bold line-through\">\n {variant?.availableForSale ? basePrice || '' : ''}\n </div>\n </>\n )}\n </div>\n {/* \u6309\u94AE\u7EC4 */}\n <div\n className={cn(\n 'shelf-flex-button-group',\n 'lg-desktop:gap-3 flex items-center gap-2',\n configuration.direction === 'vertical' ? 'flex-col' : ''\n )}\n >\n {configuration?.secondaryButton ? (\n <Button\n variant=\"secondary\"\n href={data?.custom_secondary_link}\n as={data?.custom_secondary_link ? 'a' : 'button'}\n onClick={() =>\n !data?.custom_secondary_link && onSecondaryButton(data, configuration?.index, configuration, coupon)\n }\n className={configuration.direction === 'vertical' ? 'w-full' : ''}\n >\n {configuration?.secondaryButton || ''}\n </Button>\n ) : null}\n {configuration?.primaryButton ? (\n <Button\n disabled={isSoldOut}\n variant=\"primary\"\n href={data?.custom_primary_link}\n as={data?.custom_primary_link ? 'a' : 'button'}\n onClick={() =>\n !data?.custom_primary_link && onPrimaryButton(data, configuration?.index, configuration, coupon)\n }\n className={configuration.direction === 'vertical' ? 'w-full' : ''}\n >\n {configuration?.primaryButton || ''}\n </Button>\n ) : null}\n </div>\n </div>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "0kBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,gCAAAE,GAAA,yBAAAC,GAAA,oBAAAC,KAAA,eAAAC,GAAAL,IAoJc,IAAAM,EAAA,6BApJdC,GAA+B,oCAC/BC,GAAmC,6BACnCC,EAAoB,2CACpBC,EAAkB,yCAClBC,EAAmB,kCACnBC,GAAqB,oCACrBC,EAAmB,0CACnBC,GAAwB,iCACxBC,GAA4B,uCAC5BC,GAAwB,uCAExBC,GAA4B,sCAC5BC,EAAqD,iBAErD,MAAMC,EAAgB,QAChBC,EAAgB,gBAEhBC,EAAiB,aAGVjB,GAAmBkB,GAAc,CAC5C,MAAMC,EAAMD,GAAM,IACZE,EAAWF,GAAM,SACjBG,EAAUD,GAAU,KAAME,GAAcA,GAAM,MAAQH,CAAG,EACzDI,EAAWF,GAAS,OAAO,KAAOD,IAAW,CAAC,GAAG,OAAO,KAAO,GAC/DI,EAAUH,GAAS,OAAO,SAAWD,IAAW,CAAC,GAAG,OAAO,SAAWF,GAAM,aAAeA,GAAM,OAAS,GAEhH,MAAO,CACL,SAAAK,EACA,QAAAC,CACF,CACF,EAEazB,GAAuB,CAAC,CAAE,KAAAmB,EAAM,cAAAO,CAAc,IAA0C,CACnG,KAAM,CACJ,mBAAAC,EAAqB,GACrB,UAAAC,EACA,WAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EACA,oBAAAC,EACA,iBAAAC,EAAmB,EACrB,EAAIP,GAAiB,CAAC,EAChB,CAAE,OAAAQ,EAAS,KAAM,YAAAC,EAAa,gB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B,CAEJ",
|
|
6
6
|
"names": ["shelfDisplayItem_exports", "__export", "ShelfDisplayHorizontalItem", "ShelfDisplayWrapItem", "getProductImage", "__toCommonJS", "import_jsx_runtime", "import_AiuiProvider", "import_shelfDisplay", "import_picture", "import_badge", "import_utils", "import_text", "import_button", "import_track", "import_trackUrlRef", "import_heading", "import_useExposure", "import_react", "componentType", "componentName", "SOLD_OUT_PRICE", "data", "sku", "skuArray", "findSku", "item", "imageUrl", "altText", "configuration", "isDisplayBackImage", "itemShape", "metafields", "isTopTag", "isShowTag", "isShowOriginalPrice", "isShowShortTitle", "locale", "copyWriting", "currencyDisplay", "discounts", "discountsCopy", "ref", "showTags", "setShowTags", "currentPriceTag", "setCurrentPriceTag", "onPrimaryButton", "params", "index", "coupon", "onSecondaryButton", "variant", "variants", "variantArr", "variantId", "isSoldOut", "shouldUseCouponPrice", "currencyCode", "priceInfo", "price", "basePrice", "discount", "discountAmount", "displayTitle", "currentDisplayTitle", "displayDescription", "showPrice", "amountStr", "match", "prefix", "numeric", "suffix", "updatedNumeric", "handleTags", "discountTag", "newTags", "bottomContent", "Badge", "Button", "Picture", "itemLength", "showSizeClass", "handleWrapClass"]
|
|
7
7
|
}
|
|
@@ -2,13 +2,16 @@ import * as React from 'react';
|
|
|
2
2
|
import { type VariantProps } from 'class-variance-authority';
|
|
3
3
|
declare const badgeVariants: (props?: ({
|
|
4
4
|
size?: "lg" | "sm" | null | undefined;
|
|
5
|
+
variant?: "fill" | "outline" | "promotional" | null | undefined;
|
|
6
|
+
promotionalType?: "plus-member" | "regular-member" | "regular-discount" | "time-limited-discount" | null | undefined;
|
|
5
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
8
|
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
|
|
9
|
+
promotionalType?: 'plus-member' | 'regular-member' | 'regular-discount' | 'time-limited-discount';
|
|
7
10
|
}
|
|
8
11
|
/**
|
|
9
12
|
* Badge - 徽章
|
|
10
13
|
*
|
|
11
|
-
* @description
|
|
14
|
+
* @description 用于显示状态、标签或计数的小型标识组件,支持不同尺寸和促销类型
|
|
12
15
|
*/
|
|
13
|
-
declare function Badge({ className, size, ...props }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare function Badge({ className, size, variant, promotionalType, ...props }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
14
17
|
export default Badge;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(i,e)=>{for(var o in e)r(i,o,{get:e[o],enumerable:!0})},m=(i,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of g(e))!c.call(i,n)&&n!==o&&r(i,n,{get:()=>e[n],enumerable:!(a=d(e,n))||a.enumerable});return i};var f=i=>m(r({},"__esModule",{value:!0}),i);var Z={};u(Z,{default:()=>_});module.exports=f(Z);var t=require("react/jsx-runtime"),y=require("react"),p=require("class-variance-authority"),C=require("../helpers/index.js");const x=(0,p.cva)("text-brand-0 outline-brand-0 inline-flex items-center justify-center whitespace-nowrap rounded-[16px] border-none text-xs font-bold outline outline-[1.6px] outline-offset-[-1.6px] transition-colors focus:outline-none",{variants:{size:{sm:"h-[24px] px-[6px] pb-[3px] pt-[4px] text-[14px] leading-tight",lg:"lg-desktop:px-[8px] lg-desktop:pb-[4px] lg-desktop:pt-[5px] lg-desktop:text-[16px] lg-desktop:h-[28px] h-[24px] p-[6px] pb-[3px] pt-[4px] text-[14px] leading-tight"},variant:{outline:"bg-transparent",fill:"bg-brand-0 bg-gradient-brand text-white",promotional:"bg-gradient-brand relative border-none text-white outline-none"},promotionalType:{"plus-member":"bg-gradient-to-r from-[#6E6754] via-[#4A453A] to-[#070708] ","regular-member":"bg-brand-0 bg-gradient-brand ","regular-discount":"bg-brand-0 bg-gradient-brand ","time-limited-discount":"bg-brand-0 bg-gradient-brand "}},compoundVariants:[{variant:"promotional",size:"sm",class:"!pl-[24px]"},{variant:"promotional",size:"lg",class:"lg-desktop:!pl-[28px] !pl-[24px]"}],defaultVariants:{size:"lg",variant:"outline"}}),h=()=>(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 28",fill:"none",className:"h-full w-auto",children:[(0,t.jsx)("path",{d:"M23.2222 0C24.2096 0 25.1341 0.501396 25.6903 1.34106L31.4814 10.0846C32.283 11.2948 32.1429 12.9193 31.1474 13.9659L19.0336 26.6998C17.3854 28.4319 14.6772 28.4335 13.0264 26.7039L0.855644 13.9536C-0.130438 12.9204 -0.281462 11.3186 0.492455 10.1091L6.07548 1.38199C6.6279 0.518743 7.56576 0 8.57008 0H23.2222Z",fill:"url(#paint0_linear_22508_6946)"}),(0,t.jsx)("path",{d:"M22.4084 10.2119C22.9545 9.66492 23.8409 9.66346 24.3881 10.2092C24.9351 10.7553 24.9366 11.6416 24.3908 12.1889L17.451 19.1397C16.8776 19.714 15.9474 19.7155 15.3729 19.1424L8.41114 12.1916C7.86414 11.6455 7.86268 10.7592 8.40841 10.2119C8.95451 9.66492 9.84087 9.66346 10.3881 10.2092L16.4092 16.2193L22.4084 10.2119Z",fill:"url(#paint1_linear_22508_6946)"}),(0,t.jsxs)("defs",{children:[(0,t.jsxs)("linearGradient",{id:"paint0_linear_22508_6946",x1:"2.1318",y1:"0.390243",x2:"33.6892",y2:"7.35765",gradientUnits:"userSpaceOnUse",children:[(0,t.jsx)("stop",{offset:"0.0865385",stopColor:"#FFF5E0"}),(0,t.jsx)("stop",{offset:"1",stopColor:"#E8C08A"})]}),(0,t.jsxs)("linearGradient",{id:"paint1_linear_22508_6946",x1:"7.79513",y1:"9.80078",x2:"25.937",y2:"13.8215",gradientUnits:"userSpaceOnUse",children:[(0,t.jsx)("stop",{offset:"0.9999",stopColor:"#6E6754"}),(0,t.jsx)("stop",{offset:"1",stopColor:"#050608"})]})]})]}),b=()=>(0,t.jsxs)("svg",{width:"32",height:"28",viewBox:"0 0 32 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-full w-auto",children:[(0,t.jsx)("path",{d:"M23.2222 0C24.2096 0 25.1341 0.501396 25.6903 1.34106L31.4814 10.0846C32.283 11.2948 32.1429 12.9193 31.1474 13.9659L19.0336 26.6998C17.3854 28.4319 14.6772 28.4335 13.0264 26.7039L0.855644 13.9536C-0.130438 12.9204 -0.281462 11.3186 0.492455 10.1091L6.07548 1.38199C6.6279 0.518743 7.56576 0 8.57008 0H23.2222Z",fill:"#B5E5F9"}),(0,t.jsx)("path",{d:"M22.4084 10.2119C22.9545 9.66492 23.8409 9.66346 24.3881 10.2092C24.9351 10.7553 24.9366 11.6416 24.3908 12.1889L17.451 19.1397C16.8776 19.714 15.9474 19.7155 15.3729 19.1424L8.41114 12.1916C7.86414 11.6455 7.86268 10.7592 8.40841 10.2119C8.95451 9.66492 9.84087 9.66346 10.3881 10.2092L16.4092 16.2193L22.4084 10.2119Z",fill:"white"})]}),L=()=>(0,t.jsxs)("svg",{width:"32",height:"28",viewBox:"0 0 32 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-full w-auto",children:[(0,t.jsxs)("g",{clipPath:"url(#clip0_20420_244316)",children:[(0,t.jsx)("path",{opacity:"0.4",d:"M3.90567 7.45107C4.19697 6.0806 5.21359 4.9787 6.55622 4.57818L13.8699 2.39643C15.1173 2.02431 16.4683 2.31148 17.4565 3.15879L23.2505 8.12665C24.3141 9.03864 24.7946 10.4588 24.5033 11.8292L21.3938 26.4587C20.9541 28.527 18.921 29.8474 16.8527 29.4077L3.74508 26.6216C1.67675 26.182 0.356442 24.1489 0.796078 22.0805L3.90567 7.45107Z",fill:"#B5E5F9"}),(0,t.jsx)("path",{d:"M5 7.9615C5 6.50843 5.78799 5.16965 7.05839 4.46433L14.0584 0.57797C15.266 -0.0924777 16.734 -0.0924768 17.9416 0.577971L24.9416 4.46434C26.212 5.16966 27 6.50844 27 7.9615V24C27 26.2091 25.2091 28 23 28H9C6.79086 28 5 26.2091 5 24V7.9615Z",fill:"#B5E5F9"}),(0,t.jsx)("path",{d:"M20.3094 17.6141C21.0396 17.6143 21.7533 17.8311 22.3603 18.2371C22.9672 18.6431 23.4402 19.22 23.7194 19.8949C23.9986 20.5698 24.0715 21.3124 23.9288 22.0287C23.7861 22.745 23.4343 23.4029 22.9178 23.9192C22.4013 24.4355 21.7434 24.787 21.0272 24.9293C20.311 25.0715 19.5687 24.9982 18.8942 24.7184C18.2197 24.4387 17.6433 23.9652 17.2378 23.3577C16.8324 22.7503 16.6161 22.0362 16.6163 21.3058C16.6163 19.2667 18.2697 17.6141 20.3094 17.6141ZM10.8221 20.5232L19.527 11.8217C19.7491 11.6041 20.0454 11.4786 20.3562 11.4704C20.667 11.4622 20.9695 11.5719 21.2028 11.7776C21.4361 11.9832 21.583 12.2695 21.6139 12.579C21.6449 12.8885 21.5577 13.1983 21.3698 13.4461L21.2677 13.5618L12.5628 22.2632C12.3407 22.4808 12.0444 22.6064 11.7336 22.6145C11.4228 22.6227 11.1203 22.513 10.887 22.3074C10.6537 22.1017 10.5068 21.8154 10.4759 21.5059C10.4449 21.1964 10.5321 20.8867 10.72 20.6388L10.8221 20.5232ZM20.3094 20.0752C19.9831 20.0752 19.6702 20.2049 19.4395 20.4356C19.2088 20.6664 19.0792 20.9794 19.0792 21.3058C19.0792 21.6322 19.2088 21.9452 19.4395 22.176C19.6702 22.4067 19.9831 22.5364 20.3094 22.5364C20.6357 22.5364 20.9486 22.4067 21.1793 22.176C21.41 21.9452 21.5396 21.6322 21.5396 21.3058C21.5396 20.9794 21.41 20.6664 21.1793 20.4356C20.9486 20.2049 20.6357 20.0752 20.3094 20.0752ZM11.6931 9C12.4232 9.00024 13.1369 9.21707 13.7439 9.62306C14.3509 10.0291 14.8239 10.606 15.1031 11.2809C15.3823 11.9558 15.4552 12.6983 15.3125 13.4146C15.1698 14.131 14.818 14.7889 14.3015 15.3052C13.785 15.8215 13.1271 16.173 12.4109 16.3152C11.6947 16.4575 10.9524 16.3841 10.2779 16.1044C9.60339 15.8246 9.02696 15.3511 8.6215 14.7437C8.21604 14.1362 7.99976 13.4221 8 12.6917C8 10.6527 9.65339 9 11.6931 9ZM11.6931 11.4612C11.5315 11.4611 11.3715 11.4928 11.2222 11.5546C11.073 11.6164 10.9373 11.7069 10.823 11.8212C10.5922 12.0518 10.4624 12.3648 10.4622 12.6911C10.4621 13.0175 10.5915 13.3306 10.8221 13.5615C11.0527 13.7923 11.3656 13.9222 11.6918 13.9223C12.0181 13.9223 12.331 13.7927 12.5617 13.5619C12.7924 13.3311 12.922 13.0181 12.922 12.6917C12.922 12.3654 12.7924 12.0524 12.5617 11.8216C12.331 11.5908 12.0181 11.4612 11.6918 11.4612H11.6931Z",fill:"white"})]}),(0,t.jsx)("defs",{children:(0,t.jsx)("clipPath",{id:"clip0_20420_244316",children:(0,t.jsx)("rect",{width:"32",height:"28",fill:"white"})})})]}),w=()=>(0,t.jsxs)("svg",{width:"24",height:"28",viewBox:"0 0 24 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-full w-auto",children:[(0,t.jsx)("path",{d:"M0.112855 14.5991L6.23786 0.599179C6.3971 0.235193 6.75672 0 7.15401 0H19.4534C20.1791 0 20.6631 0.74862 20.3653 1.41036L16.5 10H22.5443C23.36 10 23.8326 10.9242 23.3549 11.5855L11.5 28.0001L9.6547 16L1.029 15.9999C0.307853 15.9999 -0.176196 15.2598 0.112855 14.5991Z",fill:"#B5E5F9"}),(0,t.jsx)("path",{d:"M0.112855 14.5991L6.23786 0.599179C6.3971 0.235193 6.75672 0 7.15401 0H19.4534C20.1791 0 20.6631 0.74862 20.3653 1.41036L16.5 10H22.5443C23.36 10 23.8326 10.9242 23.3549 11.5855L11.5 28.0001L9.6547 16L1.029 15.9999C0.307853 15.9999 -0.176196 15.2598 0.112855 14.5991Z",fill:"#B5E5F9"})]}),v={"plus-member":()=>(0,t.jsx)(h,{}),"regular-member":()=>(0,t.jsx)(b,{}),"regular-discount":()=>(0,t.jsx)(L,{}),"time-limited-discount":()=>(0,t.jsx)(w,{})};function M({className:i,size:e,variant:o="outline",promotionalType:a,...n}){const l=o==="promotional",s=l?v[a||"regular-discount"]:null;return(0,t.jsxs)("div",{className:(0,C.cn)(x({size:e,variant:o,promotionalType:l?a:void 0}),i),...n,children:[l&&s&&(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 flex -translate-x-1/3 items-center",children:(0,t.jsx)(s,{})}),(0,t.jsx)("span",{className:l?"relative z-10":"",children:n.children})]})}var _=M;
|
|
2
2
|
//# sourceMappingURL=badge.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/badge.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react'\nimport { type VariantProps, cva } from 'class-variance-authority'\n\nimport { cn } from '../helpers/index.js'\n\nconst badgeVariants = cva(\n 'text-brand-0 outline-brand-0 inline-flex items-center justify-center rounded-[16px] border-none text-xs font-bold outline outline-[1.6px] outline-offset-[-1.6px] backdrop-blur-sm transition-colors focus:outline-none',\n {\n variants: {\n size: {\n sm: 'h-[24px] px-[6px] pb-[3px] pt-[4px] text-[14px] leading-tight',\n lg: 'lg-desktop:px-[8px] lg-desktop:pb-[4px] lg-desktop:pt-[5px] lg-desktop:text-[16px] lg-desktop:h-[28px] h-[24px] px-[6px] pb-[3px] pt-[4px] text-[14px] leading-tight',\n },\n },\n defaultVariants: {\n size: 'lg',\n },\n }\n)\n\nexport interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}\n\n/**\n * Badge - \u5FBD\u7AE0\n *\n * @description \u7528\u4E8E\u663E\u793A\u72B6\u6001\u3001\u6807\u7B7E\u6216\u8BA1\u6570\u7684\u5C0F\u578B\u6807\u8BC6\u7EC4\u4EF6\uFF0C\u652F\u6301\u4E0D\u540C\u5C3A\u5BF8\n */\nfunction Badge({ className, size, ...props }: BadgeProps) {\n return <div className={cn(badgeVariants({ size }), className)} {...props} />\n}\n\nexport default Badge\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["badge_exports", "__export", "badge_default", "__toCommonJS", "import_jsx_runtime", "React", "import_class_variance_authority", "import_helpers", "badgeVariants", "Badge", "className", "size", "props"]
|
|
4
|
+
"sourcesContent": ["import * as React from 'react'\nimport { type VariantProps, cva } from 'class-variance-authority'\n\nimport { cn } from '../helpers/index.js'\n\nconst badgeVariants = cva(\n 'text-brand-0 outline-brand-0 inline-flex items-center justify-center whitespace-nowrap rounded-[16px] border-none text-xs font-bold outline outline-[1.6px] outline-offset-[-1.6px] transition-colors focus:outline-none',\n {\n variants: {\n size: {\n sm: 'h-[24px] px-[6px] pb-[3px] pt-[4px] text-[14px] leading-tight',\n lg: 'lg-desktop:px-[8px] lg-desktop:pb-[4px] lg-desktop:pt-[5px] lg-desktop:text-[16px] lg-desktop:h-[28px] h-[24px] p-[6px] pb-[3px] pt-[4px] text-[14px] leading-tight',\n },\n variant: {\n outline: 'bg-transparent',\n fill: 'bg-brand-0 bg-gradient-brand text-white',\n promotional: 'bg-gradient-brand relative border-none text-white outline-none',\n },\n promotionalType: {\n 'plus-member': 'bg-gradient-to-r from-[#6E6754] via-[#4A453A] to-[#070708] ',\n 'regular-member': 'bg-brand-0 bg-gradient-brand ',\n 'regular-discount': 'bg-brand-0 bg-gradient-brand ',\n 'time-limited-discount': 'bg-brand-0 bg-gradient-brand ',\n },\n },\n compoundVariants: [\n {\n variant: 'promotional',\n size: 'sm',\n class: '!pl-[24px]',\n },\n {\n variant: 'promotional',\n size: 'lg',\n class: 'lg-desktop:!pl-[28px] !pl-[24px]',\n },\n ],\n defaultVariants: {\n size: 'lg',\n variant: 'outline',\n },\n }\n)\n\n// \u4F1A\u5458\u6807\u8BC6\u56FE\u6807\nconst PlusPromotionalIcon = () => {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 28\" fill=\"none\" className=\"h-full w-auto\">\n <path\n d=\"M23.2222 0C24.2096 0 25.1341 0.501396 25.6903 1.34106L31.4814 10.0846C32.283 11.2948 32.1429 12.9193 31.1474 13.9659L19.0336 26.6998C17.3854 28.4319 14.6772 28.4335 13.0264 26.7039L0.855644 13.9536C-0.130438 12.9204 -0.281462 11.3186 0.492455 10.1091L6.07548 1.38199C6.6279 0.518743 7.56576 0 8.57008 0H23.2222Z\"\n fill=\"url(#paint0_linear_22508_6946)\"\n />\n <path\n d=\"M22.4084 10.2119C22.9545 9.66492 23.8409 9.66346 24.3881 10.2092C24.9351 10.7553 24.9366 11.6416 24.3908 12.1889L17.451 19.1397C16.8776 19.714 15.9474 19.7155 15.3729 19.1424L8.41114 12.1916C7.86414 11.6455 7.86268 10.7592 8.40841 10.2119C8.95451 9.66492 9.84087 9.66346 10.3881 10.2092L16.4092 16.2193L22.4084 10.2119Z\"\n fill=\"url(#paint1_linear_22508_6946)\"\n />\n <defs>\n <linearGradient\n id=\"paint0_linear_22508_6946\"\n x1=\"2.1318\"\n y1=\"0.390243\"\n x2=\"33.6892\"\n y2=\"7.35765\"\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop offset=\"0.0865385\" stopColor={'#FFF5E0'} />\n <stop offset=\"1\" stopColor={'#E8C08A'} />\n </linearGradient>\n <linearGradient\n id=\"paint1_linear_22508_6946\"\n x1=\"7.79513\"\n y1=\"9.80078\"\n x2=\"25.937\"\n y2=\"13.8215\"\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop offset=\"0.9999\" stopColor={'#6E6754'} />\n <stop offset=\"1\" stopColor={'#050608'} />\n </linearGradient>\n </defs>\n </svg>\n )\n}\n\nconst RegularMemberIcon = () => (\n <svg\n width=\"32\"\n height=\"28\"\n viewBox=\"0 0 32 28\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-full w-auto\"\n >\n <path\n d=\"M23.2222 0C24.2096 0 25.1341 0.501396 25.6903 1.34106L31.4814 10.0846C32.283 11.2948 32.1429 12.9193 31.1474 13.9659L19.0336 26.6998C17.3854 28.4319 14.6772 28.4335 13.0264 26.7039L0.855644 13.9536C-0.130438 12.9204 -0.281462 11.3186 0.492455 10.1091L6.07548 1.38199C6.6279 0.518743 7.56576 0 8.57008 0H23.2222Z\"\n fill=\"#B5E5F9\"\n />\n <path\n d=\"M22.4084 10.2119C22.9545 9.66492 23.8409 9.66346 24.3881 10.2092C24.9351 10.7553 24.9366 11.6416 24.3908 12.1889L17.451 19.1397C16.8776 19.714 15.9474 19.7155 15.3729 19.1424L8.41114 12.1916C7.86414 11.6455 7.86268 10.7592 8.40841 10.2119C8.95451 9.66492 9.84087 9.66346 10.3881 10.2092L16.4092 16.2193L22.4084 10.2119Z\"\n fill=\"white\"\n />\n </svg>\n)\n\nconst NormalDiscountIcon = () => (\n <svg\n width=\"32\"\n height=\"28\"\n viewBox=\"0 0 32 28\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-full w-auto\"\n >\n <g clipPath=\"url(#clip0_20420_244316)\">\n <path\n opacity=\"0.4\"\n d=\"M3.90567 7.45107C4.19697 6.0806 5.21359 4.9787 6.55622 4.57818L13.8699 2.39643C15.1173 2.02431 16.4683 2.31148 17.4565 3.15879L23.2505 8.12665C24.3141 9.03864 24.7946 10.4588 24.5033 11.8292L21.3938 26.4587C20.9541 28.527 18.921 29.8474 16.8527 29.4077L3.74508 26.6216C1.67675 26.182 0.356442 24.1489 0.796078 22.0805L3.90567 7.45107Z\"\n fill=\"#B5E5F9\"\n />\n <path\n d=\"M5 7.9615C5 6.50843 5.78799 5.16965 7.05839 4.46433L14.0584 0.57797C15.266 -0.0924777 16.734 -0.0924768 17.9416 0.577971L24.9416 4.46434C26.212 5.16966 27 6.50844 27 7.9615V24C27 26.2091 25.2091 28 23 28H9C6.79086 28 5 26.2091 5 24V7.9615Z\"\n fill=\"#B5E5F9\"\n />\n <path\n d=\"M20.3094 17.6141C21.0396 17.6143 21.7533 17.8311 22.3603 18.2371C22.9672 18.6431 23.4402 19.22 23.7194 19.8949C23.9986 20.5698 24.0715 21.3124 23.9288 22.0287C23.7861 22.745 23.4343 23.4029 22.9178 23.9192C22.4013 24.4355 21.7434 24.787 21.0272 24.9293C20.311 25.0715 19.5687 24.9982 18.8942 24.7184C18.2197 24.4387 17.6433 23.9652 17.2378 23.3577C16.8324 22.7503 16.6161 22.0362 16.6163 21.3058C16.6163 19.2667 18.2697 17.6141 20.3094 17.6141ZM10.8221 20.5232L19.527 11.8217C19.7491 11.6041 20.0454 11.4786 20.3562 11.4704C20.667 11.4622 20.9695 11.5719 21.2028 11.7776C21.4361 11.9832 21.583 12.2695 21.6139 12.579C21.6449 12.8885 21.5577 13.1983 21.3698 13.4461L21.2677 13.5618L12.5628 22.2632C12.3407 22.4808 12.0444 22.6064 11.7336 22.6145C11.4228 22.6227 11.1203 22.513 10.887 22.3074C10.6537 22.1017 10.5068 21.8154 10.4759 21.5059C10.4449 21.1964 10.5321 20.8867 10.72 20.6388L10.8221 20.5232ZM20.3094 20.0752C19.9831 20.0752 19.6702 20.2049 19.4395 20.4356C19.2088 20.6664 19.0792 20.9794 19.0792 21.3058C19.0792 21.6322 19.2088 21.9452 19.4395 22.176C19.6702 22.4067 19.9831 22.5364 20.3094 22.5364C20.6357 22.5364 20.9486 22.4067 21.1793 22.176C21.41 21.9452 21.5396 21.6322 21.5396 21.3058C21.5396 20.9794 21.41 20.6664 21.1793 20.4356C20.9486 20.2049 20.6357 20.0752 20.3094 20.0752ZM11.6931 9C12.4232 9.00024 13.1369 9.21707 13.7439 9.62306C14.3509 10.0291 14.8239 10.606 15.1031 11.2809C15.3823 11.9558 15.4552 12.6983 15.3125 13.4146C15.1698 14.131 14.818 14.7889 14.3015 15.3052C13.785 15.8215 13.1271 16.173 12.4109 16.3152C11.6947 16.4575 10.9524 16.3841 10.2779 16.1044C9.60339 15.8246 9.02696 15.3511 8.6215 14.7437C8.21604 14.1362 7.99976 13.4221 8 12.6917C8 10.6527 9.65339 9 11.6931 9ZM11.6931 11.4612C11.5315 11.4611 11.3715 11.4928 11.2222 11.5546C11.073 11.6164 10.9373 11.7069 10.823 11.8212C10.5922 12.0518 10.4624 12.3648 10.4622 12.6911C10.4621 13.0175 10.5915 13.3306 10.8221 13.5615C11.0527 13.7923 11.3656 13.9222 11.6918 13.9223C12.0181 13.9223 12.331 13.7927 12.5617 13.5619C12.7924 13.3311 12.922 13.0181 12.922 12.6917C12.922 12.3654 12.7924 12.0524 12.5617 11.8216C12.331 11.5908 12.0181 11.4612 11.6918 11.4612H11.6931Z\"\n fill=\"white\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_20420_244316\">\n <rect width=\"32\" height=\"28\" fill=\"white\" />\n </clipPath>\n </defs>\n </svg>\n)\n\nconst FlashDiscountIcon = () => (\n <svg\n width=\"24\"\n height=\"28\"\n viewBox=\"0 0 24 28\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-full w-auto\"\n >\n <path\n d=\"M0.112855 14.5991L6.23786 0.599179C6.3971 0.235193 6.75672 0 7.15401 0H19.4534C20.1791 0 20.6631 0.74862 20.3653 1.41036L16.5 10H22.5443C23.36 10 23.8326 10.9242 23.3549 11.5855L11.5 28.0001L9.6547 16L1.029 15.9999C0.307853 15.9999 -0.176196 15.2598 0.112855 14.5991Z\"\n fill=\"#B5E5F9\"\n />\n <path\n d=\"M0.112855 14.5991L6.23786 0.599179C6.3971 0.235193 6.75672 0 7.15401 0H19.4534C20.1791 0 20.6631 0.74862 20.3653 1.41036L16.5 10H22.5443C23.36 10 23.8326 10.9242 23.3549 11.5855L11.5 28.0001L9.6547 16L1.029 15.9999C0.307853 15.9999 -0.176196 15.2598 0.112855 14.5991Z\"\n fill=\"#B5E5F9\"\n />\n </svg>\n)\n\n// \u4FC3\u9500\u7C7B\u578B\u56FE\u6807\u6620\u5C04\nconst PromotionalIcons = {\n 'plus-member': () => <PlusPromotionalIcon />,\n 'regular-member': () => <RegularMemberIcon />,\n 'regular-discount': () => <NormalDiscountIcon />,\n 'time-limited-discount': () => <FlashDiscountIcon />,\n} as const\n\nexport interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {\n promotionalType?: 'plus-member' | 'regular-member' | 'regular-discount' | 'time-limited-discount'\n}\n\n/**\n * Badge - \u5FBD\u7AE0\n *\n * @description \u7528\u4E8E\u663E\u793A\u72B6\u6001\u3001\u6807\u7B7E\u6216\u8BA1\u6570\u7684\u5C0F\u578B\u6807\u8BC6\u7EC4\u4EF6\uFF0C\u652F\u6301\u4E0D\u540C\u5C3A\u5BF8\u548C\u4FC3\u9500\u7C7B\u578B\n */\nfunction Badge({ className, size, variant = 'outline', promotionalType, ...props }: BadgeProps) {\n const isPromotional = variant === 'promotional'\n\n // \u6839\u636E promotionalType \u9009\u62E9\u56FE\u6807\uFF0C\u5982\u679C\u6CA1\u6709\u6307\u5B9A\u5219\u4F7F\u7528\u9ED8\u8BA4\u7684 regular-discount\n const IconComponent = isPromotional ? PromotionalIcons[promotionalType || 'regular-discount'] : null\n\n return (\n <div\n className={cn(\n badgeVariants({\n size,\n variant,\n promotionalType: isPromotional ? promotionalType : undefined,\n }),\n className\n )}\n {...props}\n >\n {isPromotional && IconComponent && (\n <div className=\"absolute inset-y-0 left-0 flex -translate-x-1/3 items-center\">\n <IconComponent />\n </div>\n )}\n <span className={isPromotional ? 'relative z-10' : ''}>{props.children}</span>\n </div>\n )\n}\n\nexport default Badge\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAgDM,IAAAI,EAAA,6BAhDNC,EAAuB,iBACvBC,EAAuC,oCAEvCC,EAAmB,+BAEnB,MAAMC,KAA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UACP,KACA,OAAC,QACC,EAAE,kPACF,KAAK,UACP,KACA,OAAC,QACC,EAAE,knEACF,KAAK,QACP,GACF,KACA,OAAC,QACC,mBAAC,YAAS,GAAG,qBACX,mBAAC,QAAK,MAAM,KAAK,OAAO,KAAK,KAAK,QAAQ,EAC5C,EACF,GACF,EAGIC,EAAoB,OACxB,QAAC,OACC,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OACL,MAAM,6BACN,UAAU,gBAEV,oBAAC,QACC,EAAE,8QACF,KAAK,UACP,KACA,OAAC,QACC,EAAE,8QACF,KAAK,UACP,GACF,EAIIC,EAAmB,CACvB,cAAe,OAAM,OAACJ,EAAA,EAAoB,EAC1C,iBAAkB,OAAM,OAACC,EAAA,EAAkB,EAC3C,mBAAoB,OAAM,OAACC,EAAA,EAAmB,EAC9C,wBAAyB,OAAM,OAACC,EAAA,EAAkB,CACpD,EAWA,SAASE,EAAM,CAAE,UAAAC,EAAW,KAAAC,EAAM,QAAAC,EAAU,UAAW,gBAAAC,EAAiB,GAAGC,CAAM,EAAe,CAC9F,MAAMC,EAAgBH,IAAY,cAG5BI,EAAgBD,EAAgBP,EAAiBK,GAAmB,kBAAkB,EAAI,KAEhG,SACE,QAAC,OACC,aAAW,MACTV,EAAc,CACZ,KAAAQ,EACA,QAAAC,EACA,gBAAiBG,EAAgBF,EAAkB,MACrD,CAAC,EACDH,CACF,EACC,GAAGI,EAEH,UAAAC,GAAiBC,MAChB,OAAC,OAAI,UAAU,+DACb,mBAACA,EAAA,EAAc,EACjB,KAEF,OAAC,QAAK,UAAWD,EAAgB,gBAAkB,GAAK,SAAAD,EAAM,SAAS,GACzE,CAEJ,CAEA,IAAOjB,EAAQY",
|
|
6
|
+
"names": ["badge_exports", "__export", "badge_default", "__toCommonJS", "import_jsx_runtime", "React", "import_class_variance_authority", "import_helpers", "badgeVariants", "PlusPromotionalIcon", "RegularMemberIcon", "NormalDiscountIcon", "FlashDiscountIcon", "PromotionalIcons", "Badge", "className", "size", "variant", "promotionalType", "props", "isPromotional", "IconComponent"]
|
|
7
7
|
}
|