import{a as C,r as D,m as T,f as c,k as i,a1 as k,H as I,af as B,cO as M,j as s,cA as P,aP as E,cx as L,aQ as b,o as j,aR as q,p as _,i as g,t as W,q as R}from"./index.0d073eaa.js";import{D as O}from"./index.0fb15725.js";import{P as Q}from"./index.566277e5.js";import"./index.e9a84cba.js";import"./index.0972fd96.js";import"./useSize.bb4e5ce5.js";import"./eagerComputed.156e81ff.js";import"./useWindowSizeFn.ef20ece8.js";import"./useContentViewHeight.01b9d1c6.js";import"./ArrowLeftOutlined.90d2e05e.js";import"./index.8680e4c4.js";import"./transButton.8c1b1a4f.js";const U={height:[Number,String],maxHeight:[Number,String],maxWidth:[Number,String],minHeight:[Number,String],minWidth:[Number,String],width:[Number,String],bench:{type:[Number,String],default:0},itemHeight:{type:[Number,String],required:!0},items:{type:Array,default:()=>[]}},x="virtual-scroll";function o(t,n="px"){if(!(t==null||t===""))return isNaN(+t)?String(t):`${Number(t)}${n}`}var z=C({name:"VirtualScroll",props:U,setup(t,{slots:n}){const u=D(null),a=T({first:0,last:0,scrollTop:0}),p=c(()=>parseInt(t.bench,10)),d=c(()=>parseInt(t.itemHeight,10)),m=c(()=>Math.max(0,a.first-i(p))),f=c(()=>Math.min((t.items||[]).length,a.last+i(p))),v=c(()=>({height:o((t.items||[]).length*i(d))})),h=c(()=>{const e={},r=o(t.height),l=o(t.minHeight),y=o(t.minWidth),H=o(t.maxHeight),N=o(t.maxWidth),F=o(t.width);return r&&(e.height=r),l&&(e.minHeight=l),y&&(e.minWidth=y),H&&(e.maxHeight=H),N&&(e.maxWidth=N),F&&(e.width=F),e});k([()=>t.itemHeight,()=>t.height],()=>{w()});function S(e){const r=i(u);if(!r)return 0;const l=parseInt(t.height||0,10)||r.clientHeight;return e+Math.ceil(l/i(d))}function V(){return Math.floor(a.scrollTop/i(d))}function w(){const e=i(u);!e||(a.scrollTop=e.scrollTop,a.first=V(),a.last=S(a.first))}function $(){const{items:e=[]}=t;return e.slice(i(m),i(f)).map(A)}function A(e,r){r+=i(m);const l=o(r*i(d));return s("div",{class:`${x}__item`,style:{top:l},key:r},[P(n,"default",{index:r,item:e})])}return I(()=>{a.last=S(0),B(()=>{const e=i(u);!e||M({el:e,name:"scroll",listener:w,wait:0})})}),()=>s("div",{class:x,style:i(h),ref:u},[s("div",{class:`${x}__container`,style:i(v)},[$()])])}});var G=E(z,[["__scopeId","data-v-dd7becb6"]]);const J=L(G);const K=(()=>{const t=[];for(let n=1;n<2e4;n++)t.push({title:"\u5217\u8868\u9879"+n});return t})(),X=C({components:{VScroll:J,Divider:O,PageWrapper:Q},setup(){return{data:K}}}),Y=R("\u57FA\u7840\u6EDA\u52A8\u793A\u4F8B"),Z={class:"virtual-scroll-demo-wrap"},tt={class:"virtual-scroll-demo__item"},et=R("\u5373\u4F7F\u4E0D\u53EF\u89C1\uFF0C\u4E5F\u9884\u5148\u52A0\u8F7D50\u6761\u6570\u636E\uFF0C\u9632\u6B62\u7A7A\u767D"),it={class:"virtual-scroll-demo-wrap"},rt={class:"virtual-scroll-demo__item"};function at(t,n,u,a,p,d){const m=b("Divider"),f=b("VScroll"),v=b("PageWrapper");return j(),q(v,{class:"virtual-scroll-demo"},{default:_(()=>[s(m,null,{default:_(()=>[Y]),_:1}),g("div",Z,[s(f,{itemHeight:41,items:t.data,height:300,width:300},{default:_(({item:h})=>[g("div",tt,W(h.title),1)]),_:1},8,["items"])]),s(m,null,{default:_(()=>[et]),_:1}),g("div",it,[s(f,{itemHeight:41,items:t.data,height:300,width:300,bench:50},{default:_(({item:h})=>[g("div",rt,W(h.title),1)]),_:1},8,["items"])])]),_:1})}var pt=E(X,[["render",at],["__scopeId","data-v-002a1a68"]]);export{pt as default};
