UNPKG

primeng

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primeng.svg)](https://badge.fury.io/js/primeng) [![Build Status](https://travis-ci.org/primefaces/primeng.

2 lines 8.69 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/animations"),require("@angular/common"),require("primeng/api")):"function"==typeof define&&define.amd?define("primeng/organizationchart",["exports","@angular/core","@angular/animations","@angular/common","primeng/api"],t):t(((e=e||self).primeng=e.primeng||{},e.primeng.organizationchart={}),e.ng.core,e.ng.animations,e.ng.common,e.primeng.api)}(this,(function(e,t,n,o,i){"use strict";var r=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,a=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(a=(r<3?i(a):r>3?i(t,n,a):i(t,n))||a);return r>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},l=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,i,r=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=r.next()).done;)a.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return a},d=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(l(arguments[t]));return e},s=function(){function e(e){this.chart=e}return Object.defineProperty(e.prototype,"leaf",{get:function(){return 0!=this.node.leaf&&!(this.node.children&&this.node.children.length)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"colspan",{get:function(){return this.node.children&&this.node.children.length?2*this.node.children.length:null},enumerable:!0,configurable:!0}),e.prototype.onNodeClick=function(e,t){this.chart.onNodeClick(e,t)},e.prototype.toggleNode=function(e,t){t.expanded=!t.expanded,t.expanded?this.chart.onNodeExpand.emit({originalEvent:e,node:this.node}):this.chart.onNodeCollapse.emit({originalEvent:e,node:this.node}),e.preventDefault()},e.prototype.isSelected=function(){return this.chart.isSelected(this.node)},e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[t.forwardRef((function(){return c}))]}]}]},r([t.Input()],e.prototype,"node",void 0),r([t.Input()],e.prototype,"root",void 0),r([t.Input()],e.prototype,"first",void 0),r([t.Input()],e.prototype,"last",void 0),e=r([t.Component({selector:"[pOrganizationChartNode]",template:'\n <tr *ngIf="node">\n <td [attr.colspan]="colspan">\n <div class="ui-organizationchart-node-content ui-widget-content ui-corner-all {{node.styleClass}}" \n [ngClass]="{\'ui-organizationchart-selectable-node\': chart.selectionMode && node.selectable !== false,\'ui-state-highlight\':isSelected()}"\n (click)="onNodeClick($event,node)">\n <div *ngIf="!chart.getTemplateForNode(node)">{{node.label}}</div>\n <div *ngIf="chart.getTemplateForNode(node)">\n <ng-container *ngTemplateOutlet="chart.getTemplateForNode(node); context: {$implicit: node}"></ng-container>\n </div>\n <a *ngIf="!leaf" tabindex="0" class="ui-node-toggler" (click)="toggleNode($event, node)" (keydown.enter)="toggleNode($event, node)">\n <i class="ui-node-toggler-icon pi" [ngClass]="{\'pi-chevron-down\': node.expanded, \'pi-chevron-up\': !node.expanded}"></i>\n </a>\n </div>\n </td>\n </tr>\n <tr [ngClass]="!leaf&&node.expanded ? \'ui-organizationchart-node-visible\' : \'ui-organizationchart-node-hidden\'" class="ui-organizationchart-lines" [@childState]="\'in\'">\n <td [attr.colspan]="colspan">\n <div class="ui-organizationchart-line-down"></div>\n </td>\n </tr>\n <tr [ngClass]="!leaf&&node.expanded ? \'ui-organizationchart-node-visible\' : \'ui-organizationchart-node-hidden\'" class="ui-organizationchart-lines" [@childState]="\'in\'">\n <ng-container *ngIf="node.children && node.children.length === 1">\n <td [attr.colspan]="colspan">\n <div class="ui-organizationchart-line-down"></div>\n </td>\n </ng-container>\n <ng-container *ngIf="node.children && node.children.length > 1">\n <ng-template ngFor let-child [ngForOf]="node.children" let-first="first" let-last="last">\n <td class="ui-organizationchart-line-left" [ngClass]="{\'ui-organizationchart-line-top\':!first}">&nbsp;</td>\n <td class="ui-organizationchart-line-right" [ngClass]="{\'ui-organizationchart-line-top\':!last}">&nbsp;</td>\n </ng-template>\n </ng-container>\n </tr>\n <tr [ngClass]="!leaf&&node.expanded ? \'ui-organizationchart-node-visible\' : \'ui-organizationchart-node-hidden\'" class="ui-organizationchart-nodes" [@childState]="\'in\'">\n <td *ngFor="let child of node.children" colspan="2">\n <table class="ui-organizationchart-table" pOrganizationChartNode [node]="child"></table>\n </td>\n </tr>\n ',animations:[n.trigger("childState",[n.state("in",n.style({opacity:1})),n.transition("void => *",[n.style({opacity:0}),n.animate(150)]),n.transition("* => void",[n.animate(150,n.style({opacity:0}))])])]}),a(0,t.Inject(t.forwardRef((function(){return c}))))],e)}(),c=function(){function e(e){this.el=e,this.preserveSpace=!0,this.selectionChange=new t.EventEmitter,this.onNodeSelect=new t.EventEmitter,this.onNodeUnselect=new t.EventEmitter,this.onNodeExpand=new t.EventEmitter,this.onNodeCollapse=new t.EventEmitter}return Object.defineProperty(e.prototype,"root",{get:function(){return this.value&&this.value.length?this.value[0]:null},enumerable:!0,configurable:!0}),e.prototype.ngAfterContentInit=function(){var e=this;this.templates.length&&(this.templateMap={}),this.templates.forEach((function(t){e.templateMap[t.getType()]=t.template}))},e.prototype.getTemplateForNode=function(e){return this.templateMap?e.type?this.templateMap[e.type]:this.templateMap.default:null},e.prototype.onNodeClick=function(e,t){var n=e.target;if((!n.className||-1===n.className.indexOf("ui-node-toggler")&&-1===n.className.indexOf("ui-node-toggler-icon"))&&this.selectionMode){if(!1===t.selectable)return;var o=this.findIndexInSelection(t),i=o>=0;"single"===this.selectionMode?i?(this.selection=null,this.onNodeUnselect.emit({originalEvent:e,node:t})):(this.selection=t,this.onNodeSelect.emit({originalEvent:e,node:t})):"multiple"===this.selectionMode&&(i?(this.selection=this.selection.filter((function(e,t){return t!=o})),this.onNodeUnselect.emit({originalEvent:e,node:t})):(this.selection=d(this.selection||[],[t]),this.onNodeSelect.emit({originalEvent:e,node:t}))),this.selectionChange.emit(this.selection)}},e.prototype.findIndexInSelection=function(e){var t=-1;if(this.selectionMode&&this.selection)if("single"===this.selectionMode)t=this.selection==e?0:-1;else if("multiple"===this.selectionMode)for(var n=0;n<this.selection.length;n++)if(this.selection[n]==e){t=n;break}return t},e.prototype.isSelected=function(e){return-1!=this.findIndexInSelection(e)},e.ctorParameters=function(){return[{type:t.ElementRef}]},r([t.Input()],e.prototype,"value",void 0),r([t.Input()],e.prototype,"style",void 0),r([t.Input()],e.prototype,"styleClass",void 0),r([t.Input()],e.prototype,"selectionMode",void 0),r([t.Input()],e.prototype,"selection",void 0),r([t.Input()],e.prototype,"preserveSpace",void 0),r([t.Output()],e.prototype,"selectionChange",void 0),r([t.Output()],e.prototype,"onNodeSelect",void 0),r([t.Output()],e.prototype,"onNodeUnselect",void 0),r([t.Output()],e.prototype,"onNodeExpand",void 0),r([t.Output()],e.prototype,"onNodeCollapse",void 0),r([t.ContentChildren(i.PrimeTemplate)],e.prototype,"templates",void 0),e=r([t.Component({selector:"p-organizationChart",template:'\n <div [ngStyle]="style" [class]="styleClass" [ngClass]="{\'ui-organizationchart ui-widget\': true, \'ui-organizationchart-preservespace\': preserveSpace}">\n <table class="ui-organizationchart-table" pOrganizationChartNode [node]="root" *ngIf="root"></table>\n </div>\n ',changeDetection:t.ChangeDetectionStrategy.Default})],e)}(),p=function(){function e(){}return e=r([t.NgModule({imports:[o.CommonModule],exports:[c,i.SharedModule],declarations:[c,s]})],e)}();e.OrganizationChart=c,e.OrganizationChartModule=p,e.OrganizationChartNode=s,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=primeng-organizationchart.umd.min.js.map