element-gui
Version:
A Component Library for Vue.js.
1 lines • 16.4 kB
JavaScript
module.exports=function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/dist/",n(n.s=143)}({0:function(t,e,n){"use strict";function i(t,e,n,i,r,o,l,s){var a,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),l?(a=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(l)},u._ssrRegister=a):r&&(a=s?function(){r.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:r),a)if(u.functional){u._injectStyles=a;var c=u.render;u.render=function(t,e){return a.call(e),c(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,a):[a]}return{exports:t,options:u}}n.d(e,"a",(function(){return i}))},143:function(t,e,n){"use strict";n.r(e);var i=function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"el-table-virtual",class:[this.isExpanding?"is-expanding":"",this.isHideAppend?"hide-append":"",this.scrollPosition?"is-scrolling-"+this.scrollPosition:""]},[this._t("default")],2)};i._withStripped=!0;var r=n(23),o=n.n(r),l=n(2),s=n(6);function a(t){var e=window.getComputedStyle(t,null),n=["auto","scroll"];return n.includes(e.overflow)||n.includes(e["overflow-y"])}function u(t){return t===window?window.pageYOffset:t.scrollTop}function c(t,e){t===window?window.scroll(0,e):t.scrollTop=e}function f(t){return null==t}var d=[".el-table__body-wrapper",".el-table__fixed-right .el-table__fixed-body-wrapper",".el-table__fixed .el-table__fixed-body-wrapper"],h={name:"el-table-virtual",props:{data:{type:Array,required:!0},itemSize:{type:Number,default:40},scrollBox:{type:String},buffer:{type:Number,default:400},keyProp:{type:String,default:"id"},throttleTime:{type:Number,default:10},dynamic:{type:Boolean,default:!0},virtualized:{type:Boolean,default:!0},rowSpanKey:{type:Function},clearFixedMapTime:{type:Number,default:2e3}},data:function(){return{sizes:{},start:0,end:void 0,curRow:null,isExpanding:!1,isHideAppend:!1,scrollPosition:""}},computed:{offsetMap:function(t){var e=t.keyProp,n=t.itemSize,i=t.sizes,r=t.data;if(!this.dynamic)return{};for(var o={},l=0,s=0;s<r.length;s++){var a=r[s][e];void 0===a&&console.warn("data["+s+"]["+e+"] 为 undefined,请确保 keyProp 对应的值不为undefined"),o[a]=l;var u=i[a];l+="number"==typeof u?u:n}return o},isExpand:function(){return this.elTable.$children.filter((function(t){return t.columnConfig&&"expand"===t.columnConfig.type})).length>0}},methods:{initData:function(){var t=this;if(this.renderData=[],this.top=void 0,this.bottom=void 0,this.start=0,this.end=void 0,this.isInnerScroll=!1,this.toTop=0,this.elTable=this.$children[0],!this.elTable||"ElTable"!==this.elTable.$options.name)throw new Error("Error! el-table-virtual slot must be el-table");this.scroller=this.getScroller(),this.setToTop(),this.observeScrollPosition(),setTimeout((function(){t.handleScroll()}),100),this.onScroll=this.throttleTime?o()(this.throttleTime,this.handleScroll):this.handleScroll,this.scroller.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.onScroll),this.bindTableExpandEvent()},getScroller:function(){var t=void 0;if(this.scrollBox){if("window"===this.scrollBox||this.scrollBox===window)return window;if(!(t=document.querySelector(this.scrollBox)))throw new Error(" scrollBox prop: '"+this.scrollBox+"' is not a valid selector");return a(t)||console.warn("Warning! scrollBox prop: '"+this.scrollBox+"' is not a scroll element"),t}return this.elTable&&(this.elTable.height||this.elTable.maxHeight)?(this.isInnerScroll=!0,this.$el.querySelector(".el-table__scrollbar-wrap")):function(t){for(var e=t;e;){if([window,document,document.documentElement].includes(e))return window;if(a(e))return e;e=e.parentNode}return e||window}(this.$el)},setToTop:function(){this.isInnerScroll?this.toTop=0:this.toTop=this.$el.getBoundingClientRect().top-(this.scroller===window?0:this.scroller.getBoundingClientRect().top)+u(this.scroller)},observeScrollPosition:function(){var t=this;this.scrollUnWatch=this.$watch((function(){return t.elTable.scrollPosition}),(function(e){t.scrollPosition=e}),{immediate:!0})},handleScroll:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.virtualized&&(!this.isInnerScroll||this.scroller?(this.updateSizes(),this.removeHoverRows(),this.calcRenderData(),this.calcPosition(),t&&this.updatePosition(),this.$emit("change",this.renderData,this.start,this.end),this.setRowsExpanded(),0===this.start&&this.end>30&&this.end===this.data.length-1&&console.warn("[el-table-virtual] all data rendering,render count:"+this.data.length)):this.updatePosition())},removeHoverRows:function(){var t=this.$el.querySelectorAll(".el-table__cell-row-hover");t.length>1&&Array.from(t).forEach((function(t){t.classList.remove("el-table__cell-row-hover")}))},updateSizes:function(){var t=this;if(this.dynamic){var e=this.$el.querySelectorAll(".el-table__body > tbody > .el-table__row"),n=this.elTable.lazy,i=/el-table__row--level-[1-9]\d*/;n&&(e=Array.from(this.$el.querySelectorAll(".el-table__body > tbody > .el-table__row")).filter((function(t){return!i.test(t.className)}))),Array.from(e).forEach((function(e,r){var o=t.renderData[r];if(o){var l=e.offsetHeight;if(e.classList.contains("expanded")&&e.nextSibling&&i.test(e.nextSibling.className)&&(l+=e.nextSibling.offsetHeight),n)for(var s=e.nextSibling;s&&"TR"===s.tagName&&i.test(s.className);)l+=s.offsetHeight,s=s.nextSibling;var a=o[t.keyProp];l&&t.sizes[a]!==l&&t.$set(t.sizes,a,l)}}))}},getItemOffsetTop:function(t){if(!this.dynamic)return this.itemSize*t;var e=this.data[t];return e&&this.offsetMap[e[this.keyProp]]||0},getItemSize:function(t){if(t<=-1)return 0;var e=this.data[t];if(e){var n=e[this.keyProp];return this.sizes[n]||this.itemSize}return this.itemSize},calcRenderData:function(){var t,e=this.scroller,n=this.data,i=this.buffer,r=u(e)-i-this.toTop,o=u(e)+((t=e)===window?window.innerHeight:t.offsetHeight)+i-this.toTop,l=void 0,s=void 0;if(this.dynamic){for(var a=0,c=n.length-1,f=0;a<=c;){if(f=Math.floor((a+c)/2),this.getItemOffsetTop(f)<r){if(this.getItemOffsetTop(f+1)>=r)break;a=f+1}else c=f-1}l=f,s=n.length-1;for(var d=l+1;d<n.length;d++){if(this.getItemOffsetTop(d)>=o){s=d;break}}}else l=r<=0?0:Math.floor(r/this.itemSize),s=o<=0?0:Math.ceil(o/this.itemSize);if(this.isRowSpan()){var h=this.calcRenderSpanData(l,s);l=h[0],s=h[1]}else l%2&&(l-=1);this.top=r,this.bottom=o,this.start=l,this.end=s,this.renderData=n.slice(l,s+1)},isRowSpan:function(){return"function"==typeof this.rowSpanKey},calcRenderSpanData:function(t,e){for(var n=void 0;t>0;){var i=this.data[t],r=this.rowSpanKey(i,t);if(f(r))break;if(!f(n)&&n!==r){t++;break}n=r,t--}var o=this.data.length;for(n=void 0;e<o;){var l=this.data[e],s=this.rowSpanKey(l,e);if(!s)break;if(n&&n!==s){e--;break}n=s,e++}return[t,e]},calcPosition:function(){var t=this,e=this.data.length-1,n=this.getItemOffsetTop(e)+this.getItemSize(e),i=this.getItemOffsetTop(this.start);d.forEach((function(e){var r=t.$el.querySelector(e);if(r)if(r.className.indexOf("fixed")>0){if(!r.wrapEl){var o=document.createElement("div");o.classList.add("el-table__fixed-virtual-wrapper");var s=document.createElement("div");s.classList.add("el-table__fixed-virtual-inner"),o.appendChild(s),s.appendChild(r.children[0]),r.insertBefore(o,r.firstChild),r.wrapEl=o,r.innerEl=s}r.wrapEl&&(r.wrapEl.style.height=n+"px",r.innerEl.style.transform="translateY("+i+"px)")}else{var a=r.querySelector(".el-table__scrollbar-view"),u=r.querySelector(".el-table__body");a.style.height=n+"px",u.style.transform="translateY("+i+"px)",Object(l.isIE)()||t.cellFixedStyle()}}))},updatePosition:function(){var t=this;this.timer&&clearTimeout(this.timer),this.timer=setTimeout((function(){t.timer&&clearTimeout(t.timer),t.handleScroll(!1)}),this.throttleTime+10)},renderAllData:function(){var t=this;this.renderData=this.data,this.$emit("change",this.data,0,this.data.length-1),this.$nextTick((function(){d.forEach((function(e){var n=t.$el.querySelector(e);n&&n.wrapEl&&(n.wrapEl.style.height="auto",n.innerEl.style.transform="translateY(0px)")}))}))},update:function(){this.setToTop(),this.handleScroll()},scrollTo:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.data[t];i&&this.scroller&&(this.updateSizes(),this.calcRenderData(),this.$nextTick((function(){var i=e.getItemOffsetTop(t);c(e.scroller,i),n||setTimeout((function(){e.scrollTo(t,!0)}),50)})))},reset:function(){this.sizes={},this.scrollTo(0,!1)},bindTableExpandEvent:function(){var t=this;this.isExpand&&this.elTable.$on("expand-change",(function(e,n){t.$set(e,"$v_expanded",n.includes(e))}))},setRowsExpanded:function(){var t=this;this.isExpand&&this.$nextTick((function(){var e=t.renderData.filter((function(t){return t.$v_expanded}));0!==e.length&&(e.forEach((function(e){t.elTable.toggleRowExpansion(e,!0)})),t.isExpanding=!0,setTimeout((function(){t.isExpanding=!1}),10))}))},toggleRowExpansion:function(t,e){var n="boolean"==typeof e;this.$set(t,"$v_expanded",n?e:!t.$v_expanded),this.renderData.includes(t)&&this.elTable.toggleRowExpansion(t,e)},setCurrentRow:function(t){t&&(this.curRow=t,this.elTable.setCurrentRow(t))},updateData:function(t){this.$emit("update:data",t)},doUpdate:function(){var t=this;this.hasDoUpdate||this.scroller&&(this.isHideAppend=!0,this.update(),this.hasDoUpdate=!0,this.$nextTick((function(){t.hasDoUpdate=!1,t.isHideAppend=!1})))},cellFixedStyle:function(){for(var t,e,n=this,i=this.elTable.$children,r=[],o=[],l=[],a=[],u=0;u<i.length;u++)!0!==i[u].fixedPro&&"left"!==i[u].fixedPro||(r.push(i[u]),o.push(u)),"right"===i[u].fixedPro&&(l.push(i[u]),a.push(u));t=Object(s.i)(r,"left",o),e=Object(s.i)(l.reverse(),"right",a.reverse()).reverse(),this.$nextTick((function(){if(t.length>0)for(var i=0;i<t.length;i++)Object(s.a)(n.elTable.$el,t[i].index,t[i].style,t[i].width);if(e.length>0)for(var r=0;r<e.length;r++)Object(s.a)(n.elTable.$el,e[r].index,e[r].style,e[r].width)}))},doHeaderLayout:function(){this.elTable&&(this.fixedMap=null,this.elTable.$refs.tableHeader.$forceUpdate())}},watch:{data:function(){this.virtualized?this.doUpdate():this.renderAllData()},virtualized:{immediate:!0,handler:function(t){t?this.doUpdate():this.renderAllData()}}},created:function(){var t=this;this.$nextTick((function(){t.initData()}))},beforeDestroy:function(){this.scroller&&(this.scroller.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onScroll)),this.scrollUnWatch&&this.scrollUnWatch()}},p=n(0),v=Object(p.a)(h,i,[],!1,null,null,null).exports;v.install=function(t){t.component(v.name,v)};e.default=v},2:function(t,e){t.exports=require("element-gui/lib/utils/util")},23:function(t,e){t.exports=require("throttle-debounce/throttle")},6:function(t,e,n){"use strict";n.d(e,"e",(function(){return o})),n.d(e,"o",(function(){return s})),n.d(e,"g",(function(){return a})),n.d(e,"h",(function(){return u})),n.d(e,"f",(function(){return c})),n.d(e,"k",(function(){return f})),n.d(e,"j",(function(){return d})),n.d(e,"n",(function(){return p})),n.d(e,"r",(function(){return v})),n.d(e,"q",(function(){return y})),n.d(e,"p",(function(){return m})),n.d(e,"b",(function(){return b})),n.d(e,"s",(function(){return g})),n.d(e,"t",(function(){return x})),n.d(e,"c",(function(){return w})),n.d(e,"l",(function(){return S})),n.d(e,"m",(function(){return T})),n.d(e,"i",(function(){return _})),n.d(e,"a",(function(){return E})),n.d(e,"d",(function(){return $}));var i=n(2),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=function(t){for(var e=t.target;e&&"HTML"!==e.tagName.toUpperCase();){if("TD"===e.tagName.toUpperCase())return e;e=e.parentNode}return null},l=function(t){return null!==t&&"object"===(void 0===t?"undefined":r(t))},s=function(t,e,n,r,o){if(!e&&!r&&(!o||Array.isArray(o)&&!o.length))return t;n="string"==typeof n?"descending"===n?-1:1:n&&n<0?-1:1;var s=r?null:function(n,r){return o?(Array.isArray(o)||(o=[o]),o.map((function(e){return"string"==typeof e?Object(i.getValueByPath)(n,e):e(n,r,t)}))):("$key"!==e&&l(n)&&"$value"in n&&(n=n.$value),[l(n)?Object(i.getValueByPath)(n,e):n])};return t.map((function(t,e){return{value:t,index:e,key:s?s(t,e):null}})).sort((function(t,e){var i=function(t,e){if(r)return r(t.value,e.value);for(var n=0,i=t.key.length;n<i;n++){if(t.key[n]<e.key[n])return-1;if(t.key[n]>e.key[n])return 1}return 0}(t,e);return i||(i=t.index-e.index),i*n})).map((function(t){return t.value}))},a=function(t,e){var n=null;return t.columns.forEach((function(t){t.id===e&&(n=t)})),n},u=function(t,e){for(var n=null,i=0;i<t.columns.length;i++){var r=t.columns[i];if(r.columnKey===e){n=r;break}}return n},c=function(t,e){var n=(e.className||"").match(/el-table_[^\s]+/gm);return n?a(t,n[0]):null},f=function(t,e){if(!t)throw new Error("row is required when get row identity");if("string"==typeof e){if(e.indexOf(".")<0)return t[e];for(var n=e.split("."),i=t,r=0;r<n.length;r++)i=i[n[r]];return i}if("function"==typeof e)return e.call(null,t)},d=function(t,e){var n={};return(t||[]).forEach((function(t,i){n[f(t,e)]={row:t,index:i}})),n};function h(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function p(t,e){var n={},i=void 0;for(i in t)n[i]=t[i];for(i in e)if(h(e,i)){var r=e[i];void 0!==r&&(n[i]=r)}return n}function v(t){return void 0!==t&&(t=parseInt(t,10),isNaN(t)&&(t=null)),t}function y(t){return void 0!==t&&(t=v(t),isNaN(t)&&(t=80)),t}function m(t){return"number"==typeof t?t:"string"==typeof t?/^\d+(?:px)?$/.test(t)?parseInt(t,10):t:null}function b(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce((function(t,e){return function(){return t(e.apply(void 0,arguments))}}))}function g(t,e,n){var i=!1,r=t.indexOf(e),o=-1!==r,l=function(){t.push(e),i=!0},s=function(){t.splice(r,1),i=!0};return"boolean"==typeof n?n&&!o?l():!n&&o&&s():o?s():l(),i}function x(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"children",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"hasChildren",r=function(t){return!(Array.isArray(t)&&t.length)};function o(t,l,s){e(t,l,s),l.forEach((function(t){if(t[i])e(t,null,s+1);else{var l=t[n];r(l)||o(t,l,s+1)}}))}t.forEach((function(t){if(t[i])e(t,null,0);else{var l=t[n];r(l)||o(t,l,0)}}))}function w(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"children",i=null,r=0;r<t.length;r++){var o=t[r],l=o[n]||[];if(l.indexOf(e)>-1&&(i=o),!i&&l.length&&(i=w(l,e,n)),i)return i}return null}function S(t){return!0===t.fixedPro||"left"===t.fixedPro?"left":"right"===t.fixedPro?"right":void 0}function T(t){return!0!==t.fixedPro&&"left"!==t.fixedPro||!0!==t.isFixedLeftLast?"right"===t.fixedPro&&!0===t.isFixedRightFirst?"first":void 0:"last"}function _(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"left",n=arguments[2],i=[],r=0,o=0;o<t.length;o++)0===o?r=0:r+=t[o-1].realWidth||t[o-1].width,i.push({index:".el-table__column-"+n[o],style:e,width:r});return i}function E(t,e,n,i){for(var r=t.querySelectorAll(e),o=r.length,l=0;l<o;l++)r[l].style[n]=i+"px"}function $(t,e){var n=[];return function t(i){i&&i.length>0&&i.forEach((function(i){n.push(i),t(i[e])}))}(t),n}}});