1 |
- import{aD as oe,bl as Ae,ex as Be,am as ne,b4 as Pe,r as f,K as B,a as e,bq as $e,bU as U,L as O,be as Ve,k as se,d2 as De,aA as Oe,at as Re,c7 as qe,bX as ze,d as X,aF as re,o as N,c as P,g as j,v as ie,w as G,x as R,Z as L,av as q,f as z,ax as ue,bB as Fe,a4 as F,$ as ce,P as K,bC as Ke,aG as ve,ay as de,F as We,q as Xe,t as je,aH as he,bP as Ge,e as Ue,l as Ye,bN as Ze,aI as Je,aM as Qe,__tla as ea}from"./index-430b3151.js";import{t as me,__tla as aa}from"./el-image-viewer-467ebe35.js";let pe,fe,ta=Promise.all([(()=>{try{return ea}catch{}})(),(()=>{try{return aa}catch{}})()]).then(async()=>{const ge=oe({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}}),ye={change:(o,x)=>[o,x].every(Ae)},Y=Symbol("carouselContextKey"),Ie=(o,x,i)=>{const{children:n,addChild:T,removeChild:g}=Be(ne(),"ElCarouselItem"),S=Pe(),s=f(-1),d=f(null),I=f(!1),h=f(),w=f(0),y=f(!0),_=B(()=>o.arrow!=="never"&&!e(u)),b=B(()=>n.value.some(a=>a.props.label.toString().length>0)),M=B(()=>o.type==="card"),u=B(()=>o.direction==="vertical"),p=B(()=>o.height!=="auto"?{height:o.height}:{height:`${w.value}px`,overflow:"hidden"}),$=me(a=>{C(a)},300,{trailing:!0}),V=me(a=>{(function(t){o.trigger==="hover"&&t!==s.value&&(s.value=t)})(a)},300);function E(){d.value&&(clearInterval(d.value),d.value=null)}function H(){o.interval<=0||!o.autoplay||d.value||(d.value=setInterval(()=>A(),o.interval))}const A=()=>{s.value<n.value.length-1?s.value=s.value+1:o.loop&&(s.value=0)};function C(a){if($e(a)){const c=n.value.filter(k=>k.props.name===a);c.length>0&&(a=n.value.indexOf(c[0]))}if(a=Number(a),Number.isNaN(a)||a!==Math.floor(a))return void U(i,"index must be integer.");const t=n.value.length,r=s.value;s.value=a<0?o.loop?t-1:0:a>=t?o.loop?0:t-1:a,r===s.value&&v(r),l()}function v(a){n.value.forEach((t,r)=>{t.translateItem(r,s.value,a)})}function l(){E(),o.pauseOnHover||H()}O(()=>s.value,(a,t)=>{v(t),y.value&&(a%=2,t%=2),t>-1&&x("change",a,t)}),O(()=>o.autoplay,a=>{a?H():E()}),O(()=>o.loop,()=>{C(s.value)}),O(()=>o.interval,()=>{l()});const m=Ve();return se(()=>{O(()=>n.value,()=>{n.value.length>0&&C(o.initialIndex)},{immediate:!0}),m.value=De(h.value,()=>{v()}),H()}),Oe(()=>{E(),h.value&&m.value&&m.value.stop()}),Re(Y,{root:h,isCardType:M,isVertical:u,items:n,loop:o.loop,addItem:T,removeItem:g,setActiveItem:C,setContainerHeight:function(a){o.height==="auto"&&(w.value=a)}}),{root:h,activeIndex:s,arrowDisplay:_,hasLabel:b,hover:I,isCardType:M,items:n,isVertical:u,containerStyle:p,isItemsTwoLength:y,handleButtonEnter:function(a){e(u)||n.value.forEach((t,r)=>{a===function(c,k){var W,Q,ee,ae;const D=e(n),te=D.length;if(te===0||!c.states.inStage)return!1;const Me=k+1,Ee=k-1,le=te-1,He=D[le].states.active,Ne=D[0].states.active,Le=(Q=(W=D[Me])==null?void 0:W.states)==null?void 0:Q.active,Te=(ae=(ee=D[Ee])==null?void 0:ee.states)==null?void 0:ae.active;return k===le&&Ne||Le?"left":!!(k===0&&He||Te)&&"right"}(t,r)&&(t.states.hover=!0)})},handleButtonLeave:function(){e(u)||n.value.forEach(a=>{a.states.hover=!1})},handleIndicatorClick:function(a){s.value=a},handleMouseEnter:function(){I.value=!0,o.pauseOnHover&&E()},handleMouseLeave:function(){I.value=!1,H()},setActiveItem:C,prev:function(){C(s.value-1)},next:function(){C(s.value+1)},PlaceholderItem:function(){var a;const t=(a=S.default)==null?void 0:a.call(S);if(!t)return null;const r=qe(t).filter(c=>ze(c)&&c.type.name==="ElCarouselItem");return(r==null?void 0:r.length)===2&&o.loop&&!M.value?(y.value=!0,r):(y.value=!1,null)},isTwoLengthShow:a=>!y.value||(s.value<=1?a<=1:a>1),throttledArrowClick:$,throttledIndicatorHover:V}},be=["onMouseenter","onClick"],Ce={key:0},Z="ElCarousel",ke=X({name:Z});var we=he(X({...ke,props:ge,emits:ye,setup(o,{expose:x,emit:i}){const n=o,{root:T,activeIndex:g,arrowDisplay:S,hasLabel:s,hover:d,isCardType:I,items:h,isVertical:w,containerStyle:y,handleButtonEnter:_,handleButtonLeave:b,handleIndicatorClick:M,handleMouseEnter:u,handleMouseLeave:p,setActiveItem:$,prev:V,next:E,PlaceholderItem:H,isTwoLengthShow:A,throttledArrowClick:C,throttledIndicatorHover:v}=Ie(n,i,Z),l=re("carousel"),m=B(()=>{const t=[l.b(),l.m(n.direction)];return e(I)&&t.push(l.m("card")),t}),a=B(()=>{const t=[l.e("indicators"),l.em("indicators",n.direction)];return e(s)&&t.push(l.em("indicators","labels")),n.indicatorPosition==="outside"&&t.push(l.em("indicators","outside")),e(w)&&t.push(l.em("indicators","right")),t});return x({setActiveItem:$,prev:V,next:E}),(t,r)=>(N(),P("div",{ref_key:"root",ref:T,class:L(e(m)),onMouseenter:r[6]||(r[6]=q((...c)=>e(u)&&e(u)(...c),["stop"])),onMouseleave:r[7]||(r[7]=q((...c)=>e(p)&&e(p)(...c),["stop"]))},[j("div",{class:L(e(l).e("container")),style:de(e(y))},[e(S)?(N(),ie(ce,{key:0,name:"carousel-arrow-left",persisted:""},{default:G(()=>[R(j("button",{type:"button",class:L([e(l).e("arrow"),e(l).em("arrow","left")]),onMouseenter:r[0]||(r[0]=c=>e(_)("left")),onMouseleave:r[1]||(r[1]=(...c)=>e(b)&&e(b)(...c)),onClick:r[2]||(r[2]=q(c=>e(C)(e(g)-1),["stop"]))},[z(e(ue),null,{default:G(()=>[z(e(Fe))]),_:1})],34),[[F,(t.arrow==="always"||e(d))&&(n.loop||e(g)>0)]])]),_:1})):K("v-if",!0),e(S)?(N(),ie(ce,{key:1,name:"carousel-arrow-right",persisted:""},{default:G(()=>[R(j("button",{type:"button",class:L([e(l).e("arrow"),e(l).em("arrow","right")]),onMouseenter:r[3]||(r[3]=c=>e(_)("right")),onMouseleave:r[4]||(r[4]=(...c)=>e(b)&&e(b)(...c)),onClick:r[5]||(r[5]=q(c=>e(C)(e(g)+1),["stop"]))},[z(e(ue),null,{default:G(()=>[z(e(Ke))]),_:1})],34),[[F,(t.arrow==="always"||e(d))&&(n.loop||e(g)<e(h).length-1)]])]),_:1})):K("v-if",!0),z(e(H)),ve(t.$slots,"default")],6),t.indicatorPosition!=="none"?(N(),P("ul",{key:0,class:L(e(a))},[(N(!0),P(We,null,Xe(e(h),(c,k)=>R((N(),P("li",{key:k,class:L([e(l).e("indicator"),e(l).em("indicator",t.direction),e(l).is("active",k===e(g))]),onMouseenter:W=>e(v)(k),onClick:q(W=>e(M)(k),["stop"])},[j("button",{class:L(e(l).e("button"))},[e(s)?(N(),P("span",Ce,je(c.props.label),1)):K("v-if",!0)],2)],42,be)),[[F,e(A)(k)]])),128))],2)):K("v-if",!0)],34))}}),[["__file","/home/runner/work/element-plus/element-plus/packages/components/carousel/src/carousel.vue"]]);const _e=oe({name:{type:String,default:""},label:{type:[String,Number],default:""}}),xe=(o,x)=>{const i=Ge(Y),n=ne();i||U(x,"usage: <el-carousel></el-carousel-item></el-carousel>"),n||U(x,"compositional hook can only be invoked inside setups");const T=.83,g=f(),S=f(!1),s=f(0),d=f(1),I=f(!1),h=f(!1),w=f(!1),y=f(!1),{isCardType:_,isVertical:b}=i,M=(u,p,$)=>{var V;const E=e(_),H=(V=i.items.value.length)!=null?V:Number.NaN,A=u===p;E||Ze($)||(y.value=A||u===$),!A&&H>2&&i.loop&&(u=function(v,l,m){const a=m-1,t=m/2;return l===0&&v===a?-1:l===a&&v===0?m:v<l-1&&l-v>=t?m+1:v>l+1&&v-l>=t?-2:v}(u,p,H));const C=e(b);I.value=A,E?(w.value=Math.round(Math.abs(u-p))<=1,s.value=function(v,l){var m,a;const t=e(b)?((m=i.root.value)==null?void 0:m.offsetHeight)||0:((a=i.root.value)==null?void 0:a.offsetWidth)||0;return w.value?t*(1.17*(v-l)+1)/4:v<l?-1.83*t/4:3.83*t/4}(u,p),d.value=e(I)?1:T):s.value=function(v,l,m){const a=i.root.value;return a?((m?a.offsetHeight:a.offsetWidth)||0)*(v-l):0}(u,p,C),h.value=!0,A&&g.value&&i.setContainerHeight(g.value.offsetHeight)};return se(()=>{i.addItem({props:o,states:Ue({hover:S,translate:s,scale:d,active:I,ready:h,inStage:w,animating:y}),uid:n.uid,translateItem:M})}),Ye(()=>{i.removeItem(n.uid)}),{carouselItemRef:g,active:I,animating:y,hover:S,inStage:w,isVertical:b,translate:s,isCardType:_,scale:d,ready:h,handleItemClick:function(){if(i&&e(_)){const u=i.items.value.findIndex(({uid:p})=>p===n.uid);i.setActiveItem(u)}}}},Se=X({name:"ElCarouselItem"});var J=he(X({...Se,props:_e,setup(o){const x=o,i=re("carousel"),{carouselItemRef:n,active:T,animating:g,hover:S,inStage:s,isVertical:d,translate:I,isCardType:h,scale:w,ready:y,handleItemClick:_}=xe(x,"ElCarouselItem"),b=B(()=>({transform:[`${"translate"+(e(d)?"Y":"X")}(${e(I)}px)`,`scale(${e(w)})`].join(" ")}));return(M,u)=>R((N(),P("div",{ref_key:"carouselItemRef",ref:n,class:L([e(i).e("item"),e(i).is("active",e(T)),e(i).is("in-stage",e(s)),e(i).is("hover",e(S)),e(i).is("animating",e(g)),{[e(i).em("item","card")]:e(h),[e(i).em("item","card-vertical")]:e(h)&&e(d)}]),style:de(e(b)),onClick:u[0]||(u[0]=(...p)=>e(_)&&e(_)(...p))},[e(h)?R((N(),P("div",{key:0,class:L(e(i).e("mask"))},null,2)),[[F,!e(T)]]):K("v-if",!0),ve(M.$slots,"default")],6)),[[F,e(y)]])}}),[["__file","/home/runner/work/element-plus/element-plus/packages/components/carousel/src/carousel-item.vue"]]);fe=Je(we,{CarouselItem:J}),pe=Qe(J)});export{pe as E,ta as __tla,fe as a};
|