UNPKG

@lidorsystems/integralui-web

Version:

IntegralUI Web - Advanced UI Components for Angular

15 lines (12 loc) 30.6 kB
/* filename: integralui.treelist.js version : 20.2.0 Copyright © 2016-2020 Lidor Systems. All rights reserved. This file is part of the "IntegralUI Web" Library. The contents of this file are subject to the IntegralUI Web License, and may not be used except in compliance with the License. A copy of the License should have been installed in the product's root installation directory or it can be found at http://www.lidorsystems.com/products/web/studio/license-agreement.aspx. This SOFTWARE is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Any infringement will be prosecuted under applicable laws. */ "use strict";var __extends=this&&this.__extends||function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)if(t.hasOwnProperty(i))e[i]=t[i]})(t,i)};return function(t,i){e(t,i);function r(){this.constructor=t}t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0});var core_1=require("@angular/core"),integralui_core_1=require("./integralui.core"),integralui_common_service_1=require("../services/integralui.common.service"),integralui_data_service_1=require("../services/integralui.data.service"),i0=require("@angular/core"),i1=require("../services/integralui.common.service"),i2=require("./integralui.core"),i3=require("@angular/common"),i4=require("../services/integralui.data.service"),i5=require("./integralui.scrollbar");function IntegralUITreeListItem_ng_template_2_Template(e,t){}var _c0=function(e,t){return{height:e,width:t}},_c1=function(e){return{"iui-treelistitem-animate-select iui-treelistitem-animate-select-left":e}},_c2=function(e){return{height:e}};function IntegralUITreeListItem_span_3_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"span",4);i0.ɵɵelement(1,"span",5);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction2(3,_c0,i.getSize().height+"px",i.clickPos.x+"px"));i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(6,_c1,i.isClicked))("ngStyle",i0.ɵɵpureFunction1(8,_c2,i.getSize().height+"px"))}}var _c3=function(e,t,i){return{left:e,height:t,width:i}},_c4=function(e){return{"iui-treelistitem-animate-select iui-treelistitem-animate-select-right":e}};function IntegralUITreeListItem_span_4_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"span",4);i0.ɵɵelement(1,"span",5);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction3(3,_c3,i.clickPos.x+"px",i.getSize().height+"px",i.getSize().width-i.clickPos.x+"px"));i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(7,_c4,i.isClicked))("ngStyle",i0.ɵɵpureFunction1(9,_c2,i.getSize().height+"px"))}}var _c5=function(e,t,i){return{"iui-treelistitem-general":e,"iui-treelistitem-animate":t,"iui-treelistitem-animate-enter-suspended":i}},_c6=["contentBlock"],_c7=["header"],_c8=["leftBlock"],_c9=["rightBlock"],_c10=["itemElem"];function IntegralUITreeList_span_3_Template(e,t){if(1&e)i0.ɵɵelement(0,"span",14)}var _c11=function(e){return{"iui-treelist-header-animate-select iui-treelistitem-animate-select-left":e}};function IntegralUITreeList_span_6_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"span",15);i0.ɵɵelement(1,"span",16);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction2(3,_c0,i.animateItemSize.height+"px",i.clickPos.x+"px"));i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(6,_c11,i.isClicked))("ngStyle",i0.ɵɵpureFunction1(8,_c2,i.animateItemSize.height+"px"))}}var _c12=function(e){return{"iui-treelist-header-animate-select iui-treelistitem-animate-select-right":e}};function IntegralUITreeList_span_7_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"span",15);i0.ɵɵelement(1,"span",16);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction3(3,_c3,i.clickPos.x+"px",i.animateItemSize.height+"px",i.animateItemSize.width-i.clickPos.x+"px"));i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(7,_c12,i.isClicked))("ngStyle",i0.ɵɵpureFunction1(9,_c2,i.animateItemSize.height+"px"))}}function IntegralUITreeList_iui_treelistitem_11_Template(e,t){if(1&e)i0.ɵɵelement(0,"iui-treelistitem",17);if(2&e){var i=t.$implicit,r=i0.ɵɵnextContext();i0.ɵɵproperty("allowAnimation",r.allowAnimation)("enabled",i.data.enabled)("text",i.data.text)("templateRef",r.itemTemplate)("data",i.data)("type",i.data.type)}}function IntegralUITreeList_iui_treelistitem_14_Template(e,t){if(1&e){var i=i0.ɵɵgetCurrentView();i0.ɵɵelementStart(0,"iui-treelistitem",18,19);i0.ɵɵlistener("mouseDown",function(e){i0.ɵɵrestoreView(i);var r=t.$implicit;return i0.ɵɵnextContext().onItemMouseDown(e,r.data)})("mouseEnter",function(e){i0.ɵɵrestoreView(i);var r=t.$implicit;return i0.ɵɵnextContext().onItemMouseEnter(e,r.data)})("mouseLeave",function(e){i0.ɵɵrestoreView(i);var r=t.$implicit;return i0.ɵɵnextContext().onItemMouseLeave(e,r.data)});i0.ɵɵelementEnd()}if(2&e){var r=t.$implicit,n=i0.ɵɵnextContext();i0.ɵɵproperty("allowAnimation",n.allowAnimation)("enabled",r.data.enabled)("text",r.data.text)("templateRef",n.itemTemplate)("data",r.data)("type",r.data.type)("indent",r.indent)("state",n.getItemState(r.data))}}function IntegralUITreeList_iui_treelistitem_17_Template(e,t){if(1&e)i0.ɵɵelement(0,"iui-treelistitem",17);if(2&e){var i=t.$implicit,r=i0.ɵɵnextContext();i0.ɵɵproperty("allowAnimation",r.allowAnimation)("enabled",i.data.enabled)("text",i.data.text)("templateRef",r.itemTemplate)("data",i.data)("type",i.data.type)}}var _c13=function(e,t){return{"iui-treelist-scroll-available":e,"iui-treelist-scroll-not-available":t}};function IntegralUITreeList_iui_scrollbar_18_Template(e,t){if(1&e){var i=i0.ɵɵgetCurrentView();i0.ɵɵelementStart(0,"iui-scrollbar",20,21);i0.ɵɵlistener("mouseenter",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext().scrollMouseEnter(e)})("valueChanged",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext().onVerticalScrollChanged(e)})("scrollStart",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext().onVerticalScrollStart(e)})("scrollEnd",function(e){i0.ɵɵrestoreView(i);return i0.ɵɵnextContext().onVerticalScrollEnd(e)});i0.ɵɵelementEnd()}if(2&e){var r=i0.ɵɵnextContext();i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction2(6,_c13,r.isScrollAvailable,!r.isScrollAvailable))("enabled",r.enabled)("value",r.currentScrollPos.y)("max",r.maxScrollPos.y)("largeChange",r.scrollLargeChange.y)("height",r.scrollBarSize.height)}}var _c14=function(e){return{width:e}},_c15=function(e,t){return{width:e,height:t}},_c16=function(e,t,i,r,n){return{top:e,left:t,width:i,height:r,opacity:n}},IntegralUITreeListItem=function(e){__extends(t,e);function t(t,i,r){var n=e.call(this,t,i)||this;n.elemRef=t;n.commonService=i;n.baseService=r;n.templateData=[];n.clickPos={x:0,y:0};n.isClicked=!1;n.isHovered=!1;n.parentCtrl=null;n.indent=0;return n}t.prototype.ngOnInit=function(){this.templateData.push(this.data);this.parentCtrl=this.baseService.getComponent();this.generalClassName="group"===this.type?"iui-treelistgroup":"iui-treelistitem";this.contentClassName=this.generalClassName+"-content";this.initStyle()};t.prototype.onMouseDown=function(e){var t=this;if(t.isEnabled){t.isClicked=!0;t.clickPos=t.commonService.getClientPos(e,t.elemRef.nativeElement.firstElementChild);var i=setTimeout(function(){t.isClicked=!1;clearTimeout(i)},500);t.mouseDown.emit(e)}e.stopPropagation()};t.prototype.onMouseEnter=function(e){if(this.isEnabled){this.state|=integralui_core_1.IntegralUIObjectState.hovered;this.isHovered=!0;this.mouseEnter.emit(e)}e.stopPropagation()};t.prototype.onMouseMove=function(e){if(this.isEnabled)this.mouseMove.emit(e)};t.prototype.onMouseLeave=function(e){if(this.isEnabled){this.state&=~integralui_core_1.IntegralUIObjectState.hovered;this.mouseLeave.emit(e)}this.isHovered=!1;e.stopPropagation()};t.prototype.getControlStyle=function(){var e={position:this.positionType,top:this.itemPos.top+"px",left:this.itemPos.left+"px"};if(this.ctrlSize.width>0)e.width=this.ctrlSize.width+"px";if(this.ctrlSize.height>0)e.height=this.ctrlSize.height+"px";if(this.indent)e["padding-left"]=this.indent+"px";return e};t.ɵfac=function(e){return new(e||t)(i0.ɵɵdirectiveInject(i0.ElementRef),i0.ɵɵdirectiveInject(i1.IntegralUICommonService),i0.ɵɵdirectiveInject(i2.IntegralUIBaseService))};t.ɵcmp=i0.ɵɵdefineComponent({type:t,selectors:[["iui-treelistitem"]],inputs:{controlStyle:"controlStyle",data:"data",enabled:"enabled",icon:"icon",name:"name",size:"size",state:"state",text:"text",indent:"indent",templateRef:"templateRef",type:"type"},outputs:{click:"click",mouseDown:"mouseDown",mouseEnter:"mouseEnter",mouseLeave:"mouseLeave",mouseMove:"mouseMove",mouseUp:"mouseUp"},features:[i0.ɵɵInheritDefinitionFeature],decls:5,vars:11,consts:[[3,"ngClass","mouseenter","mousemove","mouseleave"],[2,"position","relative",3,"ngClass","ngStyle","click","mousedown","mouseup"],["ngFor","",3,"ngForOf","ngForTemplate"],["class","iui-treelistitem-animate-select-block",3,"ngStyle",4,"ngIf"],[1,"iui-treelistitem-animate-select-block",3,"ngStyle"],[3,"ngClass","ngStyle"]],template:function(e,t){if(1&e){i0.ɵɵelementStart(0,"li",0);i0.ɵɵlistener("mouseenter",function(e){return t.onMouseEnter(e)})("mousemove",function(e){return t.onMouseMove(e)})("mouseleave",function(e){return t.onMouseLeave(e)});i0.ɵɵelementStart(1,"div",1);i0.ɵɵlistener("click",function(e){return t.onClick(e)})("mousedown",function(e){return t.onMouseDown(e)})("mouseup",function(e){return t.onMouseUp(e)});i0.ɵɵtemplate(2,IntegralUITreeListItem_ng_template_2_Template,0,0,"ng-template",2);i0.ɵɵtemplate(3,IntegralUITreeListItem_span_3_Template,2,10,"span",3);i0.ɵɵtemplate(4,IntegralUITreeListItem_span_4_Template,2,11,"span",3);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction3(7,_c5,!t.allowAnimation,t.allowAnimation,t.allowAnimation&&t.isHovered));i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",t.getControlClass())("ngStyle",t.getControlStyle());i0.ɵɵadvance(1);i0.ɵɵproperty("ngForOf",t.templateData)("ngForTemplate",t.templateRef);i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",t.allowAnimation&&t.isClicked);i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",t.allowAnimation&&t.isClicked)}},directives:[i3.NgClass,i3.NgStyle,i3.NgForOf,i3.NgIf],encapsulation:2});return t}(integralui_core_1.IntegralUIItem);exports.IntegralUITreeListItem=IntegralUITreeListItem;var IntegralUITreeList=function(e){__extends(t,e);function t(t,i,r,n,l){var o=e.call(this,r)||this;o.dataService=t;o.elemRef=i;o.commonService=r;o.cmpResolver=n;o.baseService=l;o.animateItemSize={width:0,height:0};o.animSpeed=300;o.prevClickedObj=null;o.currentDataFields={};o.currentList=[];o.currentTitle="";o.nextList=[];o.prevList=[];o.clickPos={x:0,y:0};o.hoverItem=null;o.isClicked=!1;o.avgItemHeight=0;o.blockPos={top:30,left:0};o.currentIndent=15;o.headerWidth=0;o.leftBlockPos={top:30,left:-300};o.rightBlockPos={top:30,left:300};o.blockSize={width:0,height:0};o.currentBlockHeight=0;o.maxBlockHeight=0;o.leftBlockOpacity=0;o.blockOpacity=1;o.rightBlockOpacity=0;o.updateTimer=null;o.currentScrollPos={x:0,y:0};o.maxScrollPos={x:0,y:0};o.isScrollActive=!1;o.isScrollAllowed=!0;o.isScrollAvailable=!1;o.isScrollTimerActive=!1;o.prevScrollPos={x:0,y:0};o.scrollBarSize={width:0,height:0};o.scrollCount=0;o.scrollLargeChange={x:0,y:0};o.scrollSize={width:0,height:0};o.scrollTimerID=null;o.currentSelection=null;o.headerItem=null;o.headerText="";o.tRef=null;o.mouseWheelSpeed=integralui_core_1.IntegralUISpeedMode.Normal;o.afterSelect=new core_1.EventEmitter;o.beforeSelect=new core_1.EventEmitter;o.clear=new core_1.EventEmitter;o.itemAdding=new core_1.EventEmitter;o.itemAdded=new core_1.EventEmitter;o.itemRemoving=new core_1.EventEmitter;o.itemRemoved=new core_1.EventEmitter;o.scrollPosChanged=new core_1.EventEmitter;o.selectionChanged=new core_1.EventEmitter;o.scrollAppearanceTimeout=null;o.updateDataFields();o.selList=[];return o}Object.defineProperty(t.prototype,"dataFields",{set:function(e){this.updateDataFields(e)},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"indent",{get:function(){return this.currentIndent},set:function(e){if(this.currentIndent!==e)this.currentIndent=e},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"selectedItem",{get:function(){return this.currentSelection},set:function(e){var t={cancel:!1,header:this.headerItem,item:e};this.beforeSelect.emit(t);if(1!=t.cancel&&!this.isGroupItem(e)&&this.currentSelection!=e){this.currentSelection=e;if(!e){this.headerItem=null;this.headerText=this.title}else if(e[this.currentDataFields.items]&&e[this.currentDataFields.items].length>0){this.headerItem=e;this.headerText=e.text}this.afterSelect.emit({header:this.headerItem,item:e});this.selectionChanged.emit(null)}},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"showScroll",{get:function(){return this.isScrollAllowed},set:function(e){this.isScrollAllowed=e},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"title",{get:function(){return this.currentTitle},set:function(e){if(this.currentTitle!==e){this.currentTitle=e;if(!this.headerItem)this.headerText=this.currentTitle}},enumerable:!0,configurable:!0});t.prototype.ngOnInit=function(){this.baseService.setComponent(this);this.dataService.init([{data:this.items}]);this.updateList(this.currentList,this.items);this.headerText=this.title;this.generalClassName="iui-treelist";this.initStyle()};t.prototype.ngAfterViewInit=function(){var e=this,t=setTimeout(function(){var i=e.cmpResolver.resolveComponentFactory(integralui_core_1.IntegralUITComponent);if(i&&e.contentRef)e.tRef=e.contentRef.createComponent(i);clearTimeout(t)},100);e.updateLayout();setTimeout(function(){e.updateLayout()},250)};t.prototype.ngOnDestroy=function(){this.resetLayoutTimer();this.resetScrollAppearanceTimeout();if(this.tRef)this.tRef.destroy()};t.prototype.updateList=function(e,t){var i=this;e.length=0;if(t)t.forEach(function(t){i.addChildItems(e,t,0,null)})};t.prototype.addChildItems=function(e,t,i,r,n){var l=this,o=!0;if(!t[l.currentDataFields.items])return o=l.addItemToCurrentList(e,t,i,r,n);if(o=l.addItemToCurrentList(e,t,i,r,n))if("group"===t[l.currentDataFields.type]&&l.isItemExpanded(t)){var a=t[l.currentDataFields.items];if(a)a.forEach(function(r){l.addChildItems(e,r,i+l.currentIndent,t[l.currentDataFields.id],t)})}return o};t.prototype.addItemToCurrentList=function(e,t,i,r,n){if(!this.isGroupItem(t))t[this.currentDataFields.type]="item";if(!t[this.currentDataFields.id])t[this.currentDataFields.id]=this.commonService.getUniqueId();if(r)t[this.currentDataFields.pid]=r;var l=this.isItemAllowed(t);if(l)e.push({data:t,indent:i});return l};t.prototype.updateDataFields=function(e){if(e)this.currentDataFields={enabled:e.enabled?e.enabled:"enabled",expanded:e.expanded?e.expanded:"expanded",hasChildren:e.hasChildren?e.hasChildren:"hasChildren",icon:e.icon?e.icon:"icon",id:e.id?e.id:"id",items:e.items?e.items:"items",pid:e.pid?e.pid:"pid",selected:e.selected?e.selected:"selected",style:e.style?e.style:"style",text:e.text?e.text:"text",tooltip:e.tooltip?e.tooltip:"tooltip",type:e.type?e.type:"type",value:e.value?e.value:"value",visible:e.visible?e.visible:"visible"};else this.currentDataFields={enabled:"enabled",expanded:"expanded",hasChildren:"hasChildren",icon:"icon",id:"id",items:"items",pid:"pid",selected:"selected",style:"style",text:"text",tooltip:"tooltip",type:"type",value:"value",visible:"visible"}};t.prototype.resetScrollAppearanceTimeout=function(){if(this.scrollAppearanceTimeout)clearTimeout(this.scrollAppearanceTimeout);this.scrollAppearanceTimeout=null};t.prototype.updateScrollAppearance=function(e){var t=this;t.resetScrollAppearanceTimeout();this.scrollAppearanceTimeout=setTimeout(function(){var i=t.commonService.getShiftPos(),r=t.commonService.getMousePos(e);r.x-=i.x;r.y-=i.y;var n=t.commonService.getPageRect(t.elemRef.nativeElement.firstElementChild);if(r.x<=n.right&&r.x>=n.right-75)t.isScrollAvailable=!0;else t.isScrollAvailable=!1},100)};t.prototype.ctrlMouseMove=function(e){if(this.isEnabled&&this.isVerScrollVisible())this.updateScrollAppearance(e);else this.isScrollAvailable=!1};t.prototype.ctrlMouseLeave=function(e){this.resetScrollAppearanceTimeout();this.isScrollAvailable=this.isEnabled&&this.isScrollActive?!0:!1};t.prototype.onItemMouseEnter=function(e,t){if(this.isEnabled)this.hoverItem=t};t.prototype.onItemMouseLeave=function(e,t){this.hoverItem=null};t.prototype.onItemMouseDown=function(e,t){var i=this;if(i.isEnabled&&1==e.buttons&&t)if(i.isGroupItem(t)){var r=!1!==t[i.currentDataFields.expanded]?!0:!1;t[i.currentDataFields.expanded]=!r;i.updateLayout()}else if(t[i.currentDataFields.items]&&t[i.currentDataFields.items].length>0){i.selList.push(i.headerItem);i.updateList(i.nextList,t[i.currentDataFields.items]);i.currentScrollPos.y=0;var n=0,l=5/i.clientRect.width,o=.5,a=1/i.clientRect.width,s=0;if(i.allowAnimation)var c=setInterval(function(){if(n<i.clientRect.width){n+=10;o-=l;s+=a;i.blockPos.left=-n;i.blockOpacity=o;i.rightBlockPos.left=i.clientRect.width-n;i.rightBlockOpacity=s}else{i.selectedItem=t;i.currentList=i.nextList;i.blockPos.left=0;i.blockOpacity=1;i.rightBlockPos.left=i.clientRect.width;i.rightBlockOpacity=0;i.updateScrollSize();clearInterval(c)}},10);else{i.selectedItem=t;i.currentList=i.nextList;i.blockPos.left=0;i.blockOpacity=1;i.rightBlockPos.left=i.clientRect.width;i.rightBlockOpacity=0;i.updateScrollSize()}}else i.selectedItem=t};t.prototype.onHeaderMouseDown=function(e){var t=this;if(this.isEnabled&&1==e.buttons&&t.selList.length>0){var i=t.selList.length-1;if(t.selList[i]&&t.selList[i][t.currentDataFields.items])t.updateList(t.prevList,t.selList[i][t.currentDataFields.items]);else t.updateList(t.prevList,t.items);t.currentScrollPos.y=0;var r=0,n=5/t.clientRect.width,l=.5,o=1/t.clientRect.width,a=0;if(t.allowAnimation){var s=setInterval(function(){if(r<t.clientRect.width){r+=10;l-=n;a+=o;t.blockPos.left=r;t.blockOpacity=l;t.leftBlockPos.left=r-t.clientRect.width;t.leftBlockOpacity=a}else{t.selectedItem=t.selList[i];t.currentList=t.prevList;t.selList.splice(i,1);t.blockPos.left=0;t.blockOpacity=1;t.leftBlockPos.left=-t.clientRect.width;t.leftBlockOpacity=0;t.updateScrollSize();clearInterval(s)}},10);t.isClicked=!0;t.clickPos=t.commonService.getClientPos(e,t.headerElem.nativeElement);var c=setTimeout(function(){t.isClicked=!1;clearTimeout(c)},500)}else{t.selectedItem=t.selList[i];t.currentList=t.prevList;t.selList.splice(i,1);t.blockPos.left=0;t.blockOpacity=1;t.leftBlockPos.left=-t.clientRect.width;t.leftBlockOpacity=0;t.updateScrollSize()}}};t.prototype.getHeaderText=function(){return this.headerItem?this.headerItem.text:this.title};t.prototype.getItemElemList=function(){return this.itemElems?this.itemElems.toArray():null};t.prototype.getItemParent=function(e){return this.dataService.getParent(e)};t.prototype.getItemState=function(e){if(e==this.selectedItem)return integralui_core_1.IntegralUIObjectState.selected;else if(e==this.hoverItem)return integralui_core_1.IntegralUIObjectState.hovered;return integralui_core_1.IntegralUIObjectState.normal};t.prototype.isGroupItem=function(e){return e&&"group"===e[this.currentDataFields.type]?!0:!1};t.prototype.isItemAllowed=function(e){return e&&!1!==e[this.currentDataFields.visible]?!0:!1};t.prototype.isItemExpanded=function(e){return e?e[this.currentDataFields.expanded]||void 0===e[this.currentDataFields.expanded]?!0:!1:!0};t.prototype.resetLayoutTimer=function(){if(this.updateTimer)clearTimeout(this.updateTimer);this.updateTimer=null};t.prototype.updateBlockSize=function(){this.blockPos.top=this.leftBlockPos.top=this.rightBlockPos.top=this.headerElem.nativeElement.offsetHeight;this.blockSize={width:this.scrollBarSize.width,height:this.currentBlockHeight};this.leftBlockPos.left=-this.blockSize.width;this.rightBlockPos.left=this.blockSize.width;this.maxBlockHeight=Math.max(this.blockSize.height,this.clientRect.height-this.headerElem.nativeElement.offsetHeight)};t.prototype.updateLayout=function(){var e=this;e.resetLayoutTimer();e.updateTimer=setTimeout(function(){e.clientRect={width:e.elemRef.nativeElement.firstElementChild.clientWidth,height:e.elemRef.nativeElement.firstElementChild.clientHeight};e.updateSelList();e.updateList(e.currentList,e.headerItem?e.headerItem[e.currentDataFields.items]:e.items);e.updateScrollSize();clearTimeout(e.updateTimer)},1)};t.prototype.updateScrollSize=function(){var e=this,t=setTimeout(function(){e.avgItemHeight=0;e.currentBlockHeight=0;var i=e.getItemElemList();if(i&&i.length>0){for(var r=0;r<i.length;r++)e.currentBlockHeight+=i[r].nativeElement.firstElementChild.offsetHeight;e.avgItemHeight=Math.floor(e.currentBlockHeight/i.length)}e.animateItemSize={width:e.headerElem.nativeElement.offsetWidth,height:e.headerElem.nativeElement.offsetHeight};e.scrollSize={width:0,height:e.currentBlockHeight+e.headerElem.nativeElement.offsetHeight-e.clientRect.height+2};e.scrollSize.width=e.scrollSize.width>0?e.scrollSize.width:0;e.scrollSize.height=e.scrollSize.height>0?e.scrollSize.height:0;e.maxScrollPos={x:e.scrollSize.width,y:e.scrollSize.height};if(e.currentScrollPos.y>e.maxScrollPos.y)e.changeVerticalScrollPos(e.maxScrollPos.y);e.scrollBarSize={width:e.isVerScrollVisible()?e.clientRect.width-16:e.clientRect.width,height:e.isHorScrollVisible()?e.clientRect.height-16:e.clientRect.height-4};e.scrollLargeChange={x:e.scrollBarSize.width,y:e.scrollBarSize.height};e.updateBlockSize();var n=e.commonService.getPadding(e.headerElem.nativeElement),l=e.commonService.getBorderWidth(e.headerElem.nativeElement);e.headerWidth=e.scrollBarSize.width-(n.left+n.right)-(l.left+l.right);clearTimeout(t)},1)};t.prototype.updateSelList=function(){this.selList.length=0;if(this.headerItem){this.selList.push(null);for(var e=this.getItemParent(this.headerItem);e;){this.selList.push(e);e=this.getItemParent(e)}}};t.prototype.updateView=function(){this.blockPos.top=this.headerElem.nativeElement.offsetHeight-this.currentScrollPos.y};t.prototype.scrollPos=function(e){if(e){this.currentScrollPos={x:Math.max(0,Math.min(e.x,this.maxScrollPos.x)),y:Math.max(0,Math.min(e.y,this.maxScrollPos.y))};this.scrollPosChanged.emit({value:this.currentScrollPos})}return{x:Math.floor(this.currentScrollPos.x),y:Math.floor(this.currentScrollPos.y)}};t.prototype.changeVerticalScrollPos=function(e){this.currentScrollPos.y=Math.max(0,Math.min(e,this.maxScrollPos.y));if(this.currentScrollPos.y!=this.prevScrollPos.y){this.updateView();this.scrollPosChanged.emit({value:this.scrollPos()});this.prevScrollPos.y=this.currentScrollPos.y}};t.prototype.processMouseWheel=function(e,t){if(this.isEnabled){this.hoverItem=null;var i=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),r=5;switch(this.mouseWheelSpeed){case integralui_core_1.IntegralUISpeedMode.VerySlow:r=15;break;case integralui_core_1.IntegralUISpeedMode.Slow:r=9;break;case integralui_core_1.IntegralUISpeedMode.Fast:r=3;break;case integralui_core_1.IntegralUISpeedMode.VeryFast:r=1}e.preventDefault();if(this.isVerScrollVisible()){var n=Math.floor(this.clientRect.height/r);if(this.mouseWheelSpeed==integralui_core_1.IntegralUISpeedMode.VerySlow&&this.avgItemHeight>0)n=this.avgItemHeight;var l=this.currentScrollPos.y+n*i*-1;this.changeVerticalScrollPos(l)}e.stopPropagation()}};t.prototype.isHorScrollVisible=function(){return!1};t.prototype.isVerScrollVisible=function(){return this.isEnabled&&this.isScrollAllowed&&this.scrollSize.height>0?!0:!1};t.prototype.onVerticalScrollStart=function(e){this.hoverItem=null;this.isScrollActive=!0};t.prototype.onVerticalScrollEnd=function(e){this.isScrollActive=!1;this.updateScrollAppearance(e)};t.prototype.onVerticalScrollChanged=function(e){this.changeVerticalScrollPos(e.value)};t.prototype.scrollMouseEnter=function(e){};t.prototype.getControlStyle=function(){var e={};if(this.ctrlSize.width>0)e.width=this.ctrlSize.width+"px";if(this.ctrlSize.height>0)e.height=this.ctrlSize.height+"px";return e};t.prototype.refresh=function(){};t.ɵfac=function(e){return new(e||t)(i0.ɵɵdirectiveInject(i4.IntegralUIDataService),i0.ɵɵdirectiveInject(i0.ElementRef),i0.ɵɵdirectiveInject(i1.IntegralUICommonService),i0.ɵɵdirectiveInject(i0.ComponentFactoryResolver),i0.ɵɵdirectiveInject(i2.IntegralUIBaseService))};t.ɵcmp=i0.ɵɵdefineComponent({type:t,selectors:[["iui-treelist"]],contentQueries:function(e,t,i){if(1&e)i0.ɵɵcontentQuery(i,core_1.TemplateRef,!0);if(2&e){var r;i0.ɵɵqueryRefresh(r=i0.ɵɵloadQuery())&&(t.itemTemplate=r.first)}},viewQuery:function(e,t){if(1&e){i0.ɵɵviewQuery(_c6,!0,core_1.ViewContainerRef);i0.ɵɵviewQuery(_c6,!0,core_1.ElementRef);i0.ɵɵviewQuery(_c7,!0,core_1.ElementRef);i0.ɵɵviewQuery(_c8,!0,core_1.ElementRef);i0.ɵɵviewQuery(_c9,!0,core_1.ElementRef);i0.ɵɵviewQuery(IntegralUITreeListItem,!0);i0.ɵɵviewQuery(_c10,!0,core_1.ElementRef)}if(2&e){var i;i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.contentRef=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.blockElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.headerElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.leftBlockElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.rightBlockElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.contentList=i);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.itemElems=i)}},inputs:{controlStyle:"controlStyle",data:"data",enabled:"enabled",state:"state",dataFields:"dataFields",indent:"indent",items:"items",mouseWheelSpeed:"mouseWheelSpeed",selectedItem:"selectedItem",showScroll:"showScroll",title:"title"},outputs:{afterSelect:"afterSelect",beforeSelect:"beforeSelect",clear:"clear",itemAdding:"itemAdding",itemAdded:"itemAdded",itemRemoving:"itemRemoving",itemRemoved:"itemRemoved",scrollPosChanged:"scrollPosChanged",selectionChanged:"selectionChanged"},features:[i0.ɵɵProvidersFeature([integralui_core_1.IntegralUIBaseService,integralui_data_service_1.IntegralUIDataService]),i0.ɵɵInheritDefinitionFeature],decls:19,vars:37,consts:[[3,"ngClass","DOMMouseScroll","mousewheel","mousemove","mouseleave"],[1,"iui-treelist-header",3,"ngStyle","mousedown"],["header",""],["class","expand-icons back",4,"ngIf"],[1,"iui-treelist-header-title"],["class","iui-treelistitem-animate-select-block",3,"ngStyle",4,"ngIf"],[1,"iui-treelist-block",3,"ngStyle"],[3,"ngStyle"],["leftBlock",""],[3,"allowAnimation","enabled","text","templateRef","data","type",4,"ngFor","ngForOf"],["contentBlock",""],[3,"allowAnimation","enabled","text","templateRef","data","type","indent","state","mouseDown","mouseEnter","mouseLeave",4,"ngFor","ngForOf"],["rightBlock",""],["class","iui-treelist-scroll",3,"ngClass","enabled","value","max","largeChange","height","mouseenter","valueChanged","scrollStart","scrollEnd",4,"ngIf"],[1,"expand-icons","back"],[1,"iui-treelistitem-animate-select-block",3,"ngStyle"],[3,"ngClass","ngStyle"],[3,"allowAnimation","enabled","text","templateRef","data","type"],[3,"allowAnimation","enabled","text","templateRef","data","type","indent","state","mouseDown","mouseEnter","mouseLeave"],["itemElem",""],[1,"iui-treelist-scroll",3,"ngClass","enabled","value","max","largeChange","height","mouseenter","valueChanged","scrollStart","scrollEnd"],["verScroll",""]],template:function(e,t){if(1&e){i0.ɵɵelementStart(0,"div",0);i0.ɵɵlistener("DOMMouseScroll",function(e){return t.processMouseWheel(e)})("mousewheel",function(e){return t.processMouseWheel(e)})("mousemove",function(e){return t.ctrlMouseMove(e)})("mouseleave",function(e){return t.ctrlMouseLeave(e)});i0.ɵɵelementStart(1,"div",1,2);i0.ɵɵlistener("mousedown",function(e){return t.onHeaderMouseDown(e)});i0.ɵɵtemplate(3,IntegralUITreeList_span_3_Template,1,0,"span",3);i0.ɵɵelementStart(4,"span",4);i0.ɵɵtext(5);i0.ɵɵelementEnd();i0.ɵɵtemplate(6,IntegralUITreeList_span_6_Template,2,10,"span",5);i0.ɵɵtemplate(7,IntegralUITreeList_span_7_Template,2,11,"span",5);i0.ɵɵelementEnd();i0.ɵɵelementStart(8,"div",6);i0.ɵɵelementStart(9,"ul",7,8);i0.ɵɵtemplate(11,IntegralUITreeList_iui_treelistitem_11_Template,1,6,"iui-treelistitem",9);i0.ɵɵelementEnd();i0.ɵɵelementStart(12,"ul",7,10);i0.ɵɵtemplate(14,IntegralUITreeList_iui_treelistitem_14_Template,2,8,"iui-treelistitem",11);i0.ɵɵelementEnd();i0.ɵɵelementStart(15,"ul",7,12);i0.ɵɵtemplate(17,IntegralUITreeList_iui_treelistitem_17_Template,1,6,"iui-treelistitem",9);i0.ɵɵelementEnd();i0.ɵɵelementEnd();i0.ɵɵtemplate(18,IntegralUITreeList_iui_scrollbar_18_Template,2,9,"iui-scrollbar",13);i0.ɵɵelementEnd()}if(2&e){i0.ɵɵproperty("ngClass",t.getControlClass());i0.ɵɵadvance(1);i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction1(14,_c14,t.headerWidth+"px"));i0.ɵɵadvance(2);i0.ɵɵproperty("ngIf",null!=t.headerItem);i0.ɵɵadvance(2);i0.ɵɵtextInterpolate(t.getHeaderText());i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",t.allowAnimation&&t.isClicked);i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",t.allowAnimation&&t.isClicked);i0.ɵɵadvance(1);i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction2(16,_c15,t.blockSize.width+"px",t.maxBlockHeight+"px"));i0.ɵɵadvance(1);i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction5(19,_c16,t.leftBlockPos.top+"px",t.leftBlockPos.left+"px",t.blockSize.width+"px",t.maxBlockHeight+"px",t.leftBlockOpacity));i0.ɵɵadvance(2);i0.ɵɵproperty("ngForOf",t.prevList);i0.ɵɵadvance(1);i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction5(25,_c16,t.blockPos.top+"px",t.blockPos.left+"px",t.blockSize.width+"px",t.blockSize.height+"px",t.blockOpacity));i0.ɵɵadvance(2);i0.ɵɵproperty("ngForOf",t.currentList);i0.ɵɵadvance(1);i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction5(31,_c16,t.rightBlockPos.top+"px",t.rightBlockPos.left+"px",t.blockSize.width+"px",t.maxBlockHeight+"px",t.rightBlockOpacity));i0.ɵɵadvance(2);i0.ɵɵproperty("ngForOf",t.nextList);i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",t.isVerScrollVisible())}},directives:[i3.NgClass,i3.NgStyle,i3.NgIf,i3.NgForOf,IntegralUITreeListItem,i5.IntegralUIScrollBar],encapsulation:2});return t}(integralui_core_1.IntegralUIBaseComponent);exports.IntegralUITreeList=IntegralUITreeList;