You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
222 lines
22 KiB
222 lines
22 KiB
import{X as Ke,P as gt,i as xt,d as G,s as T,a4 as bt,G as w,c as h,v as Ue,S as We,O as wt,E as yt,ad as St,t as q,Q as Ee,y as Ct,z as Rt,T as Pt,n as zt,B as kt,p as _t,o as Se,f as It,w as Dt,b as Ae,F as Nt,r as Vt,m as $t}from"./index-bVOhw2NF.js";import{v as Tt,u as ce,c as Et,a as c,b as V,d,f as Ze,h as At}from"./light-Cua7cqmF.js";import{c as Mt}from"./context-KbjOeZY_.js";import{i as jt}from"./index-L98eAIry.js";import{t as Bt}from"./toString-eibgRg41.js";import{u as Ot}from"./upperFirst-Bq7Kgunw.js";import{c as Lt}from"./_createCompounder-D746aL6M.js";import{k as Me}from"./keep-B1eBS8j0.js";import{u as Xt}from"./use-merged-state-CzrzZJbg.js";import{c as Ft}from"./light-DhWiRhmf.js";import{f as Yt}from"./flatten-7z_8MaI9.js";import{V as je}from"./VResizeObserver-Tzd5ds8d.js";import{b as Be}from"./resolve-slot-Dzko3qih.js";import{g as Kt}from"./get-precise-event-target-DhO46Lpt.js";import{o as Z,a as H}from"./delegate-CI_DDEu_.js";import"./_initCloneObject-K-Y0ueWp.js";import"./_baseFor-mOzdmxoL.js";function Ut(e){return Ot(Bt(e).toLowerCase())}var Oe=Lt(function(e,o,a){return o=o.toLowerCase(),e+(a?Ut(o):o)});function Wt(e){const{length:o}=e;return o>1&&(e.push(Le(e[0],0,"append")),e.unshift(Le(e[o-1],o-1,"prepend"))),e}function Le(e,o,a){return Ke(e,{key:`carousel-item-duplicate-${o}-${a}`})}function Xe(e,o,a){return o===1?0:a?e===0?o-3:e===o-1?0:e-1:e}function Ce(e,o){return o?e+1:e}function Zt(e,o,a){return e<0?null:e===0?a?o-1:null:e-1}function Ht(e,o,a){return e>o-1?null:e===o-1?a?0:null:e+1}function qt(e,o){return o&&e>3?e-2:e}function Fe(e){return window.TouchEvent&&e instanceof window.TouchEvent}function Ye(e,o){let{offsetWidth:a,offsetHeight:i}=e;if(o){const f=getComputedStyle(e);a=a-Number.parseFloat(f.getPropertyValue("padding-left"))-Number.parseFloat(f.getPropertyValue("padding-right")),i=i-Number.parseFloat(f.getPropertyValue("padding-top"))-Number.parseFloat(f.getPropertyValue("padding-bottom"))}return{width:a,height:i}}function le(e,o,a){return e<o?o:e>a?a:e}function Gt(e){if(e===void 0)return 0;if(typeof e=="number")return e;const o=/^((\d+)?\.?\d+?)(ms|s)?$/,a=e.match(o);if(a){const[,i,,f="ms"]=a;return Number(i)*(f==="ms"?1:1e3)}return 0}const He=Mt("n-carousel-methods");function Qt(e){gt(He,e)}function Pe(e="unknown",o="component"){const a=xt(He);return a||Tt(e,`\`${o}\` must be placed inside \`n-carousel\`.`),a}const Jt={total:{type:Number,default:0},currentIndex:{type:Number,default:0},dotType:{type:String,default:"dot"},trigger:{type:String,default:"click"},keyboard:Boolean},en=G({name:"CarouselDots",props:Jt,setup(e){const{mergedClsPrefixRef:o}=ce(e),a=T([]),i=Pe();function f(g,v){switch(g.key){case"Enter":case" ":g.preventDefault(),i.to(v);return}e.keyboard&&y(g)}function p(g){e.trigger==="hover"&&i.to(g)}function C(g){e.trigger==="click"&&i.to(g)}function y(g){var v;if(g.shiftKey||g.altKey||g.ctrlKey||g.metaKey)return;const b=(v=document.activeElement)===null||v===void 0?void 0:v.nodeName.toLowerCase();if(b==="input"||b==="textarea")return;const{code:P}=g,M=P==="PageUp"||P==="ArrowUp",j=P==="PageDown"||P==="ArrowDown",R=P==="PageUp"||P==="ArrowRight",z=P==="PageDown"||P==="ArrowLeft",k=i.isVertical(),E=k?M:R,Y=k?j:z;!E&&!Y||(g.preventDefault(),E&&!i.isNextDisabled()?(i.next(),S(i.currentIndexRef.value)):Y&&!i.isPrevDisabled()&&(i.prev(),S(i.currentIndexRef.value)))}function S(g){var v;(v=a.value[g])===null||v===void 0||v.focus()}return bt(()=>a.value.length=0),{mergedClsPrefix:o,dotEls:a,handleKeydown:f,handleMouseenter:p,handleClick:C}},render(){const{mergedClsPrefix:e,dotEls:o}=this;return w("div",{class:[`${e}-carousel__dots`,`${e}-carousel__dots--${this.dotType}`],role:"tablist"},jt(this.total,a=>{const i=a===this.currentIndex;return w("div",{"aria-selected":i,ref:f=>o.push(f),role:"button",tabindex:"0",class:[`${e}-carousel__dot`,i&&`${e}-carousel__dot--active`],key:a,onClick:()=>{this.handleClick(a)},onMouseenter:()=>{this.handleMouseenter(a)},onKeydown:f=>{this.handleKeydown(f,a)}})}))}}),tn=w("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16"},w("g",{fill:"none"},w("path",{d:"M10.26 3.2a.75.75 0 0 1 .04 1.06L6.773 8l3.527 3.74a.75.75 0 1 1-1.1 1.02l-4-4.25a.75.75 0 0 1 0-1.02l4-4.25a.75.75 0 0 1 1.06-.04z",fill:"currentColor"}))),nn=w("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16"},w("g",{fill:"none"},w("path",{d:"M5.74 3.2a.75.75 0 0 0-.04 1.06L9.227 8L5.7 11.74a.75.75 0 1 0 1.1 1.02l4-4.25a.75.75 0 0 0 0-1.02l-4-4.25a.75.75 0 0 0-1.06-.04z",fill:"currentColor"}))),on=G({name:"CarouselArrow",setup(e){const{mergedClsPrefixRef:o}=ce(e),{isVertical:a,isPrevDisabled:i,isNextDisabled:f,prev:p,next:C}=Pe();return{mergedClsPrefix:o,isVertical:a,isPrevDisabled:i,isNextDisabled:f,prev:p,next:C}},render(){const{mergedClsPrefix:e}=this;return w("div",{class:`${e}-carousel__arrow-group`},w("div",{class:[`${e}-carousel__arrow`,this.isPrevDisabled()&&`${e}-carousel__arrow--disabled`],role:"button",onClick:this.prev},tn),w("div",{class:[`${e}-carousel__arrow`,this.isNextDisabled()&&`${e}-carousel__arrow--disabled`],role:"button",onClick:this.next},nn))}}),ue="CarouselItem";function an(e){var o;return((o=e.type)===null||o===void 0?void 0:o.name)===ue}const rn=G({name:ue,setup(e){const{mergedClsPrefixRef:o}=ce(e),a=Pe(Oe(ue),`n-${Oe(ue)}`),i=T(),f=h(()=>{const{value:v}=i;return v?a.getSlideIndex(v):-1}),p=h(()=>a.isPrev(f.value)),C=h(()=>a.isNext(f.value)),y=h(()=>a.isActive(f.value)),S=h(()=>a.getSlideStyle(f.value));Ue(()=>{a.addSlide(i.value)}),We(()=>{a.removeSlide(i.value)});function g(v){const{value:b}=f;b!==void 0&&(a==null||a.onCarouselItemClick(b,v))}return{mergedClsPrefix:o,selfElRef:i,isPrev:p,isNext:C,isActive:y,index:f,style:S,handleClick:g}},render(){var e;const{$slots:o,mergedClsPrefix:a,isPrev:i,isNext:f,isActive:p,index:C,style:y}=this,S=[`${a}-carousel__slide`,{[`${a}-carousel__slide--current`]:p,[`${a}-carousel__slide--prev`]:i,[`${a}-carousel__slide--next`]:f}];return w("div",{ref:"selfElRef",class:S,role:"option",tabindex:"-1","data-index":C,"aria-hidden":!p,style:y,onClickCapture:this.handleClick},(e=o.default)===null||e===void 0?void 0:e.call(o,{isPrev:i,isNext:f,isActive:p,index:C}))}}),sn=Et("carousel",`
|
|
position: relative;
|
|
width: 100%;
|
|
height: 100%;
|
|
touch-action: pan-y;
|
|
overflow: hidden;
|
|
`,[c("slides",`
|
|
display: flex;
|
|
width: 100%;
|
|
height: 100%;
|
|
transition-timing-function: var(--n-bezier);
|
|
transition-property: transform;
|
|
`,[c("slide",`
|
|
flex-shrink: 0;
|
|
position: relative;
|
|
width: 100%;
|
|
height: 100%;
|
|
outline: none;
|
|
overflow: hidden;
|
|
`,[V("> img",`
|
|
display: block;
|
|
`)])]),c("dots",`
|
|
position: absolute;
|
|
display: flex;
|
|
flex-wrap: nowrap;
|
|
`,[d("dot",[c("dot",`
|
|
height: var(--n-dot-size);
|
|
width: var(--n-dot-size);
|
|
background-color: var(--n-dot-color);
|
|
border-radius: 50%;
|
|
cursor: pointer;
|
|
transition:
|
|
box-shadow .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier);
|
|
outline: none;
|
|
`,[V("&:focus",`
|
|
background-color: var(--n-dot-color-focus);
|
|
`),d("active",`
|
|
background-color: var(--n-dot-color-active);
|
|
`)])]),d("line",[c("dot",`
|
|
border-radius: 9999px;
|
|
width: var(--n-dot-line-width);
|
|
height: 4px;
|
|
background-color: var(--n-dot-color);
|
|
cursor: pointer;
|
|
transition:
|
|
width .3s var(--n-bezier),
|
|
box-shadow .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier);
|
|
outline: none;
|
|
`,[V("&:focus",`
|
|
background-color: var(--n-dot-color-focus);
|
|
`),d("active",`
|
|
width: var(--n-dot-line-width-active);
|
|
background-color: var(--n-dot-color-active);
|
|
`)])])]),c("arrow",`
|
|
transition: background-color .3s var(--n-bezier);
|
|
cursor: pointer;
|
|
height: 28px;
|
|
width: 28px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background-color: rgba(255, 255, 255, .2);
|
|
color: var(--n-arrow-color);
|
|
border-radius: 8px;
|
|
user-select: none;
|
|
-webkit-user-select: none;
|
|
font-size: 18px;
|
|
`,[V("svg",`
|
|
height: 1em;
|
|
width: 1em;
|
|
`),V("&:hover",`
|
|
background-color: rgba(255, 255, 255, .3);
|
|
`)]),d("vertical",`
|
|
touch-action: pan-x;
|
|
`,[c("slides",`
|
|
flex-direction: column;
|
|
`),d("fade",[c("slide",`
|
|
top: 50%;
|
|
left: unset;
|
|
transform: translateY(-50%);
|
|
`)]),d("card",[c("slide",`
|
|
top: 50%;
|
|
left: unset;
|
|
transform: translateY(-50%) translateZ(-400px);
|
|
`,[d("current",`
|
|
transform: translateY(-50%) translateZ(0);
|
|
`),d("prev",`
|
|
transform: translateY(-100%) translateZ(-200px);
|
|
`),d("next",`
|
|
transform: translateY(0%) translateZ(-200px);
|
|
`)])])]),d("usercontrol",[c("slides",[V(">",[V("div",`
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
width: 100%;
|
|
height: 100%;
|
|
transform: translate(-50%, -50%);
|
|
`)])])]),d("left",[c("dots",`
|
|
transform: translateY(-50%);
|
|
top: 50%;
|
|
left: 12px;
|
|
flex-direction: column;
|
|
`,[d("line",[c("dot",`
|
|
width: 4px;
|
|
height: var(--n-dot-line-width);
|
|
margin: 4px 0;
|
|
transition:
|
|
height .3s var(--n-bezier),
|
|
box-shadow .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier);
|
|
outline: none;
|
|
`,[d("active",`
|
|
height: var(--n-dot-line-width-active);
|
|
`)])])]),c("dot",`
|
|
margin: 4px 0;
|
|
`)]),c("arrow-group",`
|
|
position: absolute;
|
|
display: flex;
|
|
flex-wrap: nowrap;
|
|
`),d("vertical",[c("arrow",`
|
|
transform: rotate(90deg);
|
|
`)]),d("show-arrow",[d("bottom",[c("dots",`
|
|
transform: translateX(0);
|
|
bottom: 18px;
|
|
left: 18px;
|
|
`)]),d("top",[c("dots",`
|
|
transform: translateX(0);
|
|
top: 18px;
|
|
left: 18px;
|
|
`)]),d("left",[c("dots",`
|
|
transform: translateX(0);
|
|
top: 18px;
|
|
left: 18px;
|
|
`)]),d("right",[c("dots",`
|
|
transform: translateX(0);
|
|
top: 18px;
|
|
right: 18px;
|
|
`)])]),d("left",[c("arrow-group",`
|
|
bottom: 12px;
|
|
left: 12px;
|
|
flex-direction: column;
|
|
`,[V("> *:first-child",`
|
|
margin-bottom: 12px;
|
|
`)])]),d("right",[c("dots",`
|
|
transform: translateY(-50%);
|
|
top: 50%;
|
|
right: 12px;
|
|
flex-direction: column;
|
|
`,[d("line",[c("dot",`
|
|
width: 4px;
|
|
height: var(--n-dot-line-width);
|
|
margin: 4px 0;
|
|
transition:
|
|
height .3s var(--n-bezier),
|
|
box-shadow .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier);
|
|
outline: none;
|
|
`,[d("active",`
|
|
height: var(--n-dot-line-width-active);
|
|
`)])])]),c("dot",`
|
|
margin: 4px 0;
|
|
`),c("arrow-group",`
|
|
bottom: 12px;
|
|
right: 12px;
|
|
flex-direction: column;
|
|
`,[V("> *:first-child",`
|
|
margin-bottom: 12px;
|
|
`)])]),d("top",[c("dots",`
|
|
transform: translateX(-50%);
|
|
top: 12px;
|
|
left: 50%;
|
|
`,[d("line",[c("dot",`
|
|
margin: 0 4px;
|
|
`)])]),c("dot",`
|
|
margin: 0 4px;
|
|
`),c("arrow-group",`
|
|
top: 12px;
|
|
right: 12px;
|
|
`,[V("> *:first-child",`
|
|
margin-right: 12px;
|
|
`)])]),d("bottom",[c("dots",`
|
|
transform: translateX(-50%);
|
|
bottom: 12px;
|
|
left: 50%;
|
|
`,[d("line",[c("dot",`
|
|
margin: 0 4px;
|
|
`)])]),c("dot",`
|
|
margin: 0 4px;
|
|
`),c("arrow-group",`
|
|
bottom: 12px;
|
|
right: 12px;
|
|
`,[V("> *:first-child",`
|
|
margin-right: 12px;
|
|
`)])]),d("fade",[c("slide",`
|
|
position: absolute;
|
|
opacity: 0;
|
|
transition-property: opacity;
|
|
pointer-events: none;
|
|
`,[d("current",`
|
|
opacity: 1;
|
|
pointer-events: auto;
|
|
`)])]),d("card",[c("slides",`
|
|
perspective: 1000px;
|
|
`),c("slide",`
|
|
position: absolute;
|
|
left: 50%;
|
|
opacity: 0;
|
|
transform: translateX(-50%) translateZ(-400px);
|
|
transition-property: opacity, transform;
|
|
`,[d("current",`
|
|
opacity: 1;
|
|
transform: translateX(-50%) translateZ(0);
|
|
z-index: 1;
|
|
`),d("prev",`
|
|
opacity: 0.4;
|
|
transform: translateX(-100%) translateZ(-200px);
|
|
`),d("next",`
|
|
opacity: 0.4;
|
|
transform: translateX(0%) translateZ(-200px);
|
|
`)])])]),ln=["transitionDuration","transitionTimingFunction"],un=Object.assign(Object.assign({},Ze.props),{defaultIndex:{type:Number,default:0},currentIndex:Number,showArrow:Boolean,dotType:{type:String,default:"dot"},dotPlacement:{type:String,default:"bottom"},slidesPerView:{type:[Number,String],default:1},spaceBetween:{type:Number,default:0},centeredSlides:Boolean,direction:{type:String,default:"horizontal"},autoplay:Boolean,interval:{type:Number,default:5e3},loop:{type:Boolean,default:!0},effect:{type:String,default:"slide"},showDots:{type:Boolean,default:!0},trigger:{type:String,default:"click"},transitionStyle:{type:Object,default:()=>({transitionDuration:"300ms"})},transitionProps:Object,draggable:Boolean,prevSlideStyle:[Object,String],nextSlideStyle:[Object,String],touchable:{type:Boolean,default:!0},mousewheel:Boolean,keyboard:Boolean,"onUpdate:currentIndex":Function,onUpdateCurrentIndex:Function});let Re=!1;const cn=G({name:"Carousel",props:un,setup(e){const{mergedClsPrefixRef:o,inlineThemeDisabled:a}=ce(e),i=T(null),f=T(null),p=T([]),C={value:[]},y=h(()=>e.direction==="vertical"),S=h(()=>y.value?"height":"width"),g=h(()=>y.value?"bottom":"right"),v=h(()=>e.effect==="slide"),b=h(()=>e.loop&&e.slidesPerView===1&&v.value),P=h(()=>e.effect==="custom"),M=h(()=>!v.value||e.centeredSlides?1:e.slidesPerView),j=h(()=>P.value?1:e.slidesPerView),R=h(()=>M.value==="auto"||e.slidesPerView==="auto"&&e.centeredSlides),z=T({width:0,height:0}),k=h(()=>{const{value:t}=p;if(!t.length)return[];const{value:n}=R;if(n)return t.map(x=>Ye(x));const{value:r}=j,{value:l}=z,{value:u}=S;let s=l[u];if(r!=="auto"){const{spaceBetween:x}=e,_=s-(r-1)*x,ie=1/Math.max(1,r);s=_*ie}const m=Object.assign(Object.assign({},l),{[u]:s});return t.map(()=>m)}),E=h(()=>{const{value:t}=k;if(!t.length)return[];const{centeredSlides:n,spaceBetween:r}=e,{value:l}=S,{[l]:u}=z.value;let s=0;return t.map(({[l]:m})=>{let x=s;return n&&(x+=(m-u)/2),s+=m+r,x})}),Y=T(!1),de=h(()=>{const{transitionStyle:t}=e;return t?Me(t,ln):{}}),fe=h(()=>P.value?0:Gt(de.value.transitionDuration)),ze=h(()=>{const{value:t}=p;if(!t.length)return[];const n=!(R.value||j.value===1),r=m=>{if(n){const{value:x}=S;return{[x]:`${k.value[m][x]}px`}}};if(P.value)return t.map((m,x)=>r(x));const{effect:l,spaceBetween:u}=e,{value:s}=g;return t.reduce((m,x,_)=>{const ie=Object.assign(Object.assign({},r(_)),{[`margin-${s}`]:`${u}px`});return m.push(ie),Y.value&&(l==="fade"||l==="card")&&Object.assign(ie,de.value),m},[])}),I=h(()=>{const{value:t}=M,{length:n}=p.value;if(t!=="auto")return Math.max(n-t,0)+1;{const{value:r}=k,{length:l}=r;if(!l)return n;const{value:u}=E,{value:s}=S,m=z.value[s];let x=r[r.length-1][s],_=l;for(;_>1&&x<m;)_--,x+=u[_]-u[_-1];return le(_+1,1,l)}}),Q=h(()=>qt(I.value,b.value)),qe=Ce(e.defaultIndex,b.value),ve=T(Xe(qe,I.value,b.value)),$=Xt(wt(e,"currentIndex"),ve),D=h(()=>Ce($.value,b.value));function K(t){var n,r;t=le(t,0,I.value-1);const l=Xe(t,I.value,b.value),{value:u}=$;l!==$.value&&(ve.value=l,(n=e["onUpdate:currentIndex"])===null||n===void 0||n.call(e,l,u),(r=e.onUpdateCurrentIndex)===null||r===void 0||r.call(e,l,u))}function J(t=D.value){return Zt(t,I.value,e.loop)}function ee(t=D.value){return Ht(t,I.value,e.loop)}function Ge(t){const n=O(t);return n!==null&&J()===n}function Qe(t){const n=O(t);return n!==null&&ee()===n}function ke(t){return D.value===O(t)}function Je(t){return $.value===t}function _e(){return J()===null}function Ie(){return ee()===null}function pe(t){const n=le(Ce(t,b.value),0,I.value);(t!==$.value||n!==D.value)&&K(n)}function he(){const t=J();t!==null&&K(t)}function te(){const t=ee();t!==null&&K(t)}let N=!1;function et(){(!N||!b.value)&&he()}function tt(){(!N||!b.value)&&te()}let B=0;const me=T({});function ne(t,n=0){me.value=Object.assign({},de.value,{transform:y.value?`translateY(${-t}px)`:`translateX(${-t}px)`,transitionDuration:`${n}ms`})}function U(t=0){v.value?ge(D.value,t):B!==0&&(!N&&t>0&&(N=!0),ne(B=0,t))}function ge(t,n){const r=De(t);r!==B&&n>0&&(N=!0),B=De(D.value),ne(r,n)}function De(t){let n;return t>=I.value-1?n=Ne():n=E.value[t]||0,n}function Ne(){if(M.value==="auto"){const{value:t}=S,{[t]:n}=z.value,{value:r}=E,l=r[r.length-1];let u;if(l===void 0)u=n;else{const{value:s}=k;u=l+s[s.length-1][t]}return u-n}else{const{value:t}=E;return t[I.value-1]||0}}const W={currentIndexRef:$,to:pe,prev:et,next:tt,isVertical:()=>y.value,isHorizontal:()=>!y.value,isPrev:Ge,isNext:Qe,isActive:ke,isPrevDisabled:_e,isNextDisabled:Ie,getSlideIndex:O,getSlideStyle:at,addSlide:nt,removeSlide:ot,onCarouselItemClick:rt};Qt(W);function nt(t){t&&p.value.push(t)}function ot(t){if(!t)return;const n=O(t);n!==-1&&p.value.splice(n,1)}function O(t){return typeof t=="number"?t:t?p.value.indexOf(t):-1}function at(t){const n=O(t);if(n!==-1){const r=[ze.value[n]],l=W.isPrev(n),u=W.isNext(n);return l&&r.push(e.prevSlideStyle||""),u&&r.push(e.nextSlideStyle||""),zt(r)}}let xe=0,be=0,A=0,we=0,oe=!1,ye=!1;function rt(t,n){let r=!N&&!oe&&!ye;e.effect==="card"&&r&&!ke(t)&&(pe(t),r=!1),r||(n.preventDefault(),n.stopPropagation())}let ae=null;function re(){ae&&(clearInterval(ae),ae=null)}function L(){re(),!e.autoplay||Q.value<2||(ae=window.setInterval(te,e.interval))}function Ve(t){var n;if(Re||!(!((n=f.value)===null||n===void 0)&&n.contains(Kt(t))))return;Re=!0,oe=!0,ye=!1,we=Date.now(),re(),t.type!=="touchstart"&&!t.target.isContentEditable&&t.preventDefault();const r=Fe(t)?t.touches[0]:t;y.value?be=r.clientY:xe=r.clientX,e.touchable&&(Z("touchmove",document,se),Z("touchend",document,X),Z("touchcancel",document,X)),e.draggable&&(Z("mousemove",document,se),Z("mouseup",document,X))}function se(t){const{value:n}=y,{value:r}=S,l=Fe(t)?t.touches[0]:t,u=n?l.clientY-be:l.clientX-xe,s=z.value[r];A=le(u,-s,s),t.cancelable&&t.preventDefault(),v.value&&ne(B-A,0)}function X(){const{value:t}=D;let n=t;if(!N&&A!==0&&v.value){const r=B-A,l=[...E.value.slice(0,I.value-1),Ne()];let u=null;for(let s=0;s<l.length;s++){const m=Math.abs(l[s]-r);if(u!==null&&u<m)break;u=m,n=s}}if(n===t){const r=Date.now()-we,{value:l}=S,u=z.value[l];A>u/2||A/r>.4?n=J(t):(A<-u/2||A/r<-.4)&&(n=ee(t))}n!==null&&n!==t?(ye=!0,K(n),Ee(()=>{(!b.value||ve.value!==$.value)&&U(fe.value)})):U(fe.value),$e(),L()}function $e(){oe&&(Re=!1),oe=!1,xe=0,be=0,A=0,we=0,H("touchmove",document,se),H("touchend",document,X),H("touchcancel",document,X),H("mousemove",document,se),H("mouseup",document,X)}function st(){if(v.value&&N){const{value:t}=D;ge(t,0)}else L();v.value&&(me.value.transitionDuration="0ms"),N=!1}function it(t){if(t.preventDefault(),N)return;let{deltaX:n,deltaY:r}=t;t.shiftKey&&!n&&(n=r);const l=-1,u=1,s=(n||r)>0?u:l;let m=0,x=0;y.value?x=s:m=s;const _=10;(x*r>=_||m*n>=_)&&(s===u&&!Ie()?te():s===l&&!_e()&&he())}function lt(){z.value=Ye(i.value,!0),L()}function ut(){var t,n;R.value&&((n=(t=k.effect).scheduler)===null||n===void 0||n.call(t),k.effect.run())}function ct(){e.autoplay&&re()}function dt(){e.autoplay&&L()}Ue(()=>{yt(L),requestAnimationFrame(()=>Y.value=!0)}),We(()=>{$e(),re()}),St(()=>{const{value:t}=p,{value:n}=C,r=new Map,l=s=>r.has(s)?r.get(s):-1;let u=!1;for(let s=0;s<t.length;s++){const m=n.findIndex(x=>x.el===t[s]);m!==s&&(u=!0),r.set(t[s],m)}u&&t.sort((s,m)=>l(s)-l(m))}),q(D,(t,n)=>{if(t!==n)if(L(),v.value){if(b.value){const{value:r}=I;Q.value>2&&t===r-2&&n===1?t=0:t===1&&n===r-2&&(t=r-1)}ge(t,fe.value)}else U()},{immediate:!0}),q([b,M],()=>void Ee(()=>{K(D.value)})),q(E,()=>{v.value&&U()},{deep:!0}),q(v,t=>{t?U():(N=!1,ne(B=0))});const ft=h(()=>({onTouchstartPassive:e.touchable?Ve:void 0,onMousedown:e.draggable?Ve:void 0,onWheel:e.mousewheel?it:void 0})),vt=h(()=>Object.assign(Object.assign({},Me(W,["to","prev","next","isPrevDisabled","isNextDisabled"])),{total:Q.value,currentIndex:$.value})),pt=h(()=>({total:Q.value,currentIndex:$.value,to:W.to})),ht={getCurrentIndex:()=>$.value,to:pe,prev:he,next:te},mt=Ze("Carousel","-carousel",sn,Ft,e,o),Te=h(()=>{const{common:{cubicBezierEaseInOut:t},self:{dotSize:n,dotColor:r,dotColorActive:l,dotColorFocus:u,dotLineWidth:s,dotLineWidthActive:m,arrowColor:x}}=mt.value;return{"--n-bezier":t,"--n-dot-color":r,"--n-dot-color-focus":u,"--n-dot-color-active":l,"--n-dot-size":n,"--n-dot-line-width":s,"--n-dot-line-width-active":m,"--n-arrow-color":x}}),F=a?At("carousel",void 0,Te,e):void 0;return Object.assign(Object.assign({mergedClsPrefix:o,selfElRef:i,slidesElRef:f,slideVNodes:C,duplicatedable:b,userWantsControl:P,autoSlideSize:R,realIndex:D,slideStyles:ze,translateStyle:me,slidesControlListeners:ft,handleTransitionEnd:st,handleResize:lt,handleSlideResize:ut,handleMouseenter:ct,handleMouseleave:dt,isActive:Je,arrowSlotProps:vt,dotSlotProps:pt},ht),{cssVars:a?void 0:Te,themeClass:F==null?void 0:F.themeClass,onRender:F==null?void 0:F.onRender})},render(){var e;const{mergedClsPrefix:o,showArrow:a,userWantsControl:i,slideStyles:f,dotType:p,dotPlacement:C,slidesControlListeners:y,transitionProps:S={},arrowSlotProps:g,dotSlotProps:v,$slots:{default:b,dots:P,arrow:M}}=this,j=b&&Yt(b())||[];let R=dn(j);return R.length||(R=j.map(z=>w(rn,null,{default:()=>Ke(z)}))),this.duplicatedable&&(R=Wt(R)),this.slideVNodes.value=R,this.autoSlideSize&&(R=R.map(z=>w(je,{onResize:this.handleSlideResize},{default:()=>z}))),(e=this.onRender)===null||e===void 0||e.call(this),w("div",Object.assign({ref:"selfElRef",class:[this.themeClass,`${o}-carousel`,this.direction==="vertical"&&`${o}-carousel--vertical`,this.showArrow&&`${o}-carousel--show-arrow`,`${o}-carousel--${C}`,`${o}-carousel--${this.direction}`,`${o}-carousel--${this.effect}`,i&&`${o}-carousel--usercontrol`],style:this.cssVars},y,{onMouseenter:this.handleMouseenter,onMouseleave:this.handleMouseleave}),w(je,{onResize:this.handleResize},{default:()=>w("div",{ref:"slidesElRef",class:`${o}-carousel__slides`,role:"listbox",style:this.translateStyle,onTransitionend:this.handleTransitionEnd},i?R.map((z,k)=>w("div",{style:f[k],key:k},Ct(w(Pt,Object.assign({},S),{default:()=>z}),[[Rt,this.isActive(k)]]))):R)}),this.showDots&&v.total>1&&Be(P,v,()=>[w(en,{key:p+C,total:v.total,currentIndex:v.currentIndex,dotType:p,trigger:this.trigger,keyboard:this.keyboard})]),a&&Be(M,g,()=>[w(on,null)]))}});function dn(e){return e.reduce((o,a)=>(an(a)&&o.push(a),o),[])}const fn=G({name:"EsCarousel",components:{},props:{options:{type:Object,default:()=>({})},datasets:{type:[Array,Object,String],default:()=>[]},eventData:{type:[String,Boolean,Number],default:""},element:{type:Object,default:()=>({})}},emits:["updateValue","update:eventData"],setup(e,{emit:o}){function a(p){o("update:eventData",p),o("updateValue",p)}const i=T(1);function f(p){i.value=p}return q(()=>e.options.currentPage,p=>{f(p)}),{...kt(e.options),handleSelect:a,currentIndex:i,handleCurrentIndex:f}}}),vn=["src","onClick"];function pn(e,o,a,i,f,p){const C=cn;return Se(),It(C,$t(e.options,{"current-index":e.currentIndex,"on-update:current-index":e.handleCurrentIndex}),{default:Dt(()=>[(Se(!0),Ae(Nt,null,Vt(e.datasets,(y,S)=>(Se(),Ae("img",{key:S,src:y.src,class:"carousel-img",onClick:g=>e.handleSelect(y)},null,8,vn))),128))]),_:1},16,["current-index","on-update:current-index"])}const Vn=_t(fn,[["render",pn]]);export{Vn as default};
|