index.5129965e.js 8.8 KB

1
  1. import{s as ce,bi as ve,bj as fe,aq as de,bb as Le,bk as Ae,r as C,y as P,k as e,W as K,C as me,aU as Be,be as Oe,S as Pe,a7 as Ve,a5 as he,f as x,N as pe,o as B,c as D,a as Q,m as ne,w as Z,$ as G,a2 as O,a3 as q,b as X,B as le,bl as Re,a0 as J,bm as re,n as Y,av as ze,R as ge,a4 as ye,H as De,I as je,t as Ue,_ as Ie,O as We,j as Fe,b6 as Ke,aF as qe,as as Xe,at as Ye}from"./entry.97b97815.js";import{t as ie}from"./throttle.3cebe6b3.js";const Ge=(a,_,n)=>ve(a.subTree).filter(u=>{var v;return fe(u)&&((v=u.type)==null?void 0:v.name)===_&&!!u.component}).map(u=>u.component.uid).map(u=>n[u]).filter(u=>!!u),Je=(a,_)=>{const n={},s=ce([]);return{children:s,addChild:v=>{n[v.uid]=v,s.value=Ge(a,_,n)},removeChild:v=>{delete n[v],s.value=s.value.filter(o=>o.uid!==v)}}},Qe=de({initialIndex:{type:Number,default:0},height:{type:String,default:""},trigger:{type:String,values:["hover","click"],default:"hover"},autoplay:{type:Boolean,default:!0},interval:{type:Number,default:3e3},indicatorPosition:{type:String,values:["","none","outside"],default:""},arrow:{type:String,values:["always","hover","never"],default:"hover"},type:{type:String,values:["","card"],default:""},loop:{type:Boolean,default:!0},direction:{type:String,values:["horizontal","vertical"],default:"horizontal"},pauseOnHover:{type:Boolean,default:!0}}),Ze={change:(a,_)=>[a,_].every(Le)},Ce=Symbol("carouselContextKey"),ue=300,xe=(a,_,n)=>{const{children:s,addChild:b,removeChild:u}=Je(he(),"ElCarouselItem"),v=Ae(),o=C(-1),p=C(null),k=C(!1),g=C(),E=C(0),w=C(!0),T=P(()=>a.arrow!=="never"&&!e(S)),N=P(()=>s.value.some(t=>t.props.label.toString().length>0)),L=P(()=>a.type==="card"),S=P(()=>a.direction==="vertical"),M=P(()=>a.height!=="auto"?{height:a.height}:{height:`${E.value}px`,overflow:"hidden"}),A=ie(t=>{d(t)},ue,{trailing:!0}),j=ie(t=>{ee(t)},ue),l=t=>w.value?o.value<=1?t<=1:t>1:!0;function r(){p.value&&(clearInterval(p.value),p.value=null)}function f(){a.interval<=0||!a.autoplay||p.value||(p.value=setInterval(()=>h(),a.interval))}const h=()=>{o.value<s.value.length-1?o.value=o.value+1:a.loop&&(o.value=0)};function d(t){if(Ve(t)){const z=s.value.filter(V=>V.props.name===t);z.length>0&&(t=s.value.indexOf(z[0]))}if(t=Number(t),Number.isNaN(t)||t!==Math.floor(t))return;const c=s.value.length,H=o.value;t<0?o.value=a.loop?c-1:0:t>=c?o.value=a.loop?0:c-1:o.value=t,H===o.value&&i(H),ae()}function i(t){s.value.forEach((c,H)=>{c.translateItem(H,o.value,t)})}function $(t,c){var H,z,V,W;const F=e(s),se=F.length;if(se===0||!t.states.inStage)return!1;const Ne=c+1,Ee=c-1,oe=se-1,Te=F[oe].states.active,Me=F[0].states.active,$e=(z=(H=F[Ne])==null?void 0:H.states)==null?void 0:z.active,He=(W=(V=F[Ee])==null?void 0:V.states)==null?void 0:W.active;return c===oe&&Me||$e?"left":c===0&&Te||He?"right":!1}function U(){k.value=!0,a.pauseOnHover&&r()}function y(){k.value=!1,f()}function m(t){e(S)||s.value.forEach((c,H)=>{t===$(c,H)&&(c.states.hover=!0)})}function I(){e(S)||s.value.forEach(t=>{t.states.hover=!1})}function R(t){o.value=t}function ee(t){a.trigger==="hover"&&t!==o.value&&(o.value=t)}function we(){d(o.value-1)}function Se(){d(o.value+1)}function ae(){r(),a.pauseOnHover||f()}function _e(t){a.height==="auto"&&(E.value=t)}function ke(){var t;const c=(t=v.default)==null?void 0:t.call(v);if(!c)return null;const H=ve(c),z="ElCarouselItem",V=H.filter(W=>fe(W)&&W.type.name===z);return(V==null?void 0:V.length)===2&&a.loop&&!L.value?(w.value=!0,V):(w.value=!1,null)}K(()=>o.value,(t,c)=>{i(c),w.value&&(t=t%2,c=c%2),c>-1&&_("change",t,c)}),K(()=>a.autoplay,t=>{t?f():r()}),K(()=>a.loop,()=>{d(o.value)}),K(()=>a.interval,()=>{ae()});const te=ce();return me(()=>{K(()=>s.value,()=>{s.value.length>0&&d(a.initialIndex)},{immediate:!0}),te.value=Be(g.value,()=>{i()}),f()}),Oe(()=>{r(),g.value&&te.value&&te.value.stop()}),Pe(Ce,{root:g,isCardType:L,isVertical:S,items:s,loop:a.loop,addItem:b,removeItem:u,setActiveItem:d,setContainerHeight:_e}),{root:g,activeIndex:o,arrowDisplay:T,hasLabel:N,hover:k,isCardType:L,items:s,isVertical:S,containerStyle:M,isItemsTwoLength:w,handleButtonEnter:m,handleButtonLeave:I,handleIndicatorClick:R,handleMouseEnter:U,handleMouseLeave:y,setActiveItem:d,prev:we,next:Se,PlaceholderItem:ke,isTwoLengthShow:l,throttledArrowClick:A,throttledIndicatorHover:j}},et=["onMouseenter","onClick"],tt={key:0},at="ElCarousel",st=x({name:at}),ot=x({...st,props:Qe,emits:Ze,setup(a,{expose:_,emit:n}){const s=a,{root:b,activeIndex:u,arrowDisplay:v,hasLabel:o,hover:p,isCardType:k,items:g,isVertical:E,containerStyle:w,handleButtonEnter:T,handleButtonLeave:N,handleIndicatorClick:L,handleMouseEnter:S,handleMouseLeave:M,setActiveItem:A,prev:j,next:l,PlaceholderItem:r,isTwoLengthShow:f,throttledArrowClick:h,throttledIndicatorHover:d}=xe(s,n),i=pe("carousel"),$=P(()=>{const y=[i.b(),i.m(s.direction)];return e(k)&&y.push(i.m("card")),y}),U=P(()=>{const y=[i.e("indicators"),i.em("indicators",s.direction)];return e(o)&&y.push(i.em("indicators","labels")),s.indicatorPosition==="outside"&&y.push(i.em("indicators","outside")),e(E)&&y.push(i.em("indicators","right")),y});return _({setActiveItem:A,prev:j,next:l}),(y,m)=>(B(),D("div",{ref_key:"root",ref:b,class:O(e($)),onMouseenter:m[6]||(m[6]=q((...I)=>e(S)&&e(S)(...I),["stop"])),onMouseleave:m[7]||(m[7]=q((...I)=>e(M)&&e(M)(...I),["stop"]))},[Q("div",{class:O(e(i).e("container")),style:ye(e(w))},[e(v)?(B(),ne(re,{key:0,name:"carousel-arrow-left",persisted:""},{default:Z(()=>[G(Q("button",{type:"button",class:O([e(i).e("arrow"),e(i).em("arrow","left")]),onMouseenter:m[0]||(m[0]=I=>e(T)("left")),onMouseleave:m[1]||(m[1]=(...I)=>e(N)&&e(N)(...I)),onClick:m[2]||(m[2]=q(I=>e(h)(e(u)-1),["stop"]))},[X(e(le),null,{default:Z(()=>[X(e(Re))]),_:1})],34),[[J,(y.arrow==="always"||e(p))&&(s.loop||e(u)>0)]])]),_:1})):Y("v-if",!0),e(v)?(B(),ne(re,{key:1,name:"carousel-arrow-right",persisted:""},{default:Z(()=>[G(Q("button",{type:"button",class:O([e(i).e("arrow"),e(i).em("arrow","right")]),onMouseenter:m[3]||(m[3]=I=>e(T)("right")),onMouseleave:m[4]||(m[4]=(...I)=>e(N)&&e(N)(...I)),onClick:m[5]||(m[5]=q(I=>e(h)(e(u)+1),["stop"]))},[X(e(le),null,{default:Z(()=>[X(e(ze))]),_:1})],34),[[J,(y.arrow==="always"||e(p))&&(s.loop||e(u)<e(g).length-1)]])]),_:1})):Y("v-if",!0),X(e(r)),ge(y.$slots,"default")],6),y.indicatorPosition!=="none"?(B(),D("ul",{key:0,class:O(e(U))},[(B(!0),D(De,null,je(e(g),(I,R)=>G((B(),D("li",{key:R,class:O([e(i).e("indicator"),e(i).em("indicator",y.direction),e(i).is("active",R===e(u))]),onMouseenter:ee=>e(d)(R),onClick:q(ee=>e(L)(R),["stop"])},[Q("button",{class:O(e(i).e("button"))},[e(o)?(B(),D("span",tt,Ue(I.props.label),1)):Y("v-if",!0)],2)],42,et)),[[J,e(f)(R)]])),128))],2)):Y("v-if",!0)],34))}});var nt=Ie(ot,[["__file","carousel.vue"]]);const lt=de({name:{type:String,default:""},label:{type:[String,Number],default:""}}),rt=(a,_)=>{const n=We(Ce),s=he(),b=.83,u=C(),v=C(!1),o=C(0),p=C(1),k=C(!1),g=C(!1),E=C(!1),w=C(!1),{isCardType:T,isVertical:N}=n;function L(l,r,f){const h=f-1,d=r-1,i=r+1,$=f/2;return r===0&&l===h?-1:r===h&&l===0?f:l<d&&r-l>=$?f+1:l>i&&l-r>=$?-2:l}function S(l,r){var f,h;const d=e(N)?((f=n.root.value)==null?void 0:f.offsetHeight)||0:((h=n.root.value)==null?void 0:h.offsetWidth)||0;return E.value?d*((2-b)*(l-r)+1)/4:l<r?-(1+b)*d/4:(3+b)*d/4}function M(l,r,f){const h=n.root.value;return h?((f?h.offsetHeight:h.offsetWidth)||0)*(l-r):0}const A=(l,r,f)=>{var h;const d=e(T),i=(h=n.items.value.length)!=null?h:Number.NaN,$=l===r;!d&&!qe(f)&&(w.value=$||l===f),!$&&i>2&&n.loop&&(l=L(l,r,i));const U=e(N);k.value=$,d?(E.value=Math.round(Math.abs(l-r))<=1,o.value=S(l,r),p.value=e(k)?1:b):o.value=M(l,r,U),g.value=!0,$&&u.value&&n.setContainerHeight(u.value.offsetHeight)};function j(){if(n&&e(T)){const l=n.items.value.findIndex(({uid:r})=>r===s.uid);n.setActiveItem(l)}}return me(()=>{n.addItem({props:a,states:Fe({hover:v,translate:o,scale:p,active:k,ready:g,inStage:E,animating:w}),uid:s.uid,translateItem:A})}),Ke(()=>{n.removeItem(s.uid)}),{carouselItemRef:u,active:k,animating:w,hover:v,inStage:E,isVertical:N,translate:o,isCardType:T,scale:p,ready:g,handleItemClick:j}},it=x({name:"ElCarouselItem"}),ut=x({...it,props:lt,setup(a){const _=a,n=pe("carousel"),{carouselItemRef:s,active:b,animating:u,hover:v,inStage:o,isVertical:p,translate:k,isCardType:g,scale:E,ready:w,handleItemClick:T}=rt(_),N=P(()=>[n.e("item"),n.is("active",b.value),n.is("in-stage",o.value),n.is("hover",v.value),n.is("animating",u.value),{[n.em("item","card")]:g.value,[n.em("item","card-vertical")]:g.value&&p.value}]),L=P(()=>{const M=`${`translate${e(p)?"Y":"X"}`}(${e(k)}px)`,A=`scale(${e(E)})`;return{transform:[M,A].join(" ")}});return(S,M)=>G((B(),D("div",{ref_key:"carouselItemRef",ref:s,class:O(e(N)),style:ye(e(L)),onClick:M[0]||(M[0]=(...A)=>e(T)&&e(T)(...A))},[e(g)?G((B(),D("div",{key:0,class:O(e(n).e("mask"))},null,2)),[[J,!e(b)]]):Y("v-if",!0),ge(S.$slots,"default")],6)),[[J,e(w)]])}});var be=Ie(ut,[["__file","carousel-item.vue"]]);const ft=Xe(nt,{CarouselItem:be}),dt=Ye(be);export{ft as E,dt as a};