1 |
- import{aw as oe,be as Ae,ew as Be,am as ne,bI as Pe,r as f,K as B,a as e,bk as $e,bR as X,L as O,b6 as Ve,l as se,cU as ze,aH as Oe,bQ as Re,c4 as De,bU as je,d as W,ay as re,o as L,c as P,g as q,v as ie,w as Q,x as R,Z as N,b3 as D,f as j,aM as ue,bv as Fe,a4 as F,$ as ce,P as K,bw as Ke,az as ve,au as de,F as Ue,q as We,t as qe,aA as he,bL as Qe,e as Xe,m as Ye,bH as Ze,aB as Ge,aF as Je,__tla as ea}from"./index-c6f9ee0e.js";import{t as me,__tla as aa}from"./el-image-viewer-7498b9bf.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)},Y=Symbol("carouselContextKey"),Ie=(o,S,i)=>{const{children:n,addChild:T,removeChild:g}=Be(ne(),"ElCarouselItem"),M=Pe(),s=f(-1),d=f(null),I=f(!1),h=f(),C=f(0),y=f(!0),_=B(()=>o.arrow!=="never"&&!e(u)),b=B(()=>n.value.some(a=>a.props.label.toString().length>0)),x=B(()=>o.type==="card"),u=B(()=>o.direction==="vertical"),p=B(()=>o.height!=="auto"?{height:o.height}:{height:`${C.value}px`,overflow:"hidden"}),$=me(a=>{w(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 w(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 X(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&&S("change",a,t)}),O(()=>o.autoplay,a=>{a?H():E()}),O(()=>o.loop,()=>{w(s.value)}),O(()=>o.interval,()=>{l()});const m=Ve();return se(()=>{O(()=>n.value,()=>{n.value.length>0&&w(o.initialIndex)},{immediate:!0}),m.value=ze(h.value,()=>{v()}),H()}),Oe(()=>{E(),h.value&&m.value&&m.value.stop()}),Re(Y,{root:h,isCardType:x,isVertical:u,items:n,loop:o.loop,addItem:T,removeItem:g,setActiveItem:w,setContainerHeight:function(a){o.height==="auto"&&(C.value=a)}}),{root:h,activeIndex:s,arrowDisplay:_,hasLabel:b,hover:I,isCardType:x,items:n,isVertical:u,containerStyle:p,isItemsTwoLength:y,handleButtonEnter:function(a){e(u)||n.value.forEach((t,r)=>{a===function(c,k){var U,J,ee,ae;const z=e(n),te=z.length;if(te===0||!c.states.inStage)return!1;const xe=k+1,Ee=k-1,le=te-1,He=z[le].states.active,Le=z[0].states.active,Ne=(J=(U=z[xe])==null?void 0:U.states)==null?void 0:J.active,Te=(ae=(ee=z[Ee])==null?void 0:ee.states)==null?void 0:ae.active;return k===le&&Le||Ne?"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:w,prev:function(){w(s.value-1)},next:function(){w(s.value+1)},PlaceholderItem:function(){var a;const t=(a=M.default)==null?void 0:a.call(M);if(!t)return null;const r=De(t).filter(c=>je(c)&&c.type.name==="ElCarouselItem");return(r==null?void 0:r.length)===2&&o.loop&&!x.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"],we={key:0},Z="ElCarousel",ke=W({name:Z});var Ce=he(W({...ke,props:ge,emits:ye,setup(o,{expose:S,emit:i}){const n=o,{root:T,activeIndex:g,arrowDisplay:M,hasLabel:s,hover:d,isCardType:I,items:h,isVertical:C,containerStyle:y,handleButtonEnter:_,handleButtonLeave:b,handleIndicatorClick:x,handleMouseEnter:u,handleMouseLeave:p,setActiveItem:$,prev:V,next:E,PlaceholderItem:H,isTwoLengthShow:A,throttledArrowClick:w,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(C)&&t.push(l.em("indicators","right")),t});return S({setActiveItem:$,prev:V,next:E}),(t,r)=>(L(),P("div",{ref_key:"root",ref:T,class:N(e(m)),onMouseenter:r[6]||(r[6]=D((...c)=>e(u)&&e(u)(...c),["stop"])),onMouseleave:r[7]||(r[7]=D((...c)=>e(p)&&e(p)(...c),["stop"]))},[q("div",{class:N(e(l).e("container")),style:de(e(y))},[e(M)?(L(),ie(ce,{key:0,name:"carousel-arrow-left",persisted:""},{default:Q(()=>[R(q("button",{type:"button",class:N([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]=D(c=>e(w)(e(g)-1),["stop"]))},[j(e(ue),null,{default:Q(()=>[j(e(Fe))]),_:1})],34),[[F,(t.arrow==="always"||e(d))&&(n.loop||e(g)>0)]])]),_:1})):K("v-if",!0),e(M)?(L(),ie(ce,{key:1,name:"carousel-arrow-right",persisted:""},{default:Q(()=>[R(q("button",{type:"button",class:N([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]=D(c=>e(w)(e(g)+1),["stop"]))},[j(e(ue),null,{default:Q(()=>[j(e(Ke))]),_:1})],34),[[F,(t.arrow==="always"||e(d))&&(n.loop||e(g)<e(h).length-1)]])]),_:1})):K("v-if",!0),j(e(H)),ve(t.$slots,"default")],6),t.indicatorPosition!=="none"?(L(),P("ul",{key:0,class:N(e(a))},[(L(!0),P(Ue,null,We(e(h),(c,k)=>R((L(),P("li",{key:k,class:N([e(l).e("indicator"),e(l).em("indicator",t.direction),e(l).is("active",k===e(g))]),onMouseenter:U=>e(v)(k),onClick:D(U=>e(x)(k),["stop"])},[q("button",{class:N(e(l).e("button"))},[e(s)?(L(),P("span",we,qe(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:""}}),Se=(o,S)=>{const i=Qe(Y),n=ne();i||X(S,"usage: <el-carousel></el-carousel-item></el-carousel>"),n||X(S,"compositional hook can only be invoked inside setups");const T=.83,g=f(),M=f(!1),s=f(0),d=f(1),I=f(!1),h=f(!1),C=f(!1),y=f(!1),{isCardType:_,isVertical:b}=i,x=(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 w=e(b);I.value=A,E?(C.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 C.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,w),h.value=!0,A&&g.value&&i.setContainerHeight(g.value.offsetHeight)};return se(()=>{i.addItem({props:o,states:Xe({hover:M,translate:s,scale:d,active:I,ready:h,inStage:C,animating:y}),uid:n.uid,translateItem:x})}),Ye(()=>{i.removeItem(n.uid)}),{carouselItemRef:g,active:I,animating:y,hover:M,inStage:C,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)}}}},Me=W({name:"ElCarouselItem"});var G=he(W({...Me,props:_e,setup(o){const S=o,i=re("carousel"),{carouselItemRef:n,active:T,animating:g,hover:M,inStage:s,isVertical:d,translate:I,isCardType:h,scale:C,ready:y,handleItemClick:_}=Se(S,"ElCarouselItem"),b=B(()=>({transform:[`${"translate"+(e(d)?"Y":"X")}(${e(I)}px)`,`scale(${e(C)})`].join(" ")}));return(x,u)=>R((L(),P("div",{ref_key:"carouselItemRef",ref:n,class:N([e(i).e("item"),e(i).is("active",e(T)),e(i).is("in-stage",e(s)),e(i).is("hover",e(M)),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((L(),P("div",{key:0,class:N(e(i).e("mask"))},null,2)),[[F,!e(T)]]):K("v-if",!0),ve(x.$slots,"default")],6)),[[F,e(y)]])}}),[["__file","/home/runner/work/element-plus/element-plus/packages/components/carousel/src/carousel-item.vue"]]);fe=Ge(Ce,{CarouselItem:G}),pe=Je(G)});export{pe as E,ta as __tla,fe as a};
|