ngx-treeview
Version:
An Angular treeview component with checkbox
17 lines (15 loc) • 25.1 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/forms"),require("@angular/common"),require("lodash")):"function"==typeof define&&define.amd?define("ngx-treeview",["exports","@angular/core","@angular/forms","@angular/common","lodash"],t):t((e=e||self)["ngx-treeview"]={},e.ng.core,e.ng.forms,e.ng.common,e.lodash)}(this,(function(e,t,n,r,i){"use strict";var o=function(){function e(){this.internalOpen=!1,this.openChange=new t.EventEmitter}return Object.defineProperty(e.prototype,"isOpen",{get:function(){return this.internalOpen},enumerable:!1,configurable:!0}),e.prototype.onKeyupEsc=function(){this.close()},e.prototype.onDocumentClick=function(e){2===e.button||this.isEventFromToggle(e)||this.close()},e.prototype.open=function(){this.internalOpen||(this.internalOpen=!0,this.openChange.emit(!0))},e.prototype.close=function(){this.internalOpen&&(this.internalOpen=!1,this.openChange.emit(!1))},e.prototype.toggle=function(){this.isOpen?this.close():this.open()},e.prototype.isEventFromToggle=function(e){return!i.isNil(this.toggleElement)&&this.toggleElement.contains(e.target)},e}();o.decorators=[{type:t.Directive,args:[{selector:"[ngxDropdown]",exportAs:"ngxDropdown"}]}],o.propDecorators={internalOpen:[{type:t.Input,args:["open"]}],openChange:[{type:t.Output}],isOpen:[{type:t.HostBinding,args:["class.show"]}],onKeyupEsc:[{type:t.HostListener,args:["keyup.esc"]}],onDocumentClick:[{type:t.HostListener,args:["document:click",["$event"]]}]};var l=function(e){this.dropdown=e};l.decorators=[{type:t.Directive,args:[{selector:"[ngxDropdownMenu]",host:{"[class.dropdown-menu]":"true","[class.show]":"dropdown.isOpen"}}]}],l.ctorParameters=function(){return[{type:o}]};var a=function(e,t){this.dropdown=e,e.toggleElement=t.nativeElement};a.decorators=[{type:t.Directive,args:[{selector:"[ngxDropdownToggle]",host:{class:"dropdown-toggle","aria-haspopup":"true","[attr.aria-expanded]":"dropdown.isOpen","(click)":"dropdown.toggle()"}}]}],a.ctorParameters=function(){return[{type:o},{type:t.ElementRef}]};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var c=function(e,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function s(e,t){function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}Object.create;function h(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)l.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return l}function p(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(d(arguments[t]));return e}Object.create;var u=function(){};u.decorators=[{type:t.Injectable}];var f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.prototype.getText=function(e){if(0===e.uncheckedItems.length)return e.checkedItems.length>0?this.getAllCheckboxText():"";switch(e.checkedItems.length){case 0:return"Select options";case 1:return e.checkedItems[0].text;default:return e.checkedItems.length+" options selected"}},t.prototype.getAllCheckboxText=function(){return"All"},t.prototype.getFilterPlaceholder=function(){return"Filter"},t.prototype.getFilterNoItemsFoundText=function(){return"No items found"},t.prototype.getTooltipCollapseExpandText=function(e){return e?"Expand":"Collapse"},t}(u);f.decorators=[{type:t.Injectable}];var g=function(){function e(){this.hasAllCheckBox=!0,this.hasFilter=!1,this.hasCollapseExpand=!1,this.decoupleChildFromParent=!1,this.maxHeight=500}return Object.defineProperty(e.prototype,"hasDivider",{get:function(){return this.hasFilter||this.hasAllCheckBox||this.hasCollapseExpand},enumerable:!1,configurable:!0}),e.create=function(t){var n=new e;return Object.assign(n,t),n},e}();g.decorators=[{type:t.Injectable}];var m={findItem:v,findItemInList:function(e,t){var n,r;if(i.isNil(e))return;try{for(var o=h(e),l=o.next();!l.done;l=o.next()){var a=v(l.value,t);if(a)return a}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return},findParent:C,removeItem:function(e,t){var n=C(e,t);if(n)return i.pull(n.children,t),0===n.children.length?n.children=void 0:n.correctChecked(),!0;return!1},concatSelection:function(e,t,n){var r,o,l=p(t),a=p(n);try{for(var c=h(e),s=c.next();!s.done;s=c.next()){var d=s.value.getSelection();l=i.concat(l,d.checkedItems),a=i.concat(a,d.uncheckedItems)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}return{checked:l,unchecked:a}}};function v(e,t){var n,r;if(!i.isNil(e)){if(e.value===t)return e;if(e.children)try{for(var o=h(e.children),l=o.next();!l.done;l=o.next()){var a=v(l.value,t);if(a)return a}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}}function C(e,t){var n,r;if(!i.isNil(e)&&!i.isNil(e.children))try{for(var o=h(e.children),l=o.next();!l.done;l=o.next()){var a=l.value;if(a===t)return e;var c=C(a,t);if(c)return c}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}var y=function(){function e(t,n){var r=this;if(void 0===n&&(n=!1),this.internalDisabled=!1,this.internalChecked=!0,this.internalCollapsed=!1,i.isNil(t))throw new Error("Item must be defined");if(!i.isString(t.text))throw new Error("A text of item must be string object");this.text=t.text,this.value=t.value,i.isBoolean(t.checked)&&(this.checked=t.checked),i.isBoolean(t.collapsed)&&(this.collapsed=t.collapsed),i.isBoolean(t.disabled)&&(this.disabled=t.disabled),!i.isNil(t.children)&&t.children.length>0&&(this.children=t.children.map((function(t){return!0===r.disabled&&(t.disabled=!0),new e(t)}))),n&&this.correctChecked()}return Object.defineProperty(e.prototype,"checked",{get:function(){return this.internalChecked},set:function(e){this.internalDisabled||this.internalChecked!==e&&(this.internalChecked=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indeterminate",{get:function(){return void 0===this.checked},enumerable:!1,configurable:!0}),e.prototype.setCheckedRecursive=function(e){this.internalDisabled||(this.internalChecked=e,i.isNil(this.internalChildren)||this.internalChildren.forEach((function(t){return t.setCheckedRecursive(e)})))},Object.defineProperty(e.prototype,"disabled",{get:function(){return this.internalDisabled},set:function(e){this.internalDisabled!==e&&(this.internalDisabled=e,i.isNil(this.internalChildren)||this.internalChildren.forEach((function(t){return t.disabled=e})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"collapsed",{get:function(){return this.internalCollapsed},set:function(e){this.internalCollapsed!==e&&(this.internalCollapsed=e)},enumerable:!1,configurable:!0}),e.prototype.setCollapsedRecursive=function(e){this.internalCollapsed=e,i.isNil(this.internalChildren)||this.internalChildren.forEach((function(t){return t.setCollapsedRecursive(e)}))},Object.defineProperty(e.prototype,"children",{get:function(){return this.internalChildren},set:function(e){if(this.internalChildren!==e){if(!i.isNil(e)&&0===e.length)throw new Error("Children must be not an empty array");if(this.internalChildren=e,!i.isNil(this.internalChildren)){var t=null;this.internalChildren.forEach((function(e){if(null===t)t=e.checked;else if(e.checked!==t)return void(t=void 0)})),this.internalChecked=t}}},enumerable:!1,configurable:!0}),e.prototype.getSelection=function(){var e=[],t=[];if(i.isNil(this.internalChildren))this.internalChecked?e.push(this):t.push(this);else{var n=m.concatSelection(this.internalChildren,e,t);e=n.checked,t=n.unchecked}return{checkedItems:e,uncheckedItems:t}},e.prototype.correctChecked=function(){this.internalChecked=this.getCorrectChecked()},e.prototype.getCorrectChecked=function(){var e,t,n=null;if(i.isNil(this.internalChildren))n=this.checked;else try{for(var r=h(this.internalChildren),o=r.next();!o.done;o=r.next()){var l=o.value;if(l.internalChecked=l.getCorrectChecked(),null===n)n=l.internalChecked;else if(n!==l.internalChecked){n=void 0;break}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},e}(),w=function(){};w.decorators=[{type:t.Injectable}];var k=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.prototype.getSelectedChange=function(e){var t=e.selection.checkedItems;return i.isNil(t)?[]:t.map((function(e){return e.value}))},t}(w);k.decorators=[{type:t.Injectable}];var x=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.prototype.getSelectedChange=function(e){var t=this,n=e.items;if(!i.isNil(n)){var r=[];return n.forEach((function(e){var n=t.getLinks(e,null);i.isNil(n)||(r=r.concat(n))})),r}return[]},t.prototype.getLinks=function(e,t){var n=this;if(!i.isNil(e.children)){var r={item:e,parent:t},o=[];return e.children.forEach((function(e){var t=n.getLinks(e,r);i.isNil(t)||(o=o.concat(t))})),o}return e.checked?[{item:e,parent:t}]:null},t}(w);x.decorators=[{type:t.Injectable}];var b=function(e){function t(){var t=e.apply(this,p(arguments))||this;return t.currentDownlines=[],t.parser=new x,t}return s(t,e),t.prototype.getSelectedChange=function(e){var t=this.parser.getSelectedChange(e);if(0===this.currentDownlines.length)this.currentDownlines=t;else{var n=[];this.currentDownlines.forEach((function(e){for(var r=-1,i=t.length,o=0;o<i;o++)if(e.item.value===t[o].item.value){r=o;break}-1!==r&&(n.push(t[r]),t.splice(r,1))})),this.currentDownlines=n.concat(t)}return this.currentDownlines},t}(w);b.decorators=[{type:t.Injectable}];var I=function(e){function t(t){var n=e.call(this,{text:t.text,value:t.value,disabled:t.disabled,checked:t.checked,collapsed:t.collapsed,children:t.children})||this;return n.refItem=t,n}return s(t,e),t.prototype.updateRefChecked=function(){var e,n;this.children.forEach((function(e){e instanceof t&&e.updateRefChecked()}));var r=this.checked;if(r)try{for(var i=h(this.refItem.children),o=i.next();!o.done;o=i.next()){if(!o.value.checked){r=!1;break}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}this.refItem.checked=r},t}(y),T=function(){function e(e,n,r){this.i18n=e,this.defaultConfig=n,this.eventParser=r,this.selectedChange=new t.EventEmitter,this.filterChange=new t.EventEmitter,this.filterText="",this.config=this.defaultConfig,this.allItem=new y({text:"All",value:void 0})}return Object.defineProperty(e.prototype,"hasFilterItems",{get:function(){return!i.isNil(this.filterItems)&&this.filterItems.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxHeight",{get:function(){return""+this.config.maxHeight},enumerable:!1,configurable:!0}),e.prototype.ngOnInit=function(){this.createHeaderTemplateContext(),this.generateSelection()},e.prototype.ngOnChanges=function(e){var t=e.items;i.isNil(t)||i.isNil(this.items)||(this.updateFilterItems(),this.updateCollapsedOfAll(),this.raiseSelectedChange())},e.prototype.onAllCollapseExpand=function(){var e=this;this.allItem.collapsed=!this.allItem.collapsed,this.filterItems.forEach((function(t){return t.setCollapsedRecursive(e.allItem.collapsed)}))},e.prototype.onFilterTextChange=function(e){this.filterText=e,this.filterChange.emit(e),this.updateFilterItems()},e.prototype.onAllCheckedChange=function(){var e=this.allItem.checked;this.filterItems.forEach((function(t){t.setCheckedRecursive(e),t instanceof I&&t.updateRefChecked()})),this.raiseSelectedChange()},e.prototype.onItemCheckedChange=function(e,t){e instanceof I&&e.updateRefChecked(),this.updateCheckedOfAll(),this.raiseSelectedChange()},e.prototype.raiseSelectedChange=function(){var e=this;this.generateSelection();var t=this.eventParser.getSelectedChange(this);setTimeout((function(){e.selectedChange.emit(t)}))},e.prototype.createHeaderTemplateContext=function(){var e=this;this.headerTemplateContext={config:this.config,item:this.allItem,onCheckedChange:function(){return e.onAllCheckedChange()},onCollapseExpand:function(){return e.onAllCollapseExpand()},onFilterTextChange:function(t){return e.onFilterTextChange(t)}}},e.prototype.generateSelection=function(){var e=[],t=[];if(!i.isNil(this.items)){var n=m.concatSelection(this.items,e,t);e=n.checked,t=n.unchecked}this.selection={checkedItems:e,uncheckedItems:t}},e.prototype.updateFilterItems=function(){var e=this;if(""!==this.filterText){var t=[],n=this.filterText.toLowerCase();this.items.forEach((function(r){var o=e.filterItem(r,n);i.isNil(o)||t.push(o)})),this.filterItems=t}else this.filterItems=this.items;this.updateCheckedOfAll()},e.prototype.filterItem=function(e,t){var n=this;if(i.includes(e.text.toLowerCase(),t))return e;if(!i.isNil(e.children)){var r=[];if(e.children.forEach((function(e){var o=n.filterItem(e,t);i.isNil(o)||r.push(o)})),r.length>0){var o=new I(e);return o.collapsed=!1,o.children=r,o}}},e.prototype.updateCheckedOfAll=function(){var e,t,n=null;try{for(var r=h(this.filterItems),i=r.next();!i.done;i=r.next()){var o=i.value;if(null===n)n=o.checked;else if(n!==o.checked){n=void 0;break}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}null===n&&(n=!1),this.allItem.checked=n},e.prototype.updateCollapsedOfAll=function(){var e,t,n=!1;try{for(var r=h(this.filterItems),i=r.next();!i.done;i=r.next()){if(!i.value.collapsed){n=!0;break}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}this.allItem.collapsed=!n},e}();T.decorators=[{type:t.Component,args:[{selector:"ngx-treeview",template:'<ng-template #defaultItemTemplate let-item="item" let-onCollapseExpand="onCollapseExpand"\r\n let-onCheckedChange="onCheckedChange">\r\n <div class="form-inline row-item">\r\n <i *ngIf="item.children" (click)="onCollapseExpand()" aria-hidden="true" [ngSwitch]="item.collapsed">\r\n <svg *ngSwitchCase="true" width="0.8rem" height="0.8rem" viewBox="0 0 16 16" class="bi bi-caret-right-fill"\r\n fill="currentColor" xmlns="http://www.w3.org/2000/svg">\r\n <path\r\n d="M12.14 8.753l-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z" />\r\n </svg>\r\n <svg *ngSwitchCase="false" width="0.8rem" height="0.8rem" viewBox="0 0 16 16" class="bi bi-caret-down-fill"\r\n fill="currentColor" xmlns="http://www.w3.org/2000/svg">\r\n <path\r\n d="M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z" />\r\n </svg>\r\n </i>\r\n <div class="form-check">\r\n <input type="checkbox" class="form-check-input" [(ngModel)]="item.checked" (ngModelChange)="onCheckedChange()"\r\n [disabled]="item.disabled" [indeterminate]="item.indeterminate" />\r\n <label class="form-check-label" (click)="item.checked = !item.checked; onCheckedChange()">\r\n {{item.text}}\r\n </label>\r\n </div>\r\n </div>\r\n</ng-template>\r\n<ng-template #defaultHeaderTemplate let-config="config" let-item="item" let-onCollapseExpand="onCollapseExpand"\r\n let-onCheckedChange="onCheckedChange" let-onFilterTextChange="onFilterTextChange">\r\n <div *ngIf="config.hasFilter" class="row row-filter">\r\n <div class="col-12">\r\n <input class="form-control" type="text" [placeholder]="i18n.getFilterPlaceholder()" [(ngModel)]="filterText"\r\n (ngModelChange)="onFilterTextChange($event)" />\r\n </div>\r\n </div>\r\n <div *ngIf="hasFilterItems">\r\n <div *ngIf="config.hasAllCheckBox || config.hasCollapseExpand" class="row row-all">\r\n <div class="col-12">\r\n <div class="form-check form-check-inline" *ngIf="config.hasAllCheckBox">\r\n <input type="checkbox" class="form-check-input" [(ngModel)]="item.checked" (ngModelChange)="onCheckedChange()"\r\n [indeterminate]="item.indeterminate" />\r\n <label class="form-check-label" (click)="item.checked = !item.checked; onCheckedChange()">\r\n {{i18n.getAllCheckboxText()}}\r\n </label>\r\n </div>\r\n <label *ngIf="config.hasCollapseExpand" class="float-right form-check-label" (click)="onCollapseExpand()">\r\n <i [title]="i18n.getTooltipCollapseExpandText(item.collapsed)" aria-hidden="true" [ngSwitch]="item.collapsed">\r\n <svg *ngSwitchCase="true" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrows-angle-expand"\r\n fill="currentColor" xmlns="http://www.w3.org/2000/svg">\r\n <path fill-rule="evenodd"\r\n d="M1.5 10.036a.5.5 0 0 1 .5.5v3.5h3.5a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5v-4a.5.5 0 0 1 .5-.5z" />\r\n <path fill-rule="evenodd"\r\n d="M6.354 9.646a.5.5 0 0 1 0 .708l-4.5 4.5a.5.5 0 0 1-.708-.708l4.5-4.5a.5.5 0 0 1 .708 0zm8.5-8.5a.5.5 0 0 1 0 .708l-4.5 4.5a.5.5 0 0 1-.708-.708l4.5-4.5a.5.5 0 0 1 .708 0z" />\r\n <path fill-rule="evenodd"\r\n d="M10.036 1.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 .5.5v4a.5.5 0 1 1-1 0V2h-3.5a.5.5 0 0 1-.5-.5z" />\r\n </svg>\r\n <svg *ngSwitchCase="false" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrows-angle-contract"\r\n fill="currentColor" xmlns="http://www.w3.org/2000/svg">\r\n <path fill-rule="evenodd"\r\n d="M9.5 2.036a.5.5 0 0 1 .5.5v3.5h3.5a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5v-4a.5.5 0 0 1 .5-.5z" />\r\n <path fill-rule="evenodd"\r\n d="M14.354 1.646a.5.5 0 0 1 0 .708l-4.5 4.5a.5.5 0 1 1-.708-.708l4.5-4.5a.5.5 0 0 1 .708 0zm-7.5 7.5a.5.5 0 0 1 0 .708l-4.5 4.5a.5.5 0 0 1-.708-.708l4.5-4.5a.5.5 0 0 1 .708 0z" />\r\n <path fill-rule="evenodd"\r\n d="M2.036 9.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0V10h-3.5a.5.5 0 0 1-.5-.5z" />\r\n </svg>\r\n </i>\r\n </label>\r\n </div>\r\n </div>\r\n <div *ngIf="config.hasDivider" class="dropdown-divider"></div>\r\n </div>\r\n</ng-template>\r\n<div class="treeview-header">\r\n <ng-template [ngTemplateOutlet]="headerTemplate || defaultHeaderTemplate"\r\n [ngTemplateOutletContext]="headerTemplateContext">\r\n </ng-template>\r\n</div>\r\n<div [ngSwitch]="hasFilterItems">\r\n <div *ngSwitchCase="true" class="treeview-container" [style.max-height.px]="maxHeight">\r\n <ngx-treeview-item *ngFor="let item of filterItems" [config]="config" [item]="item"\r\n [template]="itemTemplate || defaultItemTemplate" (checkedChange)="onItemCheckedChange(item, $event)">\r\n </ngx-treeview-item>\r\n </div>\r\n <div *ngSwitchCase="false" class="treeview-text">\r\n {{i18n.getFilterNoItemsFoundText()}}\r\n </div>\r\n</div>\r\n',styles:[":host .treeview-header .row-filter{margin-bottom:.5rem}:host .treeview-header .row-all .bi{cursor:pointer}:host .treeview-container .row-item{flex-wrap:nowrap;margin-bottom:.3rem}:host .treeview-container .row-item .bi{cursor:pointer;margin-right:.3rem}.treeview-container{overflow-y:auto;padding-right:.3rem}.treeview-text{padding:.3rem 0;white-space:nowrap}"]}]}],T.ctorParameters=function(){return[{type:u},{type:g},{type:w}]},T.propDecorators={headerTemplate:[{type:t.Input}],itemTemplate:[{type:t.Input}],items:[{type:t.Input}],config:[{type:t.Input}],selectedChange:[{type:t.Output}],filterChange:[{type:t.Output}]};var E=function(){function e(e,n){this.i18n=e,this.defaultConfig=n,this.buttonClass="btn-outline-secondary",this.selectedChange=new t.EventEmitter(!0),this.filterChange=new t.EventEmitter,this.config=this.defaultConfig}return e.prototype.onSelectedChange=function(e){this.buttonLabel=this.i18n.getText(this.treeviewComponent.selection),this.selectedChange.emit(e)},e.prototype.onFilterChange=function(e){this.filterChange.emit(e)},e}();E.decorators=[{type:t.Component,args:[{selector:"ngx-dropdown-treeview",template:'<div class="dropdown" ngxDropdown>\r\n <button class="btn" [ngClass]="buttonClass" type="button" role="button" ngxDropdownToggle>\r\n {{buttonLabel}}\r\n </button>\r\n <div ngxDropdownMenu aria-labelledby="dropdownMenu" (click)="$event.stopPropagation()">\r\n <div class="dropdown-container">\r\n <ngx-treeview [config]="config" [headerTemplate]="headerTemplate" [items]="items" [itemTemplate]="itemTemplate"\r\n (selectedChange)="onSelectedChange($event)" (filterChange)="onFilterChange($event)">\r\n </ngx-treeview>\r\n </div>\r\n </div>\r\n</div>\r\n',styles:[".dropdown{display:inline-block;width:100%}.dropdown button{margin-right:.9rem;overflow:hidden;padding-right:30px;text-align:left;text-overflow:ellipsis;width:100%}.dropdown button:after{margin-top:.6rem;position:absolute;right:.6rem}.dropdown .dropdown-menu .dropdown-container{padding:0 .6rem}"]}]}],E.ctorParameters=function(){return[{type:u},{type:g}]},E.propDecorators={buttonClass:[{type:t.Input}],headerTemplate:[{type:t.Input}],itemTemplate:[{type:t.Input}],items:[{type:t.Input}],config:[{type:t.Input}],selectedChange:[{type:t.Output}],filterChange:[{type:t.Output}],treeviewComponent:[{type:t.ViewChild,args:[T,{static:!1}]}]};var O=function(){function e(e){var n=this;this.defaultConfig=e,this.checkedChange=new t.EventEmitter,this.onCollapseExpand=function(){n.item.collapsed=!n.item.collapsed},this.onCheckedChange=function(){var e=n.item.checked;i.isNil(n.item.children)||n.config.decoupleChildFromParent||n.item.children.forEach((function(t){return t.setCheckedRecursive(e)})),n.checkedChange.emit(e)},this.config=this.defaultConfig}return e.prototype.onChildCheckedChange=function(e,t){var n,r;if(!this.config.decoupleChildFromParent){var i=null;try{for(var o=h(this.item.children),l=o.next();!l.done;l=o.next()){var a=l.value;if(null===i)i=a.checked;else if(i!==a.checked){i=void 0;break}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}null===i&&(i=!1),this.item.checked!==i&&(this.item.checked=i)}this.checkedChange.emit(t)},e}();O.decorators=[{type:t.Component,args:[{selector:"ngx-treeview-item",template:'<div *ngIf="item" class="treeview-item">\r\n <ng-template [ngTemplateOutlet]="template"\r\n [ngTemplateOutletContext]="{item: item, onCollapseExpand: onCollapseExpand, onCheckedChange: onCheckedChange}">\r\n </ng-template>\r\n <div *ngIf="!item.collapsed">\r\n <ngx-treeview-item [config]="config" *ngFor="let child of item.children" [item]="child" [template]="template"\r\n (checkedChange)="onChildCheckedChange(child, $event)">\r\n </ngx-treeview-item>\r\n </div>\r\n</div>\r\n',styles:[":host{display:block}:host .treeview-item{white-space:nowrap}:host .treeview-item .treeview-item{margin-left:2rem}"]}]}],O.ctorParameters=function(){return[{type:g}]},O.propDecorators={config:[{type:t.Input}],template:[{type:t.Input}],item:[{type:t.Input}],checkedChange:[{type:t.Output}]};var D=function(){function e(){}return e.prototype.transform=function(e,t){if(!i.isNil(e))return e.map((function(e){return new y({text:e[t],value:e})}))},e}();D.decorators=[{type:t.Pipe,args:[{name:"ngxTreeview"}]}];var S=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[g,{provide:u,useClass:f},{provide:w,useClass:k}]}},e}();S.decorators=[{type:t.NgModule,args:[{imports:[n.FormsModule,r.CommonModule],declarations:[T,O,D,o,l,a,E],exports:[T,D,E]}]}],e.DefaultTreeviewEventParser=k,e.DefaultTreeviewI18n=f,e.DownlineTreeviewEventParser=x,e.DropdownDirective=o,e.DropdownToggleDirective=a,e.DropdownTreeviewComponent=E,e.OrderDownlineTreeviewEventParser=b,e.TreeviewComponent=T,e.TreeviewConfig=g,e.TreeviewEventParser=w,e.TreeviewHelper=m,e.TreeviewI18n=u,e.TreeviewItem=y,e.TreeviewModule=S,e.TreeviewPipe=D,e.ɵa=O,e.ɵb=l,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-treeview.umd.min.js.map