2 lines
2.9 KiB
JavaScript
2 lines
2.9 KiB
JavaScript
"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var r=1;r<arguments.length;r++){var l=null!=arguments[r]?arguments[r]:{};r%2?e(Object(l),!0).forEach((function(e){n(t,e,l[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(l)):e(Object(l)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(l,e))}))}return t}function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){var n=function(e){return{name:"element-tree-line",props:{node:{type:Object,required:!0},data:{type:Object},treeData:{type:Array},indent:{type:Number,default:function(){return 16}},showLabelLine:{type:Boolean,default:!0}},render:function(n){for(var r=e||n,l=this.getScopedSlot("default"),o=this.getScopedSlot("node-label"),i=this.getScopedSlot("after-node-label"),a=l?this.getScopedSlotValue(l,{node:this.node,data:this.data}):[o?this.getScopedSlotValue(o,{node:this.node,data:this.data}):r("span",{class:"element-tree-node-label"},this.node.label),this.showLabelLine?r("span",{class:"element-tree-node-label-line"}):null,this.getScopedSlotValue(i,{node:this.node,data:this.data})],s=[],d=this.node;d;){var u=d.parent;if(1===d.level&&!d.parent){if(!this.treeData||!Array.isArray(this.treeData))throw Error("if you using el-tree-v2 (Virtualized Tree) of element-plus,element-tree-line required data.");u={children:Array.isArray(this.treeData)?this.treeData.map((function(e){return t(t({},e),{},{key:e.id})})):[],level:0,key:"node-0",parent:null}}if(u){var c=(u.children||u.childNodes).findIndex((function(e){return(e.key||e.id)===(d.key||d.id)}));s.unshift(c===(u.children||u.childNodes).length-1)}d=u}for(var p=[],f=0;f<this.node.level;f++)s[f]&&this.node.level-1!==f||p.push(r("span",{class:{"element-tree-node-line-ver":!0,"last-node-isLeaf-line":s[f]&&this.node.level-1===f},style:{left:this.indent*f+"px"}}));return r("span",{class:"element-tree-node-label-wrapper"},[a].concat(p).concat([r("span",{class:"element-tree-node-line-hor",style:{width:(this.node.isLeaf?24:8)+"px",left:(this.node.level-1)*this.indent+"px"}})]))},methods:{getScopedSlot:function(e){if(!e)return null;for(var t=e.split("||"),n=null,r=0;r<t.length;r++){var l=t[r],o=(this.$slots||{})[l];if(o){n=o;break}if(n=(this.$scopedSlots||{})[l])break}return n},getScopedSlotValue:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return"function"==typeof e?e(t)||n:e||n}}}}(e);return e&&(n.methods.getScopedSlot=function(e){if(!e)return null;for(var t=e.split("||"),n=null,r=0;r<t.length;r++){var l=t[r],o=(this.$slots||{})[l];if(o){n=o;break}}return n}),n}Object.defineProperty(exports,"__esModule",{value:!0});var l=r();exports.default=l,exports.getElementLabelLine=r;
|