2 lines
5.4 KiB
JavaScript
2 lines
5.4 KiB
JavaScript
function e(e,l){return(null==l?void 0:l[e?"scrollWidth":"scrollHeight"])||0}function l(e,l,t){if(!t)return 0;const{scrollLeft:n,offsetWidth:a,scrollWidth:o}=t;return e?l?o-a+n:n:t.scrollTop}function t(e,l){return(null==l?void 0:l[e?"offsetWidth":"offsetHeight"])||0}function n(e,l){return(null==l?void 0:l[e?"offsetLeft":"offsetTop"])||0}import{b as a}from"./index-CjuU1OvA.js";import{p as o,_ as s,j as u,bb as i,n as r,s as v,am as c,a1 as d,A as f,C as p,B as m,bl as h,aO as g,W as y,H as b,d as x,bj as w}from"./index-CAPtrJAk.js";import{e as k,u as E}from"./VBtn-azOSVwQy.js";import{V as S}from"./VIcon-BNrbGrm9.js";const _=o({centerActive:Boolean,direction:{type:String,default:"horizontal"},symbol:{type:null,default:Symbol.for("vuetify:v-slide-group")},nextIcon:{type:s,default:"$next"},prevIcon:{type:s,default:"$prev"},showArrows:{type:[Boolean,String],validator:e=>"boolean"==typeof e||["always","desktop","mobile"].includes(e)},...u(),...i({mobile:null}),...r(),...k({selectedClass:"v-slide-group-item--active"})},"VSlideGroup"),A=v()({name:"VSlideGroup",props:_(),emits:{"update:modelValue":e=>!0},setup(o,s){function u(e,a){let o=0;o=a?function(e){let{selectedElement:l,containerElement:a,isHorizontal:o}=e;const s=t(o,a);return n(o,l)-s/2+t(o,l)/2}({containerElement:q.el,isHorizontal:L.value,selectedElement:e}):function(e){let{selectedElement:a,containerElement:o,isRtl:s,isHorizontal:u}=e;const i=t(u,o),r=l(u,s,o),v=t(u,a),c=n(u,a),d=.4*v;return r>c?c-d:c+v>r+i?c-i+v+d:r}({containerElement:q.el,isHorizontal:L.value,isRtl:M.value,selectedElement:e}),i(o)}function i(n){if(!g||!q.el)return;const a=t(L.value,q.el),o=l(L.value,M.value,q.el);if(e(L.value,q.el)>a&&Math.abs(n-o)>=16){if(L.value&&M.value&&q.el){const{scrollWidth:e,offsetWidth:l}=q.el;n=e-l-n}L.value?P.horizontal(n,$.value):P(n,$.value)}}function r(e){const{scrollTop:l,scrollLeft:t}=e.target;T.value=L.value?t:l}function v(e){if(Q.value=!0,j.value&&D.el)for(const l of e.composedPath())for(const e of D.el.children)if(e===l)return void u(e)}function k(e){Q.value=!1}function _(e){var l;U||Q.value||e.relatedTarget&&(null==(l=D.el)?void 0:l.contains(e.relatedTarget))||z(),U=!1}function A(){U=!0}function W(e){function l(l){e.preventDefault(),z(l)}D.el&&(L.value?"ArrowRight"===e.key?l(M.value?"prev":"next"):"ArrowLeft"===e.key&&l(M.value?"next":"prev"):"ArrowDown"===e.key?l("next"):"ArrowUp"===e.key&&l("prev"),"Home"===e.key?l("first"):"End"===e.key&&l("last"))}function z(e){var l,t;if(!D.el)return;let n;if(e)if("next"===e){if(n=null==(l=D.el.querySelector(":focus"))?void 0:l.nextElementSibling,!n)return z("first")}else if("prev"===e){if(n=null==(t=D.el.querySelector(":focus"))?void 0:t.previousElementSibling,!n)return z("last")}else"first"===e?n=D.el.firstElementChild:"last"===e&&(n=D.el.lastElementChild);else n=w(D.el)[0];n&&n.focus({preventScroll:!0})}function H(e){const l=L.value&&M.value?-1:1;let t=T.value+("prev"===e?-l:l)*F.value;if(L.value&&M.value&&q.el){const{scrollWidth:e,offsetWidth:l}=q.el;t+=e-l}i(t)}let{slots:I}=s;const{isRtl:M}=c(),{displayClasses:R,mobile:C}=d(o),V=E(o,o.symbol),j=f(!1),T=f(0),F=f(0),B=f(0),L=p((()=>"horizontal"===o.direction)),{resizeRef:q,contentRect:O}=m(),{resizeRef:D,contentRect:G}=m(),P=h(),$=p((()=>({container:q.el,duration:200,easing:"easeOutQuart"}))),K=p((()=>V.selected.value.length?V.items.value.findIndex((e=>e.id===V.selected.value[0])):-1)),N=p((()=>V.selected.value.length?V.items.value.findIndex((e=>e.id===V.selected.value[V.selected.value.length-1])):-1));if(g){let e=-1;y((()=>[V.selected.value,O.value,G.value,L.value]),(()=>{cancelAnimationFrame(e),e=requestAnimationFrame((()=>{if(O.value&&G.value){const e=L.value?"width":"height";F.value=O.value[e],B.value=G.value[e],j.value=B.value>F.value+1}K.value>=0&&D.el&&u(D.el.children[N.value],o.centerActive)}))}))}const Q=f(!1);let U=!1;const J=p((()=>({next:V.next,prev:V.prev,select:V.select,isSelected:V.isSelected}))),X=p((()=>{switch(o.showArrows){case"always":return!0;case"desktop":return!C.value;case!0:return j.value||Math.abs(T.value)>0;case"mobile":return C.value||j.value||Math.abs(T.value)>0;default:return!C.value&&(j.value||Math.abs(T.value)>0)}})),Y=p((()=>Math.abs(T.value)>1)),Z=p((()=>{if(!q.value)return!1;const l=e(L.value,q.el),t=function(e,l){return(null==l?void 0:l[e?"clientWidth":"clientHeight"])||0}(L.value,q.el);return l-t-Math.abs(T.value)>1}));return b((()=>x(o.tag,{class:["v-slide-group",{"v-slide-group--vertical":!L.value,"v-slide-group--has-affixes":X.value,"v-slide-group--is-overflowing":j.value},R.value,o.class],style:o.style,tabindex:Q.value||V.selected.value.length?-1:0,onFocus:_},{default:()=>{var e,l,t;return[X.value&&x("div",{key:"prev",class:["v-slide-group__prev",{"v-slide-group__prev--disabled":!Y.value}],onMousedown:A,onClick:()=>Y.value&&H("prev")},[(null==(e=I.prev)?void 0:e.call(I,J.value))??x(a,null,{default:()=>[x(S,{icon:M.value?o.nextIcon:o.prevIcon},null)]})]),x("div",{key:"container",ref:q,class:"v-slide-group__container",onScroll:r},[x("div",{ref:D,class:"v-slide-group__content",onFocusin:v,onFocusout:k,onKeydown:W},[null==(l=I.default)?void 0:l.call(I,J.value)])]),X.value&&x("div",{key:"next",class:["v-slide-group__next",{"v-slide-group__next--disabled":!Z.value}],onMousedown:A,onClick:()=>Z.value&&H("next")},[(null==(t=I.next)?void 0:t.call(I,J.value))??x(a,null,{default:()=>[x(S,{icon:M.value?o.prevIcon:o.nextIcon},null)]})])]}}))),{selected:V.selected,scrollTo:H,scrollOffset:T,focus:z,hasPrev:Y,hasNext:Z}}});export{A as V,_ as m};
|