mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-06 03:57:49 +08:00
2 lines
26 KiB
JavaScript
2 lines
26 KiB
JavaScript
import{a as Z,o as fe}from"./evtd@0.2.4-CI_DDEu_.js";import{B as ze,d as pe,z as G,y as De,a as Ne}from"./seemly@0.3.8-DjGKl9dV.js";import{I as _e,F as Ie,J as je,l as W,x as Ee,d as Ce,i as ne,v as re,N as Fe,j as D,h as z,R as Pe,k as R,w as Q,n as Ae,Q as Be,L as Ue,M as qe,m as Ke}from"./@vue_runtime-core@3.5.12-Ds-HrVrM.js";import{k as F,n as N}from"./@vue_reactivity@3.5.12-Bs6EYLxJ.js";import{u as oe}from"./@css-render_vue3-ssr@0.15.14_vue@3.5.12-CJ-8xq3W.js";import{h as Ge,u as q,o as Je,i as Qe}from"./vooks@0.2.12_vue@3.5.12-CeQQlSXI.js";import{z as Ze}from"./vdirs@0.1.8_vue@3.5.12-C0KV5pCE.js";import{R as Re}from"./@juggle_resize-observer@3.4.0-C8OzoCMD.js";import{C as et}from"./css-render@0.15.14-C5toWlUr.js";function ce(n,e,t="default"){const r=e[t];if(r===void 0)throw new Error(`[vueuc/${n}]: slot[${t}] is empty.`);return r()}function he(n,e=!0,t=[]){return n.forEach(r=>{if(r!==null){if(typeof r!="object"){(typeof r=="string"||typeof r=="number")&&t.push(_e(String(r)));return}if(Array.isArray(r)){he(r,e,t);return}if(r.type===Ie){if(r.children===null)return;Array.isArray(r.children)&&he(r.children,e,t)}else r.type!==je&&t.push(r)}}),t}function me(n,e,t="default"){const r=e[t];if(r===void 0)throw new Error(`[vueuc/${n}]: slot[${t}] is empty.`);const o=he(r());if(o.length===1)return o[0];throw new Error(`[vueuc/${n}]: slot[${t}] should have exactly one child.`)}let L=null;function We(){if(L===null&&(L=document.getElementById("v-binder-view-measurer"),L===null)){L=document.createElement("div"),L.id="v-binder-view-measurer";const{style:n}=L;n.position="fixed",n.left="0",n.right="0",n.top="0",n.bottom="0",n.pointerEvents="none",n.visibility="hidden",document.body.appendChild(L)}return L.getBoundingClientRect()}function tt(n,e){const t=We();return{top:e,left:n,height:0,width:0,right:t.width-n,bottom:t.height-e}}function ue(n){const e=n.getBoundingClientRect(),t=We();return{left:e.left-t.left,top:e.top-t.top,bottom:t.height+t.top-e.bottom,right:t.width+t.left-e.right,width:e.width,height:e.height}}function nt(n){return n.nodeType===9?null:n.parentNode}function ke(n){if(n===null)return null;const e=nt(n);if(e===null)return null;if(e.nodeType===9)return document;if(e.nodeType===1){const{overflow:t,overflowX:r,overflowY:o}=getComputedStyle(e);if(/(auto|scroll|overlay)/.test(t+o+r))return e}return ke(e)}const It=W({name:"Binder",props:{syncTargetWithParent:Boolean,syncTarget:{type:Boolean,default:!0}},setup(n){var e;Ee("VBinder",(e=Ce())===null||e===void 0?void 0:e.proxy);const t=ne("VBinder",null),r=F(null),o=i=>{r.value=i,t&&n.syncTargetWithParent&&t.setTargetRef(i)};let u=[];const b=()=>{let i=r.value;for(;i=ke(i),i!==null;)u.push(i);for(const g of u)fe("scroll",g,x,!0)},w=()=>{for(const i of u)Z("scroll",i,x,!0);u=[]},l=new Set,h=i=>{l.size===0&&b(),l.has(i)||l.add(i)},p=i=>{l.has(i)&&l.delete(i),l.size===0&&w()},x=()=>{ze(d)},d=()=>{l.forEach(i=>i())},f=new Set,m=i=>{f.size===0&&fe("resize",window,a),f.has(i)||f.add(i)},v=i=>{f.has(i)&&f.delete(i),f.size===0&&Z("resize",window,a)},a=()=>{f.forEach(i=>i())};return re(()=>{Z("resize",window,a),w()}),{targetRef:r,setTargetRef:o,addScrollListener:h,removeScrollListener:p,addResizeListener:m,removeResizeListener:v}},render(){return ce("binder",this.$slots)}}),Et=W({name:"Target",setup(){const{setTargetRef:n,syncTarget:e}=ne("VBinder");return{syncTarget:e,setTargetDirective:{mounted:n,updated:n}}},render(){const{syncTarget:n,setTargetDirective:e}=this;return n?Fe(me("follower",this.$slots),[[e]]):me("follower",this.$slots)}});function ve(n,e){console.error(`[vueuc/${n}]: ${e}`)}const{c:B}=et(),ie="vueuc-style";function be(n){return n&-n}class Oe{constructor(e,t){this.l=e,this.min=t;const r=new Array(e+1);for(let o=0;o<e+1;++o)r[o]=0;this.ft=r}add(e,t){if(t===0)return;const{l:r,ft:o}=this;for(e+=1;e<=r;)o[e]+=t,e+=be(e)}get(e){return this.sum(e+1)-this.sum(e)}sum(e){if(e===void 0&&(e=this.l),e<=0)return 0;const{ft:t,min:r,l:o}=this;if(e>o)throw new Error("[FinweckTree.sum]: `i` is larger than length.");let u=e*r;for(;e>0;)u+=t[e],e-=be(e);return u}getBound(e){let t=0,r=this.l;for(;r>t;){const o=Math.floor((t+r)/2),u=this.sum(o);if(u>e){r=o;continue}else if(u<e){if(t===o)return this.sum(t+1)<=e?t+1:o;t=o}else return o}return t}}function we(n){return typeof n=="string"?document.querySelector(n):n()}const rt=W({name:"LazyTeleport",props:{to:{type:[String,Object],default:void 0},disabled:Boolean,show:{type:Boolean,required:!0}},setup(n){return{showTeleport:Ge(N(n,"show")),mergedTo:D(()=>{const{to:e}=n;return e??"body"})}},render(){return this.showTeleport?this.disabled?ce("lazy-teleport",this.$slots):z(Pe,{disabled:this.disabled,to:this.mergedTo},ce("lazy-teleport",this.$slots)):null}}),ee={top:"bottom",bottom:"top",left:"right",right:"left"},ge={start:"end",center:"center",end:"start"},ae={top:"height",bottom:"height",left:"width",right:"width"},ot={"bottom-start":"top left",bottom:"top center","bottom-end":"top right","top-start":"bottom left",top:"bottom center","top-end":"bottom right","right-start":"top left",right:"center left","right-end":"bottom left","left-start":"top right",left:"center right","left-end":"bottom right"},it={"bottom-start":"bottom left",bottom:"bottom center","bottom-end":"bottom right","top-start":"top left",top:"top center","top-end":"top right","right-start":"top right",right:"center right","right-end":"bottom right","left-start":"top left",left:"center left","left-end":"bottom left"},lt={"bottom-start":"right","bottom-end":"left","top-start":"right","top-end":"left","right-start":"bottom","right-end":"top","left-start":"bottom","left-end":"top"},ye={top:!0,bottom:!1,left:!0,right:!1},xe={top:"end",bottom:"start",left:"end",right:"start"};function st(n,e,t,r,o,u){if(!o||u)return{placement:n,top:0,left:0};const[b,w]=n.split("-");let l=w??"center",h={top:0,left:0};const p=(f,m,v)=>{let a=0,i=0;const g=t[f]-e[m]-e[f];return g>0&&r&&(v?i=ye[m]?g:-g:a=ye[m]?g:-g),{left:a,top:i}},x=b==="left"||b==="right";if(l!=="center"){const f=lt[n],m=ee[f],v=ae[f];if(t[v]>e[v]){if(e[f]+e[v]<t[v]){const a=(t[v]-e[v])/2;e[f]<a||e[m]<a?e[f]<e[m]?(l=ge[w],h=p(v,m,x)):h=p(v,f,x):l="center"}}else t[v]<e[v]&&e[m]<0&&e[f]>e[m]&&(l=ge[w])}else{const f=b==="bottom"||b==="top"?"left":"top",m=ee[f],v=ae[f],a=(t[v]-e[v])/2;(e[f]<a||e[m]<a)&&(e[f]>e[m]?(l=xe[f],h=p(v,f,x)):(l=xe[m],h=p(v,m,x)))}let d=b;return e[b]<t[ae[b]]&&e[b]<e[ee[b]]&&(d=ee[b]),{placement:l!=="center"?`${d}-${l}`:d,left:h.left,top:h.top}}function ut(n,e){return e?it[n]:ot[n]}function at(n,e,t,r,o,u){if(u)switch(n){case"bottom-start":return{top:`${Math.round(t.top-e.top+t.height)}px`,left:`${Math.round(t.left-e.left)}px`,transform:"translateY(-100%)"};case"bottom-end":return{top:`${Math.round(t.top-e.top+t.height)}px`,left:`${Math.round(t.left-e.left+t.width)}px`,transform:"translateX(-100%) translateY(-100%)"};case"top-start":return{top:`${Math.round(t.top-e.top)}px`,left:`${Math.round(t.left-e.left)}px`,transform:""};case"top-end":return{top:`${Math.round(t.top-e.top)}px`,left:`${Math.round(t.left-e.left+t.width)}px`,transform:"translateX(-100%)"};case"right-start":return{top:`${Math.round(t.top-e.top)}px`,left:`${Math.round(t.left-e.left+t.width)}px`,transform:"translateX(-100%)"};case"right-end":return{top:`${Math.round(t.top-e.top+t.height)}px`,left:`${Math.round(t.left-e.left+t.width)}px`,transform:"translateX(-100%) translateY(-100%)"};case"left-start":return{top:`${Math.round(t.top-e.top)}px`,left:`${Math.round(t.left-e.left)}px`,transform:""};case"left-end":return{top:`${Math.round(t.top-e.top+t.height)}px`,left:`${Math.round(t.left-e.left)}px`,transform:"translateY(-100%)"};case"top":return{top:`${Math.round(t.top-e.top)}px`,left:`${Math.round(t.left-e.left+t.width/2)}px`,transform:"translateX(-50%)"};case"right":return{top:`${Math.round(t.top-e.top+t.height/2)}px`,left:`${Math.round(t.left-e.left+t.width)}px`,transform:"translateX(-100%) translateY(-50%)"};case"left":return{top:`${Math.round(t.top-e.top+t.height/2)}px`,left:`${Math.round(t.left-e.left)}px`,transform:"translateY(-50%)"};case"bottom":default:return{top:`${Math.round(t.top-e.top+t.height)}px`,left:`${Math.round(t.left-e.left+t.width/2)}px`,transform:"translateX(-50%) translateY(-100%)"}}switch(n){case"bottom-start":return{top:`${Math.round(t.top-e.top+t.height+r)}px`,left:`${Math.round(t.left-e.left+o)}px`,transform:""};case"bottom-end":return{top:`${Math.round(t.top-e.top+t.height+r)}px`,left:`${Math.round(t.left-e.left+t.width+o)}px`,transform:"translateX(-100%)"};case"top-start":return{top:`${Math.round(t.top-e.top+r)}px`,left:`${Math.round(t.left-e.left+o)}px`,transform:"translateY(-100%)"};case"top-end":return{top:`${Math.round(t.top-e.top+r)}px`,left:`${Math.round(t.left-e.left+t.width+o)}px`,transform:"translateX(-100%) translateY(-100%)"};case"right-start":return{top:`${Math.round(t.top-e.top+r)}px`,left:`${Math.round(t.left-e.left+t.width+o)}px`,transform:""};case"right-end":return{top:`${Math.round(t.top-e.top+t.height+r)}px`,left:`${Math.round(t.left-e.left+t.width+o)}px`,transform:"translateY(-100%)"};case"left-start":return{top:`${Math.round(t.top-e.top+r)}px`,left:`${Math.round(t.left-e.left+o)}px`,transform:"translateX(-100%)"};case"left-end":return{top:`${Math.round(t.top-e.top+t.height+r)}px`,left:`${Math.round(t.left-e.left+o)}px`,transform:"translateX(-100%) translateY(-100%)"};case"top":return{top:`${Math.round(t.top-e.top+r)}px`,left:`${Math.round(t.left-e.left+t.width/2+o)}px`,transform:"translateY(-100%) translateX(-50%)"};case"right":return{top:`${Math.round(t.top-e.top+t.height/2+r)}px`,left:`${Math.round(t.left-e.left+t.width+o)}px`,transform:"translateY(-50%)"};case"left":return{top:`${Math.round(t.top-e.top+t.height/2+r)}px`,left:`${Math.round(t.left-e.left+o)}px`,transform:"translateY(-50%) translateX(-100%)"};case"bottom":default:return{top:`${Math.round(t.top-e.top+t.height+r)}px`,left:`${Math.round(t.left-e.left+t.width/2+o)}px`,transform:"translateX(-50%)"}}}const dt=B([B(".v-binder-follower-container",{position:"absolute",left:"0",right:"0",top:"0",height:"0",pointerEvents:"none",zIndex:"auto"}),B(".v-binder-follower-content",{position:"absolute",zIndex:"auto"},[B("> *",{pointerEvents:"all"})])]),Ct=W({name:"Follower",inheritAttrs:!1,props:{show:Boolean,enabled:{type:Boolean,default:void 0},placement:{type:String,default:"bottom"},syncTrigger:{type:Array,default:["resize","scroll"]},to:[String,Object],flip:{type:Boolean,default:!0},internalShift:Boolean,x:Number,y:Number,width:String,minWidth:String,containerClass:String,teleportDisabled:Boolean,zindexable:{type:Boolean,default:!0},zIndex:Number,overlap:Boolean},setup(n){const e=ne("VBinder"),t=q(()=>n.enabled!==void 0?n.enabled:n.show),r=F(null),o=F(null),u=()=>{const{syncTrigger:d}=n;d.includes("scroll")&&e.addScrollListener(l),d.includes("resize")&&e.addResizeListener(l)},b=()=>{e.removeScrollListener(l),e.removeResizeListener(l)};R(()=>{t.value&&(l(),u())});const w=oe();dt.mount({id:"vueuc/binder",head:!0,anchorMetaName:ie,ssr:w}),re(()=>{b()}),Je(()=>{t.value&&l()});const l=()=>{if(!t.value)return;const d=r.value;if(d===null)return;const f=e.targetRef,{x:m,y:v,overlap:a}=n,i=m!==void 0&&v!==void 0?tt(m,v):ue(f);d.style.setProperty("--v-target-width",`${Math.round(i.width)}px`),d.style.setProperty("--v-target-height",`${Math.round(i.height)}px`);const{width:g,minWidth:M,placement:E,internalShift:_,flip:V}=n;d.setAttribute("v-placement",E),a?d.setAttribute("v-overlap",""):d.removeAttribute("v-overlap");const{style:T}=d;g==="target"?T.width=`${i.width}px`:g!==void 0?T.width=g:T.width="",M==="target"?T.minWidth=`${i.width}px`:M!==void 0?T.minWidth=M:T.minWidth="";const H=ue(d),j=ue(o.value),{left:X,top:P,placement:U}=st(E,i,H,_,V,a),s=ut(U,a),{left:c,top:y,transform:$}=at(U,j,i,P,X,a);d.setAttribute("v-placement",U),d.style.setProperty("--v-offset-left",`${Math.round(X)}px`),d.style.setProperty("--v-offset-top",`${Math.round(P)}px`),d.style.transform=`translateX(${c}) translateY(${y}) ${$}`,d.style.setProperty("--v-transform-origin",s),d.style.transformOrigin=s};Q(t,d=>{d?(u(),h()):b()});const h=()=>{Ae().then(l).catch(d=>console.error(d))};["placement","x","y","internalShift","flip","width","overlap","minWidth"].forEach(d=>{Q(N(n,d),l)}),["teleportDisabled"].forEach(d=>{Q(N(n,d),h)}),Q(N(n,"syncTrigger"),d=>{d.includes("resize")?e.addResizeListener(l):e.removeResizeListener(l),d.includes("scroll")?e.addScrollListener(l):e.removeScrollListener(l)});const p=Qe(),x=q(()=>{const{to:d}=n;if(d!==void 0)return d;p.value});return{VBinder:e,mergedEnabled:t,offsetContainerRef:o,followerRef:r,mergedTo:x,syncPosition:l}},render(){return z(rt,{show:this.show,to:this.mergedTo,disabled:this.teleportDisabled},{default:()=>{var n,e;const t=z("div",{class:["v-binder-follower-container",this.containerClass],ref:"offsetContainerRef"},[z("div",{class:"v-binder-follower-content",ref:"followerRef"},(e=(n=this.$slots).default)===null||e===void 0?void 0:e.call(n))]);return this.zindexable?Fe(t,[[Ze,{enabled:this.mergedEnabled,zIndex:this.zIndex}]]):t}})}});class ft{constructor(){this.handleResize=this.handleResize.bind(this),this.observer=new(typeof window<"u"&&window.ResizeObserver||Re)(this.handleResize),this.elHandlersMap=new Map}handleResize(e){for(const t of e){const r=this.elHandlersMap.get(t.target);r!==void 0&&r(t)}}registerHandler(e,t){this.elHandlersMap.set(e,t),this.observer.observe(e)}unregisterHandler(e){this.elHandlersMap.has(e)&&(this.elHandlersMap.delete(e),this.observer.unobserve(e))}}const Me=new ft,$e=W({name:"ResizeObserver",props:{onResize:Function},setup(n){let e=!1;const t=Ce().proxy;function r(o){const{onResize:u}=n;u!==void 0&&u(o)}R(()=>{const o=t.$el;if(o===void 0){ve("resize-observer","$el does not exist.");return}if(o.nextElementSibling!==o.nextSibling&&o.nodeType===3&&o.nodeValue!==""){ve("resize-observer","$el can not be observed (it may be a text node).");return}o.nextElementSibling!==null&&(Me.registerHandler(o.nextElementSibling,r),e=!0)}),re(()=>{e&&Me.unregisterHandler(t.$el.nextElementSibling)})},render(){return Be(this.$slots,"default")}});let te;function ct(){return typeof document>"u"?!1:(te===void 0&&("matchMedia"in window?te=window.matchMedia("(pointer:coarse)").matches:te=!1),te)}let de;function Se(){return typeof document>"u"?1:(de===void 0&&(de="chrome"in window?window.devicePixelRatio:1),de)}const Le="VVirtualListXScroll";function ht({columnsRef:n,renderColRef:e,renderItemWithColsRef:t}){const r=F(0),o=F(0),u=D(()=>{const h=n.value;if(h.length===0)return null;const p=new Oe(h.length,0);return h.forEach((x,d)=>{p.add(d,x.width)}),p}),b=q(()=>{const h=u.value;return h!==null?Math.max(h.getBound(o.value)-1,0):0}),w=h=>{const p=u.value;return p!==null?p.sum(h):0},l=q(()=>{const h=u.value;return h!==null?Math.min(h.getBound(o.value+r.value)+1,n.value.length-1):0});return Ee(Le,{startIndexRef:b,endIndexRef:l,columnsRef:n,renderColRef:e,renderItemWithColsRef:t,getLeft:w}),{listWidthRef:r,scrollLeftRef:o}}const Te=W({name:"VirtualListRow",props:{index:{type:Number,required:!0},item:{type:Object,required:!0}},setup(){const{startIndexRef:n,endIndexRef:e,columnsRef:t,getLeft:r,renderColRef:o,renderItemWithColsRef:u}=ne(Le);return{startIndex:n,endIndex:e,columns:t,renderCol:o,renderItemWithCols:u,getLeft:r}},render(){const{startIndex:n,endIndex:e,columns:t,renderCol:r,renderItemWithCols:o,getLeft:u,item:b}=this;if(o!=null)return o({itemIndex:this.index,startColIndex:n,endColIndex:e,allColumns:t,item:b,getLeft:u});if(r!=null){const w=[];for(let l=n;l<=e;++l){const h=t[l];w.push(r({column:h,left:u(l),item:b}))}return w}return null}}),pt=B(".v-vl",{maxHeight:"inherit",height:"100%",overflow:"auto",minWidth:"1px"},[B("&:not(.v-vl--show-scrollbar)",{scrollbarWidth:"none"},[B("&::-webkit-scrollbar, &::-webkit-scrollbar-track-piece, &::-webkit-scrollbar-thumb",{width:0,height:0,display:"none"})])]),Ft=W({name:"VirtualList",inheritAttrs:!1,props:{showScrollbar:{type:Boolean,default:!0},columns:{type:Array,default:()=>[]},renderCol:Function,renderItemWithCols:Function,items:{type:Array,default:()=>[]},itemSize:{type:Number,required:!0},itemResizable:Boolean,itemsStyle:[String,Object],visibleItemsTag:{type:[String,Object],default:"div"},visibleItemsProps:Object,ignoreItemResize:Boolean,onScroll:Function,onWheel:Function,onResize:Function,defaultScrollKey:[Number,String],defaultScrollIndex:Number,keyField:{type:String,default:"key"},paddingTop:{type:[Number,String],default:0},paddingBottom:{type:[Number,String],default:0}},setup(n){const e=oe();pt.mount({id:"vueuc/virtual-list",head:!0,anchorMetaName:ie,ssr:e}),R(()=>{const{defaultScrollIndex:s,defaultScrollKey:c}=n;s!=null?a({index:s}):c!=null&&a({key:c})});let t=!1,r=!1;Ue(()=>{if(t=!1,!r){r=!0;return}a({top:f.value,left:b.value})}),qe(()=>{t=!0,r||(r=!0)});const o=q(()=>{if(n.renderCol==null&&n.renderItemWithCols==null||n.columns.length===0)return;let s=0;return n.columns.forEach(c=>{s+=c.width}),s}),u=D(()=>{const s=new Map,{keyField:c}=n;return n.items.forEach((y,$)=>{s.set(y[c],$)}),s}),{scrollLeftRef:b,listWidthRef:w}=ht({columnsRef:N(n,"columns"),renderColRef:N(n,"renderCol"),renderItemWithColsRef:N(n,"renderItemWithCols")}),l=F(null),h=F(void 0),p=new Map,x=D(()=>{const{items:s,itemSize:c,keyField:y}=n,$=new Oe(s.length,c);return s.forEach((I,C)=>{const S=I[y],A=p.get(S);A!==void 0&&$.add(C,A)}),$}),d=F(0),f=F(0),m=q(()=>Math.max(x.value.getBound(f.value-pe(n.paddingTop))-1,0)),v=D(()=>{const{value:s}=h;if(s===void 0)return[];const{items:c,itemSize:y}=n,$=m.value,I=Math.min($+Math.ceil(s/y+1),c.length-1),C=[];for(let S=$;S<=I;++S)C.push(c[S]);return C}),a=(s,c)=>{if(typeof s=="number"){E(s,c,"auto");return}const{left:y,top:$,index:I,key:C,position:S,behavior:A,debounce:O=!0}=s;if(y!==void 0||$!==void 0)E(y,$,A);else if(I!==void 0)M(I,A,O);else if(C!==void 0){const le=u.value.get(C);le!==void 0&&M(le,A,O)}else S==="bottom"?E(0,Number.MAX_SAFE_INTEGER,A):S==="top"&&E(0,0,A)};let i,g=null;function M(s,c,y){const{value:$}=x,I=$.sum(s)+pe(n.paddingTop);if(!y)l.value.scrollTo({left:0,top:I,behavior:c});else{i=s,g!==null&&window.clearTimeout(g),g=window.setTimeout(()=>{i=void 0,g=null},16);const{scrollTop:C,offsetHeight:S}=l.value;if(I>C){const A=$.get(s);I+A<=C+S||l.value.scrollTo({left:0,top:I+A-S,behavior:c})}else l.value.scrollTo({left:0,top:I,behavior:c})}}function E(s,c,y){l.value.scrollTo({left:s,top:c,behavior:y})}function _(s,c){var y,$,I;if(t||n.ignoreItemResize||U(c.target))return;const{value:C}=x,S=u.value.get(s),A=C.get(S),O=(I=($=(y=c.borderBoxSize)===null||y===void 0?void 0:y[0])===null||$===void 0?void 0:$.blockSize)!==null&&I!==void 0?I:c.contentRect.height;if(O===A)return;O-n.itemSize===0?p.delete(s):p.set(s,O-n.itemSize);const K=O-A;if(K===0)return;C.add(S,K);const Y=l.value;if(Y!=null){if(i===void 0){const se=C.sum(S);Y.scrollTop>se&&Y.scrollBy(0,K)}else if(S<i)Y.scrollBy(0,K);else if(S===i){const se=C.sum(S);O+se>Y.scrollTop+Y.offsetHeight&&Y.scrollBy(0,K)}P()}d.value++}const V=!ct();let T=!1;function H(s){var c;(c=n.onScroll)===null||c===void 0||c.call(n,s),(!V||!T)&&P()}function j(s){var c;if((c=n.onWheel)===null||c===void 0||c.call(n,s),V){const y=l.value;if(y!=null){if(s.deltaX===0&&(y.scrollTop===0&&s.deltaY<=0||y.scrollTop+y.offsetHeight>=y.scrollHeight&&s.deltaY>=0))return;s.preventDefault(),y.scrollTop+=s.deltaY/Se(),y.scrollLeft+=s.deltaX/Se(),P(),T=!0,ze(()=>{T=!1})}}}function X(s){if(t||U(s.target))return;if(n.renderCol==null&&n.renderItemWithCols==null){if(s.contentRect.height===h.value)return}else if(s.contentRect.height===h.value&&s.contentRect.width===w.value)return;h.value=s.contentRect.height,w.value=s.contentRect.width;const{onResize:c}=n;c!==void 0&&c(s)}function P(){const{value:s}=l;s!=null&&(f.value=s.scrollTop,b.value=s.scrollLeft)}function U(s){let c=s;for(;c!==null;){if(c.style.display==="none")return!0;c=c.parentElement}return!1}return{listHeight:h,listStyle:{overflow:"auto"},keyToIndex:u,itemsStyle:D(()=>{const{itemResizable:s}=n,c=G(x.value.sum());return d.value,[n.itemsStyle,{boxSizing:"content-box",width:G(o.value),height:s?"":c,minHeight:s?c:"",paddingTop:G(n.paddingTop),paddingBottom:G(n.paddingBottom)}]}),visibleItemsStyle:D(()=>(d.value,{transform:`translateY(${G(x.value.sum(m.value))})`})),viewportItems:v,listElRef:l,itemsElRef:F(null),scrollTo:a,handleListResize:X,handleListScroll:H,handleListWheel:j,handleItemResize:_}},render(){const{itemResizable:n,keyField:e,keyToIndex:t,visibleItemsTag:r}=this;return z($e,{onResize:this.handleListResize},{default:()=>{var o,u;return z("div",Ke(this.$attrs,{class:["v-vl",this.showScrollbar&&"v-vl--show-scrollbar"],onScroll:this.handleListScroll,onWheel:this.handleListWheel,ref:"listElRef"}),[this.items.length!==0?z("div",{ref:"itemsElRef",class:"v-vl-items",style:this.itemsStyle},[z(r,Object.assign({class:"v-vl-visible-items",style:this.visibleItemsStyle},this.visibleItemsProps),{default:()=>{const{renderCol:b,renderItemWithCols:w}=this;return this.viewportItems.map(l=>{const h=l[e],p=t.get(h),x=b!=null?z(Te,{index:p,item:l}):void 0,d=w!=null?z(Te,{index:p,item:l}):void 0,f=this.$slots.default({item:l,renderedCols:x,renderedItemWithCols:d,index:p})[0];return n?z($e,{key:h,onResize:m=>this.handleItemResize(h,m)},{default:()=>f}):(f.key=h,f)})}})]):(u=(o=this.$slots).empty)===null||u===void 0?void 0:u.call(o)])}})}}),mt=B(".v-x-scroll",{overflow:"auto",scrollbarWidth:"none"},[B("&::-webkit-scrollbar",{width:0,height:0})]),At=W({name:"XScroll",props:{disabled:Boolean,onScroll:Function},setup(){const n=F(null);function e(o){!(o.currentTarget.offsetWidth<o.currentTarget.scrollWidth)||o.deltaY===0||(o.currentTarget.scrollLeft+=o.deltaY+o.deltaX,o.preventDefault())}const t=oe();return mt.mount({id:"vueuc/x-scroll",head:!0,anchorMetaName:ie,ssr:t}),Object.assign({selfRef:n,handleWheel:e},{scrollTo(...o){var u;(u=n.value)===null||u===void 0||u.scrollTo(...o)}})},render(){return z("div",{ref:"selfRef",onScroll:this.onScroll,onWheel:this.disabled?void 0:this.handleWheel,class:"v-x-scroll"},this.$slots)}}),k="v-hidden",vt=B("[v-hidden]",{display:"none!important"}),Bt=W({name:"Overflow",props:{getCounter:Function,getTail:Function,updateCounter:Function,onUpdateCount:Function,onUpdateOverflow:Function},setup(n,{slots:e}){const t=F(null),r=F(null);function o(b){const{value:w}=t,{getCounter:l,getTail:h}=n;let p;if(l!==void 0?p=l():p=r.value,!w||!p)return;p.hasAttribute(k)&&p.removeAttribute(k);const{children:x}=w;if(b.showAllItemsBeforeCalculate)for(const M of x)M.hasAttribute(k)&&M.removeAttribute(k);const d=w.offsetWidth,f=[],m=e.tail?h==null?void 0:h():null;let v=m?m.offsetWidth:0,a=!1;const i=w.children.length-(e.tail?1:0);for(let M=0;M<i-1;++M){if(M<0)continue;const E=x[M];if(a){E.hasAttribute(k)||E.setAttribute(k,"");continue}else E.hasAttribute(k)&&E.removeAttribute(k);const _=E.offsetWidth;if(v+=_,f[M]=_,v>d){const{updateCounter:V}=n;for(let T=M;T>=0;--T){const H=i-1-T;V!==void 0?V(H):p.textContent=`${H}`;const j=p.offsetWidth;if(v-=f[T],v+j<=d||T===0){a=!0,M=T-1,m&&(M===-1?(m.style.maxWidth=`${d-j}px`,m.style.boxSizing="border-box"):m.style.maxWidth="");const{onUpdateCount:X}=n;X&&X(H);break}}}}const{onUpdateOverflow:g}=n;a?g!==void 0&&g(!0):(g!==void 0&&g(!1),p.setAttribute(k,""))}const u=oe();return vt.mount({id:"vueuc/overflow",head:!0,anchorMetaName:ie,ssr:u}),R(()=>o({showAllItemsBeforeCalculate:!1})),{selfRef:t,counterRef:r,sync:o}},render(){const{$slots:n}=this;return Ae(()=>this.sync({showAllItemsBeforeCalculate:!1})),z("div",{class:"v-overflow",ref:"selfRef"},[Be(n,"default"),n.counter?n.counter():z("span",{style:{display:"inline-block"},ref:"counterRef"}),n.tail?n.tail():null])}});function Ve(n){return n instanceof HTMLElement}function He(n){for(let e=0;e<n.childNodes.length;e++){const t=n.childNodes[e];if(Ve(t)&&(Ye(t)||He(t)))return!0}return!1}function Xe(n){for(let e=n.childNodes.length-1;e>=0;e--){const t=n.childNodes[e];if(Ve(t)&&(Ye(t)||Xe(t)))return!0}return!1}function Ye(n){if(!bt(n))return!1;try{n.focus({preventScroll:!0})}catch{}return document.activeElement===n}function bt(n){if(n.tabIndex>0||n.tabIndex===0&&n.getAttribute("tabIndex")!==null)return!0;if(n.getAttribute("disabled"))return!1;switch(n.nodeName){case"A":return!!n.href&&n.rel!=="ignore";case"INPUT":return n.type!=="hidden"&&n.type!=="file";case"BUTTON":case"SELECT":case"TEXTAREA":return!0;default:return!1}}let J=[];const Wt=W({name:"FocusTrap",props:{disabled:Boolean,active:Boolean,autoFocus:{type:Boolean,default:!0},onEsc:Function,initialFocusTo:String,finalFocusTo:String,returnFocusOnDeactivated:{type:Boolean,default:!0}},setup(n){const e=De(),t=F(null),r=F(null);let o=!1,u=!1;const b=typeof document>"u"?null:document.activeElement;function w(){return J[J.length-1]===e}function l(a){var i;a.code==="Escape"&&w()&&((i=n.onEsc)===null||i===void 0||i.call(n,a))}R(()=>{Q(()=>n.active,a=>{a?(x(),fe("keydown",document,l)):(Z("keydown",document,l),o&&d())},{immediate:!0})}),re(()=>{Z("keydown",document,l),o&&d()});function h(a){if(!u&&w()){const i=p();if(i===null||i.contains(Ne(a)))return;f("first")}}function p(){const a=t.value;if(a===null)return null;let i=a;for(;i=i.nextSibling,!(i===null||i instanceof Element&&i.tagName==="DIV"););return i}function x(){var a;if(!n.disabled){if(J.push(e),n.autoFocus){const{initialFocusTo:i}=n;i===void 0?f("first"):(a=we(i))===null||a===void 0||a.focus({preventScroll:!0})}o=!0,document.addEventListener("focus",h,!0)}}function d(){var a;if(n.disabled||(document.removeEventListener("focus",h,!0),J=J.filter(g=>g!==e),w()))return;const{finalFocusTo:i}=n;i!==void 0?(a=we(i))===null||a===void 0||a.focus({preventScroll:!0}):n.returnFocusOnDeactivated&&b instanceof HTMLElement&&(u=!0,b.focus({preventScroll:!0}),u=!1)}function f(a){if(w()&&n.active){const i=t.value,g=r.value;if(i!==null&&g!==null){const M=p();if(M==null||M===g){u=!0,i.focus({preventScroll:!0}),u=!1;return}u=!0;const E=a==="first"?He(M):Xe(M);u=!1,E||(u=!0,i.focus({preventScroll:!0}),u=!1)}}}function m(a){if(u)return;const i=p();i!==null&&(a.relatedTarget!==null&&i.contains(a.relatedTarget)?f("last"):f("first"))}function v(a){u||(a.relatedTarget!==null&&a.relatedTarget===t.value?f("last"):f("first"))}return{focusableStartRef:t,focusableEndRef:r,focusableStyle:"position: absolute; height: 0; width: 0;",handleStartFocus:m,handleEndFocus:v}},render(){const{default:n}=this.$slots;if(n===void 0)return null;if(this.disabled)return n();const{active:e,focusableStyle:t}=this;return z(Ie,null,[z("div",{"aria-hidden":"true",tabindex:e?"0":"-1",ref:"focusableStartRef",style:t,onFocus:this.handleStartFocus}),n(),z("div",{"aria-hidden":"true",style:t,ref:"focusableEndRef",tabindex:e?"0":"-1",onFocus:this.handleEndFocus})])}});export{It as B,Wt as F,rt as L,$e as V,Ft as a,Ct as b,Et as c,Bt as d,At as e,Me as r};
|