mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
7 lines
17 KiB
JavaScript
Vendored
7 lines
17 KiB
JavaScript
Vendored
import{c as Z}from"./@babel.f9bcab46.js";import{r as tt}from"./vue.fd9b772e.js";import{l as et}from"./lodash.18c5398d.js";var k={exports:{}};/*!
|
|
* vue-virtual-scroll-list v2.3.5-16
|
|
* open source under the MIT license
|
|
* https://github.com/tangbc/vue-virtual-scroll-list#readme
|
|
*/(function(q,it){(function(h,z){q.exports=z(tt,et.exports)})(Z,function(h,z){h=h&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h;function b(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?b=function(e){return typeof e}:b=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(r)}function w(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function C(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,i.key,i)}}function D(r,e,t){return e&&C(r.prototype,e),t&&C(r,t),r}function A(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function B(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,i)}return t}function M(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?B(Object(t),!0).forEach(function(i){A(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):B(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function N(r){return _(r)||j(r)||H(r)||L()}function _(r){if(Array.isArray(r))return E(r)}function j(r){if(typeof Symbol!="undefined"&&Symbol.iterator in Object(r))return Array.from(r)}function H(r,e){if(!!r){if(typeof r=="string")return E(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return E(r,e)}}function E(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=r[t];return i}function L(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var m={FRONT:"FRONT",BEHIND:"BEHIND"},p={INIT:"INIT",FIXED:"FIXED",DYNAMIC:"DYNAMIC"},F=0,K=function(){function r(e,t,i){w(this,r),this.init(e,t,i)}return D(r,[{key:"init",value:function(t,i,s){this.param=t,this.callUpdate=typeof i=="function"?i:function(){},this.callBefore=typeof s=="function"?s:function(){},this.sizes=new Map,this.firstRangeTotalSize=0,this.firstRangeAverageSize=0,this.fixedSizeValue=0,this.calcType=p.INIT,this.temporaryEstimatedSize=0,this.offset=0,this.direction="",this.range=Object.create(null),t&&this.checkRange(0,t.keeps-1)}},{key:"destroy",value:function(){this.init(null,null)}},{key:"getRange",value:function(){var t=Object.create(null);return t.start=this.range.start,t.end=this.range.end,t.padFront=this.range.padFront,t.padBehind=this.range.padBehind,t}},{key:"isBehind",value:function(){return this.direction===m.BEHIND}},{key:"isFront",value:function(){return this.direction===m.FRONT}},{key:"getOffset",value:function(t){return(t<1?0:this.getIndexOffset(t))+this.param.slotHeaderSize}},{key:"updateParam",value:function(t,i){var s=this;this.param&&t in this.param&&(t==="uniqueIds"&&this.sizes.forEach(function(a,n){i.includes(n)||s.sizes.delete(n)}),this.param[t]=i)}},{key:"saveSize",value:function(t,i){this.sizes.set(t,i),this.calcType===p.INIT?(this.fixedSizeValue=i,this.calcType=p.FIXED):this.calcType===p.FIXED&&this.fixedSizeValue!==i&&(this.calcType=p.DYNAMIC,delete this.fixedSizeValue),this.calcType!==p.FIXED&&typeof this.firstRangeTotalSize!="undefined"&&(this.sizes.size<Math.min(this.param.keeps,this.param.uniqueIds.length)?(this.firstRangeTotalSize=N(this.sizes.values()).reduce(function(s,a){return s+a},0),this.firstRangeAverageSize=Math.round(this.firstRangeTotalSize/this.sizes.size)):delete this.firstRangeTotalSize)}},{key:"handleDataSourcesChange",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,i=this.range.start;this.isFront()?i=i-F:this.isBehind()&&(i=i+F),i=Math.max(i,0),t&&b(t)==="object"&&typeof t.estimateSize=="number"?this.temporaryEstimatedSize=t.estimateSize:this.temporaryEstimatedSize=0,this.updateRange(this.range.start,this.getEndByStart(i))}},{key:"handleSlotSizeChange",value:function(){this.handleDataSourcesChange()}},{key:"handleScroll",value:function(t){this.direction=t<this.offset||t===0?m.FRONT:m.BEHIND,this.offset=t,this.param&&(this.direction===m.FRONT?this.handleFront():this.direction===m.BEHIND&&this.handleBehind())}},{key:"handleFront",value:function(){var t=this.getScrollOvers();if(!(t>this.range.start)){var i=Math.max(t-this.param.buffer,0);this.checkRange(i,this.getEndByStart(i))}}},{key:"handleBehind",value:function(){var t=this.getScrollOvers();t<this.range.start+this.param.buffer||this.checkRange(t,this.getEndByStart(t))}},{key:"getScrollOvers",value:function(){var t=this.offset-this.param.slotHeaderSize;if(t<=0)return 0;if(this.isFixedType())return Math.floor(t/this.fixedSizeValue);for(var i=0,s=0,a=0,n=this.param.uniqueIds.length;i<=n;){if(s=i+Math.floor((n-i)/2),a=this.getIndexOffset(s),a===t)return s;a<t?i=s+1:a>t&&(n=s-1)}return i>0?--i:0}},{key:"getIndexOffset",value:function(t){if(!t)return 0;for(var i=0,s=0,a=0;a<t;a++)s=this.sizes.get(this.param.uniqueIds[a]),i=i+(typeof s=="number"?s:this.getEstimateSize());return i}},{key:"isFixedType",value:function(){return this.calcType===p.FIXED}},{key:"getLastIndex",value:function(){return this.param.uniqueIds.length-1}},{key:"checkRange",value:function(t,i){var s=this.param.keeps,a=this.param.uniqueIds.length;a<=s?(t=0,i=this.getLastIndex()):i-t<s-1&&(t=i-s+1),this.range.start!==t&&this.updateRange(t,i)}},{key:"updateRange",value:function(t,i){this.callBefore(),this.range.start=t,this.range.end=i,this.range.padFront=this.getPadFront(),this.range.padBehind=this.getPadBehind(),this.callUpdate(this.getRange())}},{key:"getEndByStart",value:function(t){var i=t+this.param.keeps-1,s=Math.min(i,this.getLastIndex());return s}},{key:"getPadFront",value:function(){return this.isFixedType()?this.fixedSizeValue*this.range.start:this.getIndexOffset(this.range.start)}},{key:"getPadBehind",value:function(){var t=this.range.end,i=this.getLastIndex();return(i-t)*this.getEstimateSize()}},{key:"getEstimateSize",value:function(){return this.isFixedType()?this.fixedSizeValue:this.temporaryEstimatedSize>0?this.temporaryEstimatedSize:this.param.estimateSize}}]),r}(),U={dataKey:{type:[String,Function],required:!0},dataSources:{type:Array,required:!0},dataComponent:{type:[Object,Function],required:!0},keeps:{type:Number,default:30},extraProps:{type:Object},estimateSize:{type:Number,default:50},direction:{type:String,default:"vertical"},start:{type:Number,default:0},offset:{type:Number,default:0},topThreshold:{type:Number,default:0},bottomThreshold:{type:Number,default:0},pageMode:{type:Boolean,default:!1},rootTag:{type:String,default:"div"},wrapTag:{type:String,default:"div"},wrapClass:{type:String,default:""},wrapStyle:{type:Object},itemTag:{type:String,default:"div"},itemClass:{type:String,default:""},itemClassAdd:{type:Function},itemStyle:{type:Object},headerTag:{type:String,default:"div"},headerClass:{type:String,default:""},headerStyle:{type:Object},footerTag:{type:String,default:"div"},footerClass:{type:String,default:""},footerStyle:{type:Object},itemScopedSlots:{type:Object},disabled:{type:Boolean,default:!1},activePrefix:{type:String,default:""}},V={index:{type:Number},event:{type:String},tag:{type:String},horizontal:{type:Boolean},source:{type:Object},component:{type:[Object,Function]},slotComponent:{type:Function},uniqueKey:{type:[String,Number]},extraProps:{type:Object},scopedSlots:{type:Object}},Y={event:{type:String},uniqueKey:{type:String},tag:{type:String},horizontal:{type:Boolean}},P={created:function(){this.shapeKey=this.horizontal?"offsetWidth":"offsetHeight"},mounted:function(){var e=this;typeof ResizeObserver!="undefined"&&(this.resizeObserver=new ResizeObserver(function(){e.dispatchSizeChange()}),this.resizeObserver.observe(this.$el))},updated:function(){this.dispatchSizeChange()},beforeDestroy:function(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)},methods:{getCurrentSize:function(){return this.$el?this.$el[this.shapeKey]:0},dispatchSizeChange:function(){this.$parent.$emit(this.event,this.uniqueKey,this.getCurrentSize(),this.hasInitial)}}},X=h.component("virtual-list-item",{mixins:[P],props:V,render:function(e){var t=this.tag,i=this.component,s=this.extraProps,a=s===void 0?{}:s,n=this.index,o=this.source,l=this.scopedSlots,g=l===void 0?{}:l,u=this.uniqueKey,f=this.slotComponent,c=M({},a,{source:o,index:n});return e(t,{key:u,attrs:{role:"listitem",unique:u}},[f?f({item:o,index:n,scope:c}):e(i,{props:c,scopedSlots:g})])}}),R=h.component("virtual-list-slot",{mixins:[P],props:Y,render:function(e){var t=this.tag,i=this.uniqueKey;return e(t,{key:i,attrs:{role:i}},this.$slots.default)}}),y={ITEM:"item_resize",SLOT:"slot_resize"},T={HEADER:"thead",FOOTER:"tfoot"},W=h.component("virtual-list",{props:U,data:function(){return{range:null,toBottomTimer:null,visibleUniques:null}},watch:{"dataSources.length":function(e){this.virtual.updateParam("uniqueIds",this.getUniqueIdFromDataSources()),this.virtual.handleDataSourcesChange(e>0?this.dataSources[e-1]:null)},estimateSize:function(e){this.virtual.updateParam("estimateSize",e)},keeps:function(e){this.virtual.updateParam("keeps",e),this.virtual.handleSlotSizeChange()},start:function(e){this.scrollToIndex(e)},offset:function(e){this.scrollToOffset(e)},visibleUniques:function(e){this.$emit("visible",JSON.parse(e))}},created:function(){this.isHorizontal=this.direction==="horizontal",this.directionKey=this.isHorizontal?"scrollLeft":"scrollTop",this.installVirtual(),this.$on(y.ITEM,this.onItemResized),(this.$slots.header||this.$slots.footer)&&this.$on(y.SLOT,this.onSlotResized)},activated:function(){this.scrollToOffset(this.virtual.offset),this.pageMode&&document.addEventListener("scroll",this.onScroll,{passive:!1})},deactivated:function(){this.pageMode&&document.removeEventListener("scroll",this.onScroll)},mounted:function(){this.start?this.scrollToIndex(this.start):this.offset&&this.scrollToOffset(this.offset),this.pageMode&&(this.updatePageModeFront(),document.addEventListener("scroll",this.onScroll,{passive:!1}))},beforeDestroy:function(){this.virtual.destroy(),this.pageMode&&document.removeEventListener("scroll",this.onScroll)},methods:{getSize:function(e){return this.virtual.sizes.get(e)},getSizes:function(){return this.virtual.sizes.size},getOffset:function(){if(this.pageMode)return document.documentElement[this.directionKey]||document.body[this.directionKey];var e=this.$refs.root;return e?Math.ceil(e[this.directionKey]):0},getClientSize:function(){var e=this.isHorizontal?"clientWidth":"clientHeight";if(this.pageMode)return document.documentElement[e]||document.body[e];var t=this.$refs.root;return t?Math.ceil(t[e]):0},getScrollSize:function(){var e=this.isHorizontal?"scrollWidth":"scrollHeight";if(this.pageMode)return document.documentElement[e]||document.body[e];var t=this.$refs.root;return t?Math.ceil(t[e]):0},scrollToBehavior:function(e,t,i){if(i){var s={behavior:"smooth"};this.isHorizontal?s.left=t:s.top=t,e.scrollTo(s)}else e[this.directionKey]=t},scrollToOffset:function(e){var t=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.$emit("activity",!0),this.pageMode)this.scrollToBehavior(document.body,e,i),this.scrollToBehavior(document.documentElement,e,i);else{var s=this.$refs.root;s&&this.scrollToBehavior(s,e,i)}requestAnimationFrame(function(){t.leaveAndEnter(),t.$emit("activity",!1)})},scrollToIndex:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(e>=this.dataSources.length-1)this.scrollToBottom();else{var i=this.virtual.getOffset(e);t!==0&&(i=Math.max(0,i+t)),this.scrollToOffset(i)}},scrollToBottom:function(){var e=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,i=this.$refs.shepherd;if(i){var s=i[this.isHorizontal?"offsetLeft":"offsetTop"];if(this.scrollToOffset(s,t),t)return;this.toBottomTimer&&(clearTimeout(this.toBottomTimer),this.toBottomTimer=null),this.toBottomTimer=setTimeout(function(){e.getOffset()+e.getClientSize()+1<e.getScrollSize()&&e.scrollToBottom()},3)}},stopToBottom:function(){this.toBottomTimer&&(clearTimeout(this.toBottomTimer),this.toBottomTimer=null)},scrollStop:function(){this.stopToBottom(),this.scrollToOffset(this.getOffset())},scrollInfo:function(){var e=this.getClientSize(),t=this.getOffset(),i=this.getScrollSize();return{offset:t,scale:t/(i-e),tail:i-e-t}},updatePageModeFront:function(){var e=this.$refs.root;if(e){var t=e.getBoundingClientRect(),i=e.ownerDocument.defaultView,s=this.isHorizontal?t.left+i.pageXOffset:t.top+i.pageYOffset;this.virtual.updateParam("slotHeaderSize",s)}},reset:function(){this.virtual.destroy(),this.scrollToOffset(0),this.installVirtual()},installVirtual:function(){this.virtual=new K({slotHeaderSize:0,slotFooterSize:0,keeps:this.keeps,estimateSize:this.estimateSize,buffer:Math.round(this.keeps/3),uniqueIds:this.getUniqueIdFromDataSources()},this.onRangeChanged,this.onBeforeChanged),this.range=this.virtual.getRange(),this.$emit("range",this.range)},getUniqueIdFromDataSources:function(){var e=this.dataKey;return this.dataSources.map(function(t){return typeof e=="function"?e(t):t[e]})},onItemResized:function(e,t){this.virtual.saveSize(e,t),this.visibleFind(),this.$emit("resized",e,t)},onSlotResized:function(e,t,i){e===T.HEADER?this.virtual.updateParam("slotHeaderSize",t):e===T.FOOTER&&this.virtual.updateParam("slotFooterSize",t),i&&this.virtual.handleSlotSizeChange()},onBeforeChanged:function(){this.$emit("activity",!0)},onRangeChanged:function(e){var t=this;this.range=e,this.$emit("range",this.range),requestAnimationFrame(function(){t.leaveAndEnter(),t.$emit("activity",!1)})},onScroll:function(e){if(!this.disabled){var t=this.getOffset(),i=this.getClientSize(),s=this.getScrollSize();t<0||t+i>s+1||!s||(this.virtual.handleScroll(t),this.leaveAndEnter(),this.emitEvent(t,i,s,e))}},emitEvent:function(e,t,i,s){this.$emit("scroll",s,this.virtual.getRange()),this.virtual.isFront()&&!!this.dataSources.length&&e-this.topThreshold<=0?this.$emit("totop"):this.virtual.isBehind()&&e+t+this.bottomThreshold>=i&&this.$emit("tobottom")},leaveAndEnter:z.throttle(function(){var r=this;if(!(!this.activePrefix||!this.$refs.root)){var e=[],t=this.$refs.root.getBoundingClientRect(),i=this.$refs.root.querySelectorAll('div[role="listitem"]');i.forEach(function(s){var a=Number(s.getAttribute("unique")),n=s.getBoundingClientRect();if(n.top<t.bottom&&n.bottom>t.top&&n.left<t.right&&n.right>t.left?(s.classList.remove("".concat(r.activePrefix,"-leave")),e.push(a)):s.classList.add("".concat(r.activePrefix,"-leave")),r.isHorizontal){var o=Math.min(100,n.width/2),l=n.left+o,g=n.right-o;g<t.left||l>t.right?s.classList.remove("".concat(r.activePrefix,"-enter")):s.classList.add("".concat(r.activePrefix,"-enter"))}else{var u=Math.min(100,n.height/2),f=n.top+u,c=n.bottom-u;c<t.top||f>t.bottom?s.classList.remove("".concat(r.activePrefix,"-enter")):s.classList.add("".concat(r.activePrefix,"-enter"))}}),this.visibleUniques=JSON.stringify(e)}},16),visibleFind:z.debounce(function(){if(!(!this.activePrefix||!this.$refs.root)){var r=this.$refs.root.querySelectorAll('div[role="listitem"]:not(.'.concat(this.activePrefix,"-leave)"));this.visibleUniques=JSON.stringify(Array.from(r).map(function(e){return Number(e.getAttribute("unique"))}))}},50),getRenderSlots:function(e){for(var t=[],i=this.range,s=i.start,a=i.end,n=this.dataSources,o=this.dataKey,l=this.itemClass,g=this.itemTag,u=this.itemStyle,f=this.isHorizontal,c=this.extraProps,O=this.dataComponent,I=this.itemScopedSlots,x=this.$scopedSlots&&this.$scopedSlots.item,d=s;d<=a;d++){var v=n[d];if(v){var S=typeof o=="function"?o(v):v[o];typeof S=="string"||typeof S=="number"?t.push(e(X,{props:{index:d,tag:g,event:y.ITEM,horizontal:f,uniqueKey:S,source:v,extraProps:c,component:O,slotComponent:x,scopedSlots:I},style:u,class:[l,this.itemClassAdd?this.itemClassAdd(d):null]})):console.warn("Cannot get the data-key '".concat(o,"' from data-sources."))}else console.warn("Cannot get the index '".concat(d,"' from data-sources."))}return t}},render:function(e){var t=this.$slots,i=t.header,s=t.footer,a=this.range,n=a.padFront,o=a.padBehind,l=this.isHorizontal,g=this.pageMode,u=this.rootTag,f=this.wrapTag,c=this.wrapClass,O=this.wrapStyle,I=this.headerTag,x=this.headerClass,d=this.headerStyle,v=this.footerTag,S=this.footerClass,J=this.footerStyle,G=this.disabled,$={padding:l?"0px ".concat(o,"px 0px ").concat(n,"px"):"".concat(n,"px 0px ").concat(o,"px")},Q=O?Object.assign({},O,$):$;return e(u,{ref:"root",style:G?{overflow:"hidden"}:null,on:{"&scroll":!g&&this.onScroll}},[i?e(R,{class:x,style:d,props:{tag:I,event:y.SLOT,uniqueKey:T.HEADER}},i):null,e(f,{class:c,attrs:{role:"group"},style:Q},this.getRenderSlots(e)),s?e(R,{class:S,style:J,props:{tag:v,event:y.SLOT,uniqueKey:T.FOOTER}},s):null,e("div",{ref:"shepherd",style:{width:l?"0px":"100%",height:l?"100%":"0px"}})])}});return W})})(k);var at=k.exports;export{at as V};
|