@anker-in/headless-ui 1.1.67 → 1.1.68
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/BuyOneGetOneShelf/index.js +1 -1
- package/dist/cjs/biz-components/BuyOneGetOneShelf/index.js.map +2 -2
- package/dist/cjs/biz-components/FeaturedBlogPosts/index.d.ts +56 -0
- package/dist/cjs/biz-components/FeaturedBlogPosts/index.js +2 -0
- package/dist/cjs/biz-components/FeaturedBlogPosts/index.js.map +7 -0
- package/dist/cjs/biz-components/HeaderNavigation/SidebarDropdown.js +1 -1
- package/dist/cjs/biz-components/HeaderNavigation/SidebarDropdown.js.map +3 -3
- package/dist/cjs/biz-components/HeaderNavigation/index.js +1 -1
- package/dist/cjs/biz-components/HeaderNavigation/index.js.map +2 -2
- package/dist/cjs/biz-components/HeroBanner/HeroBanner.js +1 -1
- package/dist/cjs/biz-components/HeroBanner/HeroBanner.js.map +3 -3
- package/dist/cjs/biz-components/Listing/utils/index.js +1 -1
- package/dist/cjs/biz-components/Listing/utils/index.js.map +3 -3
- package/dist/cjs/biz-components/MediaEndorsement/index.d.ts +11 -0
- package/dist/cjs/biz-components/MediaEndorsement/index.js +23 -0
- package/dist/cjs/biz-components/MediaEndorsement/index.js.map +7 -0
- package/dist/cjs/biz-components/MediaEndorsement/types.d.ts +44 -0
- package/dist/cjs/biz-components/MediaEndorsement/types.js +2 -0
- package/dist/cjs/biz-components/MediaEndorsement/types.js.map +7 -0
- package/dist/cjs/biz-components/MediaSceneSwitcherV2/index.d.ts +59 -0
- package/dist/cjs/biz-components/MediaSceneSwitcherV2/index.js +2 -0
- package/dist/cjs/biz-components/MediaSceneSwitcherV2/index.js.map +7 -0
- package/dist/cjs/biz-components/MediaShelf/ProductCard.d.ts +2 -0
- package/dist/cjs/biz-components/MediaShelf/ProductCard.js +1 -1
- package/dist/cjs/biz-components/MediaShelf/ProductCard.js.map +3 -3
- package/dist/cjs/biz-components/MediaShelf/index.js +1 -1
- package/dist/cjs/biz-components/MediaShelf/index.js.map +3 -3
- package/dist/cjs/biz-components/ShelfDisplay/index.js +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/index.js.map +3 -3
- package/dist/cjs/biz-components/index.d.ts +7 -0
- package/dist/cjs/biz-components/index.js +1 -1
- package/dist/cjs/biz-components/index.js.map +3 -3
- package/dist/esm/biz-components/BuyOneGetOneShelf/index.js +1 -1
- package/dist/esm/biz-components/BuyOneGetOneShelf/index.js.map +2 -2
- package/dist/esm/biz-components/FeaturedBlogPosts/index.d.ts +56 -0
- package/dist/esm/biz-components/FeaturedBlogPosts/index.js +2 -0
- package/dist/esm/biz-components/FeaturedBlogPosts/index.js.map +7 -0
- package/dist/esm/biz-components/HeaderNavigation/SidebarDropdown.js +1 -1
- package/dist/esm/biz-components/HeaderNavigation/SidebarDropdown.js.map +3 -3
- package/dist/esm/biz-components/HeaderNavigation/index.js +1 -1
- package/dist/esm/biz-components/HeaderNavigation/index.js.map +2 -2
- package/dist/esm/biz-components/HeroBanner/HeroBanner.js +1 -1
- package/dist/esm/biz-components/HeroBanner/HeroBanner.js.map +3 -3
- package/dist/esm/biz-components/Listing/utils/index.js +1 -1
- package/dist/esm/biz-components/Listing/utils/index.js.map +3 -3
- package/dist/esm/biz-components/MediaEndorsement/index.d.ts +11 -0
- package/dist/esm/biz-components/MediaEndorsement/index.js +23 -0
- package/dist/esm/biz-components/MediaEndorsement/index.js.map +7 -0
- package/dist/esm/biz-components/MediaEndorsement/types.d.ts +44 -0
- package/dist/esm/biz-components/MediaEndorsement/types.js +1 -0
- package/dist/esm/biz-components/MediaEndorsement/types.js.map +7 -0
- package/dist/esm/biz-components/MediaSceneSwitcherV2/index.d.ts +59 -0
- package/dist/esm/biz-components/MediaSceneSwitcherV2/index.js +2 -0
- package/dist/esm/biz-components/MediaSceneSwitcherV2/index.js.map +7 -0
- package/dist/esm/biz-components/MediaShelf/ProductCard.d.ts +2 -0
- package/dist/esm/biz-components/MediaShelf/ProductCard.js +1 -1
- package/dist/esm/biz-components/MediaShelf/ProductCard.js.map +3 -3
- package/dist/esm/biz-components/MediaShelf/index.js +1 -1
- package/dist/esm/biz-components/MediaShelf/index.js.map +3 -3
- package/dist/esm/biz-components/ShelfDisplay/index.js +1 -1
- package/dist/esm/biz-components/ShelfDisplay/index.js.map +3 -3
- package/dist/esm/biz-components/index.d.ts +7 -0
- package/dist/esm/biz-components/index.js +1 -1
- package/dist/esm/biz-components/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/biz-components/ShelfDisplay/tabSwitch.d.ts +0 -9
- package/dist/cjs/biz-components/ShelfDisplay/tabSwitch.js +0 -2
- package/dist/cjs/biz-components/ShelfDisplay/tabSwitch.js.map +0 -7
- package/dist/esm/biz-components/ShelfDisplay/tabSwitch.d.ts +0 -9
- package/dist/esm/biz-components/ShelfDisplay/tabSwitch.js +0 -2
- package/dist/esm/biz-components/ShelfDisplay/tabSwitch.js.map +0 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var G=Object.create;var
|
|
1
|
+
"use strict";"use client";var G=Object.create;var f=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var o in t)f(e,o,{get:t[o],enumerable:!0})},l=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of P(t))!v.call(e,n)&&n!==o&&f(e,n,{get:()=>t[n],enumerable:!(r=B(t,n))||r.enumerable});return e};var u=(e,t,o)=>(o=e!=null?G(g(e)):{},l(t||!e||!e.__esModule?f(o,"default",{value:e,enumerable:!0}):o,e)),R=e=>l(f({},"__esModule",{value:!0}),e);var b={};D(b,{default:()=>T});module.exports=R(b);var a=require("react/jsx-runtime"),m=u(require("react")),i=require("../../helpers/index.js"),d=u(require("./ProductCard.js")),p=require("../../components/index.js"),y=require("../../hooks/useExposure.js");const x="shelf",C="buy_one_get_one_shelf",c=m.forwardRef(({className:e,classNames:t={},theme:o,title:r,subtitle:n,children:O,...h},S)=>{const s=m.useRef(null);return(0,y.useExposure)(s,{componentType:x,componentName:C,componentTitle:r,componentDescription:n}),m.useImperativeHandle(S,()=>s.current),(0,a.jsxs)("div",{ref:s,className:(0,i.cn)("bogo-shelf-root w-full py-0",{"aiui-dark":o==="dark"},e,t?.root),...h,children:[r&&(0,a.jsx)(p.Heading,{as:"h2",html:r,className:(0,i.cn)("bogo-shelf-title text-info-primary mb-4",t?.title)}),n&&(0,a.jsx)(p.Text,{size:3,as:"p",html:n,className:(0,i.cn)("bogo-shelf-description text-info-primary mb-6",t?.description)}),(0,a.jsx)("div",{className:(0,i.cn)("flex flex-wrap justify-center gap-6","laptop:justify-start laptop:flex-row"),children:O})]})});c.displayName="BuyOneGetOneShelf.Root";const N={Root:c,ProductCard:d.default};var T=N;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/BuyOneGetOneShelf/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport ProductCard from './ProductCard.js'\nimport { Heading, Text } from '../../components/index.js'\nimport type { BuyOneGetOneShelfProps } from './types.js'\nimport { useExposure } from '../../hooks/useExposure.js'\n\nconst componentType = 'shelf'\nconst componentName = 'buy_one_get_one_shelf'\n\n/**\n * BuyOneGetOneShelfRoot - \u4E70\u8D60\u8D27\u67B6\u6839\u5BB9\u5668\u7EC4\u4EF6\n *\n * @description \u7EC4\u5408\u5F0F\u8BBE\u8BA1\u7684\u4E70\u8D60\u8D27\u67B6\u5BB9\u5668\uFF0C\u8D1F\u8D23\u5E03\u5C40\u548C\u6807\u9898\u5C55\u793A\n * \u652F\u6301\u4F20\u5165\u591A\u4E2A BuyOneGetOneShelf.ProductCard \u5B50\u7EC4\u4EF6\n */\nconst BuyOneGetOneShelfRoot = React.forwardRef<HTMLDivElement, BuyOneGetOneShelfProps>(\n ({ className, classNames = {}, theme, title, subtitle, children, ...props }, ref) => {\n const boxRef = React.useRef<HTMLDivElement>(null)\n\n useExposure(boxRef, {\n componentType,\n componentName,\n componentTitle: title,\n componentDescription: subtitle,\n })\n\n React.useImperativeHandle(ref, () => boxRef.current as HTMLDivElement)\n\n return (\n <div\n ref={boxRef}\n className={cn(\n 'w-full py-0',\n {\n 'aiui-dark': theme === 'dark',\n },\n className,\n classNames?.root\n )}\n {...props}\n >\n {title && <Heading as=\"h2\" html={title} className={cn('
|
|
5
|
-
"mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAgCM,IAAAI,EAAA,6BA9BNC,EAAuB,oBACvBC,EAAmB,kCACnBC,EAAwB,+BACxBC,EAA8B,qCAE9BC,EAA4B,sCAE5B,MAAMC,EAAgB,QAChBC,EAAgB,wBAQhBC,EAAwBP,EAAM,WAClC,CAAC,CAAE,UAAAQ,EAAW,WAAAC,EAAa,CAAC,EAAG,MAAAC,EAAO,MAAAC,EAAO,SAAAC,EAAU,SAAAC,EAAU,GAAGC,CAAM,EAAGC,IAAQ,CACnF,MAAMC,EAAShB,EAAM,OAAuB,IAAI,EAEhD,wBAAYgB,EAAQ,CAClB,cAAAX,EACA,cAAAC,EACA,eAAgBK,EAChB,qBAAsBC,CACxB,CAAC,EAEDZ,EAAM,oBAAoBe,EAAK,IAAMC,EAAO,OAAyB,KAGnE,QAAC,OACC,IAAKA,EACL,aAAW,MACT,
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport ProductCard from './ProductCard.js'\nimport { Heading, Text } from '../../components/index.js'\nimport type { BuyOneGetOneShelfProps } from './types.js'\nimport { useExposure } from '../../hooks/useExposure.js'\n\nconst componentType = 'shelf'\nconst componentName = 'buy_one_get_one_shelf'\n\n/**\n * BuyOneGetOneShelfRoot - \u4E70\u8D60\u8D27\u67B6\u6839\u5BB9\u5668\u7EC4\u4EF6\n *\n * @description \u7EC4\u5408\u5F0F\u8BBE\u8BA1\u7684\u4E70\u8D60\u8D27\u67B6\u5BB9\u5668\uFF0C\u8D1F\u8D23\u5E03\u5C40\u548C\u6807\u9898\u5C55\u793A\n * \u652F\u6301\u4F20\u5165\u591A\u4E2A BuyOneGetOneShelf.ProductCard \u5B50\u7EC4\u4EF6\n */\nconst BuyOneGetOneShelfRoot = React.forwardRef<HTMLDivElement, BuyOneGetOneShelfProps>(\n ({ className, classNames = {}, theme, title, subtitle, children, ...props }, ref) => {\n const boxRef = React.useRef<HTMLDivElement>(null)\n\n useExposure(boxRef, {\n componentType,\n componentName,\n componentTitle: title,\n componentDescription: subtitle,\n })\n\n React.useImperativeHandle(ref, () => boxRef.current as HTMLDivElement)\n\n return (\n <div\n ref={boxRef}\n className={cn(\n 'bogo-shelf-root w-full py-0',\n {\n 'aiui-dark': theme === 'dark',\n },\n className,\n classNames?.root\n )}\n {...props}\n >\n {title && (\n <Heading as=\"h2\" html={title} className={cn('bogo-shelf-title text-info-primary mb-4', classNames?.title)} />\n )}\n {subtitle && (\n <Text\n size={3}\n as=\"p\"\n html={subtitle}\n className={cn('bogo-shelf-description text-info-primary mb-6', classNames?.description)}\n />\n )}\n {/* \u4E70\u8D60\u8D27\u67B6\u4EA7\u54C1\u533A\u57DF */}\n <div className={cn('flex flex-wrap justify-center gap-6', 'laptop:justify-start laptop:flex-row')}>\n {children}\n </div>\n </div>\n )\n }\n)\n\nBuyOneGetOneShelfRoot.displayName = 'BuyOneGetOneShelf.Root'\n\n// \u521B\u5EFA\u547D\u540D\u7A7A\u95F4\u5BF9\u8C61\uFF0C\u5305\u542B Root \u548C ProductCard \u7EC4\u4EF6\nconst BuyOneGetOneShelf = {\n Root: BuyOneGetOneShelfRoot,\n ProductCard: ProductCard,\n}\n\nexport default BuyOneGetOneShelf\n\n// Re-export types for external use\nexport type {\n FreeGift,\n FreeGiftWithSelection,\n ProductTag,\n BuyOneGetOneShelfSemanticName,\n BuyOneGetOneShelfRootSemanticName,\n BuyOneGetOneShelfProductCardSemanticName,\n ResponsiveImage,\n ResponsiveImages,\n BaseProductData,\n PureProductData,\n WithGiftData,\n ProductData,\n ProductCardData,\n CopyConfig,\n BogoItem,\n BuyOneGetOneShelfData,\n BuyOneGetOneShelfProps,\n BuyOneGetOneShelfCardProps,\n} from './types.js'\n"],
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAgCM,IAAAI,EAAA,6BA9BNC,EAAuB,oBACvBC,EAAmB,kCACnBC,EAAwB,+BACxBC,EAA8B,qCAE9BC,EAA4B,sCAE5B,MAAMC,EAAgB,QAChBC,EAAgB,wBAQhBC,EAAwBP,EAAM,WAClC,CAAC,CAAE,UAAAQ,EAAW,WAAAC,EAAa,CAAC,EAAG,MAAAC,EAAO,MAAAC,EAAO,SAAAC,EAAU,SAAAC,EAAU,GAAGC,CAAM,EAAGC,IAAQ,CACnF,MAAMC,EAAShB,EAAM,OAAuB,IAAI,EAEhD,wBAAYgB,EAAQ,CAClB,cAAAX,EACA,cAAAC,EACA,eAAgBK,EAChB,qBAAsBC,CACxB,CAAC,EAEDZ,EAAM,oBAAoBe,EAAK,IAAMC,EAAO,OAAyB,KAGnE,QAAC,OACC,IAAKA,EACL,aAAW,MACT,8BACA,CACE,YAAaN,IAAU,MACzB,EACAF,EACAC,GAAY,IACd,EACC,GAAGK,EAEH,UAAAH,MACC,OAAC,WAAQ,GAAG,KAAK,KAAMA,EAAO,aAAW,MAAG,0CAA2CF,GAAY,KAAK,EAAG,EAE5GG,MACC,OAAC,QACC,KAAM,EACN,GAAG,IACH,KAAMA,EACN,aAAW,MAAG,gDAAiDH,GAAY,WAAW,EACxF,KAGF,OAAC,OAAI,aAAW,MAAG,sCAAuC,sCAAsC,EAC7F,SAAAI,EACH,GACF,CAEJ,CACF,EAEAN,EAAsB,YAAc,yBAGpC,MAAMU,EAAoB,CACxB,KAAMV,EACN,YAAa,EAAAW,OACf,EAEA,IAAOrB,EAAQoB",
|
|
6
6
|
"names": ["BuyOneGetOneShelf_exports", "__export", "BuyOneGetOneShelf_default", "__toCommonJS", "import_jsx_runtime", "React", "import_helpers", "import_ProductCard", "import_components", "import_useExposure", "componentType", "componentName", "BuyOneGetOneShelfRoot", "className", "classNames", "theme", "title", "subtitle", "children", "props", "ref", "boxRef", "BuyOneGetOneShelf", "ProductCard"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Img } from '../../types/props.js';
|
|
3
|
+
export type FeaturedBlogPostsSemanticName = 'root' | 'header' | 'title' | 'subtitle' | 'grid' | 'card' | 'cardImage' | 'cardContent' | 'cardTitle' | 'cardDescription' | 'cardMeta' | 'separator';
|
|
4
|
+
/**
|
|
5
|
+
* 卡片宽度比例
|
|
6
|
+
*/
|
|
7
|
+
export type FeaturedBlogPostSpan = 'full' | '2/3' | '1/3';
|
|
8
|
+
/**
|
|
9
|
+
* 博文卡片项数据接口
|
|
10
|
+
*/
|
|
11
|
+
export interface FeaturedBlogPostItem {
|
|
12
|
+
/** 封面图片 */
|
|
13
|
+
image: {
|
|
14
|
+
mobile?: Img;
|
|
15
|
+
pad?: Img;
|
|
16
|
+
laptop?: Img;
|
|
17
|
+
desktop?: Img;
|
|
18
|
+
lgDesktop?: Img;
|
|
19
|
+
};
|
|
20
|
+
/** 文章标题 */
|
|
21
|
+
title: string;
|
|
22
|
+
/** 文章描述 */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** 日期信息(分类·日期·作者) */
|
|
25
|
+
date?: string;
|
|
26
|
+
/** 文章链接 */
|
|
27
|
+
link?: string;
|
|
28
|
+
/** 卡片宽度比例,默认 full */
|
|
29
|
+
width?: FeaturedBlogPostSpan;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* FeaturedBlogPosts 业务组件数据接口
|
|
33
|
+
*/
|
|
34
|
+
export interface FeaturedBlogPostsData {
|
|
35
|
+
/** 主标题 */
|
|
36
|
+
title?: string;
|
|
37
|
+
/** 副标题 */
|
|
38
|
+
subtitle?: string;
|
|
39
|
+
/** 博文列表 */
|
|
40
|
+
items: FeaturedBlogPostItem[];
|
|
41
|
+
}
|
|
42
|
+
export interface FeaturedBlogPostsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
43
|
+
/** 业务数据 */
|
|
44
|
+
data: FeaturedBlogPostsData;
|
|
45
|
+
/** 语义化类名覆盖 */
|
|
46
|
+
classNames?: Partial<Record<FeaturedBlogPostsSemanticName, string>>;
|
|
47
|
+
/** 卡片点击回调 */
|
|
48
|
+
onItemClick?: (item: FeaturedBlogPostItem, index: number, event: React.MouseEvent) => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* FeaturedBlogPosts - 精选博文
|
|
52
|
+
*
|
|
53
|
+
* @description 展示经过筛选的优质文章,支持不同宽度和布局的卡片组合
|
|
54
|
+
*/
|
|
55
|
+
declare const FeaturedBlogPosts: React.ForwardRefExoticComponent<FeaturedBlogPostsProps & React.RefAttributes<HTMLDivElement>>;
|
|
56
|
+
export default FeaturedBlogPosts;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";"use client";var F=Object.create;var n=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var l in t)n(e,l,{get:t[l],enumerable:!0})},h=(e,t,l,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of B(t))!R.call(e,p)&&p!==l&&n(e,p,{get:()=>t[p],enumerable:!(r=I(t,p))||r.enumerable});return e};var k=(e,t,l)=>(l=e!=null?F(w(e)):{},h(t||!e||!e.__esModule?n(l,"default",{value:e,enumerable:!0}):l,e)),S=e=>h(n({},"__esModule",{value:!0}),e);var H={};C(H,{default:()=>E});module.exports=S(H);var a=require("react/jsx-runtime"),m=k(require("react")),s=require("../../helpers/index.js"),b=k(require("../../components/picture.js")),i=require("../../index.js");const M=e=>{const t=[{key:"lgDesktop",width:1920},{key:"desktop",width:1440},{key:"laptop",width:1024},{key:"pad",width:768},{key:"mobile",width:390}],l=t.filter(({key:r})=>e[r]?.url).map(({key:r,width:p})=>`${e[r].url} ${p}`);if(l.length>0)return l.join(", ");for(const{key:r}of t)if(e[r]?.url)return e[r].url;return""},D=(e,t)=>{const l=["desktop","laptop","pad","mobile","lgDesktop"];for(const r of l)if(e[r]?.alt)return e[r].alt;return t},N=(e="full")=>({full:"laptop:col-span-3","2/3":"laptop:col-span-2","1/3":"laptop:col-span-1"})[e],z=(e="full")=>e==="1/3"?"":"laptop:flex-row",T=(e="full")=>({full:"laptop:h-full laptop:w-2/3","2/3":"laptop:h-full laptop:w-1/2","1/3":"laptop:flex-1 h-[200px] lg-desktop:h-[240px]"})[e],x=m.forwardRef(({className:e,classNames:t={},data:l,onItemClick:r,...p},v)=>{const{title:g,subtitle:c,items:f}=l,y=m.useCallback((o,d)=>u=>{r?.(o,d,u)},[r]);return(0,a.jsxs)("div",{ref:v,className:(0,s.cn)("blog-posts-root","text-info-primary w-full",e,t.root),...p,children:[(g||c)&&(0,a.jsxs)("div",{className:(0,s.cn)("blog-posts-header mb-6",t.header),children:[g&&(0,a.jsx)(i.Heading,{as:"h2",size:4,html:g,className:(0,s.cn)("blog-posts-title",t.title)}),c&&(0,a.jsx)(i.Text,{as:"p",size:3,className:(0,s.cn)("",t?.subtitle),html:c})]}),(0,a.jsx)("div",{className:(0,s.cn)("blog-posts-grid","laptop:grid-cols-3 grid grid-cols-1 gap-4",t.grid),children:f.map((o,d)=>{const u=o.link?"a":"div",P=o.link?{href:o.link}:{};return(0,a.jsxs)(m.Fragment,{children:[(0,a.jsxs)(u,{...P,className:(0,s.cn)("blog-posts-card rounded-box","flex cursor-pointer flex-col gap-4","laptop:h-[336px] desktop:h-[448px] lg-desktop:h-[560px]","laptop:bg-container-secondary-0 laptop:p-4 desktop:p-6 lg-desktop:p-8","laptop:overflow-hidden laptop:transition-opacity ",N(o.width||"full"),z(o.width||"full"),t.card),onClick:y(o,d),children:[(0,a.jsx)("div",{className:(0,s.cn)("blog-posts-card-image","relative w-full overflow-hidden","h-[200px] shrink-0",T(o.width||"full"),t.cardImage),children:(0,a.jsx)(b.default,{source:M(o.image),alt:D(o.image,o.title),className:"rounded-box h-full object-cover",imgClassName:"h-full"})}),(0,a.jsxs)("div",{className:(0,s.cn)("blog-posts-card-content","desktop:gap-6 flex flex-col justify-center gap-4",t.cardContent),children:[(0,a.jsxs)("div",{className:"desktop:gap-2 flex flex-col gap-1",children:[(0,a.jsx)(i.Heading,{size:2,as:"h6",className:(0,s.cn)("blog-posts-card-title line-clamp-3",t.cardTitle),html:o.title}),o.description&&(0,a.jsx)(i.Text,{className:(0,s.cn)("blog-posts-card-description desktop:text-[16px] lg-desktop:text-[18px] line-clamp-3 text-[14px]",t.cardDescription),html:o.description})]}),o.date&&(0,a.jsx)(i.Text,{className:(0,s.cn)("blog-posts-card-meta","text-info-tertiary desktop:text-[16px] lg-desktop:text-[18px] text-[14px]",t.cardMeta),html:o.date})]})]}),d<f.length-1&&(0,a.jsx)("div",{className:(0,s.cn)("blog-posts-separator","bg-lines-primary laptop:hidden h-px w-full",t.separator)})]},d)})})]})});x.displayName="FeaturedBlogPosts";var E=x;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/biz-components/FeaturedBlogPosts/index.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../../helpers/index.js'\nimport Picture from '../../components/picture.js'\nimport type { Img } from '../../types/props.js'\nimport { Heading, Text } from '../../index.js'\n\nexport type FeaturedBlogPostsSemanticName =\n | 'root'\n | 'header'\n | 'title'\n | 'subtitle'\n | 'grid'\n | 'card'\n | 'cardImage'\n | 'cardContent'\n | 'cardTitle'\n | 'cardDescription'\n | 'cardMeta'\n | 'separator'\n\n/**\n * \u5361\u7247\u5BBD\u5EA6\u6BD4\u4F8B\n */\nexport type FeaturedBlogPostSpan = 'full' | '2/3' | '1/3'\n\n/**\n * \u535A\u6587\u5361\u7247\u9879\u6570\u636E\u63A5\u53E3\n */\nexport interface FeaturedBlogPostItem {\n /** \u5C01\u9762\u56FE\u7247 */\n image: {\n mobile?: Img\n pad?: Img\n laptop?: Img\n desktop?: Img\n lgDesktop?: Img\n }\n /** \u6587\u7AE0\u6807\u9898 */\n title: string\n /** \u6587\u7AE0\u63CF\u8FF0 */\n description?: string\n /** \u65E5\u671F\u4FE1\u606F\uFF08\u5206\u7C7B\u00B7\u65E5\u671F\u00B7\u4F5C\u8005\uFF09 */\n date?: string\n /** \u6587\u7AE0\u94FE\u63A5 */\n link?: string\n /** \u5361\u7247\u5BBD\u5EA6\u6BD4\u4F8B\uFF0C\u9ED8\u8BA4 full */\n width?: FeaturedBlogPostSpan\n}\n\n/**\n * FeaturedBlogPosts \u4E1A\u52A1\u7EC4\u4EF6\u6570\u636E\u63A5\u53E3\n */\nexport interface FeaturedBlogPostsData {\n /** \u4E3B\u6807\u9898 */\n title?: string\n /** \u526F\u6807\u9898 */\n subtitle?: string\n /** \u535A\u6587\u5217\u8868 */\n items: FeaturedBlogPostItem[]\n}\n\nexport interface FeaturedBlogPostsProps extends React.HTMLAttributes<HTMLDivElement> {\n /** \u4E1A\u52A1\u6570\u636E */\n data: FeaturedBlogPostsData\n /** \u8BED\u4E49\u5316\u7C7B\u540D\u8986\u76D6 */\n classNames?: Partial<Record<FeaturedBlogPostsSemanticName, string>>\n /** \u5361\u7247\u70B9\u51FB\u56DE\u8C03 */\n onItemClick?: (item: FeaturedBlogPostItem, index: number, event: React.MouseEvent) => void\n}\n\n/**\n * \u54CD\u5E94\u5F0F\u56FE\u7247\u7C7B\u578B\n */\ntype ResponsiveImage = FeaturedBlogPostItem['image']\n\n/**\n * \u5C06\u54CD\u5E94\u5F0F\u56FE\u7247\u5BF9\u8C61\u8F6C\u4E3A Picture source \u683C\u5F0F\u5B57\u7B26\u4E32\n * \u683C\u5F0F: \"url1 1920, url2 1440, url3 1024, url4 768, url5 390\"\n */\nconst getImageSource = (image: ResponsiveImage): string => {\n const breakpoints: { key: keyof ResponsiveImage; width: number }[] = [\n { key: 'lgDesktop', width: 1920 },\n { key: 'desktop', width: 1440 },\n { key: 'laptop', width: 1024 },\n { key: 'pad', width: 768 },\n { key: 'mobile', width: 390 },\n ]\n\n const sources = breakpoints\n .filter(({ key }) => image[key]?.url)\n .map(({ key, width }) => `${image[key]!.url} ${width}`)\n\n // \u5982\u679C\u6709 sources\uFF0C\u8FD4\u56DE\u62FC\u63A5\u7ED3\u679C\uFF1B\u5426\u5219\u8FD4\u56DE\u7B2C\u4E00\u4E2A\u6709\u6548\u7684 url\n if (sources.length > 0) {\n return sources.join(', ')\n }\n\n // fallback: \u8FD4\u56DE\u4EFB\u610F\u4E00\u4E2A\u6709\u6548\u7684 url\n for (const { key } of breakpoints) {\n if (image[key]?.url) return image[key]!.url\n }\n\n return ''\n}\n\n/**\n * \u4ECE\u54CD\u5E94\u5F0F\u56FE\u7247\u5BF9\u8C61\u83B7\u53D6 alt \u6587\u672C\n */\nconst getImageAlt = (image: ResponsiveImage, fallback: string): string => {\n const keys: (keyof ResponsiveImage)[] = ['desktop', 'laptop', 'pad', 'mobile', 'lgDesktop']\n for (const key of keys) {\n if (image[key]?.alt) return image[key]!.alt!\n }\n return fallback\n}\n\n/**\n * \u6839\u636E span \u83B7\u53D6\u5361\u7247 grid \u5217\u6570 (laptop+)\n */\nconst getSpanClass = (span: FeaturedBlogPostSpan = 'full') => {\n const spanMap: Record<FeaturedBlogPostSpan, string> = {\n full: 'laptop:col-span-3',\n '2/3': 'laptop:col-span-2',\n '1/3': 'laptop:col-span-1',\n }\n return spanMap[span]\n}\n\n/**\n * \u6839\u636E span \u83B7\u53D6\u5361\u7247\u5E03\u5C40\u65B9\u5411 (laptop+)\n * 1/3: \u4E0A\u4E0B\u5E03\u5C40\uFF0C\u5176\u4ED6: \u5DE6\u53F3\u5E03\u5C40\n */\nconst getLayoutClass = (span: FeaturedBlogPostSpan = 'full') => {\n return span === '1/3' ? '' : 'laptop:flex-row'\n}\n\n/**\n * \u6839\u636E span \u83B7\u53D6\u56FE\u7247\u5C3A\u5BF8\u6837\u5F0F (laptop+)\n * full: \u5DE6\u53F3\u5E03\u5C40\uFF0C\u56FE\u7247\u5BBD\u5EA6\u5360 2/3\n * 2/3: \u5DE6\u53F3\u5E03\u5C40\uFF0C\u56FE\u7247\u5BBD\u5EA6\u5360 1/2\n * 1/3: \u4E0A\u4E0B\u5E03\u5C40\uFF0C\u56FE\u7247\u9AD8\u5EA6\u586B\u6EE1\u5269\u4F59\u7A7A\u95F4\n */\nconst getImageSizeClass = (span: FeaturedBlogPostSpan = 'full') => {\n const sizeMap: Record<FeaturedBlogPostSpan, string> = {\n full: 'laptop:h-full laptop:w-2/3',\n '2/3': 'laptop:h-full laptop:w-1/2',\n '1/3': 'laptop:flex-1 h-[200px] lg-desktop:h-[240px]',\n }\n return sizeMap[span]\n}\n\n/**\n * FeaturedBlogPosts - \u7CBE\u9009\u535A\u6587\n *\n * @description \u5C55\u793A\u7ECF\u8FC7\u7B5B\u9009\u7684\u4F18\u8D28\u6587\u7AE0\uFF0C\u652F\u6301\u4E0D\u540C\u5BBD\u5EA6\u548C\u5E03\u5C40\u7684\u5361\u7247\u7EC4\u5408\n */\nconst FeaturedBlogPosts = React.forwardRef<HTMLDivElement, FeaturedBlogPostsProps>(\n ({ className, classNames = {}, data, onItemClick, ...props }, ref) => {\n const { title, subtitle, items } = data\n\n const handleCardClick = React.useCallback(\n (item: FeaturedBlogPostItem, index: number) => (event: React.MouseEvent) => {\n onItemClick?.(item, index, event)\n },\n [onItemClick]\n )\n\n return (\n <div\n ref={ref}\n className={cn('blog-posts-root', 'text-info-primary w-full', className, classNames.root)}\n {...props}\n >\n {/* \u6807\u9898\u533A\u57DF */}\n {(title || subtitle) && (\n <div className={cn('blog-posts-header mb-6', classNames.header)}>\n {title && <Heading as=\"h2\" size={4} html={title} className={cn('blog-posts-title', classNames.title)} />}\n {subtitle && <Text as=\"p\" size={3} className={cn('', classNames?.subtitle)} html={subtitle} />}\n </div>\n )}\n <div className={cn('blog-posts-grid', 'laptop:grid-cols-3 grid grid-cols-1 gap-4', classNames.grid)}>\n {items.map((item, index) => {\n const CardWrapper = item.link ? 'a' : 'div'\n const cardProps = item.link ? { href: item.link } : {}\n\n return (\n <React.Fragment key={index}>\n <CardWrapper\n {...cardProps}\n className={cn(\n 'blog-posts-card rounded-box',\n 'flex cursor-pointer flex-col gap-4',\n 'laptop:h-[336px] desktop:h-[448px] lg-desktop:h-[560px]',\n 'laptop:bg-container-secondary-0 laptop:p-4 desktop:p-6 lg-desktop:p-8',\n 'laptop:overflow-hidden laptop:transition-opacity ',\n getSpanClass(item.width || 'full'),\n getLayoutClass(item.width || 'full'),\n classNames.card\n )}\n onClick={handleCardClick(item, index)}\n >\n {/* \u56FE\u7247 */}\n <div\n className={cn(\n 'blog-posts-card-image',\n 'relative w-full overflow-hidden',\n 'h-[200px] shrink-0',\n getImageSizeClass(item.width || 'full'),\n classNames.cardImage\n )}\n >\n <Picture\n source={getImageSource(item.image)}\n alt={getImageAlt(item.image, item.title)}\n className=\"rounded-box h-full object-cover\"\n imgClassName=\"h-full\"\n />\n </div>\n\n {/* \u5185\u5BB9 */}\n <div\n className={cn(\n 'blog-posts-card-content',\n 'desktop:gap-6 flex flex-col justify-center gap-4',\n classNames.cardContent\n )}\n >\n <div className=\"desktop:gap-2 flex flex-col gap-1\">\n <Heading\n size={2}\n as=\"h6\"\n className={cn('blog-posts-card-title line-clamp-3', classNames.cardTitle)}\n html={item.title}\n />\n\n {item.description && (\n <Text\n className={cn(\n 'blog-posts-card-description desktop:text-[16px] lg-desktop:text-[18px] line-clamp-3 text-[14px]',\n classNames.cardDescription\n )}\n html={item.description}\n />\n )}\n </div>\n {item.date && (\n <Text\n className={cn(\n 'blog-posts-card-meta',\n 'text-info-tertiary desktop:text-[16px] lg-desktop:text-[18px] text-[14px]',\n classNames.cardMeta\n )}\n html={item.date}\n />\n )}\n </div>\n </CardWrapper>\n\n {/* \u5206\u5272\u7EBF - \u4EC5 mobile/tablet \u663E\u793A */}\n {index < items.length - 1 && (\n <div\n className={cn(\n 'blog-posts-separator',\n 'bg-lines-primary laptop:hidden h-px w-full',\n classNames.separator\n )}\n />\n )}\n </React.Fragment>\n )\n })}\n </div>\n </div>\n )\n }\n)\n\nFeaturedBlogPosts.displayName = 'FeaturedBlogPosts'\nexport default FeaturedBlogPosts\n"],
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAiLU,IAAAI,EAAA,6BA/KVC,EAAuB,oBACvBC,EAAmB,kCACnBC,EAAoB,0CAEpBC,EAA8B,0BA2E9B,MAAMC,EAAkBC,GAAmC,CACzD,MAAMC,EAA+D,CACnE,CAAE,IAAK,YAAa,MAAO,IAAK,EAChC,CAAE,IAAK,UAAW,MAAO,IAAK,EAC9B,CAAE,IAAK,SAAU,MAAO,IAAK,EAC7B,CAAE,IAAK,MAAO,MAAO,GAAI,EACzB,CAAE,IAAK,SAAU,MAAO,GAAI,CAC9B,EAEMC,EAAUD,EACb,OAAO,CAAC,CAAE,IAAAE,CAAI,IAAMH,EAAMG,CAAG,GAAG,GAAG,EACnC,IAAI,CAAC,CAAE,IAAAA,EAAK,MAAAC,CAAM,IAAM,GAAGJ,EAAMG,CAAG,EAAG,GAAG,IAAIC,CAAK,EAAE,EAGxD,GAAIF,EAAQ,OAAS,EACnB,OAAOA,EAAQ,KAAK,IAAI,EAI1B,SAAW,CAAE,IAAA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FeaturedBlogPosts_exports", "__export", "FeaturedBlogPosts_default", "__toCommonJS", "import_jsx_runtime", "React", "import_helpers", "import_picture", "import__", "getImageSource", "image", "breakpoints", "sources", "key", "width", "getImageAlt", "fallback", "keys", "getSpanClass", "span", "getLayoutClass", "getImageSizeClass", "FeaturedBlogPosts", "className", "classNames", "data", "onItemClick", "props", "ref", "title", "subtitle", "items", "handleCardClick", "item", "index", "event", "CardWrapper", "cardProps", "Picture"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var z=Object.create;var k=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var O=(t,i)=>{for(var b in i)k(t,b,{get:i[b],enumerable:!0})},F=(t,i,b,h)=>{if(i&&typeof i=="object"||typeof i=="function")for(let g of B(i))!R.call(t,g)&&g!==b&&k(t,g,{get:()=>i[g],enumerable:!(h=j(i,g))||h.enumerable});return t};var W=(t,i,b)=>(b=t!=null?z(E(t)):{},F(i||!t||!t.__esModule?k(b,"default",{value:t,enumerable:!0}):b,t)),H=t=>F(k({},"__esModule",{value:!0}),t);var T={};O(T,{SeriesProductItem:()=>D,SidebarDropdown:()=>L});module.exports=H(T);var e=require("react/jsx-runtime"),c=W(require("react")),n=require("../../components/index.js"),f=require("../../helpers/utils.js"),$=require("./icons/index.js"),C=require("./NavProvider.js"),w=require("../AiuiProvider/index.js");const L=c.default.memo(({sidebarCategoriesMetadata:t,seriesMetadata:i})=>{const{buildProps:b,onSidebarNavClick:h}=(0,C.useNavContext)(),{locale:g="us"}=(0,w.useAiuiContext)(),[y,v]=(0,c.useState)([]),[u,x]=(0,c.useState)(-1),S=(0,c.useRef)(null),N=(0,c.useRef)(null),p=(0,c.useCallback)(()=>{const l=t?.subcategories;if(!l?.length)return;const o=l.findIndex(d=>!!d?.subSubCategories),a=l.findIndex(d=>!d?.subSubCategories),r=l.map((d,m)=>({index:m,open:o===m||a===m}));v(r)},[t]);(0,c.useEffect)(()=>{p()},[p]);const s=(0,c.useMemo)(()=>{const l=t?.subcategories?.[y?.find(a=>a.open)?.index||0],o=i?.find(a=>a?.label?.toLowerCase()===l?.label?.toLowerCase())||{};if(l?.collections){const a=b?.categories?.[l?.collections]||{};return{label:o?.label,isCollection:!0,banner:o?.banner,primary:o?.primary,series:[{products:a?.products}]}}else if(l?.subSubCategories){const a=l?.subSubCategories?.[u],r=i?.find(d=>d?.label?.toLowerCase()===a?.label?.toLowerCase())||{};if(a?.collections){const d=b?.categories?.[a?.collections]||{};return{label:r?.label,isCollection:!0,banner:r?.banner,primary:r?.primary,series:[{products:d?.products}]}}else return r}else return o},[t,y,u,i,b]),P=(0,c.useCallback)((l,o)=>{const a=o?.subSubCategories?.length>0;x(a?0:-1);const r=N.current;v(d=>d.map((m,A)=>A===l?{...m,open:!m.open}:a?{...m,open:!1}:!r&&u===-1?{...m,open:!1}:r&&!r.hasSubSubCategories&&!a&&u===-1?{...m,open:!1}:m)),N.current={index:l,hasSubSubCategories:a}},[u]),_=(l,o)=>{v(a=>a.map(r=>r.index===l?{...r,open:!0}:{...r,open:!1})),x(o)};return(0,e.jsxs)(n.Container,{childClassName:"lg-desktop:gap-12 flex bg-white gap-8",children:[(0,e.jsxs)("div",{className:"lg-desktop:basis-[356px] flex basis-[284px] flex-col gap-4 py-4",style:{userSelect:"none"},ref:S,children:[(0,e.jsx)("div",{className:"desktop:h-[416px] flex flex-col overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:t?.subcategories?.map((l,o)=>{const a=Array.isArray(l?.subSubCategories)&&l?.subSubCategories?.length>0,r=y?.find(d=>d.index===o)?.open;return(0,e.jsxs)("div",{children:[(0,e.jsxs)("button",{className:(0,f.cn)("rounded-sidebar-shelf flex w-full cursor-pointer items-center justify-between border-0 bg-transparent text-left",{"bg-[#F5F5F7]":!a&&r}),onClick:()=>{P(o,l),h?.(l,o)},"aria-expanded":a?r:void 0,"aria-haspopup":a?"true":void 0,children:[(0,e.jsx)(n.Text,{html:l.label,className:"p-4 text-sm font-bold leading-[1.4]"}),a&&(0,e.jsx)($.DownArrow,{"aria-hidden":"true",className:(0,f.cn)("size-4",{"rotate-180":r})})]}),r&&(0,e.jsx)("div",{className:"flex flex-col",role:"menu",children:l.subSubCategories?.map((d,m)=>(0,e.jsx)("button",{onClick:()=>{_(o,m),h?.(d,m)},className:(0,f.cn)("rounded-sidebar-shelf w-full cursor-pointer border-0 bg-transparent px-6 py-4 text-left leading-none hover:bg-[#F5F5F7]",{"bg-[#F5F5F7]":u===m}),role:"menuitem","aria-label":d.label,children:(0,e.jsx)(n.Text,{html:d.label,className:"text-sm font-bold leading-[1.4] text-[#4A4C56]"})},`subSubItem-${o}-${m}`))})]},`${l?.label||""}subcategoryItem-${o}`)})}),t&&(0,e.jsx)("div",{className:"flex",children:(0,e.jsxs)("div",{className:"flex flex-col gap-4",children:[t?.primary&&(0,e.jsx)(n.Button,{as:"a",href:`${(0,f.getLocalizedPath)(t?.primary?.url,g)}?ref=${t?.primary?.label}_shopall`,variant:"primary",size:"lg",className:"lg-desktop:text-base text-sm",children:t?.primary?.label}),t?.secondary&&(0,e.jsx)(n.Button,{as:"a",href:t?.secondary?.url,variant:"link",size:"lg",iconClassName:"size-4",className:"lg-desktop:text-base justify-start !p-0 text-sm",children:t?.secondary?.label})]})})]}),(0,e.jsxs)("div",{className:"flex-1 py-4",children:[Reflect.ownKeys(s).length>0&&(0,e.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(()=>{const l=(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(n.Text,{html:s?.label,className:"lg-desktop:text-2xl text-xl font-bold leading-[1.4]"}),s?.primary&&!s?.primary?.hide&&(0,e.jsx)(n.Text,{className:"lg-desktop:text-base text-sm font-bold leading-[1.2]",html:s?.primary?.label})]});return s?.primary?.url?(0,e.jsx)(n.Button,{as:"a",href:`${(0,f.getLocalizedPath)(s?.primary?.url,g)}?ref=${s?.label}_viewmore`,variant:"link",size:"lg",iconClassName:"size-4",className:"flex items-center justify-start gap-2 !p-0 no-underline",children:l}):(0,e.jsx)("div",{className:"flex items-center gap-2",children:l})})(),t?.guide?.label&&(0,e.jsx)(n.Link,{href:(0,f.getLocalizedPath)(t?.guide?.url,g),className:"lg-desktop:text-base text-sm leading-[1.2] text-[#6D6D6F]",children:t?.guide?.label})]}),(0,e.jsx)("div",{className:"flex h-[426px] flex-col gap-4 overflow-y-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:s?.series?.map((l,o)=>(0,e.jsxs)("div",{children:[l.label&&(0,e.jsx)(n.Text,{html:l.label,as:"p",className:"mb-2 text-sm font-bold leading-[1.4] text-[#6D6D6F]"}),(0,e.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[!!s?.banner&&(0,e.jsx)(n.Link,{asChild:!s?.banner?.href,href:(0,f.getLocalizedPath)(s?.banner?.href,g),children:(0,e.jsxs)("div",{className:"relative [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-500",children:[(0,e.jsx)(n.Picture,{source:s?.banner?.imageUrl,className:"laptop:h-[120px] h-[114px]",imgClassName:"object-cover h-full"}),(0,e.jsxs)("div",{className:"absolute inset-x-0 bottom-0 p-4",children:[(0,e.jsx)(n.Heading,{size:2,html:s?.banner?.title||"Buy in Guide",className:(0,f.cn)("font-bold text-white",{"text-black":s?.banner?.theme==="dark"})}),(0,e.jsx)(n.Text,{html:s?.banner?.desc||"20.000mAh",className:(0,f.cn)("text-sm font-bold text-white",{"text-black":s?.banner?.theme==="dark"})})]})]})}),l.products?.map((a,r)=>(0,e.jsx)(D,{seriesLabel:s?.label,product:a,isCollection:s?.isCollection},`seriesProductItem-${l?.label||""}-${o}-${r}`))]})]},`seriesItem-${l?.label||""}-${o}`))})]})]})});L.displayName="SidebarDropdown";const D=({product:t,isCollection:i,position:b,seriesLabel:h})=>{const{locale:g="us"}=(0,w.useAiuiContext)(),{buildProps:y,onSeriesProductClick:v}=(0,C.useNavContext)();let u=i?t:y?.products?.find(p=>p.handle===t.handle);const x=u?.variants?.find(p=>p.sku===t.sku)||u?.variants?.[0],S=(0,c.useMemo)(()=>`${(0,f.getLocalizedPath)(`/products/${u?.handle}`,g)}?variant=${(0,f.atobID)(x?.id)}`,[u?.handle,x?.id,g]),N=(0,c.useMemo)(()=>u?.tags?.filter?.(p=>p?.startsWith?.("CLtag"))?.map?.(p=>p?.replace?.("CLtag:",""))?.slice?.(0,2),[u?.tags]);return x?.availableForSale?(0,e.jsx)(n.Link,{href:S,onClick:p=>{p.preventDefault(),window.open(S,"_self"),v?.(u,b||0,h)},className:"no-underline hover:text-current",children:(0,e.jsxs)("div",{className:"rounded-sidebar-shelf flex shrink-0 items-center gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-110 [&_img]:hover:duration-500",children:[(0,e.jsx)("div",{className:"shrink-0",children:(0,e.jsx)("img",{src:`${x?.image?.url||t?.images?.[0]?.url}&width=200`,loading:"lazy",alt:u?.title||t?.name,width:90,height:90,className:"size-[96px] object-contain"})}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("div",{className:"flex gap-1",children:Array.isArray(N)&&N?.map((p,s)=>(0,e.jsx)(n.Text,{as:"p",html:p,className:"text-brand-0 mb-1 inline-block h-[24px] whitespace-nowrap rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-xs font-bold !leading-[22px]"},s))}),(0,e.jsx)(n.Text,{className:"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]",html:t?.custom_name||x?.metafields?.infos?.page_short_title||u?.title}),t?.desc&&(0,e.jsx)(n.Text,{as:"p",html:t?.desc,className:"lg-desktop:text-sm mt-1 line-clamp-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]"})]})]})}):null};
|
|
2
2
|
//# sourceMappingURL=SidebarDropdown.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/HeaderNavigation/SidebarDropdown.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { Button, Container, Text, Link, Heading, Picture } from '../../components/index.js'\nimport { cn, atobID, getLocalizedPath } from '../../helpers/utils.js'\nimport { DownArrow } from './icons/index.js'\nimport { useNavContext } from './NavProvider.js'\nimport type { Product, ProductVariant } from '../../cpn-components/CpnProductCard/types.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\n\n/**\n * \u4FA7\u8FB9\u680F\u4E0B\u62C9\n * @param categoriesItem \u5206\u7C7B\u9879\n */\nexport const SidebarDropdown = React.memo(\n ({ sidebarCategoriesMetadata, seriesMetadata }: { sidebarCategoriesMetadata: any; seriesMetadata: any }) => {\n const { buildProps, onSidebarNavClick } = useNavContext()\n const { locale = 'us' } = useAiuiContext()\n const [expandedSubcategory, setExpandedSubcategory] = useState<{ index: number; open: boolean }[]>([])\n const [activeSubSubcategoryIndex, setActiveSubSubcategoryIndex] = useState(-1)\n const sidebarDropdownRef = useRef<HTMLDivElement>(null)\n\n const initExpandedSubcategory = useCallback(() => {\n const subcategories = sidebarCategoriesMetadata?.subcategories\n if (!subcategories?.length) return\n\n const withSubSubCategoriesIndex = subcategories.findIndex((item: any) => !!item?.subSubCategories)\n const withoutSubSubCategoriesIndex = subcategories.findIndex((item: any) => !item?.subSubCategories)\n\n // \u521B\u5EFA\u5C55\u5F00\u72B6\u6001\u6570\u7EC4\n const expandedStates = subcategories.map((_: any, index: number) => ({\n index,\n open: withSubSubCategoriesIndex === index || withoutSubSubCategoriesIndex === index,\n }))\n\n setExpandedSubcategory(expandedStates)\n }, [sidebarCategoriesMetadata])\n\n useEffect(() => {\n initExpandedSubcategory()\n }, [initExpandedSubcategory])\n\n // \u901A\u8FC7categoriesMetadata\u7684subSubCategories\u7684label\u4E0Eseries\u7684label\u5339\u914D\n const matchSeriesMetadata = useMemo(() => {\n const subCategory =\n sidebarCategoriesMetadata?.subcategories?.[expandedSubcategory?.find(item => item.open)?.index || 0]\n const currentSeriesMetadata =\n seriesMetadata?.find((item: any) => item?.label?.toLowerCase() === subCategory?.label?.toLowerCase()) || {}\n if (subCategory?.collections) {\n const category = buildProps?.categories?.[subCategory?.collections] || {}\n return {\n label: currentSeriesMetadata?.label,\n isCollection: true,\n banner: currentSeriesMetadata?.banner,\n primary: currentSeriesMetadata?.primary,\n series: [\n {\n products: category?.products,\n },\n ],\n }\n } else {\n if (subCategory?.subSubCategories) {\n const activeSubSubcategory = subCategory?.subSubCategories?.[activeSubSubcategoryIndex]\n const currentActiveSeriesMetadata =\n seriesMetadata?.find(\n (item: any) => item?.label?.toLowerCase() === activeSubSubcategory?.label?.toLowerCase()\n ) || {}\n if (activeSubSubcategory?.collections) {\n const category = buildProps?.categories?.[activeSubSubcategory?.collections] || {}\n return {\n label: currentActiveSeriesMetadata?.label,\n isCollection: true,\n banner: currentActiveSeriesMetadata?.banner,\n primary: currentActiveSeriesMetadata?.primary,\n series: [\n {\n products: category?.products,\n },\n ],\n }\n } else {\n return currentActiveSeriesMetadata\n }\n } else {\n return currentSeriesMetadata\n }\n }\n }, [sidebarCategoriesMetadata, expandedSubcategory, activeSubSubcategoryIndex, seriesMetadata, buildProps])\n\n const handleSubcategoryOpen = useCallback((index: number, subcategoryItem: any) => {\n const hasSubSubCategories = subcategoryItem?.subSubCategories?.length > 0\n hasSubSubCategories ? setActiveSubSubcategoryIndex(0) : setActiveSubSubcategoryIndex(-1)\n\n setExpandedSubcategory(prev =>\n prev.map((item, i) => ({\n ...item,\n open: i === index ? !item.open : hasSubSubCategories ? false : item.open,\n }))\n )\n }, [])\n\n const handleSubSubcategoryOpen = (index: number, subSubindex: number) => {\n setExpandedSubcategory(prev =>\n prev.map(item => (item.index === index ? { ...item, open: true } : { ...item, open: false }))\n )\n setActiveSubSubcategoryIndex(subSubindex)\n }\n\n return (\n <Container childClassName=\"lg-desktop:gap-12 flex bg-white gap-8\">\n <div\n className=\"lg-desktop:basis-[356px] flex basis-[284px] flex-col gap-4 py-4\"\n style={{\n userSelect: 'none',\n }}\n ref={sidebarDropdownRef}\n >\n <div\n className=\"desktop:h-[416px] flex flex-col overflow-y-auto\"\n style={{\n scrollbarWidth: 'none',\n msOverflowStyle: 'none',\n }}\n >\n {sidebarCategoriesMetadata?.subcategories?.map((subItem: any, index: number) => {\n const hasSubSubCategory =\n Array.isArray(subItem?.subSubCategories) && subItem?.subSubCategories?.length > 0\n const isExpanded = expandedSubcategory?.find(item => item.index === index)?.open\n return (\n <div key={`${subItem?.label || ''}subcategoryItem-${index}`}>\n <button\n className={cn(\n 'rounded-sidebar-shelf flex w-full cursor-pointer items-center justify-between border-0 bg-transparent text-left',\n {\n 'bg-[#F5F5F7]': !hasSubSubCategory && isExpanded,\n }\n )}\n onClick={() => {\n handleSubcategoryOpen(index, subItem)\n onSidebarNavClick?.(subItem, index)\n }}\n aria-expanded={hasSubSubCategory ? isExpanded : undefined}\n aria-haspopup={hasSubSubCategory ? 'true' : undefined}\n >\n <Text html={subItem.label} className=\"p-4 text-sm font-bold leading-[1.4]\" />\n {hasSubSubCategory && (\n <DownArrow\n aria-hidden=\"true\"\n className={cn('size-4', {\n ['rotate-180']: isExpanded,\n })}\n />\n )}\n </button>\n {isExpanded && (\n <div className=\"flex flex-col\" role=\"menu\">\n {subItem.subSubCategories?.map((subSubItem: any, subSubindex: number) => (\n <button\n onClick={() => {\n handleSubSubcategoryOpen(index, subSubindex)\n onSidebarNavClick?.(subSubItem, subSubindex)\n }}\n key={`subSubItem-${index}-${subSubindex}`}\n className={cn(\n 'rounded-sidebar-shelf w-full cursor-pointer border-0 bg-transparent px-6 py-4 text-left leading-none hover:bg-[#F5F5F7]',\n {\n 'bg-[#F5F5F7]': activeSubSubcategoryIndex === subSubindex,\n }\n )}\n role=\"menuitem\"\n aria-label={subSubItem.label}\n >\n <Text html={subSubItem.label} className=\"text-sm font-bold leading-[1.4] text-[#4A4C56]\" />\n </button>\n ))}\n </div>\n )}\n </div>\n )\n })}\n </div>\n {sidebarCategoriesMetadata && (\n <div className=\"flex\">\n <div className=\"flex flex-col gap-4\">\n {sidebarCategoriesMetadata?.primary && (\n <Button\n as=\"a\"\n href={`${getLocalizedPath(sidebarCategoriesMetadata?.primary?.url, locale)}?ref=${sidebarCategoriesMetadata?.primary?.label}_shopall`}\n variant=\"primary\"\n size=\"lg\"\n className=\"lg-desktop:text-base text-sm\"\n >\n {sidebarCategoriesMetadata?.primary?.label}\n </Button>\n )}\n {sidebarCategoriesMetadata?.secondary && (\n <Button\n as=\"a\"\n href={sidebarCategoriesMetadata?.secondary?.url}\n variant=\"link\"\n size=\"lg\"\n iconClassName=\"size-4\"\n className=\"lg-desktop:text-base justify-start !p-0 text-sm\"\n >\n {sidebarCategoriesMetadata?.secondary?.label}\n </Button>\n )}\n </div>\n </div>\n )}\n </div>\n <div className=\"flex-1 py-4\">\n {Reflect.ownKeys(matchSeriesMetadata).length > 0 && (\n <div className=\"mb-4 flex items-center justify-between\">\n {(() => {\n const labelContent = (\n <>\n <Text\n html={matchSeriesMetadata?.label}\n className=\"lg-desktop:text-2xl text-xl font-bold leading-[1.4]\"\n />\n {matchSeriesMetadata?.primary && !matchSeriesMetadata?.primary?.hide && (\n <Text\n className=\"lg-desktop:text-base text-sm font-bold leading-[1.2]\"\n html={matchSeriesMetadata?.primary?.label}\n />\n )}\n </>\n )\n\n return matchSeriesMetadata?.primary?.url ? (\n <Button\n as=\"a\"\n href={`${getLocalizedPath(matchSeriesMetadata?.primary?.url, locale)}?ref=${matchSeriesMetadata?.label}_viewmore`}\n variant=\"link\"\n size=\"lg\"\n iconClassName=\"size-4\"\n className=\"flex items-center justify-start gap-2 !p-0 no-underline\"\n >\n {labelContent}\n </Button>\n ) : (\n <div className=\"flex items-center gap-2\">{labelContent}</div>\n )\n })()}\n {sidebarCategoriesMetadata?.guide?.label && (\n <Link\n href={getLocalizedPath(sidebarCategoriesMetadata?.guide?.url, locale)}\n className=\"lg-desktop:text-base text-sm leading-[1.2] text-[#6D6D6F]\"\n >\n {sidebarCategoriesMetadata?.guide?.label}\n </Link>\n )}\n </div>\n )}\n <div\n className=\"flex h-[426px] flex-col gap-4 overflow-y-auto\"\n style={{\n scrollbarWidth: 'none',\n msOverflowStyle: 'none',\n }}\n >\n {matchSeriesMetadata?.series?.map((seriesItem: any, seriesIndex: number) => (\n <div key={`seriesItem-${seriesItem?.label || ''}-${seriesIndex}`}>\n {seriesItem.label && (\n <Text\n html={seriesItem.label}\n as=\"p\"\n className=\"mb-2 text-sm font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n <div className=\"grid grid-cols-3 gap-4\">\n {!!matchSeriesMetadata?.banner && (\n <Link\n asChild={!matchSeriesMetadata?.banner?.href}\n href={getLocalizedPath(matchSeriesMetadata?.banner?.href, locale)}\n >\n <div className=\"relative [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-500\">\n <Picture\n source={matchSeriesMetadata?.banner?.imageUrl}\n className=\"laptop:h-[120px] h-[114px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute inset-x-0 bottom-0 p-4\">\n <Heading\n size={2}\n html={matchSeriesMetadata?.banner?.title || 'Buy in Guide'}\n className={cn('font-bold text-white', {\n 'text-black': matchSeriesMetadata?.banner?.theme === 'dark',\n })}\n />\n <Text\n html={matchSeriesMetadata?.banner?.desc || '20.000mAh'}\n className={cn('text-sm font-bold text-white', {\n 'text-black': matchSeriesMetadata?.banner?.theme === 'dark',\n })}\n />\n </div>\n </div>\n </Link>\n )}\n {seriesItem.products?.map((product: any, index: number) => (\n <SeriesProductItem\n seriesLabel={matchSeriesMetadata?.label}\n key={`seriesProductItem-${seriesItem?.label || ''}-${seriesIndex}-${index}`}\n product={product}\n isCollection={matchSeriesMetadata?.isCollection}\n />\n ))}\n </div>\n </div>\n ))}\n </div>\n </div>\n </Container>\n )\n }\n)\n\nSidebarDropdown.displayName = 'SidebarDropdown'\n\n/**\n * \u7CFB\u5217\u4EA7\u54C1\u9879\u7EC4\u4EF6\n */\nexport const SeriesProductItem = ({\n product,\n isCollection,\n position,\n seriesLabel,\n}: {\n product: any\n isCollection?: boolean\n position?: number\n seriesLabel?: string\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { buildProps, onSeriesProductClick } = useNavContext()\n let productData = isCollection\n ? product\n : buildProps?.products?.find((item: Product) => item.handle === product.handle)\n const variant =\n productData?.variants?.find((item: ProductVariant) => item.sku === product.sku) || productData?.variants?.[0]\n\n const listingLink = useMemo(() => {\n return `${getLocalizedPath(`/products/${productData?.handle}`, locale)}?variant=${atobID(variant?.id as string)}`\n }, [productData?.handle, variant?.id, locale])\n\n const tags = useMemo(() => {\n return productData?.tags\n ?.filter?.((item: any) => item?.startsWith?.('CLtag'))\n ?.map?.((item: any) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, 2)\n }, [productData?.tags])\n\n if (!variant?.availableForSale) return null\n\n return (\n <Link\n href={listingLink}\n onClick={e => {\n e.preventDefault()\n window.open(listingLink, '_self')\n onSeriesProductClick?.(productData, position || 0, seriesLabel)\n }}\n className=\"no-underline hover:text-current\"\n >\n <div className=\"rounded-sidebar-shelf flex shrink-0 items-center gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-110 [&_img]:hover:duration-500\">\n <div className=\"shrink-0\">\n <img\n src={`${variant?.image?.url || product?.images?.[0]?.url}&width=200`}\n loading=\"lazy\"\n alt={productData?.title || product?.name}\n width={90}\n height={90}\n className=\"size-[96px] object-contain\"\n />\n </div>\n <div className=\"relative\">\n <div className=\"flex gap-1\">\n {Array.isArray(tags) &&\n tags?.map((tag: string, index: number) => (\n <Text\n key={index}\n as=\"p\"\n html={tag}\n className=\"text-brand-0 mb-1 inline-block h-[24px] whitespace-nowrap rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-xs font-bold !leading-[22px]\"\n />\n ))}\n </div>\n <Text\n className=\"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]\"\n html={product?.custom_name || variant?.metafields?.infos?.page_short_title || productData?.title}\n />\n {product?.desc && (\n <Text\n as=\"p\"\n html={product?.desc}\n className=\"lg-desktop:text-sm mt-1 line-clamp-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n </div>\n </div>\n </Link>\n )\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,
|
|
6
|
-
"names": ["SidebarDropdown_exports", "__export", "SeriesProductItem", "SidebarDropdown", "__toCommonJS", "import_jsx_runtime", "import_react", "import_components", "import_utils", "import_icons", "import_NavProvider", "import_AiuiProvider", "React", "sidebarCategoriesMetadata", "seriesMetadata", "buildProps", "onSidebarNavClick", "locale", "expandedSubcategory", "setExpandedSubcategory", "activeSubSubcategoryIndex", "setActiveSubSubcategoryIndex", "sidebarDropdownRef", "initExpandedSubcategory", "subcategories", "withSubSubCategoriesIndex", "item", "withoutSubSubCategoriesIndex", "expandedStates", "_", "index", "matchSeriesMetadata", "subCategory", "currentSeriesMetadata", "category", "activeSubSubcategory", "currentActiveSeriesMetadata", "handleSubcategoryOpen", "subcategoryItem", "hasSubSubCategories", "prev", "i", "handleSubSubcategoryOpen", "subSubindex", "subItem", "hasSubSubCategory", "isExpanded", "subSubItem", "labelContent", "seriesItem", "seriesIndex", "product", "isCollection", "position", "seriesLabel", "onSeriesProductClick", "productData", "variant", "listingLink", "tags", "e", "tag"]
|
|
4
|
+
"sourcesContent": ["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { Button, Container, Text, Link, Heading, Picture } from '../../components/index.js'\nimport { cn, atobID, getLocalizedPath } from '../../helpers/utils.js'\nimport { DownArrow } from './icons/index.js'\nimport { useNavContext } from './NavProvider.js'\nimport type { Product, ProductVariant } from '../../cpn-components/CpnProductCard/types.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\n\n/**\n * \u4FA7\u8FB9\u680F\u4E0B\u62C9\n * @param categoriesItem \u5206\u7C7B\u9879\n */\nexport const SidebarDropdown = React.memo(\n ({ sidebarCategoriesMetadata, seriesMetadata }: { sidebarCategoriesMetadata: any; seriesMetadata: any }) => {\n const { buildProps, onSidebarNavClick } = useNavContext()\n const { locale = 'us' } = useAiuiContext()\n const [expandedSubcategory, setExpandedSubcategory] = useState<{ index: number; open: boolean }[]>([])\n const [activeSubSubcategoryIndex, setActiveSubSubcategoryIndex] = useState(-1)\n const sidebarDropdownRef = useRef<HTMLDivElement>(null)\n const lastClickRef = useRef<{ index: number; hasSubSubCategories: boolean } | null>(null)\n\n const initExpandedSubcategory = useCallback(() => {\n const subcategories = sidebarCategoriesMetadata?.subcategories\n if (!subcategories?.length) return\n\n const withSubSubCategoriesIndex = subcategories.findIndex((item: any) => !!item?.subSubCategories)\n const withoutSubSubCategoriesIndex = subcategories.findIndex((item: any) => !item?.subSubCategories)\n\n // \u521B\u5EFA\u5C55\u5F00\u72B6\u6001\u6570\u7EC4\n const expandedStates = subcategories.map((_: any, index: number) => ({\n index,\n open: withSubSubCategoriesIndex === index || withoutSubSubCategoriesIndex === index,\n }))\n\n setExpandedSubcategory(expandedStates)\n }, [sidebarCategoriesMetadata])\n\n useEffect(() => {\n initExpandedSubcategory()\n }, [initExpandedSubcategory])\n\n // \u901A\u8FC7categoriesMetadata\u7684subSubCategories\u7684label\u4E0Eseries\u7684label\u5339\u914D\n const matchSeriesMetadata = useMemo(() => {\n const subCategory =\n sidebarCategoriesMetadata?.subcategories?.[expandedSubcategory?.find(item => item.open)?.index || 0]\n const currentSeriesMetadata =\n seriesMetadata?.find((item: any) => item?.label?.toLowerCase() === subCategory?.label?.toLowerCase()) || {}\n if (subCategory?.collections) {\n const category = buildProps?.categories?.[subCategory?.collections] || {}\n return {\n label: currentSeriesMetadata?.label,\n isCollection: true,\n banner: currentSeriesMetadata?.banner,\n primary: currentSeriesMetadata?.primary,\n series: [\n {\n products: category?.products,\n },\n ],\n }\n } else {\n if (subCategory?.subSubCategories) {\n const activeSubSubcategory = subCategory?.subSubCategories?.[activeSubSubcategoryIndex]\n const currentActiveSeriesMetadata =\n seriesMetadata?.find(\n (item: any) => item?.label?.toLowerCase() === activeSubSubcategory?.label?.toLowerCase()\n ) || {}\n if (activeSubSubcategory?.collections) {\n const category = buildProps?.categories?.[activeSubSubcategory?.collections] || {}\n return {\n label: currentActiveSeriesMetadata?.label,\n isCollection: true,\n banner: currentActiveSeriesMetadata?.banner,\n primary: currentActiveSeriesMetadata?.primary,\n series: [\n {\n products: category?.products,\n },\n ],\n }\n } else {\n return currentActiveSeriesMetadata\n }\n } else {\n return currentSeriesMetadata\n }\n }\n }, [sidebarCategoriesMetadata, expandedSubcategory, activeSubSubcategoryIndex, seriesMetadata, buildProps])\n\n const handleSubcategoryOpen = useCallback(\n (index: number, subcategoryItem: any) => {\n const hasSubSubCategories = subcategoryItem?.subSubCategories?.length > 0\n hasSubSubCategories ? setActiveSubSubcategoryIndex(0) : setActiveSubSubcategoryIndex(-1)\n\n const lastClick = lastClickRef.current\n\n setExpandedSubcategory(prev =>\n prev.map((item, i) => {\n if (i === index) {\n return { ...item, open: !item.open }\n }\n // \u5982\u679C\u5F53\u524D\u70B9\u51FB\u7684\u9879\u6709\u5B50\u5B50\u5206\u7C7B\uFF0C\u5173\u95ED\u5176\u4ED6\u6240\u6709\u9879\n if (hasSubSubCategories) {\n return { ...item, open: false }\n }\n if (!lastClick && activeSubSubcategoryIndex === -1) {\n return { ...item, open: false }\n }\n if (\n lastClick &&\n !lastClick.hasSubSubCategories &&\n !hasSubSubCategories &&\n activeSubSubcategoryIndex === -1\n ) {\n // \u5982\u679C\u4E0A\u4E00\u6B21\u70B9\u51FB\u7684\u9879\u6CA1\u6709\u5B50\u5B50\u5206\u7C7B\uFF0C\u4E14\u8FD9\u6B21\u70B9\u51FB\u7684\u4E5F\u6CA1\u6709\u5B50\u5B50\u5206\u7C7B\uFF0C\u5E76\u4E14\u6CA1\u6709\u70B9\u51FB\u4E0A\u4E00\u6B21\u6CA1\u6709subSubCategories\u7684item \u5173\u95ED\u4E0A\u4E00\u6B21\u7684\u9879\n return { ...item, open: false }\n }\n return item\n })\n )\n\n // \u66F4\u65B0\u4E0A\u4E00\u6B21\u70B9\u51FB\u7684\u72B6\u6001\n lastClickRef.current = { index, hasSubSubCategories }\n },\n [activeSubSubcategoryIndex]\n )\n\n const handleSubSubcategoryOpen = (index: number, subSubindex: number) => {\n setExpandedSubcategory(prev =>\n prev.map(item => (item.index === index ? { ...item, open: true } : { ...item, open: false }))\n )\n setActiveSubSubcategoryIndex(subSubindex)\n }\n\n return (\n <Container childClassName=\"lg-desktop:gap-12 flex bg-white gap-8\">\n <div\n className=\"lg-desktop:basis-[356px] flex basis-[284px] flex-col gap-4 py-4\"\n style={{\n userSelect: 'none',\n }}\n ref={sidebarDropdownRef}\n >\n <div\n className=\"desktop:h-[416px] flex flex-col overflow-y-auto\"\n style={{\n scrollbarWidth: 'none',\n msOverflowStyle: 'none',\n }}\n >\n {sidebarCategoriesMetadata?.subcategories?.map((subItem: any, index: number) => {\n const hasSubSubCategory =\n Array.isArray(subItem?.subSubCategories) && subItem?.subSubCategories?.length > 0\n const isExpanded = expandedSubcategory?.find(item => item.index === index)?.open\n return (\n <div key={`${subItem?.label || ''}subcategoryItem-${index}`}>\n <button\n className={cn(\n 'rounded-sidebar-shelf flex w-full cursor-pointer items-center justify-between border-0 bg-transparent text-left',\n {\n 'bg-[#F5F5F7]': !hasSubSubCategory && isExpanded,\n }\n )}\n onClick={() => {\n handleSubcategoryOpen(index, subItem)\n onSidebarNavClick?.(subItem, index)\n }}\n aria-expanded={hasSubSubCategory ? isExpanded : undefined}\n aria-haspopup={hasSubSubCategory ? 'true' : undefined}\n >\n <Text html={subItem.label} className=\"p-4 text-sm font-bold leading-[1.4]\" />\n {hasSubSubCategory && (\n <DownArrow\n aria-hidden=\"true\"\n className={cn('size-4', {\n ['rotate-180']: isExpanded,\n })}\n />\n )}\n </button>\n {isExpanded && (\n <div className=\"flex flex-col\" role=\"menu\">\n {subItem.subSubCategories?.map((subSubItem: any, subSubindex: number) => (\n <button\n onClick={() => {\n handleSubSubcategoryOpen(index, subSubindex)\n onSidebarNavClick?.(subSubItem, subSubindex)\n }}\n key={`subSubItem-${index}-${subSubindex}`}\n className={cn(\n 'rounded-sidebar-shelf w-full cursor-pointer border-0 bg-transparent px-6 py-4 text-left leading-none hover:bg-[#F5F5F7]',\n {\n 'bg-[#F5F5F7]': activeSubSubcategoryIndex === subSubindex,\n }\n )}\n role=\"menuitem\"\n aria-label={subSubItem.label}\n >\n <Text html={subSubItem.label} className=\"text-sm font-bold leading-[1.4] text-[#4A4C56]\" />\n </button>\n ))}\n </div>\n )}\n </div>\n )\n })}\n </div>\n {sidebarCategoriesMetadata && (\n <div className=\"flex\">\n <div className=\"flex flex-col gap-4\">\n {sidebarCategoriesMetadata?.primary && (\n <Button\n as=\"a\"\n href={`${getLocalizedPath(sidebarCategoriesMetadata?.primary?.url, locale)}?ref=${sidebarCategoriesMetadata?.primary?.label}_shopall`}\n variant=\"primary\"\n size=\"lg\"\n className=\"lg-desktop:text-base text-sm\"\n >\n {sidebarCategoriesMetadata?.primary?.label}\n </Button>\n )}\n {sidebarCategoriesMetadata?.secondary && (\n <Button\n as=\"a\"\n href={sidebarCategoriesMetadata?.secondary?.url}\n variant=\"link\"\n size=\"lg\"\n iconClassName=\"size-4\"\n className=\"lg-desktop:text-base justify-start !p-0 text-sm\"\n >\n {sidebarCategoriesMetadata?.secondary?.label}\n </Button>\n )}\n </div>\n </div>\n )}\n </div>\n <div className=\"flex-1 py-4\">\n {Reflect.ownKeys(matchSeriesMetadata).length > 0 && (\n <div className=\"mb-4 flex items-center justify-between\">\n {(() => {\n const labelContent = (\n <>\n <Text\n html={matchSeriesMetadata?.label}\n className=\"lg-desktop:text-2xl text-xl font-bold leading-[1.4]\"\n />\n {matchSeriesMetadata?.primary && !matchSeriesMetadata?.primary?.hide && (\n <Text\n className=\"lg-desktop:text-base text-sm font-bold leading-[1.2]\"\n html={matchSeriesMetadata?.primary?.label}\n />\n )}\n </>\n )\n\n return matchSeriesMetadata?.primary?.url ? (\n <Button\n as=\"a\"\n href={`${getLocalizedPath(matchSeriesMetadata?.primary?.url, locale)}?ref=${matchSeriesMetadata?.label}_viewmore`}\n variant=\"link\"\n size=\"lg\"\n iconClassName=\"size-4\"\n className=\"flex items-center justify-start gap-2 !p-0 no-underline\"\n >\n {labelContent}\n </Button>\n ) : (\n <div className=\"flex items-center gap-2\">{labelContent}</div>\n )\n })()}\n {sidebarCategoriesMetadata?.guide?.label && (\n <Link\n href={getLocalizedPath(sidebarCategoriesMetadata?.guide?.url, locale)}\n className=\"lg-desktop:text-base text-sm leading-[1.2] text-[#6D6D6F]\"\n >\n {sidebarCategoriesMetadata?.guide?.label}\n </Link>\n )}\n </div>\n )}\n <div\n className=\"flex h-[426px] flex-col gap-4 overflow-y-auto\"\n style={{\n scrollbarWidth: 'none',\n msOverflowStyle: 'none',\n }}\n >\n {matchSeriesMetadata?.series?.map((seriesItem: any, seriesIndex: number) => (\n <div key={`seriesItem-${seriesItem?.label || ''}-${seriesIndex}`}>\n {seriesItem.label && (\n <Text\n html={seriesItem.label}\n as=\"p\"\n className=\"mb-2 text-sm font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n <div className=\"grid grid-cols-3 gap-4\">\n {!!matchSeriesMetadata?.banner && (\n <Link\n asChild={!matchSeriesMetadata?.banner?.href}\n href={getLocalizedPath(matchSeriesMetadata?.banner?.href, locale)}\n >\n <div className=\"relative [&_img]:hover:scale-110 [&_img]:hover:transition-all [&_img]:hover:duration-500\">\n <Picture\n source={matchSeriesMetadata?.banner?.imageUrl}\n className=\"laptop:h-[120px] h-[114px]\"\n imgClassName=\"object-cover h-full\"\n />\n <div className=\"absolute inset-x-0 bottom-0 p-4\">\n <Heading\n size={2}\n html={matchSeriesMetadata?.banner?.title || 'Buy in Guide'}\n className={cn('font-bold text-white', {\n 'text-black': matchSeriesMetadata?.banner?.theme === 'dark',\n })}\n />\n <Text\n html={matchSeriesMetadata?.banner?.desc || '20.000mAh'}\n className={cn('text-sm font-bold text-white', {\n 'text-black': matchSeriesMetadata?.banner?.theme === 'dark',\n })}\n />\n </div>\n </div>\n </Link>\n )}\n {seriesItem.products?.map((product: any, index: number) => (\n <SeriesProductItem\n seriesLabel={matchSeriesMetadata?.label}\n key={`seriesProductItem-${seriesItem?.label || ''}-${seriesIndex}-${index}`}\n product={product}\n isCollection={matchSeriesMetadata?.isCollection}\n />\n ))}\n </div>\n </div>\n ))}\n </div>\n </div>\n </Container>\n )\n }\n)\n\nSidebarDropdown.displayName = 'SidebarDropdown'\n\n/**\n * \u7CFB\u5217\u4EA7\u54C1\u9879\u7EC4\u4EF6\n */\nexport const SeriesProductItem = ({\n product,\n isCollection,\n position,\n seriesLabel,\n}: {\n product: any\n isCollection?: boolean\n position?: number\n seriesLabel?: string\n}) => {\n const { locale = 'us' } = useAiuiContext()\n const { buildProps, onSeriesProductClick } = useNavContext()\n let productData = isCollection\n ? product\n : buildProps?.products?.find((item: Product) => item.handle === product.handle)\n const variant =\n productData?.variants?.find((item: ProductVariant) => item.sku === product.sku) || productData?.variants?.[0]\n\n const listingLink = useMemo(() => {\n return `${getLocalizedPath(`/products/${productData?.handle}`, locale)}?variant=${atobID(variant?.id as string)}`\n }, [productData?.handle, variant?.id, locale])\n\n const tags = useMemo(() => {\n return productData?.tags\n ?.filter?.((item: any) => item?.startsWith?.('CLtag'))\n ?.map?.((item: any) => item?.replace?.('CLtag:', ''))\n ?.slice?.(0, 2)\n }, [productData?.tags])\n\n if (!variant?.availableForSale) return null\n\n return (\n <Link\n href={listingLink}\n onClick={e => {\n e.preventDefault()\n window.open(listingLink, '_self')\n onSeriesProductClick?.(productData, position || 0, seriesLabel)\n }}\n className=\"no-underline hover:text-current\"\n >\n <div className=\"rounded-sidebar-shelf flex shrink-0 items-center gap-4 bg-[#F5F5F7] px-4 py-3 [&_img]:hover:scale-110 [&_img]:hover:duration-500\">\n <div className=\"shrink-0\">\n <img\n src={`${variant?.image?.url || product?.images?.[0]?.url}&width=200`}\n loading=\"lazy\"\n alt={productData?.title || product?.name}\n width={90}\n height={90}\n className=\"size-[96px] object-contain\"\n />\n </div>\n <div className=\"relative\">\n <div className=\"flex gap-1\">\n {Array.isArray(tags) &&\n tags?.map((tag: string, index: number) => (\n <Text\n key={index}\n as=\"p\"\n html={tag}\n className=\"text-brand-0 mb-1 inline-block h-[24px] whitespace-nowrap rounded-full border-[1.6px] border-[#00BEFA] px-[6px] text-xs font-bold !leading-[22px]\"\n />\n ))}\n </div>\n <Text\n className=\"lg-desktop:h-[44px] lg-desktop:text-base line-clamp-2 h-[40px] text-sm font-bold leading-[1.4]\"\n html={product?.custom_name || variant?.metafields?.infos?.page_short_title || productData?.title}\n />\n {product?.desc && (\n <Text\n as=\"p\"\n html={product?.desc}\n className=\"lg-desktop:text-sm mt-1 line-clamp-1 text-xs font-bold leading-[1.4] text-[#6D6D6F]\"\n />\n )}\n </div>\n </div>\n </Link>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GA4JkB,IAAAK,EAAA,6BA5JlBC,EAAyE,oBACzEC,EAAgE,qCAChEC,EAA6C,kCAC7CC,EAA0B,4BAC1BC,EAA8B,4BAE9BC,EAA+B,oCAMxB,MAAMR,EAAkB,EAAAS,QAAM,KACnC,CAAC,CAAE,0BAAAC,EAA2B,eAAAC,CAAe,IAA+D,CAC1G,KAAM,CAAE,WAAAC,EAAY,kBAAAC,CAAkB,KAAI,iBAAc,EAClD,CAAE,OAAAC,EAAS,IAAK,KAAI,kBAAe,EACnC,CAACC,EAAqBC,CAAsB,KAAI,YAA6C,C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4C,KAAO,WAAQ,IACZH,GAAa,MAChB,SAAU/B,GAAcA,GAAM,aAAa,OAAO,CAAC,GACnD,MAAOA,GAAcA,GAAM,UAAU,SAAU,EAAE,CAAC,GAClD,QAAQ,EAAG,CAAC,EACf,CAAC+B,GAAa,IAAI,CAAC,EAEtB,OAAKC,GAAS,oBAGZ,OAAC,QACC,KAAMC,EACN,QAASE,GAAK,CACZA,EAAE,eAAe,EACjB,OAAO,KAAKF,EAAa,OAAO,EAChCH,IAAuBC,EAAaH,GAAY,EAAGC,CAAW,CAChE,EACA,UAAU,kCAEV,oBAAC,OAAI,UAAU,mIACb,oBAAC,OAAI,UAAU,WACb,mBAAC,OACC,IAAK,GAAGG,GAAS,OAAO,KAAON,GAAS,SAAS,CAAC,GAAG,GAAG,aACxD,QAAQ,OACR,IAAKK,GAAa,OAASL,GAAS,KACpC,MAAO,GACP,OAAQ,GACR,UAAU,6BACZ,EACF,KACA,QAAC,OAAI,UAAU,WACb,oBAAC,OAAI,UAAU,aACZ,eAAM,QAAQQ,CAAI,GACjBA,GAAM,IAAI,CAACE,EAAahC,OACtB,OAAC,QAEC,GAAG,IACH,KAAMgC,EACN,UAAU,qJAHLhC,CAIP,CACD,EACL,KACA,OAAC,QACC,UAAU,iGACV,KAAMsB,GAAS,aAAeM,GAAS,YAAY,OAAO,kBAAoBD,GAAa,MAC7F,EACCL,GAAS,SACR,OAAC,QACC,GAAG,IACH,KAAMA,GAAS,KACf,UAAU,sFACZ,GAEJ,GACF,EACF,EAhDqC,IAkDzC",
|
|
6
|
+
"names": ["SidebarDropdown_exports", "__export", "SeriesProductItem", "SidebarDropdown", "__toCommonJS", "import_jsx_runtime", "import_react", "import_components", "import_utils", "import_icons", "import_NavProvider", "import_AiuiProvider", "React", "sidebarCategoriesMetadata", "seriesMetadata", "buildProps", "onSidebarNavClick", "locale", "expandedSubcategory", "setExpandedSubcategory", "activeSubSubcategoryIndex", "setActiveSubSubcategoryIndex", "sidebarDropdownRef", "lastClickRef", "initExpandedSubcategory", "subcategories", "withSubSubCategoriesIndex", "item", "withoutSubSubCategoriesIndex", "expandedStates", "_", "index", "matchSeriesMetadata", "subCategory", "currentSeriesMetadata", "category", "activeSubSubcategory", "currentActiveSeriesMetadata", "handleSubcategoryOpen", "subcategoryItem", "hasSubSubCategories", "lastClick", "prev", "i", "handleSubSubcategoryOpen", "subSubindex", "subItem", "hasSubSubCategory", "isExpanded", "subSubItem", "labelContent", "seriesItem", "seriesIndex", "product", "isCollection", "position", "seriesLabel", "onSeriesProductClick", "productData", "variant", "listingLink", "tags", "e", "tag"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var Me=Object.create;var V=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var Te=(o,r)=>{for(var i in r)V(o,i,{get:r[i],enumerable:!0})},ie=(o,r,i,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of Pe(r))!Ee.call(o,m)&&m!==i&&V(o,m,{get:()=>r[m],enumerable:!(c=Se(r,m))||c.enumerable});return o};var X=(o,r,i)=>(i=o!=null?Me(De(o)):{},ie(r||!o||!o.__esModule?V(i,"default",{value:o,enumerable:!0}):i,o)),He=o=>ie(V({},"__esModule",{value:!0}),o);var Ie={};Te(Ie,{default:()=>ze});module.exports=He(Ie);var e=require("react/jsx-runtime"),t=require("react"),l=require("../../components/index.js"),me=require("../../shared/Styles.js"),y=require("../../helpers/utils.js"),O=X(require("./NavProvider.js")),n=require("./types.js"),pe=X(require("jump.js")),Z=require("@gsap/react"),ee=require("gsap"),C=require("./withCategory.js"),w=require("./icons/index.js"),fe=X(require("../NavigationSearch/index.js")),be=require("./ResourceSidebarDropdown.js"),ve=require("./MobileResourceSidebarMenu.js"),ge=require("./SidebarDropdown.js"),te=require("./useScrollLock.js"),he=require("./MulticolDropdown.js"),ye=require("./SupportsDropdown.js"),Ne=require("./MobileSidebarMenu.js"),ke=require("./MobileSupportMenu.js"),xe=require("./MobileMulticolMenu.js"),ae=require("./MobileMenuComponents.js"),oe=require("../AiuiProvider/index.js"),Ce=X(require("../../shared/throttle.js"));const le=(0,t.forwardRef)((o,r)=>{const{data:{header:i}={},buildProps:c,event:m,profile:g,theme:s="light",isTop:v=!1,searchResult:P,onSearch:d,isSearching:N,keywords:j,onPrimaryNavClick:k,onSeriesProductClick:b,onSidebarNavClick:G,headerId:H,cartCount:R,menuData:L}=o,[D,S]=(0,t.useState)(!1),[_,z]=(0,t.useState)(!1),[B,p]=(0,t.useState)(!1),[$,J]=(0,t.useState)(!1),E=(0,t.useRef)(null),f=(0,t.useRef)(null),W=()=>{const x=document?.querySelector("body")?.offsetWidth||0;J(x<=1440)};(0,t.useEffect)(()=>(W(),window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W)}),[]),(0,t.useImperativeHandle)(r,()=>f.current),(0,t.useEffect)(()=>{f.current&&v&&(0,pe.default)(f.current,{duration:0,offset:f.current?.getBoundingClientRect()?.bottom||0})},[v]),(0,t.useEffect)(()=>{let x=0,K=0,Y=0;const F=()=>document?.documentElement?.scrollTop||document?.body?.scrollTop||0,T=F();x=T,z(T>300),p(T>30);const U=(0,Ce.default)(()=>{const a=F(),u=a-x;p(a>30),u>0?(K=0,Y+=u,Y>=300&&a>300&&z(!0)):u<0&&(Y=0,K+=Math.abs(u),K>=300&&(z(!1),K=0)),x=a},100);return window.addEventListener("scroll",U,{passive:!0}),()=>window.removeEventListener("scroll",U)},[]),(0,t.useEffect)(()=>{m&&(m.search=()=>S(!0))},[m]),(0,Z.useGSAP)(()=>{E?.current&&D&&ee.gsap.fromTo(E.current,{height:0},{height:"auto",duration:.3})},[D]),(0,te.useScrollLock)(D);const I=(0,t.useMemo)(()=>i?.bar?.actions?.find(x=>x?.blockType===n.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[i]);return(0,e.jsx)(O.default,{buildProps:c,profile:g,isMobile:$,event:m,payloadData:i,onSidebarNavClick:G,onSeriesProductClick:b,cartCount:R,children:(0,e.jsx)("header",{id:H||"header","data-ui-component-id":"HeaderNavigation",className:(0,y.cn)("sticky top-0 z-[100] transition-transform duration-500 ease-in-out",{"translate-y-[-100%]":_}),ref:f,children:(0,e.jsxs)("div",{className:(0,y.cn)("hover:bg-white hover:text-black",s==="light"?"text-black":"text-white",{"!bg-white transition-all duration-500 ease-in-out":B},{"hover:!text-black":s==="dark","!text-black":B}),onClick:()=>p(!0),children:[(0,e.jsx)(se,{data:i,className:"desktop:block hidden !bg-white",theme:s,onNavItemClick:()=>p(!0),onPrimaryNavClick:k}),(0,e.jsx)(ce,{menuData:L,data:i,className:"desktop:hidden block !bg-white",onPrimaryNavClick:k}),D&&(0,e.jsxs)("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${f?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[(0,e.jsx)("div",{ref:E,className:(0,y.cn)("overflow-y-auto",{}),children:(0,e.jsx)(fe.default,{data:I,keywords:j,isSearching:N,searchResult:P,onSearch:x=>{d?.(x)},onClose:()=>{d?.(),S(!1)}})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>S(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:x=>{(x.key==="Enter"||x.key===" "||x.key==="Escape")&&(x.preventDefault(),S(!1))}})]})]})})})}),se=(0,t.forwardRef)((o,r)=>{const{data:i,onNavItemClick:c,className:m,theme:g,onPrimaryNavClick:s}=o,{event:v,profile:P}=(0,O.useNavContext)(),[d,N]=(0,t.useState)(!1),{locale:j="us"}=(0,oe.useAiuiContext)(),k=(0,t.useMemo)(()=>(0,C.WithGroupCategory)(i?.categories?.filter(a=>a?.pcShow)),[i]),[b,G]=(0,t.useState)(null),[H,R]=(0,t.useState)([]),L=(0,t.useRef)(null),[D,S]=(0,t.useState)(!1),_=(0,t.useRef)(null),z=(0,t.useRef)(null),B=(0,t.useRef)(k.map(a=>Array(a?.length||0).fill(null)));(0,t.useEffect)(()=>{k?.length&&R(k?.map((a,u)=>a?.map((h,M)=>({groupIndex:u,index:M,open:!1}))))},[k]);const p=(0,t.useMemo)(()=>{let a=null;for(const u of H){for(const h of u)if(h.open){a=h;break}if(a)break}return a},[H]);(0,te.useScrollLock)(!!p?.open||D);const $=(a,u,h)=>{S(!1);const M=k[u][h];if(M?.components?.[0]?.blockType===n.HeaderNavigationBlockType.Links)M?.components?.[0]?.url&&window.open(M?.components?.[0]?.url);else{const q=k?.flat()||[],A=q?.findIndex(ne=>ne?.id===k[u][h]?.id);a.stopPropagation(),c?.(),s?.(q[A],A),G(M),R(ne=>ne.map(we=>we.map(Q=>Q.groupIndex===u&&Q.index===h?{...Q,open:!Q.open}:{...Q,open:!1})))}},J=(a,u,h)=>{a.key==="Enter"||a.key===" "?(a.preventDefault(),$(a,u,h)):a.key==="Escape"&&p?.groupIndex===u&&p?.index===h&&(a.preventDefault(),E())},E=()=>{R(a=>a.map(u=>u.map(h=>({...h,open:!1}))))},f=(0,t.useMemo)(()=>{if(b)return b?.components?.[0]?.blockType},[b]),W=(0,C.WithSidebar)(ge.SidebarDropdown,b),I=(0,C.WithResource)(be.ResourceSidebarDropdown,b),x=(0,C.WithMulticol)(he.MulticolDropdown,b),K=(0,C.WithSupports)(ye.SupportsDropdown,{categoriesItem:b,currentNavItemRef:B.current?.[p?.groupIndex||0]?.[p?.index||0]}),Y=(0,t.useMemo)(()=>{switch(f){case n.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(W,{});case n.HeaderNavigationBlockType.Resource:return(0,e.jsx)(I,{});case n.HeaderNavigationBlockType.Supports:return(0,e.jsx)(K,{});case n.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(x,{});default:return null}},[f,b]),F=(0,t.useMemo)(()=>i?.bar?.actions?.filter(a=>a?.pcShow),[i]),T=(0,t.useMemo)(()=>F?.find(a=>a?.blockType===n.HeaderNavigationActionBlockType.Profile),[F]),U=(0,t.useCallback)(()=>{S(a=>!a)},[]);return(0,t.useEffect)(()=>{if(L?.current){const a=L.current;return a.addEventListener("click",U),()=>{a.removeEventListener("click",U)}}},[U]),(0,Z.useGSAP)(()=>{p?.open&&ee.gsap.fromTo(z?.current,{height:0},{height:"auto"})},[p?.open]),(0,e.jsxs)(l.Container,{className:(0,y.cn)("relative h-[96px]",m),children:[(0,e.jsxs)("div",{ref:_,onClick:E,className:"flex h-full flex-col justify-end gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(ue,{}),(0,e.jsx)(re,{ref:L,actions:F,activeStatus:D})]}),(0,e.jsx)("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",children:k?.map((a,u)=>(0,e.jsx)("div",{className:"flex gap-3",children:a?.map((h,M)=>{const q=p?.groupIndex===u&&p?.index===M;return(0,e.jsx)("div",{ref:A=>{B.current[u][M]=A},className:"group",children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("button",{className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4",onClick:A=>$(A,u,M),onKeyDown:A=>J(A,u,M),"aria-expanded":q,"aria-haspopup":"true","aria-label":h.text,children:[(0,e.jsx)(l.Text,{html:h.text,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)(w.DownArrow,{className:(0,y.cn)("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":p?.groupIndex===u&&p?.index===M,"opacity-100":d&&p?.groupIndex===u&&p?.index===M,invisible:!h?.components?.length||h?.components?.[0]?.blockType===n.HeaderNavigationBlockType.Links})})]}),(0,e.jsx)("div",{className:(0,y.cn)("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":q},g==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},h.id)})},`groupCategory-${u}`))})]}),(0,e.jsxs)("div",{role:"menu","aria-hidden":!(p?.open&&b),className:(0,y.cn)("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(p?.open&&b)}),onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),style:{height:`calc(100dvh - ${_?.current?.getBoundingClientRect()?.bottom}px)`},children:[(0,e.jsx)("div",{ref:z,className:(0,y.cn)("relative z-50",{"overflow-hidden":f!==n.HeaderNavigationBlockType.Supports}),children:Y}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:E,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:a=>{(a.key==="Enter"||a.key===" "||a.key==="Escape")&&(a.preventDefault(),E())}})]}),D&&(0,e.jsxs)("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[(0,e.jsx)("div",{className:"rounded-box absolute w-[272px] overflow-hidden bg-white p-4",style:{right:`calc(100% - ${L?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:P?.email?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.Text,{html:P?.nick_name||T?.welcome,className:"text-sm font-bold"}),(0,e.jsx)("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),(0,e.jsx)("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:T?.profiles?.map(a=>(0,e.jsx)(ae.MenuItem,{className:"py-2",label:a?.title,href:(0,y.getLocalizedPath)(a?.url,j)},a.id))})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(w.Polygon,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),(0,e.jsx)(l.Text,{html:T?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:T?.benefits?.map(a=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:a.benefitIcon?.url,className:"size-4",alt:a.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:a.benefit,className:"text-sm font-bold leading-[1.4]"})]},a.id))}),(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,e.jsx)(l.Button,{variant:"secondary",size:"lg",onClick:()=>v?.join?.(),children:(0,e.jsx)(l.Text,{html:T?.primaryButton||"Join Now",className:"font-bold"})}),(0,e.jsx)(l.Button,{variant:"primary",size:"lg",onClick:()=>v?.login?.(),children:(0,e.jsx)(l.Text,{html:T?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>S(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:a=>{(a.key==="Enter"||a.key===" "||a.key==="Escape")&&(a.preventDefault(),S(!1))}})]})]})}),ce=(0,t.forwardRef)(({data:o,menuData:r,className:i,onPrimaryNavClick:c},m)=>{const g=(0,t.useMemo)(()=>(0,C.WithGroupCategory)(o?.categories?.filter(f=>f?.mobileShow)),[o]),{currentMenu:s,setCurrentMenu:v,subSubCategory:P}=(0,O.useNavContext)(),[d,N]=(0,t.useState)(!1),[j,k]=(0,t.useState)(0),[b,G]=(0,t.useState)(null),H=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(H?.current&&d){const f=H?.current?.getBoundingClientRect();k(window?.innerHeight-(f?.bottom||0))}},[d]),(0,Z.useGSAP)(()=>{ee.gsap.fromTo(H.current,{height:0},{height:j,duration:.3})},[j]),(0,te.useScrollLock)(d);const R=(0,t.useMemo)(()=>b?.components?.[0]?.blockType,[b]),L=(0,C.WithSupports)(ke.MobileSupportMenu,{categoriesItem:b}),D=(0,C.WithSidebar)(Ne.MobileSidebarMenu,b),S=(0,C.WithResource)(ve.MobileResourceSidebarMenu,b),_=(0,C.WithMulticol)(xe.MobileMulticolMenu,b),z=(0,t.useMemo)(()=>{switch(R){case n.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(D,{});case n.HeaderNavigationBlockType.Resource:return(0,e.jsx)(S,{});case n.HeaderNavigationBlockType.Supports:return(0,e.jsx)(L,{});case n.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(_,{});default:return null}},[R,b,L]),B=(0,t.useCallback)(()=>{N(!1),k(0),v&&v(n.HeaderNavigationMenu.Primary)},[N,k,v]),p=(0,t.useMemo)(()=>o?.bar?.actions?.filter(f=>f?.mobileShow&&f?.blockType!==n.HeaderNavigationActionBlockType.Profile),[o]),$=(0,t.useMemo)(()=>o?.bar?.actions?.find(f=>f?.mobileShow&&f?.blockType===n.HeaderNavigationActionBlockType.Profile)||{},[o]),J=(0,t.useMemo)(()=>{switch(s){case n.HeaderNavigationMenu.Primary:return(0,e.jsx)(Re,{actions:p,menuOpen:d,onMenuOpenClose:()=>{N(!1),k(0)},onMenuOpenClick:()=>N(!0)});case n.HeaderNavigationMenu.Secondary:return(0,e.jsx)(de,{title:b?.text,onMenuOpenClose:B,onMenuBackClick:()=>v?.(n.HeaderNavigationMenu.Primary)});case n.HeaderNavigationMenu.Third:return(0,e.jsx)(de,{title:P?.label,onMenuOpenClose:B,onMenuBackClick:()=>v?.(n.HeaderNavigationMenu.Secondary)});default:return null}},[d,s,v,b,p,P,B]),E=(0,t.useCallback)((f,W)=>{const I=Array.isArray(g)?Array.isArray(g[f])?g[f][W]:{}:{};G(I),I?.components?.[0]?.blockType===n.HeaderNavigationBlockType.Links?I?.components?.[0]?.url&&window.open(I?.components?.[0]?.url):v?.(n.HeaderNavigationMenu.Secondary)},[g,v]);return(0,e.jsxs)(l.Container,{className:(0,y.cn)("relative h-[52px]",i),children:[J,d&&(0,e.jsxs)("nav",{ref:H,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:j},role:"navigation","aria-label":"Mobile navigation menu",children:[s===n.HeaderNavigationMenu.Primary&&r?(0,e.jsx)("div",{className:"pt-4",children:(0,e.jsx)(l.BrandStrip,{data:r})}):null,s===n.HeaderNavigationMenu.Primary?(0,e.jsx)(Le,{categories:g,onPrimaryMenuClick:E,onPrimaryNavClick:c,profileAction:$}):z]})]})}),Le=({categories:o,onPrimaryMenuClick:r,profileAction:i,onPrimaryNavClick:c})=>(0,e.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:o?.map((m,g)=>(0,e.jsxs)("div",{className:"",children:[(0,e.jsx)("div",{className:(0,y.cn)("my-2 h-px w-full bg-[#E5E5E7]")}),m?.map((s,v)=>(0,e.jsx)(ae.MenuItem,{label:s.text,onClick:()=>{const d=(o?.flat()||[])?.findIndex(N=>N?.id===o[g][v]?.id);r(g,v),c?.(s,d)},icon:s.components?.[0]?.icon},s.id))]},`groupCategory-${g}`))}),(0,e.jsx)(Be,{profileAction:i})]}),Be=({profileAction:o})=>{const[r,i]=(0,t.useState)(!1),{profile:c,event:m}=(0,O.useNavContext)(),{locale:g="us"}=(0,oe.useAiuiContext)();return(0,e.jsxs)("div",{className:(0,y.cn)("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":r}),children:[(0,e.jsxs)("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>i(!r),"aria-expanded":r,"aria-label":c?.nick_name||o?.welcome,children:[(0,e.jsxs)("div",{className:"flex items-center gap-[14px]",children:[(0,e.jsx)("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:(0,e.jsx)(w.User,{"aria-hidden":"true"})}),(0,e.jsx)(l.Text,{html:c?.nick_name||o?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!c?.email&&(0,e.jsx)(w.DownArrow,{"aria-hidden":"true",className:(0,y.cn)("laptop:size-4 size-5",{"rotate-180":r})})]}),c?.email&&(0,e.jsx)("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:o?.profiles?.map(s=>(0,e.jsx)(ae.MenuItem,{label:s?.title,href:(0,y.getLocalizedPath)(s?.url,g)},s.id))}),r&&!c?.email&&(0,e.jsxs)("div",{className:"mt-4",children:[(0,e.jsx)(l.Text,{html:o?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:o?.benefits?.map(s=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:s.benefitIcon?.url,className:"size-4",alt:s.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:s.benefit,className:"text-sm font-bold leading-[1.4]"})]},s.id))})]}),!c?.email&&(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-3",children:[(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>m?.join?.(),children:(0,e.jsx)(l.Text,{html:o?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>m?.login?.(),children:(0,e.jsx)(l.Text,{html:o?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},Re=({menuOpen:o,onMenuOpenClose:r,onMenuOpenClick:i,actions:c})=>(0,e.jsxs)("div",{className:"flex h-full items-center justify-between gap-4",children:[(0,e.jsx)(ue,{}),(0,e.jsxs)("div",{className:"desktop:gap-6 flex items-center gap-4",children:[(0,e.jsx)(re,{actions:c}),o?(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Close menu","aria-expanded":"true",children:(0,e.jsx)(w.Close,{className:"size-5","aria-hidden":"true"})}):(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:(0,e.jsx)(w.Menu,{className:"size-5","aria-hidden":"true"})})]})]}),ue=()=>{const{payloadData:o,isMobile:r}=(0,O.useNavContext)(),{locale:i="us"}=(0,oe.useAiuiContext)();return(0,e.jsx)("a",{href:(0,y.getLocalizedPath)("/",i),className:"hover:text-brand-0 [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:r?o?.bar?.mobileLogo:o?.bar?.desktopLogo}})},re=(0,t.forwardRef)(({actions:o,activeStatus:r=!1},i)=>{const{event:c,cartCount:m}=(0,O.useNavContext)(),[g,s]=(0,t.useState)(null),v=d=>{switch(d){case n.HeaderNavigationActionBlockType.Search:return"Search";case n.HeaderNavigationActionBlockType.Cart:return`Shopping cart${m>0?` (${m} items)`:""}`;case n.HeaderNavigationActionBlockType.Profile:return"User profile";case n.HeaderNavigationActionBlockType.Livestream:return"Livestream";default:return"Action"}},P=(0,t.useCallback)((d,N)=>{switch(s(N),d?.blockType){case n.HeaderNavigationActionBlockType.Search:c?.search?.();break;case n.HeaderNavigationActionBlockType.Cart:c?.cart?.();break;case n.HeaderNavigationActionBlockType.Profile:c?.profile?.();break;case n.HeaderNavigationActionBlockType.Livestream:c?.livestream?.();break;default:return()=>{}}},[c]);return(0,e.jsx)("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(o)&&o?.map((d,N)=>(0,e.jsxs)("button",{className:"relative cursor-pointer border-0 bg-transparent p-0",ref:d.blockType===n.HeaderNavigationActionBlockType.Profile?i:null,onClick:()=>P(d,N),"aria-label":v(d.blockType),"aria-pressed":r&&g===N,children:[(0,e.jsx)(l.Text,{html:d.icon,className:(0,y.cn)("size-5",{"text-brand-0":r&&g===N}),"aria-hidden":"true"}),d.blockType===n.HeaderNavigationActionBlockType.Cart&&m>0&&(0,e.jsx)("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:(0,e.jsx)(l.Text,{html:m?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},d.id))})}),de=({title:o,onMenuOpenClose:r,onMenuBackClick:i})=>(0,e.jsxs)("div",{className:"flex h-full items-center gap-3",children:[(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Back to previous menu",children:(0,e.jsx)(w.LeftArrow,{className:"size-5","aria-hidden":"true"})}),(0,e.jsx)(l.Text,{html:o,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Close menu",children:(0,e.jsx)(w.Close,{className:"size-5","aria-hidden":"true"})})]});ce.displayName="MobileNavigation",re.displayName="Actions",le.displayName="HeaderNavigation",se.displayName="DesktopNavigation";var ze=(0,me.withLayout)(le);
|
|
1
|
+
"use strict";"use client";var Me=Object.create;var V=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var Te=(n,r)=>{for(var i in r)V(n,i,{get:r[i],enumerable:!0})},ie=(n,r,i,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let f of Pe(r))!Ee.call(n,f)&&f!==i&&V(n,f,{get:()=>r[f],enumerable:!(u=Se(r,f))||u.enumerable});return n};var X=(n,r,i)=>(i=n!=null?Me(De(n)):{},ie(r||!n||!n.__esModule?V(i,"default",{value:n,enumerable:!0}):i,n)),He=n=>ie(V({},"__esModule",{value:!0}),n);var Ie={};Te(Ie,{default:()=>Re});module.exports=He(Ie);var e=require("react/jsx-runtime"),t=require("react"),l=require("../../components/index.js"),me=require("../../shared/Styles.js"),y=require("../../helpers/utils.js"),O=X(require("./NavProvider.js")),o=require("./types.js"),pe=X(require("jump.js")),Z=require("@gsap/react"),ee=require("gsap"),C=require("./withCategory.js"),w=require("./icons/index.js"),fe=X(require("../NavigationSearch/index.js")),be=require("./ResourceSidebarDropdown.js"),ve=require("./MobileResourceSidebarMenu.js"),ge=require("./SidebarDropdown.js"),te=require("./useScrollLock.js"),he=require("./MulticolDropdown.js"),ye=require("./SupportsDropdown.js"),Ne=require("./MobileSidebarMenu.js"),ke=require("./MobileSupportMenu.js"),xe=require("./MobileMulticolMenu.js"),ae=require("./MobileMenuComponents.js"),ne=require("../AiuiProvider/index.js"),Ce=X(require("../../shared/throttle.js"));const le=(0,t.forwardRef)((n,r)=>{const{data:{header:i}={},buildProps:u,event:f,profile:g,theme:s="light",isTop:c=!1,searchResult:P,onSearch:m,isSearching:N,keywords:j,onPrimaryNavClick:k,onSeriesProductClick:v,onSidebarNavClick:G,headerId:H,cartCount:R,menuData:L}=n,[D,S]=(0,t.useState)(!1),[_,z]=(0,t.useState)(!1),[B,p]=(0,t.useState)(!1),[$,J]=(0,t.useState)(!1),E=(0,t.useRef)(null),b=(0,t.useRef)(null),W=()=>{const x=document?.querySelector("body")?.offsetWidth||0;J(x<=1440)};(0,t.useEffect)(()=>(W(),window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W)}),[]),(0,t.useImperativeHandle)(r,()=>b.current),(0,t.useEffect)(()=>{b.current&&c&&(0,pe.default)(b.current,{duration:0,offset:b.current?.getBoundingClientRect()?.bottom||0})},[c]),(0,t.useEffect)(()=>{if(c){z(!1),p(!1);return}let x=0,K=0,Y=0;const F=()=>document?.documentElement?.scrollTop||document?.body?.scrollTop||0,T=F();x=T,z(T>300),p(T>30);const U=(0,Ce.default)(()=>{const a=F(),d=a-x;p(a>30),d>0?(K=0,Y+=d,Y>=300&&a>300&&z(!0)):d<0&&(Y=0,K+=Math.abs(d),K>=300&&(z(!1),K=0)),x=a},100);return window.addEventListener("scroll",U,{passive:!0}),()=>window.removeEventListener("scroll",U)},[c]),(0,t.useEffect)(()=>{f&&(f.search=()=>S(!0))},[f]),(0,Z.useGSAP)(()=>{E?.current&&D&&ee.gsap.fromTo(E.current,{height:0},{height:"auto",duration:.3})},[D]),(0,te.useScrollLock)(D);const I=(0,t.useMemo)(()=>i?.bar?.actions?.find(x=>x?.blockType===o.HeaderNavigationActionBlockType.Search)?.searchBar?.[0]||{},[i]);return(0,e.jsx)(O.default,{buildProps:u,profile:g,isMobile:$,event:f,payloadData:i,onSidebarNavClick:G,onSeriesProductClick:v,cartCount:R,children:(0,e.jsx)("header",{id:H||"header","data-ui-component-id":"HeaderNavigation",className:c?"relative z-[100] bg-white":(0,y.cn)("sticky top-0 z-[100] transition-transform duration-500 ease-in-out",{"translate-y-[-100%]":_}),ref:b,children:(0,e.jsxs)("div",{className:(0,y.cn)("hover:bg-white hover:text-black",s==="light"?"text-black":"text-white",{"!bg-white transition-all duration-500 ease-in-out":!c&&B},{"hover:!text-black":s==="dark","!text-black":!c&&B}),onClick:()=>!c&&p(!0),children:[(0,e.jsx)(se,{data:i,className:"desktop:block hidden !bg-white",theme:s,onNavItemClick:()=>!c&&p(!0),onPrimaryNavClick:k}),(0,e.jsx)(ce,{menuData:L,data:i,className:"desktop:hidden block !bg-white",onPrimaryNavClick:k}),D&&(0,e.jsxs)("div",{className:"absolute left-0 top-0 z-[60] flex w-full flex-col bg-black/70",style:{height:`calc(100dvh - ${b?.current?.getBoundingClientRect()?.top}px)`},role:"dialog","aria-modal":"true","aria-label":"Search",children:[(0,e.jsx)("div",{ref:E,className:(0,y.cn)("overflow-y-auto",{}),children:(0,e.jsx)(fe.default,{data:I,keywords:j,isSearching:N,searchResult:P,onSearch:x=>{m?.(x)},onClose:()=>{m?.(),S(!1)}})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>S(!1),role:"button",tabIndex:0,"aria-label":"Close search",onKeyDown:x=>{(x.key==="Enter"||x.key===" "||x.key==="Escape")&&(x.preventDefault(),S(!1))}})]})]})})})}),se=(0,t.forwardRef)((n,r)=>{const{data:i,onNavItemClick:u,className:f,theme:g,onPrimaryNavClick:s}=n,{event:c,profile:P}=(0,O.useNavContext)(),[m,N]=(0,t.useState)(!1),{locale:j="us"}=(0,ne.useAiuiContext)(),k=(0,t.useMemo)(()=>(0,C.WithGroupCategory)(i?.categories?.filter(a=>a?.pcShow)),[i]),[v,G]=(0,t.useState)(null),[H,R]=(0,t.useState)([]),L=(0,t.useRef)(null),[D,S]=(0,t.useState)(!1),_=(0,t.useRef)(null),z=(0,t.useRef)(null),B=(0,t.useRef)(k.map(a=>Array(a?.length||0).fill(null)));(0,t.useEffect)(()=>{k?.length&&R(k?.map((a,d)=>a?.map((h,M)=>({groupIndex:d,index:M,open:!1}))))},[k]);const p=(0,t.useMemo)(()=>{let a=null;for(const d of H){for(const h of d)if(h.open){a=h;break}if(a)break}return a},[H]);(0,te.useScrollLock)(!!p?.open||D);const $=(a,d,h)=>{S(!1);const M=k[d][h];if(M?.components?.[0]?.blockType===o.HeaderNavigationBlockType.Links)M?.components?.[0]?.url&&window.open(M?.components?.[0]?.url);else{const q=k?.flat()||[],A=q?.findIndex(oe=>oe?.id===k[d][h]?.id);a.stopPropagation(),u?.(),s?.(q[A],A),G(M),R(oe=>oe.map(we=>we.map(Q=>Q.groupIndex===d&&Q.index===h?{...Q,open:!Q.open}:{...Q,open:!1})))}},J=(a,d,h)=>{a.key==="Enter"||a.key===" "?(a.preventDefault(),$(a,d,h)):a.key==="Escape"&&p?.groupIndex===d&&p?.index===h&&(a.preventDefault(),E())},E=()=>{R(a=>a.map(d=>d.map(h=>({...h,open:!1}))))},b=(0,t.useMemo)(()=>{if(v)return v?.components?.[0]?.blockType},[v]),W=(0,C.WithSidebar)(ge.SidebarDropdown,v),I=(0,C.WithResource)(be.ResourceSidebarDropdown,v),x=(0,C.WithMulticol)(he.MulticolDropdown,v),K=(0,C.WithSupports)(ye.SupportsDropdown,{categoriesItem:v,currentNavItemRef:B.current?.[p?.groupIndex||0]?.[p?.index||0]}),Y=(0,t.useMemo)(()=>{switch(b){case o.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(W,{});case o.HeaderNavigationBlockType.Resource:return(0,e.jsx)(I,{});case o.HeaderNavigationBlockType.Supports:return(0,e.jsx)(K,{});case o.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(x,{});default:return null}},[b,v]),F=(0,t.useMemo)(()=>i?.bar?.actions?.filter(a=>a?.pcShow),[i]),T=(0,t.useMemo)(()=>F?.find(a=>a?.blockType===o.HeaderNavigationActionBlockType.Profile),[F]),U=(0,t.useCallback)(()=>{S(a=>!a)},[]);return(0,t.useEffect)(()=>{if(L?.current){const a=L.current;return a.addEventListener("click",U),()=>{a.removeEventListener("click",U)}}},[U]),(0,Z.useGSAP)(()=>{p?.open&&ee.gsap.fromTo(z?.current,{height:0},{height:"auto"})},[p?.open]),(0,e.jsxs)(l.Container,{className:(0,y.cn)("relative h-[96px]",f),children:[(0,e.jsxs)("div",{ref:_,onClick:E,className:"flex h-full flex-col justify-end gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(ue,{}),(0,e.jsx)(re,{ref:L,actions:F,activeStatus:D})]}),(0,e.jsx)("nav",{className:"flex justify-between",role:"navigation","aria-label":"Primary navigation",children:k?.map((a,d)=>(0,e.jsx)("div",{className:"flex gap-3",children:a?.map((h,M)=>{const q=p?.groupIndex===d&&p?.index===M;return(0,e.jsx)("div",{ref:A=>{B.current[d][M]=A},className:"group",children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("button",{className:"flex cursor-pointer items-center gap-1 border-0 bg-transparent pb-4",onClick:A=>$(A,d,M),onKeyDown:A=>J(A,d,M),"aria-expanded":q,"aria-haspopup":"true","aria-label":h.text,children:[(0,e.jsx)(l.Text,{html:h.text,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)(w.DownArrow,{className:(0,y.cn)("size-4 opacity-0 transition-opacity duration-500 group-hover:opacity-100",{"rotate-180":p?.groupIndex===d&&p?.index===M,"opacity-100":m&&p?.groupIndex===d&&p?.index===M,invisible:!h?.components?.length||h?.components?.[0]?.blockType===o.HeaderNavigationBlockType.Links})})]}),(0,e.jsx)("div",{className:(0,y.cn)("absolute bottom-0 left-0 h-[2px] w-0 transition-all duration-500",{"w-[calc(100%-20px)]":q},g==="dark"?"bg-white":"bg-[#080A0F]"),"aria-hidden":"true"})]})},h.id)})},`groupCategory-${d}`))})]}),(0,e.jsxs)("div",{role:"menu","aria-hidden":!(p?.open&&v),className:(0,y.cn)("absolute left-0 top-full z-[999] flex w-full flex-col overflow-hidden border-t border-b-[#E4E5E6] bg-black/70 text-black",{hidden:!(p?.open&&v)}),onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),style:{height:`calc(100dvh - ${_?.current?.getBoundingClientRect()?.bottom}px)`},children:[(0,e.jsx)("div",{ref:z,className:(0,y.cn)("relative z-50",{"overflow-hidden":b!==o.HeaderNavigationBlockType.Supports}),children:Y}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:E,role:"button",tabIndex:0,"aria-label":"Close menu",onKeyDown:a=>{(a.key==="Enter"||a.key===" "||a.key==="Escape")&&(a.preventDefault(),E())}})]}),D&&(0,e.jsxs)("div",{className:"absolute left-0 top-full z-[999] flex h-dvh w-full bg-black/70",role:"dialog","aria-modal":"true","aria-label":"User profile menu",children:[(0,e.jsx)("div",{className:"rounded-box absolute w-[272px] overflow-hidden bg-white p-4",style:{right:`calc(100% - ${L?.current?.getBoundingClientRect()?.right}px)`,top:"-36px"},children:P?.email?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l.Text,{html:P?.nick_name||T?.welcome,className:"text-sm font-bold"}),(0,e.jsx)("div",{className:"mt-2 h-px bg-[#D9D9D9]","aria-hidden":"true"}),(0,e.jsx)("nav",{className:"mt-2",role:"navigation","aria-label":"Profile navigation",children:T?.profiles?.map(a=>(0,e.jsx)(ae.MenuItem,{className:"py-2",label:a?.title,href:(0,y.getLocalizedPath)(a?.url,j)},a.id))})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(w.Polygon,{className:"absolute -top-2 right-[46px] z-30 text-white","aria-hidden":"true"}),(0,e.jsx)(l.Text,{html:T?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:T?.benefits?.map(a=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:a.benefitIcon?.url,className:"size-4",alt:a.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:a.benefit,className:"text-sm font-bold leading-[1.4]"})]},a.id))}),(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,e.jsx)(l.Button,{variant:"secondary",size:"lg",onClick:()=>c?.join?.(),children:(0,e.jsx)(l.Text,{html:T?.primaryButton||"Join Now",className:"font-bold"})}),(0,e.jsx)(l.Button,{variant:"primary",size:"lg",onClick:()=>c?.login?.(),children:(0,e.jsx)(l.Text,{html:T?.secondaryButton||"Log In",className:"font-bold"})})]})]})}),(0,e.jsx)("div",{className:"flex-1 bg-transparent",onClick:()=>S(!1),role:"button",tabIndex:0,"aria-label":"Close profile menu",onKeyDown:a=>{(a.key==="Enter"||a.key===" "||a.key==="Escape")&&(a.preventDefault(),S(!1))}})]})]})}),ce=(0,t.forwardRef)(({data:n,menuData:r,className:i,onPrimaryNavClick:u},f)=>{const g=(0,t.useMemo)(()=>(0,C.WithGroupCategory)(n?.categories?.filter(b=>b?.mobileShow)),[n]),{currentMenu:s,setCurrentMenu:c,subSubCategory:P}=(0,O.useNavContext)(),[m,N]=(0,t.useState)(!1),[j,k]=(0,t.useState)(0),[v,G]=(0,t.useState)(null),H=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(H?.current&&m){const b=H?.current?.getBoundingClientRect();k(window?.innerHeight-(b?.bottom||0))}},[m]),(0,Z.useGSAP)(()=>{ee.gsap.fromTo(H.current,{height:0},{height:j,duration:.3})},[j]),(0,te.useScrollLock)(m);const R=(0,t.useMemo)(()=>v?.components?.[0]?.blockType,[v]),L=(0,C.WithSupports)(ke.MobileSupportMenu,{categoriesItem:v}),D=(0,C.WithSidebar)(Ne.MobileSidebarMenu,v),S=(0,C.WithResource)(ve.MobileResourceSidebarMenu,v),_=(0,C.WithMulticol)(xe.MobileMulticolMenu,v),z=(0,t.useMemo)(()=>{switch(R){case o.HeaderNavigationBlockType.Sidebar:return(0,e.jsx)(D,{});case o.HeaderNavigationBlockType.Resource:return(0,e.jsx)(S,{});case o.HeaderNavigationBlockType.Supports:return(0,e.jsx)(L,{});case o.HeaderNavigationBlockType.Multicol:return(0,e.jsx)(_,{});default:return null}},[R,v,L]),B=(0,t.useCallback)(()=>{N(!1),k(0),c&&c(o.HeaderNavigationMenu.Primary)},[N,k,c]),p=(0,t.useMemo)(()=>n?.bar?.actions?.filter(b=>b?.mobileShow&&b?.blockType!==o.HeaderNavigationActionBlockType.Profile),[n]),$=(0,t.useMemo)(()=>n?.bar?.actions?.find(b=>b?.mobileShow&&b?.blockType===o.HeaderNavigationActionBlockType.Profile)||{},[n]),J=(0,t.useMemo)(()=>{switch(s){case o.HeaderNavigationMenu.Primary:return(0,e.jsx)(Be,{actions:p,menuOpen:m,onMenuOpenClose:()=>{N(!1),k(0)},onMenuOpenClick:()=>N(!0)});case o.HeaderNavigationMenu.Secondary:return(0,e.jsx)(de,{title:v?.text,onMenuOpenClose:B,onMenuBackClick:()=>c?.(o.HeaderNavigationMenu.Primary)});case o.HeaderNavigationMenu.Third:return(0,e.jsx)(de,{title:P?.label,onMenuOpenClose:B,onMenuBackClick:()=>c?.(o.HeaderNavigationMenu.Secondary)});default:return null}},[m,s,c,v,p,P,B]),E=(0,t.useCallback)((b,W)=>{const I=Array.isArray(g)?Array.isArray(g[b])?g[b][W]:{}:{};G(I),I?.components?.[0]?.blockType===o.HeaderNavigationBlockType.Links?I?.components?.[0]?.url&&window.open(I?.components?.[0]?.url):c?.(o.HeaderNavigationMenu.Secondary)},[g,c]);return(0,e.jsxs)(l.Container,{className:(0,y.cn)("relative h-[52px]",i),children:[J,m&&(0,e.jsxs)("nav",{ref:H,className:"absolute left-0 top-full z-[999] w-full overflow-y-auto border-t border-[#E4E5E6] bg-white text-black",style:{height:j},role:"navigation","aria-label":"Mobile navigation menu",children:[s===o.HeaderNavigationMenu.Primary&&r?(0,e.jsx)("div",{className:"pt-4",children:(0,e.jsx)(l.BrandStrip,{data:r})}):null,s===o.HeaderNavigationMenu.Primary?(0,e.jsx)(Le,{categories:g,onPrimaryMenuClick:E,onPrimaryNavClick:u,profileAction:$}):z]})]})}),Le=({categories:n,onPrimaryMenuClick:r,profileAction:i,onPrimaryNavClick:u})=>(0,e.jsxs)("div",{className:"flex h-full flex-col justify-between",children:[(0,e.jsx)("div",{className:"tablet:px-8 laptop:px-16 p-4",children:n?.map((f,g)=>(0,e.jsxs)("div",{className:"",children:[(0,e.jsx)("div",{className:(0,y.cn)("my-2 h-px w-full bg-[#E5E5E7]")}),f?.map((s,c)=>(0,e.jsx)(ae.MenuItem,{label:s.text,onClick:()=>{const m=(n?.flat()||[])?.findIndex(N=>N?.id===n[g][c]?.id);r(g,c),u?.(s,m)},icon:s.components?.[0]?.icon},s.id))]},`groupCategory-${g}`))}),(0,e.jsx)(ze,{profileAction:i})]}),ze=({profileAction:n})=>{const[r,i]=(0,t.useState)(!1),{profile:u,event:f}=(0,O.useNavContext)(),{locale:g="us"}=(0,ne.useAiuiContext)();return(0,e.jsxs)("div",{className:(0,y.cn)("tablet:px-8 laptop:px-16 bg-[#F5F5F7] px-4 py-6",{"p-4":r}),children:[(0,e.jsxs)("button",{className:"flex w-full cursor-pointer items-center justify-between border-0 bg-transparent",onClick:()=>i(!r),"aria-expanded":r,"aria-label":u?.nick_name||n?.welcome,children:[(0,e.jsxs)("div",{className:"flex items-center gap-[14px]",children:[(0,e.jsx)("div",{className:"flex size-[40px] shrink-0 items-center justify-center rounded-full bg-white",children:(0,e.jsx)(w.User,{"aria-hidden":"true"})}),(0,e.jsx)(l.Text,{html:u?.nick_name||n?.welcome,className:"text-base font-bold leading-[1.4]"})]}),!u?.email&&(0,e.jsx)(w.DownArrow,{"aria-hidden":"true",className:(0,y.cn)("laptop:size-4 size-5",{"rotate-180":r})})]}),u?.email&&(0,e.jsx)("nav",{className:"mt-4",role:"navigation","aria-label":"Profile menu",children:n?.profiles?.map(s=>(0,e.jsx)(ae.MenuItem,{label:s?.title,href:(0,y.getLocalizedPath)(s?.url,g)},s.id))}),r&&!u?.email&&(0,e.jsxs)("div",{className:"mt-4",children:[(0,e.jsx)(l.Text,{html:n?.benefits_title,className:"text-sm font-bold leading-[1.4]"}),(0,e.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:n?.benefits?.map(s=>(0,e.jsxs)("div",{className:"flex items-center gap-[6px]",children:[(0,e.jsx)(l.Picture,{source:s.benefitIcon?.url,className:"size-4",alt:s.benefit,width:16,height:16}),(0,e.jsx)(l.Text,{html:s.benefit,className:"text-sm font-bold leading-[1.4]"})]},s.id))})]}),!u?.email&&(0,e.jsxs)("div",{className:"mt-4 flex items-center gap-3",children:[(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"secondary",size:"base",onClick:()=>f?.join?.(),children:(0,e.jsx)(l.Text,{html:n?.primaryButton||"Join Now",className:"text-sm font-bold leading-[1.4]"})}),(0,e.jsx)(l.Button,{className:"tablet:flex-none flex-1",variant:"primary",size:"base",onClick:()=>f?.login?.(),children:(0,e.jsx)(l.Text,{html:n?.secondaryButton||"Log In",className:"text-sm font-bold leading-[1.4]"})})]})]})},Be=({menuOpen:n,onMenuOpenClose:r,onMenuOpenClick:i,actions:u})=>(0,e.jsxs)("div",{className:"flex h-full items-center justify-between gap-4",children:[(0,e.jsx)(ue,{}),(0,e.jsxs)("div",{className:"desktop:gap-6 flex items-center gap-4",children:[(0,e.jsx)(re,{actions:u}),n?(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Close menu","aria-expanded":"true",children:(0,e.jsx)(w.Close,{className:"size-5","aria-hidden":"true"})}):(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Open menu","aria-expanded":"false","aria-haspopup":"true",children:(0,e.jsx)(w.Menu,{className:"size-5","aria-hidden":"true"})})]})]}),ue=()=>{const{payloadData:n,isMobile:r}=(0,O.useNavContext)(),{locale:i="us"}=(0,ne.useAiuiContext)();return(0,e.jsx)("a",{href:(0,y.getLocalizedPath)("/",i),className:"hover:text-brand-0 [&>svg]:w-full","aria-label":"Home",dangerouslySetInnerHTML:{__html:r?n?.bar?.mobileLogo:n?.bar?.desktopLogo}})},re=(0,t.forwardRef)(({actions:n,activeStatus:r=!1},i)=>{const{event:u,cartCount:f}=(0,O.useNavContext)(),[g,s]=(0,t.useState)(null),c=m=>{switch(m){case o.HeaderNavigationActionBlockType.Search:return"Search";case o.HeaderNavigationActionBlockType.Cart:return`Shopping cart${f>0?` (${f} items)`:""}`;case o.HeaderNavigationActionBlockType.Profile:return"User profile";case o.HeaderNavigationActionBlockType.Livestream:return"Livestream";default:return"Action"}},P=(0,t.useCallback)((m,N)=>{switch(s(N),m?.blockType){case o.HeaderNavigationActionBlockType.Search:u?.search?.();break;case o.HeaderNavigationActionBlockType.Cart:u?.cart?.();break;case o.HeaderNavigationActionBlockType.Profile:u?.profile?.();break;case o.HeaderNavigationActionBlockType.Livestream:u?.livestream?.();break;default:return()=>{}}},[u]);return(0,e.jsx)("div",{className:"desktop:gap-6 flex items-center gap-4",children:Array.isArray(n)&&n?.map((m,N)=>(0,e.jsxs)("button",{className:"relative cursor-pointer border-0 bg-transparent p-0",ref:m.blockType===o.HeaderNavigationActionBlockType.Profile?i:null,onClick:()=>P(m,N),"aria-label":c(m.blockType),"aria-pressed":r&&g===N,children:[(0,e.jsx)(l.Text,{html:m.icon,className:(0,y.cn)("size-5",{"text-brand-0":r&&g===N}),"aria-hidden":"true"}),m.blockType===o.HeaderNavigationActionBlockType.Cart&&f>0&&(0,e.jsx)("div",{className:"bg-brand-0 absolute right-[-12px] top-[calc(100%-16px)] z-[1] flex min-h-5 min-w-5 items-center justify-center rounded-full px-[2px]","aria-hidden":"true",children:(0,e.jsx)(l.Text,{html:f?.toString(),className:"text-sm font-bold leading-[1.2] text-white"})})]},m.id))})}),de=({title:n,onMenuOpenClose:r,onMenuBackClick:i})=>(0,e.jsxs)("div",{className:"flex h-full items-center gap-3",children:[(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>i(),"aria-label":"Back to previous menu",children:(0,e.jsx)(w.LeftArrow,{className:"size-5","aria-hidden":"true"})}),(0,e.jsx)(l.Text,{html:n,className:"flex-1 text-center text-base font-bold leading-[1.4]"}),(0,e.jsx)("button",{className:"cursor-pointer border-0 bg-transparent p-0",onClick:()=>r(),"aria-label":"Close menu",children:(0,e.jsx)(w.Close,{className:"size-5","aria-hidden":"true"})})]});ce.displayName="MobileNavigation",re.displayName="Actions",le.displayName="HeaderNavigation",se.displayName="DesktopNavigation";var Re=(0,me.withLayout)(le);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|