2 lines
5.9 KiB
JavaScript
2 lines
5.9 KiB
JavaScript
import{bJ as Y,p as V,a1 as _,a4 as A,a5 as O,a6 as H,a8 as j,ag as F,a7 as G,r as E,c as h,s as x,w as z,e as D,F as m,ac as W,N as k,br as J,bK as K,i as U,bL as q,O as N,bx as Q,b as S,z as Z}from"./index-33da89aa.js";import{g as p,V as X,m as ee,b as te}from"./VBtn-952cc45b.js";import{u as ne}from"./VTextarea-65fa5d78.js";const oe=e=>{const{touchstartX:o,touchendX:t,touchstartY:n,touchendY:i}=e,u=.5,s=16;e.offsetX=t-o,e.offsetY=i-n,Math.abs(e.offsetY)<u*Math.abs(e.offsetX)&&(e.left&&t<o-s&&e.left(e),e.right&&t>o+s&&e.right(e)),Math.abs(e.offsetX)<u*Math.abs(e.offsetY)&&(e.up&&i<n-s&&e.up(e),e.down&&i>n+s&&e.down(e))};function se(e,o){var n;const t=e.changedTouches[0];o.touchstartX=t.clientX,o.touchstartY=t.clientY,(n=o.start)==null||n.call(o,{originalEvent:e,...o})}function ie(e,o){var n;const t=e.changedTouches[0];o.touchendX=t.clientX,o.touchendY=t.clientY,(n=o.end)==null||n.call(o,{originalEvent:e,...o}),oe(o)}function ae(e,o){var n;const t=e.changedTouches[0];o.touchmoveX=t.clientX,o.touchmoveY=t.clientY,(n=o.move)==null||n.call(o,{originalEvent:e,...o})}function ue(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const o={touchstartX:0,touchstartY:0,touchendX:0,touchendY:0,touchmoveX:0,touchmoveY:0,offsetX:0,offsetY:0,left:e.left,right:e.right,up:e.up,down:e.down,start:e.start,move:e.move,end:e.end};return{touchstart:t=>se(t,o),touchend:t=>ie(t,o),touchmove:t=>ae(t,o)}}function ce(e,o){var v;const t=o.value,n=t!=null&&t.parent?e.parentElement:e,i=(t==null?void 0:t.options)??{passive:!0},u=(v=o.instance)==null?void 0:v.$.uid;if(!n||!u)return;const s=ue(o.value);n._touchHandlers=n._touchHandlers??Object.create(null),n._touchHandlers[u]=s,Y(s).forEach(r=>{n.addEventListener(r,s[r],i)})}function le(e,o){var u,s;const t=(u=o.value)!=null&&u.parent?e.parentElement:e,n=(s=o.instance)==null?void 0:s.$.uid;if(!(t!=null&&t._touchHandlers)||!n)return;const i=t._touchHandlers[n];Y(i).forEach(v=>{t.removeEventListener(v,i[v])}),delete t._touchHandlers[n]}const L={mounted:ce,unmounted:le},re=L,R=Symbol.for("vuetify:v-window"),$=Symbol.for("vuetify:v-window-group"),ve=V({continuous:Boolean,nextIcon:{type:[Boolean,String,Function,Object],default:"$next"},prevIcon:{type:[Boolean,String,Function,Object],default:"$prev"},reverse:Boolean,showArrows:{type:[Boolean,String],validator:e=>typeof e=="boolean"||e==="hover"},touch:{type:[Object,Boolean],default:void 0},direction:{type:String,default:"horizontal"},modelValue:null,disabled:Boolean,selectedClass:{type:String,default:"v-window-item--active"},mandatory:{default:"force"},..._(),...A(),...O()},"VWindow"),ge=H()({name:"VWindow",directives:{Touch:L},props:ve(),emits:{"update:modelValue":e=>!0},setup(e,o){let{slots:t}=o;const{themeClasses:n}=j(e),{isRtl:i}=F(),{t:u}=G(),s=p(e,$),v=E(),r=h(()=>i.value?!e.reverse:e.reverse),d=x(!1),y=h(()=>{const a=e.direction==="vertical"?"y":"x",f=(r.value?!d.value:d.value)?"-reverse":"";return`v-window-${a}${f}-transition`}),T=x(0),b=E(void 0),g=h(()=>s.items.value.findIndex(a=>s.selected.value.includes(a.id)));z(g,(a,l)=>{const f=s.items.value.length,B=f-1;f<=2?d.value=a<l:a===B&&l===0?d.value=!0:a===0&&l===B?d.value=!1:d.value=a<l}),D(R,{transition:y,isReversed:d,transitionCount:T,transitionHeight:b,rootRef:v});const c=h(()=>e.continuous||g.value!==0),w=h(()=>e.continuous||g.value!==s.items.value.length-1);function C(){c.value&&s.prev()}function I(){w.value&&s.next()}const P=h(()=>{const a=[],l={icon:i.value?e.nextIcon:e.prevIcon,class:`v-window__${r.value?"right":"left"}`,onClick:s.prev,ariaLabel:u("$vuetify.carousel.prev")};a.push(c.value?t.prev?t.prev({props:l}):m(X,l,null):m("div",null,null));const f={icon:i.value?e.prevIcon:e.nextIcon,class:`v-window__${r.value?"left":"right"}`,onClick:s.next,ariaLabel:u("$vuetify.carousel.next")};return a.push(w.value?t.next?t.next({props:f}):m(X,f,null):m("div",null,null)),a}),M=h(()=>e.touch===!1?e.touch:{...{left:()=>{r.value?C():I()},right:()=>{r.value?I():C()},start:l=>{let{originalEvent:f}=l;f.stopPropagation()}},...e.touch===!0?{}:e.touch});return W(()=>k(m(e.tag,{ref:v,class:["v-window",{"v-window--show-arrows-on-hover":e.showArrows==="hover"},n.value,e.class],style:e.style},{default:()=>{var a,l;return[m("div",{class:"v-window__container",style:{height:b.value}},[(a=t.default)==null?void 0:a.call(t,{group:s}),e.showArrows!==!1&&m("div",{class:"v-window__controls"},[P.value])]),(l=t.additional)==null?void 0:l.call(t,{group:s})]}}),[[J("touch"),M.value]])),{group:s}}}),de=V({reverseTransition:{type:[Boolean,String],default:void 0},transition:{type:[Boolean,String],default:void 0},..._(),...ee(),...K()},"VWindowItem"),ye=H()({name:"VWindowItem",directives:{Touch:re},props:de(),emits:{"group:selected":e=>!0},setup(e,o){let{slots:t}=o;const n=U(R),i=te(e,$),{isBooted:u}=ne();if(!n||!i)throw new Error("[Vuetify] VWindowItem must be used inside VWindow");const s=x(!1),v=h(()=>u.value&&(n.isReversed.value?e.reverseTransition!==!1:e.transition!==!1));function r(){!s.value||!n||(s.value=!1,n.transitionCount.value>0&&(n.transitionCount.value-=1,n.transitionCount.value===0&&(n.transitionHeight.value=void 0)))}function d(){var c;s.value||!n||(s.value=!0,n.transitionCount.value===0&&(n.transitionHeight.value=S((c=n.rootRef.value)==null?void 0:c.clientHeight)),n.transitionCount.value+=1)}function y(){r()}function T(c){s.value&&Z(()=>{!v.value||!s.value||!n||(n.transitionHeight.value=S(c.clientHeight))})}const b=h(()=>{const c=n.isReversed.value?e.reverseTransition:e.transition;return v.value?{name:typeof c!="string"?n.transition.value:c,onBeforeEnter:d,onAfterEnter:r,onEnterCancelled:y,onBeforeLeave:d,onAfterLeave:r,onLeaveCancelled:y,onEnter:T}:!1}),{hasContent:g}=q(e,i.isSelected);return W(()=>m(Q,{transition:b.value,disabled:!u.value},{default:()=>{var c;return[k(m("div",{class:["v-window-item",i.selectedClass.value,e.class],style:e.style},[g.value&&((c=t.default)==null?void 0:c.call(t))]),[[N,i.isSelected.value]])]}})),{}}});export{ye as V,ge as a,de as b,ve as m};
|