|
|
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 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
|