@anker-in/headless-ui 1.3.77 → 1.3.78
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var K=Object.create;var x=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var oe=(e,o)=>{for(var s in o)x(e,s,{get:o[s],enumerable:!0})},V=(e,o,s,
|
|
1
|
+
"use strict";"use client";var K=Object.create;var x=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var oe=(e,o)=>{for(var s in o)x(e,s,{get:o[s],enumerable:!0})},V=(e,o,s,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of W(o))!te.call(e,i)&&i!==s&&x(e,i,{get:()=>o[i],enumerable:!(n=O(o,i))||n.enumerable});return e};var y=(e,o,s)=>(s=e!=null?K(ee(e)):{},V(o||!e||!e.__esModule?x(s,"default",{value:e,enumerable:!0}):s,e)),se=e=>V(x({},"__esModule",{value:!0}),e);var re={};oe(re,{default:()=>ie});module.exports=se(re);var t=require("react/jsx-runtime"),D=require("react-responsive"),r=y(require("react")),A=require("react-dom"),c=require("../../helpers/utils.js"),U=require("../../shared/Styles.js"),z=y(require("../SwiperBox/index.js")),l=require("../../components/index.js"),I=y(require("../Title/index.js")),H=require("../VideoModal/index.js"),R=require("../TextModal/index.js"),C=require("../../hooks/useExposure.js"),w=require("../../shared/trackUrlRef.js"),E=require("../AiuiProvider/index.js"),ae=require("swiper/css");const u="image",h="graphic",G=e=>{let o="";const s=m=>(m?.url&&(o=m.url),o),n=s(e.lgDesktop),i=s(e.desktop),p=s(e.laptop),g=s(e.tablet),b=e.default?.url;return[`${n} 9999`,`${i} 1919`,`${p} 1439`,`${g} 1024`,`${b} 768`].join(", ")},P="descTitle lg-desktop:text-[32px] desktop:mt-2 desktop:text-[24px] text-lines-2 mt-1 line-clamp-3 flex-1 text-[24px] font-bold leading-[1.2]",le=({data:e,configuration:o})=>{const s=(0,r.useRef)(null),[n,i]=(0,r.useState)({visible:!1,x:0,y:0,text:""}),p=o?.descriptionTag||"h3",g=()=>{switch(o.num){case 1:return"tablet:aspect-w-[704] tablet:aspect-h-[400] laptop:aspect-w-[896] laptop:aspect-h-[384] desktop:aspect-w-[1312] desktop:aspect-h-[512] lg-desktop:aspect-w-[1664] lg-desktop:aspect-h-[640]";case 2:return"tablet:aspect-w-[346] tablet:aspect-h-[360] laptop:aspect-w-[440] laptop:aspect-h-[360] desktop:aspect-w-[648] desktop:aspect-h-[384] lg-desktop:aspect-w-[824] lg-desktop:aspect-h-[480]";case 3:return"tablet:aspect-w-[296] tablet:aspect-h-[360] laptop:aspect-w-[288] laptop:aspect-h-[360] desktop:aspect-w-[427] desktop:aspect-h-[384] lg-desktop:aspect-w-[544] lg-desktop:aspect-h-[480]";default:return"tablet:aspect-w-[296] tablet:aspect-h-[360] laptop:aspect-w-[288] laptop:aspect-h-[360] desktop:aspect-w-[316] desktop:aspect-h-[384] lg-desktop:aspect-w-[404] lg-desktop:aspect-h-[480]"}},b=a=>{e?.description&&i({visible:!0,x:a.clientX,y:a.clientY,text:e.description})},m=()=>{i(a=>({...a,visible:!1}))};(0,C.useExposure)(s,{componentType:u,componentName:h,componentTitle:e?.title,componentDescription:e?.description,position:o?.index+1});const k=e?.href?"a":"div",T=e?.href?{href:(0,w.trackUrlRef)((0,c.getLocalizedPath)(e.href,o?.locale||"us"),`${u}_${h}`)}:{};return(0,t.jsx)("div",{ref:s,className:(0,c.cn)(g(),"graphicItem","laptop:h-auto text-info-primary md-tablet:h-[360px] flex-1 shrink-0 md:basis-[296px]",{"aiui-dark":e.theme==="dark"}),children:(0,t.jsx)("div",{className:(0,c.cn)("rounded-box absolute inset-0 overflow-hidden"),children:(0,t.jsxs)("div",{className:`graphic-children relative block size-full overflow-hidden ${e?.href?"cursor-pointer":""}`,children:[e?.href?(0,t.jsxs)("a",{"aria-label":e?.title||e?.description,href:(0,w.trackUrlRef)((0,c.getLocalizedPath)(e?.href||"",o?.locale||"us"),`${u}_${h}`),className:"rounded-card block size-full overflow-hidden","data-headless-nav-postion":`''#${o?.index+1}`,"data-headless-type-name":`${u}#${h}`,"data-headless-title-desc-button":`${e?.title}#${e?.description}`,children:[(0,t.jsx)(l.Picture,{className:"h-full",imgClassName:"h-full object-cover tablet:hover:scale-110 transition-all duration-300",source:e?.backgroundImage?.default?G(e.backgroundImage):e?.imgUrl?.url,alt:e?.backgroundImage?.lgDesktop?.alt||e?.backgroundImage?.default?.alt||e?.imgUrl?.alt||""}),(0,t.jsx)("span",{className:"sr-only",children:e?.title||e?.description})]}):(0,t.jsx)("div",{className:"rounded-card block size-full overflow-hidden",children:(0,t.jsx)(l.Picture,{className:"h-full",imgClassName:"h-full object-cover tablet:hover:scale-110 transition-all duration-300",source:e?.backgroundImage?.default?G(e.backgroundImage):e?.imgUrl?.url||"",alt:e?.backgroundImage?.lgDesktop?.alt||e?.backgroundImage?.default?.alt||e?.imgUrl?.alt||""})}),(0,t.jsxs)(k,{...T,className:(0,c.cn)("laptop:p-6 absolute bottom-0 z-[1] box-border flex w-full flex-col p-4",{"bg-gradient-to-b from-transparent to-black/80":e?.showBottomGradient&&e?.theme==="dark","bg-gradient-to-b from-transparent to-white/80":e?.showBottomGradient&&e?.theme!=="dark"}),children:[(0,t.jsxs)("div",{className:(0,c.cn)("flex items-end gap-1 overflow-hidden","graphic-bottom"),children:[(0,t.jsxs)("div",{className:"flex-1 overflow-hidden",children:[(0,t.jsx)(l.Text,{html:e?.title,style:{color:e?.textColor},className:"spanTitle graphic-title lg-desktop:text-lg desktop:text-base line-clamp-3 text-sm font-bold leading-[1.2]"}),e?.description&&(0,t.jsxs)("div",{onMouseMove:b,onMouseLeave:m,children:[e?.title?(0,t.jsx)(l.Heading,{html:e?.description,style:{color:e?.textColor},as:p,className:`${P} graphic-description`}):(0,t.jsx)(p,{style:{color:e?.textColor},dangerouslySetInnerHTML:{__html:e?.description||""},className:`${P} graphic-description-item`}),typeof window<"u"&&n.visible&&(0,A.createPortal)((0,t.jsx)(l.Text,{as:"div",html:n.text,className:"pointer-events-none fixed z-[9999] max-w-xs rounded-lg bg-black/60 px-3 py-2 text-sm text-white shadow-lg backdrop-blur-sm transition-opacity duration-200",style:{left:`${n.x+16}px`,top:`${n.y+16}px`}}),document.body)]})]}),!e?.isShowIcon&&(e?.video?.url||e?.youtubeId)&&(0,t.jsx)("button",{"aria-label":"Play Video",onClick:a=>{a.preventDefault(),a.stopPropagation(),o?.onVideoPlayBtnClick?.(o?.index||0,e)},className:"laptop:size-12 flex size-8 items-center justify-center rounded-full bg-white/20 hover:bg-black/75",children:(0,t.jsx)("svg",{width:"12",height:"14",viewBox:"0 0 12 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{d:"M12 7L0 14L0 0L12 7Z",fill:"white"})})}),e?.isShowIcon&&e?.icon?.url&&(0,t.jsx)("button",{onClick:a=>{a.preventDefault(),a.stopPropagation(),o?.onIconClick?.(e,o)},className:"laptop:size-9 flex size-8 items-center justify-center overflow-hidden rounded-full bg-white/20 hover:bg-black/75",children:(0,t.jsx)(l.Picture,{className:"h-full",imgClassName:"h-full object-cover",source:e?.icon?.url,alt:e?.icon?.alt||""})})]}),e.buttonText&&(0,t.jsx)(l.Button,{as:"a","aria-label":e?.title||e?.description,variant:"secondary",className:"bgButton mt-[8px] self-start",href:(0,w.trackUrlRef)((0,c.getLocalizedPath)(e?.href||"",o?.locale||"us"),`${u}_${h}`),"data-headless-nav-position":`''#${o?.index+1}`,"data-headless-type-name":`${u}#${h}`,"data-headless-title-desc-button":`${e?.title}#${e?.description}#${e?.buttonText}`,children:e.buttonText})]})]})})})},B=({items:e=[],sharedConfig:o})=>{const s=n=>{const i=e.length>3,p=e.length>2;switch(n){case 1440:return i?4:e.length;case 1024:return i?3:e.length;case 768:return e.length===1?1:i||p?2.3:2;default:return e.length===1?1:1.2}};return(0,t.jsx)(z.default,{id:"Graphic",className:(0,c.cn)("!overflow-visible"),data:{list:e,configuration:{...o,num:e.length}},Slide:le,breakpoints:{0:{spaceBetween:12,freeMode:!1,slidesPerView:1},374:{spaceBetween:12,freeMode:!1,slidesPerView:s()},768:{spaceBetween:16,freeMode:!1,slidesPerView:s(768)},1024:{spaceBetween:16,freeMode:!1,slidesPerView:s(1024)},1440:{spaceBetween:16,freeMode:!1,slidesPerView:s(1440)}}})},L=r.default.forwardRef(({data:e,className:o,...s},n)=>{const i=(0,D.useMediaQuery)({query:"(max-width: 768px)"}),p=(0,r.useRef)(null),[g,b]=(0,r.useState)(!1),[m,k]=(0,r.useState)(""),[T,a]=(0,r.useState)(""),[j,_]=(0,r.useState)(""),[Y,M]=(0,r.useState)(null),[q,N]=(0,r.useState)(!1),{locale:Q="us"}=(0,E.useAiuiContext)(),X=e?.isShowTab??!1,f=e?.tabs,Z=e?.tabAlign??"left",[F,J]=(0,r.useState)(f?.[0]?.id??"");(0,r.useImperativeHandle)(n,()=>p.current),(0,C.useExposure)(p,{componentType:u,componentName:h,componentTitle:e?.title});const $={itemShape:e?.itemShape,descriptionTag:e?.descriptionTag,locale:Q,onVideoPlayBtnClick:(d,v)=>{b(!0),v?.isYouTube?a?.(v?.youtubeId||""):(k?.(v?.video?.url||""),_?.(v?.mobileVideo?.url||""))},onIconClick:d=>{N(!0),M(d)}},S=()=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(H.VideoModal,{visible:g,youTubeId:T,onCloseModal:()=>b(!1),videoUrl:i&&j||m}),(0,t.jsx)(R.TextModal,{textVisible:q,extension:Y?.extension,onCloseModal:()=>{N(!1),M(null)}})]});return!X||!f||f.length===0?(0,t.jsxs)("div",{...s,ref:p,className:(0,c.cn)("graphicBlock",o),children:[(0,t.jsxs)("div",{className:"graphic-box",children:[e?.title&&(0,t.jsx)(I.default,{data:{title:e.title,align:e?.titleAlign??"left"}}),(0,t.jsx)(B,{items:e?.items,sharedConfig:$})]}),S()]}):(0,t.jsxs)("div",{...s,ref:p,className:(0,c.cn)("graphicBlock",o),children:[e?.title&&(0,t.jsx)(I.default,{data:{title:e.title,align:e?.titleAlign??"left"}}),(0,t.jsxs)(l.Tabs,{value:F,onValueChange:J,align:Z,children:[(0,t.jsx)("div",{className:"mb-[24px]",children:(0,t.jsx)(l.TabsList,{children:f.map(d=>(0,t.jsx)(l.TabsTrigger,{value:d.id,children:d.label},d.id))})}),f.map(d=>(0,t.jsx)(l.TabsContent,{value:d.id,children:(0,t.jsx)(B,{items:d.items,sharedConfig:$})},d.id))]}),S()]})});L.displayName="Graphic";var ie=(0,U.withLayout)(L);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as
|
|
1
|
+
"use client";import{Fragment as ne,jsx as t,jsxs as r}from"react/jsx-runtime";import{useMediaQuery as q}from"react-responsive";import Q,{useImperativeHandle as X,useRef as $,useState as p}from"react";import{createPortal as Z}from"react-dom";import{cn as m,getLocalizedPath as k}from"../../helpers/utils.js";import{withLayout as F}from"../../shared/Styles.js";import J from"../SwiperBox/index.js";import{Button as K,Heading as O,Picture as T,Text as S,Tabs as W,TabsList as ee,TabsTrigger as te,TabsContent as oe}from"../../components/index.js";import V from"../Title/index.js";import{VideoModal as se}from"../VideoModal/index.js";import{TextModal as le}from"../TextModal/index.js";import{useExposure as G}from"../../hooks/useExposure.js";import{trackUrlRef as y}from"../../shared/trackUrlRef.js";import{useAiuiContext as ie}from"../AiuiProvider/index.js";import"swiper/css";const u="image",h="graphic",P=e=>{let o="";const s=d=>(d?.url&&(o=d.url),o),n=s(e.lgDesktop),a=s(e.desktop),i=s(e.laptop),g=s(e.tablet),b=e.default?.url;return[`${n} 9999`,`${a} 1919`,`${i} 1439`,`${g} 1024`,`${b} 768`].join(", ")},B="descTitle lg-desktop:text-[32px] desktop:mt-2 desktop:text-[24px] text-lines-2 mt-1 line-clamp-3 flex-1 text-[24px] font-bold leading-[1.2]",re=({data:e,configuration:o})=>{const s=$(null),[n,a]=p({visible:!1,x:0,y:0,text:""}),i=o?.descriptionTag||"h3",g=()=>{switch(o.num){case 1:return"tablet:aspect-w-[704] tablet:aspect-h-[400] laptop:aspect-w-[896] laptop:aspect-h-[384] desktop:aspect-w-[1312] desktop:aspect-h-[512] lg-desktop:aspect-w-[1664] lg-desktop:aspect-h-[640]";case 2:return"tablet:aspect-w-[346] tablet:aspect-h-[360] laptop:aspect-w-[440] laptop:aspect-h-[360] desktop:aspect-w-[648] desktop:aspect-h-[384] lg-desktop:aspect-w-[824] lg-desktop:aspect-h-[480]";case 3:return"tablet:aspect-w-[296] tablet:aspect-h-[360] laptop:aspect-w-[288] laptop:aspect-h-[360] desktop:aspect-w-[427] desktop:aspect-h-[384] lg-desktop:aspect-w-[544] lg-desktop:aspect-h-[480]";default:return"tablet:aspect-w-[296] tablet:aspect-h-[360] laptop:aspect-w-[288] laptop:aspect-h-[360] desktop:aspect-w-[316] desktop:aspect-h-[384] lg-desktop:aspect-w-[404] lg-desktop:aspect-h-[480]"}},b=l=>{e?.description&&a({visible:!0,x:l.clientX,y:l.clientY,text:e.description})},d=()=>{a(l=>({...l,visible:!1}))};G(s,{componentType:u,componentName:h,componentTitle:e?.title,componentDescription:e?.description,position:o?.index+1});const x=e?.href?"a":"div",w=e?.href?{href:y(k(e.href,o?.locale||"us"),`${u}_${h}`)}:{};return t("div",{ref:s,className:m(g(),"graphicItem","laptop:h-auto text-info-primary md-tablet:h-[360px] flex-1 shrink-0 md:basis-[296px]",{"aiui-dark":e.theme==="dark"}),children:t("div",{className:m("rounded-box absolute inset-0 overflow-hidden"),children:r("div",{className:`graphic-children relative block size-full overflow-hidden ${e?.href?"cursor-pointer":""}`,children:[e?.href?r("a",{"aria-label":e?.title||e?.description,href:y(k(e?.href||"",o?.locale||"us"),`${u}_${h}`),className:"rounded-card block size-full overflow-hidden","data-headless-nav-postion":`''#${o?.index+1}`,"data-headless-type-name":`${u}#${h}`,"data-headless-title-desc-button":`${e?.title}#${e?.description}`,children:[t(T,{className:"h-full",imgClassName:"h-full object-cover tablet:hover:scale-110 transition-all duration-300",source:e?.backgroundImage?.default?P(e.backgroundImage):e?.imgUrl?.url,alt:e?.backgroundImage?.lgDesktop?.alt||e?.backgroundImage?.default?.alt||e?.imgUrl?.alt||""}),t("span",{className:"sr-only",children:e?.title||e?.description})]}):t("div",{className:"rounded-card block size-full overflow-hidden",children:t(T,{className:"h-full",imgClassName:"h-full object-cover tablet:hover:scale-110 transition-all duration-300",source:e?.backgroundImage?.default?P(e.backgroundImage):e?.imgUrl?.url||"",alt:e?.backgroundImage?.lgDesktop?.alt||e?.backgroundImage?.default?.alt||e?.imgUrl?.alt||""})}),r(x,{...w,className:m("laptop:p-6 absolute bottom-0 z-[1] box-border flex w-full flex-col p-4",{"bg-gradient-to-b from-transparent to-black/80":e?.showBottomGradient&&e?.theme==="dark","bg-gradient-to-b from-transparent to-white/80":e?.showBottomGradient&&e?.theme!=="dark"}),children:[r("div",{className:m("flex items-end gap-1 overflow-hidden","graphic-bottom"),children:[r("div",{className:"flex-1 overflow-hidden",children:[t(S,{html:e?.title,style:{color:e?.textColor},className:"spanTitle graphic-title lg-desktop:text-lg desktop:text-base line-clamp-3 text-sm font-bold leading-[1.2]"}),e?.description&&r("div",{onMouseMove:b,onMouseLeave:d,children:[e?.title?t(O,{html:e?.description,style:{color:e?.textColor},as:i,className:`${B} graphic-description`}):t(i,{style:{color:e?.textColor},dangerouslySetInnerHTML:{__html:e?.description||""},className:`${B} graphic-description-item`}),typeof window<"u"&&n.visible&&Z(t(S,{as:"div",html:n.text,className:"pointer-events-none fixed z-[9999] max-w-xs rounded-lg bg-black/60 px-3 py-2 text-sm text-white shadow-lg backdrop-blur-sm transition-opacity duration-200",style:{left:`${n.x+16}px`,top:`${n.y+16}px`}}),document.body)]})]}),!e?.isShowIcon&&(e?.video?.url||e?.youtubeId)&&t("button",{"aria-label":"Play Video",onClick:l=>{l.preventDefault(),l.stopPropagation(),o?.onVideoPlayBtnClick?.(o?.index||0,e)},className:"laptop:size-12 flex size-8 items-center justify-center rounded-full bg-white/20 hover:bg-black/75",children:t("svg",{width:"12",height:"14",viewBox:"0 0 12 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M12 7L0 14L0 0L12 7Z",fill:"white"})})}),e?.isShowIcon&&e?.icon?.url&&t("button",{onClick:l=>{l.preventDefault(),l.stopPropagation(),o?.onIconClick?.(e,o)},className:"laptop:size-9 flex size-8 items-center justify-center overflow-hidden rounded-full bg-white/20 hover:bg-black/75",children:t(T,{className:"h-full",imgClassName:"h-full object-cover",source:e?.icon?.url,alt:e?.icon?.alt||""})})]}),e.buttonText&&t(K,{as:"a","aria-label":e?.title||e?.description,variant:"secondary",className:"bgButton mt-[8px] self-start",href:y(k(e?.href||"",o?.locale||"us"),`${u}_${h}`),"data-headless-nav-position":`''#${o?.index+1}`,"data-headless-type-name":`${u}#${h}`,"data-headless-title-desc-button":`${e?.title}#${e?.description}#${e?.buttonText}`,children:e.buttonText})]})]})})})},L=({items:e=[],sharedConfig:o})=>{const s=n=>{const a=e.length>3,i=e.length>2;switch(n){case 1440:return a?4:e.length;case 1024:return a?3:e.length;case 768:return e.length===1?1:a||i?2.3:2;default:return e.length===1?1:1.2}};return t(J,{id:"Graphic",className:m("!overflow-visible"),data:{list:e,configuration:{...o,num:e.length}},Slide:re,breakpoints:{0:{spaceBetween:12,freeMode:!1,slidesPerView:1},374:{spaceBetween:12,freeMode:!1,slidesPerView:s()},768:{spaceBetween:16,freeMode:!1,slidesPerView:s(768)},1024:{spaceBetween:16,freeMode:!1,slidesPerView:s(1024)},1440:{spaceBetween:16,freeMode:!1,slidesPerView:s(1440)}}})},D=Q.forwardRef(({data:e,className:o,...s},n)=>{const a=q({query:"(max-width: 768px)"}),i=$(null),[g,b]=p(!1),[d,x]=p(""),[w,l]=p(""),[A,U]=p(""),[z,I]=p(null),[H,C]=p(!1),{locale:R="us"}=ie(),E=e?.isShowTab??!1,f=e?.tabs,j=e?.tabAlign??"left",[_,Y]=p(f?.[0]?.id??"");X(n,()=>i.current),G(i,{componentType:u,componentName:h,componentTitle:e?.title});const M={itemShape:e?.itemShape,descriptionTag:e?.descriptionTag,locale:R,onVideoPlayBtnClick:(c,v)=>{b(!0),v?.isYouTube?l?.(v?.youtubeId||""):(x?.(v?.video?.url||""),U?.(v?.mobileVideo?.url||""))},onIconClick:c=>{C(!0),I(c)}},N=()=>r(ne,{children:[t(se,{visible:g,youTubeId:w,onCloseModal:()=>b(!1),videoUrl:a&&A||d}),t(le,{textVisible:H,extension:z?.extension,onCloseModal:()=>{C(!1),I(null)}})]});return!E||!f||f.length===0?r("div",{...s,ref:i,className:m("graphicBlock",o),children:[r("div",{className:"graphic-box",children:[e?.title&&t(V,{data:{title:e.title,align:e?.titleAlign??"left"}}),t(L,{items:e?.items,sharedConfig:M})]}),N()]}):r("div",{...s,ref:i,className:m("graphicBlock",o),children:[e?.title&&t(V,{data:{title:e.title,align:e?.titleAlign??"left"}}),r(W,{value:_,onValueChange:Y,align:j,children:[t("div",{className:"mb-[24px]",children:t(ee,{children:f.map(c=>t(te,{value:c.id,children:c.label},c.id))})}),f.map(c=>t(oe,{value:c.id,children:t(L,{items:c.items,sharedConfig:M})},c.id))]}),N()]})});D.displayName="Graphic";var Te=F(D);export{Te as default};
|