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