vue-pure-admin/dist/static/js/vue-virtual-scroller.esm-e5eab073.js
2022-12-09 20:23:54 +08:00

3 lines
23 KiB
JavaScript

function Z(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return parseInt(e.substring(t+5,e.indexOf(".",t)),10);var i=e.indexOf("Trident/");if(i>0){var s=e.indexOf("rv:");return parseInt(e.substring(s+3,e.indexOf(".",s)),10)}var r=e.indexOf("Edge/");return r>0?parseInt(e.substring(r+5,e.indexOf(".",r)),10):-1}let D;function M(){M.init||(M.init=!0,D=Z()!==-1)}var A={name:"ResizeObserver",props:{emitOnMount:{type:Boolean,default:!1},ignoreWidth:{type:Boolean,default:!1},ignoreHeight:{type:Boolean,default:!1}},emits:["notify"],mounted(){M(),Vue.nextTick(()=>{this._w=this.$el.offsetWidth,this._h=this.$el.offsetHeight,this.emitOnMount&&this.emitSize()});const e=document.createElement("object");this._resizeObject=e,e.setAttribute("aria-hidden","true"),e.setAttribute("tabindex",-1),e.onload=this.addResizeHandlers,e.type="text/html",D&&this.$el.appendChild(e),e.data="about:blank",D||this.$el.appendChild(e)},beforeUnmount(){this.removeResizeHandlers()},methods:{compareAndNotify(){(!this.ignoreWidth&&this._w!==this.$el.offsetWidth||!this.ignoreHeight&&this._h!==this.$el.offsetHeight)&&(this._w=this.$el.offsetWidth,this._h=this.$el.offsetHeight,this.emitSize())},emitSize(){this.$emit("notify",{width:this._w,height:this._h})},addResizeHandlers(){this._resizeObject.contentDocument.defaultView.addEventListener("resize",this.compareAndNotify),this.compareAndNotify()},removeResizeHandlers(){this._resizeObject&&this._resizeObject.onload&&(!D&&this._resizeObject.contentDocument&&this._resizeObject.contentDocument.defaultView.removeEventListener("resize",this.compareAndNotify),this.$el.removeChild(this._resizeObject),this._resizeObject.onload=null,this._resizeObject=null)}}};const ee=Vue.withScopeId("data-v-b329ee4c");Vue.pushScopeId("data-v-b329ee4c");const te={class:"resize-observer",tabindex:"-1"};Vue.popScopeId();const ie=ee((e,t,i,s,r,o)=>(Vue.openBlock(),Vue.createBlock("div",te)));A.render=ie;A.__scopeId="data-v-b329ee4c";A.__file="src/components/ResizeObserver.vue";function R(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?R=function(t){return typeof t}:R=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(e)}function se(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function re(e,t,i){return t&&H(e.prototype,t),i&&H(e,i),e}function j(e){return ne(e)||le(e)||oe(e)||ae()}function ne(e){if(Array.isArray(e))return P(e)}function le(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function oe(e,t){if(!!e){if(typeof e=="string")return P(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);if(i==="Object"&&e.constructor&&(i=e.constructor.name),i==="Map"||i==="Set")return Array.from(e);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return P(e,t)}}function P(e,t){(t==null||t>e.length)&&(t=e.length);for(var i=0,s=new Array(t);i<t;i++)s[i]=e[i];return s}function ae(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ce(e){var t;return typeof e=="function"?t={callback:e}:t=e,t}function ue(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,r,o,l=function(n){for(var d=arguments.length,f=new Array(d>1?d-1:0),g=1;g<d;g++)f[g-1]=arguments[g];if(o=f,!(s&&n===r)){var _=i.leading;typeof _=="function"&&(_=_(n,r)),(!s||n!==r)&&_&&e.apply(void 0,[n].concat(j(o))),r=n,clearTimeout(s),s=setTimeout(function(){e.apply(void 0,[n].concat(j(o))),s=0},t)}};return l._clear=function(){clearTimeout(s),s=null},l}function q(e,t){if(e===t)return!0;if(R(e)==="object"){for(var i in e)if(!q(e[i],t[i]))return!1;return!0}return!1}var de=function(){function e(t,i,s){se(this,e),this.el=t,this.observer=null,this.frozen=!1,this.createObserver(i,s)}return re(e,[{key:"createObserver",value:function(i,s){var r=this;if(this.observer&&this.destroyObserver(),!this.frozen){if(this.options=ce(i),this.callback=function(a,n){r.options.callback(a,n),a&&r.options.once&&(r.frozen=!0,r.destroyObserver())},this.callback&&this.options.throttle){var o=this.options.throttleOptions||{},l=o.leading;this.callback=ue(this.callback,this.options.throttle,{leading:function(n){return l==="both"||l==="visible"&&n||l==="hidden"&&!n}})}this.oldResult=void 0,this.observer=new IntersectionObserver(function(a){var n=a[0];if(a.length>1){var d=a.find(function(g){return g.isIntersecting});d&&(n=d)}if(r.callback){var f=n.isIntersecting&&n.intersectionRatio>=r.threshold;if(f===r.oldResult)return;r.oldResult=f,r.callback(f,n)}},this.options.intersection),Vue.nextTick(function(){r.observer&&r.observer.observe(r.el)})}}},{key:"destroyObserver",value:function(){this.observer&&(this.observer.disconnect(),this.observer=null),this.callback&&this.callback._clear&&(this.callback._clear(),this.callback=null)}},{key:"threshold",get:function(){return this.options.intersection&&typeof this.options.intersection.threshold=="number"?this.options.intersection.threshold:0}}]),e}();function K(e,t,i){var s=t.value;if(!!s)if(typeof IntersectionObserver>"u")console.warn("[vue-observe-visibility] IntersectionObserver API is not available in your browser. Please install this polyfill: https://github.com/w3c/IntersectionObserver/tree/master/polyfill");else{var r=new de(e,s,i);e._vue_visibilityState=r}}function he(e,t,i){var s=t.value,r=t.oldValue;if(!q(s,r)){var o=e._vue_visibilityState;if(!s){Y(e);return}o?o.createObserver(s,i):K(e,{value:s},i)}}function Y(e){var t=e._vue_visibilityState;t&&(t.destroyObserver(),delete e._vue_visibilityState)}var fe={beforeMount:K,updated:he,unmounted:Y};function me(e){return{all:e=e||new Map,on:function(t,i){var s=e.get(t);s&&s.push(i)||e.set(t,[i])},off:function(t,i){var s=e.get(t);s&&s.splice(s.indexOf(i)>>>0,1)},emit:function(t,i){(e.get(t)||[]).slice().map(function(s){s(i)}),(e.get("*")||[]).slice().map(function(s){s(t,i)})}}}var pe={itemsLimit:1e3},ve=/(auto|scroll)/;function X(e,t){return e.parentNode===null?t:X(e.parentNode,t.concat([e]))}var x=function(t,i){return getComputedStyle(t,null).getPropertyValue(i)},ye=function(t){return x(t,"overflow")+x(t,"overflow-y")+x(t,"overflow-x")},be=function(t){return ve.test(ye(t))};function W(e){if(e instanceof HTMLElement||e instanceof SVGElement){for(var t=X(e.parentNode,[]),i=0;i<t.length;i+=1)if(be(t[i]))return t[i];return document.scrollingElement||document.documentElement}}function C(e){return C=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},C(e)}var G={items:{type:Array,required:!0},keyField:{type:String,default:"id"},direction:{type:String,default:"vertical",validator:function(t){return["vertical","horizontal"].includes(t)}},listTag:{type:String,default:"div"},itemTag:{type:String,default:"div"}};function J(){return this.items.length&&C(this.items[0])!=="object"}var E=!1;if(typeof window<"u"){E=!1;try{var ge=Object.defineProperty({},"passive",{get:function(){E=!0}});window.addEventListener("test",null,ge)}catch{}}let ze=0;var B={name:"RecycleScroller",components:{ResizeObserver:A},directives:{ObserveVisibility:fe},props:{...G,itemSize:{type:Number,default:null},gridItems:{type:Number,default:void 0},itemSecondarySize:{type:Number,default:void 0},minItemSize:{type:[Number,String],default:null},sizeField:{type:String,default:"size"},typeField:{type:String,default:"type"},buffer:{type:Number,default:200},pageMode:{type:Boolean,default:!1},prerender:{type:Number,default:0},emitUpdate:{type:Boolean,default:!1},skipHover:{type:Boolean,default:!1},listTag:{type:String,default:"div"},itemTag:{type:String,default:"div"},listClass:{type:[String,Object,Array],default:""},itemClass:{type:[String,Object,Array],default:""}},emits:["resize","visible","hidden","update","scroll-start","scroll-end"],data(){return{pool:[],totalSize:0,ready:!1,hoverKey:null}},computed:{sizes(){if(this.itemSize===null){const e={"-1":{accumulator:0}},t=this.items,i=this.sizeField,s=this.minItemSize;let r=1e4,o=0,l;for(let a=0,n=t.length;a<n;a++)l=t[a][i]||s,l<r&&(r=l),o+=l,e[a]={accumulator:o,size:l};return this.$_computedMinItemSize=r,e}return[]},simpleArray:J},watch:{items(){this.updateVisibleItems(!0)},pageMode(){this.applyPageMode(),this.updateVisibleItems(!1)},sizes:{handler(){this.updateVisibleItems(!1)},deep:!0},gridItems(){this.updateVisibleItems(!0)},itemSecondarySize(){this.updateVisibleItems(!0)}},created(){this.$_startIndex=0,this.$_endIndex=0,this.$_views=new Map,this.$_unusedViews=new Map,this.$_scrollDirty=!1,this.$_lastUpdateScrollPosition=0,this.prerender&&(this.$_prerender=!0,this.updateVisibleItems(!1)),this.gridItems&&!this.itemSize&&console.error("[vue-recycle-scroller] You must provide an itemSize when using gridItems")},mounted(){this.applyPageMode(),this.$nextTick(()=>{this.$_prerender=!1,this.updateVisibleItems(!0),this.ready=!0})},activated(){const e=this.$_lastUpdateScrollPosition;typeof e=="number"&&this.$nextTick(()=>{this.scrollToPosition(e)})},beforeUnmount(){this.removeListeners()},methods:{addView(e,t,i,s,r){const o=Vue.markRaw({id:ze++,index:t,used:!0,key:s,type:r}),l=Vue.shallowReactive({item:i,position:0,nr:o});return e.push(l),l},unuseView(e,t=!1){const i=this.$_unusedViews,s=e.nr.type;let r=i.get(s);r||(r=[],i.set(s,r)),r.push(e),t||(e.nr.used=!1,e.position=-9999,this.$_views.delete(e.nr.key))},handleResize(){this.$emit("resize"),this.ready&&this.updateVisibleItems(!1)},handleScroll(e){this.$_scrollDirty||(this.$_scrollDirty=!0,requestAnimationFrame(()=>{this.$_scrollDirty=!1;const{continuous:t}=this.updateVisibleItems(!1,!0);t||(clearTimeout(this.$_refreshTimout),this.$_refreshTimout=setTimeout(this.handleScroll,100))}))},handleVisibilityChange(e,t){this.ready&&(e||t.boundingClientRect.width!==0||t.boundingClientRect.height!==0?(this.$emit("visible"),requestAnimationFrame(()=>{this.updateVisibleItems(!1)})):this.$emit("hidden"))},updateVisibleItems(e,t=!1){const i=this.itemSize,s=this.gridItems||1,r=this.itemSecondarySize||i,o=this.$_computedMinItemSize,l=this.typeField,a=this.simpleArray?null:this.keyField,n=this.items,d=n.length,f=this.sizes,g=this.$_views,_=this.$_unusedViews,I=this.pool;let m,h,T,b,z;if(!d)m=h=b=z=T=0;else if(this.$_prerender)m=b=0,h=z=Math.min(this.prerender,n.length),T=null;else{const c=this.getScroll();if(t){let v=c.start-this.$_lastUpdateScrollPosition;if(v<0&&(v=-v),i===null&&v<o||v<i)return{continuous:!0}}this.$_lastUpdateScrollPosition=c.start;const p=this.buffer;c.start-=p,c.end+=p;let k=0;if(this.$refs.before&&(k=this.$refs.before.scrollHeight,c.start-=k),this.$refs.after){const v=this.$refs.after.scrollHeight;c.end+=v}if(i===null){let v,N=0,L=d-1,y=~~(d/2),F;do F=y,v=f[y].accumulator,v<c.start?N=y:y<d-1&&f[y+1].accumulator>c.start&&(L=y),y=~~((N+L)/2);while(y!==F);for(y<0&&(y=0),m=y,T=f[d-1].accumulator,h=y;h<d&&f[h].accumulator<c.end;h++);for(h===-1?h=n.length-1:(h++,h>d&&(h=d)),b=m;b<d&&k+f[b].accumulator<c.start;b++);for(z=b;z<d&&k+f[z].accumulator<c.end;z++);}else{m=~~(c.start/i*s);const v=m%s;m-=v,h=Math.ceil(c.end/i*s),b=Math.max(0,Math.floor((c.start-k)/i*s)),z=Math.floor((c.end-k)/i*s),m<0&&(m=0),h>d&&(h=d),b<0&&(b=0),z>d&&(z=d),T=Math.ceil(d/s)*i}}h-m>pe.itemsLimit&&this.itemsLimitError(),this.totalSize=T;let u;const w=m<=this.$_endIndex&&h>=this.$_startIndex;if(this.$_continuous!==w){if(w){g.clear(),_.clear();for(let c=0,p=I.length;c<p;c++)u=I[c],this.unuseView(u)}this.$_continuous=w}else if(w)for(let c=0,p=I.length;c<p;c++)u=I[c],u.nr.used&&(e&&(u.nr.index=n.indexOf(u.item)),(u.nr.index===-1||u.nr.index<m||u.nr.index>=h)&&this.unuseView(u));const U=w?null:new Map;let S,$,V,O;for(let c=m;c<h;c++){S=n[c];const p=a?S[a]:S;if(p==null)throw new Error(`Key is ${p} on item (keyField is '${a}')`);if(u=g.get(p),!i&&!f[c].size){u&&this.unuseView(u);continue}u?(u.nr.used=!0,u.item=S):(c===n.length-1&&this.$emit("scroll-end"),c===0&&this.$emit("scroll-start"),$=S[l],V=_.get($),w?V&&V.length?(u=V.pop(),u.item=S,u.nr.used=!0,u.nr.index=c,u.nr.key=p,u.nr.type=$):u=this.addView(I,c,S,p,$):(O=U.get($)||0,(!V||O>=V.length)&&(u=this.addView(I,c,S,p,$),this.unuseView(u,!0),V=_.get($)),u=V[O],u.item=S,u.nr.used=!0,u.nr.index=c,u.nr.key=p,u.nr.type=$,U.set($,O+1),O++),g.set(p,u)),i===null?(u.position=f[c-1].accumulator,u.offset=0):(u.position=Math.floor(c/s)*i,u.offset=c%s*r)}return this.$_startIndex=m,this.$_endIndex=h,this.emitUpdate&&this.$emit("update",m,h,b,z),clearTimeout(this.$_sortTimer),this.$_sortTimer=setTimeout(this.sortViews,300),{continuous:w}},getListenerTarget(){let e=W(this.$el);return window.document&&(e===window.document.documentElement||e===window.document.body)&&(e=window),e},getScroll(){const{$el:e,direction:t}=this,i=t==="vertical";let s;if(this.pageMode){const r=e.getBoundingClientRect(),o=i?r.height:r.width;let l=-(i?r.top:r.left),a=i?window.innerHeight:window.innerWidth;l<0&&(a+=l,l=0),l+a>o&&(a=o-l),s={start:l,end:l+a}}else i?s={start:e.scrollTop,end:e.scrollTop+e.clientHeight}:s={start:e.scrollLeft,end:e.scrollLeft+e.clientWidth};return s},applyPageMode(){this.pageMode?this.addListeners():this.removeListeners()},addListeners(){this.listenerTarget=this.getListenerTarget(),this.listenerTarget.addEventListener("scroll",this.handleScroll,E?{passive:!0}:!1),this.listenerTarget.addEventListener("resize",this.handleResize)},removeListeners(){!this.listenerTarget||(this.listenerTarget.removeEventListener("scroll",this.handleScroll),this.listenerTarget.removeEventListener("resize",this.handleResize),this.listenerTarget=null)},scrollToItem(e){let t;this.itemSize===null?t=e>0?this.sizes[e-1].accumulator:0:t=Math.floor(e/this.gridItems)*this.itemSize,this.scrollToPosition(t)},scrollToPosition(e){const t=this.direction==="vertical"?{scroll:"scrollTop",start:"top"}:{scroll:"scrollLeft",start:"left"};let i,s,r;if(this.pageMode){const o=W(this.$el),l=o.tagName==="HTML"?0:o[t.scroll],a=o.getBoundingClientRect(),d=this.$el.getBoundingClientRect()[t.start]-a[t.start];i=o,s=t.scroll,r=e+l+d}else i=this.$el,s=t.scroll,r=e;i[s]=r},itemsLimitError(){throw setTimeout(()=>{console.log("It seems the scroller element isn't scrolling, so it tries to render all the items at once.","Scroller:",this.$el),console.log("Make sure the scroller has a fixed height (or width) and 'overflow-y' (or 'overflow-x') set to 'auto' so it can scroll correctly and only render the items visible in the scroll viewport.")}),new Error("Rendered items limit reached")},sortViews(){this.pool.sort((e,t)=>e.index-t.index)}}};const Se={key:0,ref:"before",class:"vue-recycle-scroller__slot"},$e={key:1,ref:"after",class:"vue-recycle-scroller__slot"};function _e(e,t,i,s,r,o){const l=Vue.resolveComponent("ResizeObserver"),a=Vue.resolveDirective("observe-visibility");return Vue.withDirectives((Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["vue-recycle-scroller",{ready:r.ready,"page-mode":i.pageMode,[`direction-${e.direction}`]:!0}]),onScrollPassive:t[0]||(t[0]=(...n)=>o.handleScroll&&o.handleScroll(...n))},[e.$slots.before?(Vue.openBlock(),Vue.createElementBlock("div",Se,[Vue.renderSlot(e.$slots,"before")],512)):Vue.createCommentVNode("v-if",!0),(Vue.openBlock(),Vue.createBlock(Vue.resolveDynamicComponent(i.listTag),{ref:"wrapper",style:Vue.normalizeStyle({[e.direction==="vertical"?"minHeight":"minWidth"]:r.totalSize+"px"}),class:Vue.normalizeClass(["vue-recycle-scroller__item-wrapper",i.listClass])},{default:Vue.withCtx(()=>[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(r.pool,n=>(Vue.openBlock(),Vue.createBlock(Vue.resolveDynamicComponent(i.itemTag),Vue.mergeProps({key:n.nr.id,style:r.ready?{transform:`translate${e.direction==="vertical"?"Y":"X"}(${n.position}px) translate${e.direction==="vertical"?"X":"Y"}(${n.offset}px)`,width:i.gridItems?`${e.direction==="vertical"&&i.itemSecondarySize||i.itemSize}px`:void 0,height:i.gridItems?`${e.direction==="horizontal"&&i.itemSecondarySize||i.itemSize}px`:void 0}:null,class:["vue-recycle-scroller__item-view",[i.itemClass,{hover:!i.skipHover&&r.hoverKey===n.nr.key}]]},Vue.toHandlers(i.skipHover?{}:{mouseenter:()=>{r.hoverKey=n.nr.key},mouseleave:()=>{r.hoverKey=null}})),{default:Vue.withCtx(()=>[Vue.renderSlot(e.$slots,"default",{item:n.item,index:n.nr.index,active:n.nr.used})]),_:2},1040,["style","class"]))),128)),Vue.renderSlot(e.$slots,"empty")]),_:3},8,["style","class"])),e.$slots.after?(Vue.openBlock(),Vue.createElementBlock("div",$e,[Vue.renderSlot(e.$slots,"after")],512)):Vue.createCommentVNode("v-if",!0),Vue.createVNode(l,{onNotify:o.handleResize},null,8,["onNotify"])],34)),[[a,o.handleVisibilityChange]])}B.render=_e;B.__file="src/components/RecycleScroller.vue";var Q={name:"DynamicScroller",components:{RecycleScroller:B},provide(){return typeof ResizeObserver<"u"&&(this.$_resizeObserver=new ResizeObserver(e=>{requestAnimationFrame(()=>{if(!!Array.isArray(e)){for(const t of e)if(t.target){const i=new CustomEvent("resize",{detail:{contentRect:t.contentRect}});t.target.dispatchEvent(i)}}})})),{vscrollData:this.vscrollData,vscrollParent:this,vscrollResizeObserver:this.$_resizeObserver}},inheritAttrs:!1,props:{...G,minItemSize:{type:[Number,String],required:!0}},emits:["resize","visible"],data(){return{vscrollData:{active:!0,sizes:{},validSizes:{},keyField:this.keyField,simpleArray:!1}}},computed:{simpleArray:J,itemsWithSize(){const e=[],{items:t,keyField:i,simpleArray:s}=this,r=this.vscrollData.sizes,o=t.length;for(let l=0;l<o;l++){const a=t[l],n=s?l:a[i];let d=r[n];typeof d>"u"&&!this.$_undefinedMap[n]&&(d=0),e.push({item:a,id:n,size:d})}return e}},watch:{items(){this.forceUpdate(!1)},simpleArray:{handler(e){this.vscrollData.simpleArray=e},immediate:!0},direction(e){this.forceUpdate(!0)},itemsWithSize(e,t){const i=this.$el.scrollTop;let s=0,r=0;const o=Math.min(e.length,t.length);for(let a=0;a<o&&!(s>=i);a++)s+=t[a].size||this.minItemSize,r+=e[a].size||this.minItemSize;const l=r-s;l!==0&&(this.$el.scrollTop+=l)}},beforeCreate(){this.$_updates=[],this.$_undefinedSizes=0,this.$_undefinedMap={},this.$_events=me()},activated(){this.vscrollData.active=!0},deactivated(){this.vscrollData.active=!1},unmounted(){this.$_events.all.clear()},methods:{onScrollerResize(){this.$refs.scroller&&this.forceUpdate(),this.$emit("resize")},onScrollerVisible(){this.$_events.emit("vscroll:update",{force:!1}),this.$emit("visible")},forceUpdate(e=!0){(e||this.simpleArray)&&(this.vscrollData.validSizes={}),this.$_events.emit("vscroll:update",{force:!0})},scrollToItem(e){const t=this.$refs.scroller;t&&t.scrollToItem(e)},getItemSize(e,t=void 0){const i=this.simpleArray?t!=null?t:this.items.indexOf(e):e[this.keyField];return this.vscrollData.sizes[i]||0},scrollToBottom(){if(this.$_scrollingToBottom)return;this.$_scrollingToBottom=!0;const e=this.$el;this.$nextTick(()=>{e.scrollTop=e.scrollHeight+5e3;const t=()=>{e.scrollTop=e.scrollHeight+5e3,requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight+5e3,this.$_undefinedSizes===0?this.$_scrollingToBottom=!1:requestAnimationFrame(t)})};requestAnimationFrame(t)})}}};function Ve(e,t,i,s,r,o){const l=Vue.resolveComponent("RecycleScroller");return Vue.openBlock(),Vue.createBlock(l,Vue.mergeProps({ref:"scroller",items:o.itemsWithSize,"min-item-size":i.minItemSize,direction:e.direction,"key-field":"id","list-tag":e.listTag,"item-tag":e.itemTag},e.$attrs,{onResize:o.onScrollerResize,onVisible:o.onScrollerVisible}),{default:Vue.withCtx(({item:a,index:n,active:d})=>[Vue.renderSlot(e.$slots,"default",Vue.normalizeProps(Vue.guardReactiveProps({item:a.item,index:n,active:d,itemWithSize:a})))]),before:Vue.withCtx(()=>[Vue.renderSlot(e.$slots,"before")]),after:Vue.withCtx(()=>[Vue.renderSlot(e.$slots,"after")]),empty:Vue.withCtx(()=>[Vue.renderSlot(e.$slots,"empty")]),_:3},16,["items","min-item-size","direction","list-tag","item-tag","onResize","onVisible"])}Q.render=Ve;Q.__file="src/components/DynamicScroller.vue";var we={name:"DynamicScrollerItem",inject:["vscrollData","vscrollParent","vscrollResizeObserver"],props:{item:{required:!0},watchData:{type:Boolean,default:!1},active:{type:Boolean,required:!0},index:{type:Number,default:void 0},sizeDependencies:{type:[Array,Object],default:null},emitResize:{type:Boolean,default:!1},tag:{type:String,default:"div"}},emits:["resize"],computed:{id(){if(this.vscrollData.simpleArray)return this.index;if(this.item.hasOwnProperty(this.vscrollData.keyField))return this.item[this.vscrollData.keyField];throw new Error(`keyField '${this.vscrollData.keyField}' not found in your item. You should set a valid keyField prop on your Scroller`)},size(){return this.vscrollData.validSizes[this.id]&&this.vscrollData.sizes[this.id]||0},finalActive(){return this.active&&this.vscrollData.active}},watch:{watchData:"updateWatchData",id(){this.size||this.onDataUpdate()},finalActive(e){this.size||(e?this.vscrollParent.$_undefinedMap[this.id]||(this.vscrollParent.$_undefinedSizes++,this.vscrollParent.$_undefinedMap[this.id]=!0):this.vscrollParent.$_undefinedMap[this.id]&&(this.vscrollParent.$_undefinedSizes--,this.vscrollParent.$_undefinedMap[this.id]=!1)),this.vscrollResizeObserver?e?this.observeSize():this.unobserveSize():e&&this.$_pendingVScrollUpdate===this.id&&this.updateSize()}},created(){if(!this.$isServer&&(this.$_forceNextVScrollUpdate=null,this.updateWatchData(),!this.vscrollResizeObserver)){for(const e in this.sizeDependencies)this.$watch(()=>this.sizeDependencies[e],this.onDataUpdate);this.vscrollParent.$_events.on("vscroll:update",this.onVscrollUpdate)}},mounted(){this.vscrollData.active&&(this.updateSize(),this.observeSize())},beforeUnmount(){this.vscrollParent.$_events.off("vscroll:update",this.onVscrollUpdate),this.unobserveSize()},methods:{updateSize(){this.finalActive?this.$_pendingSizeUpdate!==this.id&&(this.$_pendingSizeUpdate=this.id,this.$_forceNextVScrollUpdate=null,this.$_pendingVScrollUpdate=null,this.computeSize(this.id)):this.$_forceNextVScrollUpdate=this.id},updateWatchData(){this.watchData&&!this.vscrollResizeObserver?this.$_watchData=this.$watch("item",()=>{this.onDataUpdate()},{deep:!0}):this.$_watchData&&(this.$_watchData(),this.$_watchData=null)},onVscrollUpdate({force:e}){!this.finalActive&&e&&(this.$_pendingVScrollUpdate=this.id),(this.$_forceNextVScrollUpdate===this.id||e||!this.size)&&this.updateSize()},onDataUpdate(){this.updateSize()},computeSize(e){this.$nextTick(()=>{if(this.id===e){const t=this.$el.offsetWidth,i=this.$el.offsetHeight;this.applySize(t,i)}this.$_pendingSizeUpdate=null})},applySize(e,t){const i=~~(this.vscrollParent.direction==="vertical"?t:e);i&&this.size!==i&&(this.vscrollParent.$_undefinedMap[this.id]&&(this.vscrollParent.$_undefinedSizes--,this.vscrollParent.$_undefinedMap[this.id]=void 0),this.vscrollData.sizes[this.id]=i,this.vscrollData.validSizes[this.id]=!0,this.emitResize&&this.$emit("resize",this.id))},observeSize(){!this.vscrollResizeObserver||!this.$el.parentNode||(this.vscrollResizeObserver.observe(this.$el.parentNode),this.$el.parentNode.addEventListener("resize",this.onResize))},unobserveSize(){!this.vscrollResizeObserver||(this.vscrollResizeObserver.unobserve(this.$el.parentNode),this.$el.parentNode.removeEventListener("resize",this.onResize))},onResize(e){const{width:t,height:i}=e.detail.contentRect;this.applySize(t,i)}},render(){return Vue.h(this.tag,this.$slots.default())}};we.__file="src/components/DynamicScrollerItem.vue";export{we as a,Q as s};