UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

2 lines (1 loc) 7.71 kB
import e from"primevue/basecomponent";import t from"primevue/organizationchart/style";import n from"primevue/icons/chevrondown";import o from"primevue/icons/chevronup";import{DomHandler as l}from"primevue/utils";import{resolveComponent as i,openBlock as s,createElementBlock as d,mergeProps as c,createElementVNode as r,normalizeProps as a,guardReactiveProps as p,createBlock as u,resolveDynamicComponent as y,createCommentVNode as h,Fragment as g,renderList as f,createVNode as m}from"vue";var b={name:"BaseOrganizationChart",extends:e,props:{value:{type:null,default:null},selectionKeys:{type:null,default:null},selectionMode:{type:String,default:null},collapsible:{type:Boolean,default:!1},collapsedKeys:{type:null,default:null}},style:t,provide:function(){return{$parentInstance:this}}},v={name:"OrganizationChartNode",hostName:"OrganizationChart",extends:e,emits:["node-click","node-toggle"],props:{node:{type:null,default:null},templates:{type:null,default:null},collapsible:{type:Boolean,default:!1},collapsedKeys:{type:null,default:null},selectionKeys:{type:null,default:null},selectionMode:{type:String,default:null}},methods:{getPTOptions:function(e){return this.ptm(e,{context:{expanded:this.expanded,selectable:this.selectable,selected:this.selected,toggleable:this.toggleable,active:this.selected}})},getNodeOptions:function(e,t){return this.ptm(t,{context:{lineTop:e}})},onNodeClick:function(e){l.getAttribute(e.target,"nodeToggler")||l.getAttribute(e.target,"nodeTogglerIcon")||this.selectionMode&&this.$emit("node-click",this.node)},onChildNodeClick:function(e){this.$emit("node-click",e)},toggleNode:function(){this.$emit("node-toggle",this.node)},onChildNodeToggle:function(e){this.$emit("node-toggle",e)},onKeydown:function(e){"Enter"!==e.code&&"NumpadEnter"!==e.code&&"Space"!==e.code||(this.toggleNode(),e.preventDefault())}},computed:{leaf:function(){return!1!==this.node.leaf&&!(this.node.children&&this.node.children.length)},colspan:function(){return this.node.children&&this.node.children.length?2*this.node.children.length:null},childStyle:function(){return{visibility:!this.leaf&&this.expanded?"inherit":"hidden"}},expanded:function(){return void 0===this.collapsedKeys[this.node.key]},selectable:function(){return this.selectionMode&&!1!==this.node.selectable},selected:function(){return this.selectable&&this.selectionKeys&&!0===this.selectionKeys[this.node.key]},toggleable:function(){return this.collapsible&&!1!==this.node.collapsible&&!this.leaf}},components:{ChevronDownIcon:n,ChevronUpIcon:o}},K=["colspan"],N=["colspan"],C=["colspan"];function O(e){return O="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(e)}function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach((function(t){w(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function w(e,t,n){var o;return(t="symbol"==O(o=T(t,"string"))?o:String(o))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(e,t){if("object"!=O(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=O(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}v.render=function(e,t,n,o,l,b){var v=i("OrganizationChartNode",!0);return s(),d("table",c({class:e.cx("table")},e.ptm("table")),[r("tbody",a(p(e.ptm("body"))),[n.node?(s(),d("tr",a(c({key:0},e.ptm("row"))),[r("td",c({colspan:b.colspan},e.ptm("cell")),[r("div",c({class:[e.cx("node"),n.node.styleClass],onClick:t[2]||(t[2]=function(){return b.onNodeClick&&b.onNodeClick.apply(b,arguments)})},b.getPTOptions("node")),[(s(),u(y(n.templates[n.node.type]||n.templates.default),{node:n.node},null,8,["node"])),b.toggleable?(s(),d("a",c({key:0,tabindex:"0",class:e.cx("nodeToggler"),onClick:t[0]||(t[0]=function(){return b.toggleNode&&b.toggleNode.apply(b,arguments)}),onKeydown:t[1]||(t[1]=function(){return b.onKeydown&&b.onKeydown.apply(b,arguments)})},b.getPTOptions("nodeToggler")),[n.templates.togglericon?(s(),u(y(n.templates.togglericon),{key:0,expanded:b.expanded,class:"p-node-toggler-icon"},null,8,["expanded"])):(s(),u(y(b.expanded?"ChevronDownIcon":"ChevronUpIcon"),c({key:1,class:e.cx("nodeTogglerIcon")},b.getPTOptions("nodeTogglerIcon")),null,16,["class"]))],16)):h("",!0)],16)],16,K)],16)):h("",!0),r("tr",c({style:b.childStyle,class:e.cx("lines")},e.ptm("lines")),[r("td",c({colspan:b.colspan},e.ptm("lineCell")),[r("div",c({class:e.cx("lineDown")},e.ptm("lineDown")),null,16)],16,N)],16),r("tr",c({style:b.childStyle,class:e.cx("lines")},e.ptm("lines")),[n.node.children&&1===n.node.children.length?(s(),d("td",c({key:0,colspan:b.colspan},e.ptm("lineCell")),[r("div",c({class:e.cx("lineDown")},e.ptm("lineDown")),null,16)],16,C)):h("",!0),n.node.children&&n.node.children.length>1?(s(!0),d(g,{key:1},f(n.node.children,(function(t,o){return s(),d(g,{key:t.key},[r("td",c({class:e.cx("lineLeft",{index:o})},b.getNodeOptions(!(0===o),"lineLeft"))," ",16),r("td",c({class:e.cx("lineRight",{index:o})},b.getNodeOptions(!(o===n.node.children.length-1),"lineRight"))," ",16)],64)})),128)):h("",!0)],16),r("tr",c({style:b.childStyle,class:e.cx("nodes")},e.ptm("nodes")),[(s(!0),d(g,null,f(n.node.children,(function(t){return s(),d("td",c({key:t.key,colspan:"2"},e.ptm("nodeCell")),[m(v,{node:t,templates:n.templates,collapsedKeys:n.collapsedKeys,onNodeToggle:b.onChildNodeToggle,collapsible:n.collapsible,selectionMode:n.selectionMode,selectionKeys:n.selectionKeys,onNodeClick:b.onChildNodeClick,pt:e.pt,unstyled:e.unstyled},null,8,["node","templates","collapsedKeys","onNodeToggle","collapsible","selectionMode","selectionKeys","onNodeClick","pt","unstyled"])],16)})),128))],16)],16)],16)};var S={name:"OrganizationChart",extends:b,emits:["node-unselect","node-select","update:selectionKeys","node-expand","node-collapse","update:collapsedKeys"],data:function(){return{d_collapsedKeys:this.collapsedKeys||{}}},watch:{collapsedKeys:function(e){this.d_collapsedKeys=e}},methods:{onNodeClick:function(e){var t=e.key;if(this.selectionMode){var n=this.selectionKeys?x({},this.selectionKeys):{};n[t]?(delete n[t],this.$emit("node-unselect",e)):("single"===this.selectionMode&&(n={}),n[t]=!0,this.$emit("node-select",e)),this.$emit("update:selectionKeys",n)}},onNodeToggle:function(e){var t=e.key;this.d_collapsedKeys[t]?(delete this.d_collapsedKeys[t],this.$emit("node-expand",e)):(this.d_collapsedKeys[t]=!0,this.$emit("node-collapse",e)),this.d_collapsedKeys=x({},this.d_collapsedKeys),this.$emit("update:collapsedKeys",this.d_collapsedKeys)}},components:{OrganizationChartNode:v}};S.render=function(e,t,n,o,l,r){var a=i("OrganizationChartNode");return s(),d("div",c({class:e.cx("root")},e.ptm("root")),[m(a,{node:e.value,templates:e.$slots,onNodeToggle:r.onNodeToggle,collapsedKeys:l.d_collapsedKeys,collapsible:e.collapsible,onNodeClick:r.onNodeClick,selectionMode:e.selectionMode,selectionKeys:e.selectionKeys,pt:e.pt,unstyled:e.unstyled},null,8,["node","templates","onNodeToggle","collapsedKeys","collapsible","onNodeClick","selectionMode","selectionKeys","pt","unstyled"])],16)};export{S as default};