UNPKG

element-gui

Version:

A Component Library for Vue.js.

1 lines 13.9 kB
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=153)}({153:function(e,t,n){"use strict";n.r(t);var r=n(2),i={default:{order:""},selection:{width:48,minWidth:48,realWidth:48,order:"",className:"el-table-column--selection"},expand:{width:48,minWidth:48,realWidth:48,order:""},index:{width:48,minWidth:48,realWidth:48,order:""}},o={selection:{renderHeader:function(e,t){var n=t.store;return e("el-checkbox",{attrs:{size:n.states.size,disabled:n.states.data&&0===n.states.data.length||n.states.isAllDisabled||n.states.headerSelectable,indeterminate:n.states.selection.length>0&&!this.isAllSelected,value:this.isAllSelected},on:{input:this.toggleAllSelection}})},renderCell:function(e,t){var n=t.row,r=t.column,i=t.store,o=t.$index;return e("el-checkbox",{attrs:{size:i.states.size,value:i.isSelected(n),indeterminate:i.isHalfSelected(n),disabled:!!r.selectable&&!r.selectable.call(null,n,o)||i.states.isAllDisabled},nativeOn:{click:function(e){return e.stopPropagation()}},on:{input:function(){i.commit("rowSelectedChanged",n)}}})},sortable:!1,resizable:!1},index:{renderHeader:function(e,t){return t.column.label||"#"},renderCell:function(e,t){var n=t.$index,r=n+1,i=t.column.index;return"number"==typeof i?r=n+i:"function"==typeof i&&(r=i(n)),e("div",[r])},sortable:!1},expand:{renderHeader:function(e,t){return t.column.label||""},renderCell:function(e,t){var n=t.row,r=t.store,i=["el-table__expand-icon"];r.states.expandRows.indexOf(n)>-1&&i.push("el-table__expand-icon--expanded");return e("div",{class:i,on:{click:function(e){e.stopPropagation(),r.toggleRowExpansion(n)}}},[e("i",{class:"el-icon el-icon-arrow-right"})])},sortable:!1,resizable:!1,className:"el-table__expand-column"}};function l(e,t){var n=t.row,i=t.column,o=t.$index,l=i.property,u=l&&Object(r.getPropByPath)(n,l).v;return i&&i.formatter?i.formatter(n,i,u,o):u}var u=n(6),a=n(19),s=n.n(a),c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},d=1,f={name:"ElTableColumn",props:{type:{type:String,default:"default"},label:String,className:String,labelClassName:String,property:String,prop:String,width:{},minWidth:{},renderHeader:Function,sortable:{type:[Boolean,String],default:!1},sortMethod:Function,sortBy:[String,Function,Array],resizable:{type:Boolean,default:!0},columnKey:String,align:String,headerAlign:String,showTooltipWhenOverflow:Boolean,showOverflowTooltip:Boolean,fixed:[Boolean,String],fixedPro:[Boolean,String],formatter:Function,selectable:Function,reserveSelection:Boolean,filterMethod:Function,filteredValue:Array,filters:Array,filterPlacement:String,filterMultiple:{type:Boolean,default:!0},filterType:{type:String,default:"checkbox",validator:function(e){return-1!==["checkbox","input"].indexOf(e)}},filterTypeOptions:{type:Object,default:function(){return{placeholder:this.label}},validator:function(e){return Object.keys(e).length&&["placeholder"].every((function(t){return Object.keys(e).indexOf(t)>-1}))}},index:[Number,Function],sortOrders:{type:Array,default:function(){return["ascending","descending",null]},validator:function(e){return e.every((function(e){return["ascending","descending",null].indexOf(e)>-1}))}}},data:function(){return{isSubColumn:!1,columns:[]}},computed:{owner:function(){for(var e=this.$parent;e&&!e.tableId;)e=e.$parent;return e},columnOrTableParent:function(){for(var e=this.$parent;e&&!e.tableId&&!e.columnId;)e=e.$parent;return e},realWidth:function(){return Object(u.r)(this.width)},realMinWidth:function(){return Object(u.q)(this.minWidth)},realAlign:function(){return this.align?"is-"+this.align:null},realHeaderAlign:function(){return this.headerAlign?"is-"+this.headerAlign:this.realAlign}},methods:{getPropsData:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.reduce((function(t,n){return Array.isArray(n)&&n.forEach((function(n){t[n]=e[n]})),t}),{})},getColumnElIndex:function(e,t){return[].indexOf.call(e,t)},setColumnWidth:function(e){return this.realWidth&&(e.width=this.realWidth),this.realMinWidth&&(e.minWidth=this.realMinWidth),e.minWidth||(e.minWidth=80),e.realWidth=void 0===e.width?e.minWidth:e.width,e},setColumnForcedProps:function(e){var t=e.type,n=o[t]||{};return Object.keys(n).forEach((function(t){var r=n[t];void 0!==r&&(e[t]="className"===t?e[t]+" "+r:r)})),e},setColumnRenders:function(e){var t=this;this.$createElement;this.renderHeader?console.warn("[Element Warn][TableColumn]Comparing to render-header, scoped-slot header is easier to use. We recommend users to use scoped-slot header."):"selection"!==e.type&&(e.renderHeader=function(n,r){var i=t.$scopedSlots.header;return i?i(r):e.label});var n=e.renderCell;return"expand"===e.type?(e.renderCell=function(e,t){return e("div",{class:"cell"},[n(e,t)])},this.owner.renderExpanded=function(e,n){return t.$scopedSlots.default?t.$scopedSlots.default(n):t.$slots.default}):(n=n||l,e.renderCell=function(r,i){var o=null;o=t.$scopedSlots.default?t.$scopedSlots.default(i):n(r,i);var l=function(e,t){var n=t.row,r=t.treeNode,i=t.store;if(!r)return null;var o=[];if(r.indent&&o.push(e("span",{class:"el-table__indent",style:{"padding-left":r.indent+"px"}})),"boolean"!=typeof r.expanded||r.noLazyChildren)o.push(e("span",{class:"el-table__placeholder"}));else{var l=["el-table__expand-icon",r.expanded?"el-table__expand-icon--expanded":""],u=["el-icon-arrow-right"];r.loading&&(u=["el-icon-loading"]),o.push(e("div",{class:l,on:{click:function(e){e.stopPropagation(),i.loadOrToggle(n)}}},[e("i",{class:u})]))}return o}(r,i),u={class:"cell",style:{}};return e.showOverflowTooltip&&(u.class+=" el-tooltip__cell"),r("div",u,[l,o])}),e},registerNormalWatchers:function(){var e=this,t={prop:"property",realAlign:"align",realHeaderAlign:"headerAlign",realWidth:"width"},n=["label","property","filters","filterMultiple","sortable","index","formatter","className","labelClassName","showOverflowTooltip"].reduce((function(e,t){return e[t]=t,e}),t);Object.keys(n).forEach((function(n){var r=t[n];e.$watch(n,(function(t){e.columnConfig[r]=t}))}))},registerComplexWatchers:function(){var e=this,t={realWidth:"width",realMinWidth:"minWidth"},n=["fixed"].reduce((function(e,t){return e[t]=t,e}),t);Object.keys(n).forEach((function(n){var r=t[n];e.$watch(n,(function(t){e.columnConfig[r]=t;var n="fixed"===r;e.owner.store.scheduleLayout(n)}))}))}},components:{ElCheckbox:s.a},beforeCreate:function(){this.row={},this.column={},this.$index=0,this.columnId=""},created:function(){var e=this.columnOrTableParent;this.isSubColumn=this.owner!==e,this.columnId=(e.tableId||e.columnId)+"_column_"+d++;var t=this.type||"default",n=""===this.sortable||this.sortable,r=c({},i[t],{id:this.columnId,type:t,property:this.prop||this.property,align:this.realAlign,headerAlign:this.realHeaderAlign,showOverflowTooltip:this.showOverflowTooltip||this.showTooltipWhenOverflow,filterable:this.filters||this.filterMethod,filteredValue:[],filterPlacement:"",isColumnGroup:!1,isFixedLeftLast:!1,isFixedRightFirst:!1,filterOpened:!1,sortable:n,index:this.index}),o=this.getPropsData(["columnKey","label","className","labelClassName","type","renderHeader","formatter","fixed","fixedPro","resizable"],["sortMethod","sortBy","sortOrders"],["selectable","reserveSelection"],["filterMethod","filters","filterMultiple","filterOpened","filteredValue","filterPlacement","filterType","filterTypeOptions"]);o=Object(u.n)(r,o),o=Object(u.b)(this.setColumnRenders,this.setColumnWidth,this.setColumnForcedProps)(o),this.columnConfig=o,this.registerNormalWatchers(),this.registerComplexWatchers()},mounted:function(){var e=this.owner,t=this.columnOrTableParent,n=this.isSubColumn?t.$el.children:t.$refs.hiddenColumns.children,r=this.getColumnElIndex(n,this.$el);e.store.commit("insertColumn",this.columnConfig,r,this.isSubColumn?t.columnConfig:null)},beforeUpdate:function(){var e=this;this.$slots.header&&this.$scopedSlots.header&&(this.columnConfig.renderHeader=function(t,n){var r=e.$scopedSlots.header;return r?r(n):e.columnConfig.label})},destroyed:function(){if(this.$parent){var e=this.$parent;this.owner.store.commit("removeColumn",this.columnConfig,this.isSubColumn?e.columnConfig:null)}},render:function(e){return e("div",this.$slots.default)},install:function(e){e.component(f.name,f)}};t.default=f},19:function(e,t){e.exports=require("element-gui/lib/checkbox")},2:function(e,t){e.exports=require("element-gui/lib/utils/util")},6:function(e,t,n){"use strict";n.d(t,"e",(function(){return o})),n.d(t,"o",(function(){return u})),n.d(t,"g",(function(){return a})),n.d(t,"h",(function(){return s})),n.d(t,"f",(function(){return c})),n.d(t,"k",(function(){return d})),n.d(t,"j",(function(){return f})),n.d(t,"n",(function(){return p})),n.d(t,"r",(function(){return m})),n.d(t,"q",(function(){return g})),n.d(t,"p",(function(){return b})),n.d(t,"b",(function(){return v})),n.d(t,"s",(function(){return y})),n.d(t,"t",(function(){return x})),n.d(t,"c",(function(){return w})),n.d(t,"l",(function(){return O})),n.d(t,"m",(function(){return C})),n.d(t,"i",(function(){return S})),n.d(t,"a",(function(){return W})),n.d(t,"d",(function(){return A}));var r=n(2),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(e){for(var t=e.target;t&&"HTML"!==t.tagName.toUpperCase();){if("TD"===t.tagName.toUpperCase())return t;t=t.parentNode}return null},l=function(e){return null!==e&&"object"===(void 0===e?"undefined":i(e))},u=function(e,t,n,i,o){if(!t&&!i&&(!o||Array.isArray(o)&&!o.length))return e;n="string"==typeof n?"descending"===n?-1:1:n&&n<0?-1:1;var u=i?null:function(n,i){return o?(Array.isArray(o)||(o=[o]),o.map((function(t){return"string"==typeof t?Object(r.getValueByPath)(n,t):t(n,i,e)}))):("$key"!==t&&l(n)&&"$value"in n&&(n=n.$value),[l(n)?Object(r.getValueByPath)(n,t):n])};return e.map((function(e,t){return{value:e,index:t,key:u?u(e,t):null}})).sort((function(e,t){var r=function(e,t){if(i)return i(e.value,t.value);for(var n=0,r=e.key.length;n<r;n++){if(e.key[n]<t.key[n])return-1;if(e.key[n]>t.key[n])return 1}return 0}(e,t);return r||(r=e.index-t.index),r*n})).map((function(e){return e.value}))},a=function(e,t){var n=null;return e.columns.forEach((function(e){e.id===t&&(n=e)})),n},s=function(e,t){for(var n=null,r=0;r<e.columns.length;r++){var i=e.columns[r];if(i.columnKey===t){n=i;break}}return n},c=function(e,t){var n=(t.className||"").match(/el-table_[^\s]+/gm);return n?a(e,n[0]):null},d=function(e,t){if(!e)throw new Error("row is required when get row identity");if("string"==typeof t){if(t.indexOf(".")<0)return e[t];for(var n=t.split("."),r=e,i=0;i<n.length;i++)r=r[n[i]];return r}if("function"==typeof t)return t.call(null,e)},f=function(e,t){var n={};return(e||[]).forEach((function(e,r){n[d(e,t)]={row:e,index:r}})),n};function h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function p(e,t){var n={},r=void 0;for(r in e)n[r]=e[r];for(r in t)if(h(t,r)){var i=t[r];void 0!==i&&(n[r]=i)}return n}function m(e){return void 0!==e&&(e=parseInt(e,10),isNaN(e)&&(e=null)),e}function g(e){return void 0!==e&&(e=m(e),isNaN(e)&&(e=80)),e}function b(e){return"number"==typeof e?e:"string"==typeof e?/^\d+(?:px)?$/.test(e)?parseInt(e,10):e:null}function v(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function y(e,t,n){var r=!1,i=e.indexOf(t),o=-1!==i,l=function(){e.push(t),r=!0},u=function(){e.splice(i,1),r=!0};return"boolean"==typeof n?n&&!o?l():!n&&o&&u():o?u():l(),r}function x(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"children",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"hasChildren",i=function(e){return!(Array.isArray(e)&&e.length)};function o(e,l,u){t(e,l,u),l.forEach((function(e){if(e[r])t(e,null,u+1);else{var l=e[n];i(l)||o(e,l,u+1)}}))}e.forEach((function(e){if(e[r])t(e,null,0);else{var l=e[n];i(l)||o(e,l,0)}}))}function w(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"children",r=null,i=0;i<e.length;i++){var o=e[i],l=o[n]||[];if(l.indexOf(t)>-1&&(r=o),!r&&l.length&&(r=w(l,t,n)),r)return r}return null}function O(e){return!0===e.fixedPro||"left"===e.fixedPro?"left":"right"===e.fixedPro?"right":void 0}function C(e){return!0!==e.fixedPro&&"left"!==e.fixedPro||!0!==e.isFixedLeftLast?"right"===e.fixedPro&&!0===e.isFixedRightFirst?"first":void 0:"last"}function S(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"left",n=arguments[2],r=[],i=0,o=0;o<e.length;o++)0===o?i=0:i+=e[o-1].realWidth||e[o-1].width,r.push({index:".el-table__column-"+n[o],style:t,width:i});return r}function W(e,t,n,r){for(var i=e.querySelectorAll(t),o=i.length,l=0;l<o;l++)i[l].style[n]=r+"px"}function A(e,t){var n=[];return function e(r){r&&r.length>0&&r.forEach((function(r){n.push(r),e(r[t])}))}(e),n}}});