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D,KAAK,cAAL,CAAoB,OAApB,EAA6B,CAC3B,KAAK,MAAL,CAAY,aAAZ,CAD2B,EAE3B,KAAK,OAAL,EAF2B,EAG3B,KAAK,MAAL,CAAY,YAAZ,CAH2B,CAA7B,CADC,CAHI,CAAP;AAUD,KApCM;AAqCP,IAAA,UArCO,wBAqCG;AACR,aAAO,KAAK,cAAL,CAAoB,KAApB,EAA2B;AAChC,QAAA,WAAW,EAAE,0BADmB;AAEhC,QAAA,KAAK,EAAE;AACL,UAAA,MAAM,EAAE,4BAAc,KAAK,MAAnB;AADH;AAFyB,OAA3B,EAKJ,CACD,KAAK,QAAL,EADC,CALI,CAAP;AAQD;AA9CM,GAhFwC;AAiIjD,EAAA,MAjIiD,kBAiIzC,CAjIyC,EAiIxC;AACP,WAAO,CAAC,CAAC,KAAD,EAAQ;AACd,MAAA,WAAW,EAAE,8BADC;AAEd,MAAA,KAAK,EAAE,KAAK;AAFE,KAAR,EAGL,CACD,KAAK,MAAL,CAAY,GADX,EAED,KAAK,UAAL,EAFC,EAGD,KAAK,MAAL,CAAY,MAHX,CAHK,CAAR;AAQD;AA1IgD,CAApC,C","sourcesContent":["import './VVirtualTable.sass'\n\n// Components\nimport VSimpleTable from './VSimpleTable'\n\n// Types\nimport { VNode, VNodeChildren } from 'vue'\nimport { PropValidator } from 'vue/types/options'\nimport mixins from '../../util/mixins'\n\n// Utiltiies\nimport { convertToUnit, debounce } from '../../util/helpers'\n\n// Types\nconst baseMixins = mixins(VSimpleTable)\n\ninterface options extends InstanceType<typeof baseMixins> {\n $refs: {\n table: HTMLElement\n }\n cachedItems: VNodeChildren\n}\n\nexport default baseMixins.extend<options>().extend({\n name: 'v-virtual-table',\n\n props: {\n chunkSize: {\n type: Number,\n default: 25,\n },\n headerHeight: {\n type: Number,\n default: 48,\n },\n items: {\n type: Array,\n default: () => ([]),\n } as PropValidator<any[]>,\n rowHeight: {\n type: Number,\n default: 48,\n },\n },\n\n data: () => ({\n scrollTop: 0,\n oldChunk: 0,\n scrollDebounce: null as any,\n invalidateCache: false,\n }),\n\n computed: {\n itemsLength (): number {\n return this.items.length\n },\n totalHeight (): number {\n return (this.itemsLength * this.rowHeight) + this.headerHeight\n },\n topIndex (): number {\n return Math.floor(this.scrollTop / this.rowHeight)\n },\n chunkIndex (): number {\n return Math.floor(this.topIndex / this.chunkSize)\n },\n startIndex (): number {\n return Math.max(0, (this.chunkIndex * this.chunkSize) - this.chunkSize)\n },\n offsetTop (): number {\n return Math.max(0, this.startIndex * this.rowHeight)\n },\n stopIndex (): number {\n return Math.min(this.startIndex + (this.chunkSize * 3), this.itemsLength)\n },\n offsetBottom (): number {\n return Math.max(0, (this.itemsLength - this.stopIndex - this.startIndex) * this.rowHeight)\n },\n },\n\n watch: {\n chunkIndex (newValue, oldValue) {\n this.oldChunk = oldValue\n },\n items () {\n this.cachedItems = null\n this.$refs.table.scrollTop = 0\n },\n },\n\n created () {\n this.cachedItems = null\n },\n\n mounted () {\n this.scrollDebounce = debounce(this.onScroll, 50)\n\n this.$refs.table.addEventListener('scroll', this.scrollDebounce, { passive: true })\n },\n\n beforeDestroy () {\n this.$refs.table.removeEventListener('scroll', this.scrollDebounce)\n },\n\n methods: {\n createStyleHeight (height: number) {\n return {\n height: `${height}px`,\n }\n },\n genBody () {\n if (this.cachedItems === null || this.chunkIndex !== this.oldChunk) {\n this.cachedItems = this.genItems()\n this.oldChunk = this.chunkIndex\n }\n\n return this.$createElement('tbody', [\n this.$createElement('tr', { style: this.createStyleHeight(this.offsetTop) }),\n this.cachedItems,\n this.$createElement('tr', { style: this.createStyleHeight(this.offsetBottom) }),\n ])\n },\n genItems () {\n return this.$scopedSlots.items!({ items: this.items.slice(this.startIndex, this.stopIndex) })\n },\n onScroll (e: Event) {\n const target = e.target as Element\n this.scrollTop = target.scrollTop\n },\n genTable () {\n return this.$createElement('div', {\n ref: 'table',\n staticClass: 'v-virtual-table__table',\n }, [\n this.$createElement('table', [\n this.$slots['body.before'],\n this.genBody(),\n this.$slots['body.after'],\n ]),\n ])\n },\n genWrapper () {\n return this.$createElement('div', {\n staticClass: 'v-virtual-table__wrapper',\n style: {\n height: convertToUnit(this.height),\n },\n }, [\n this.genTable(),\n ])\n },\n },\n\n render (h): VNode {\n return h('div', {\n staticClass: 'v-data-table v-virtual-table',\n class: this.classes,\n }, [\n this.$slots.top,\n this.genWrapper(),\n this.$slots.bottom,\n ])\n },\n})\n"],"sourceRoot":"","file":"VVirtualTable.js"} |