UNPKG

@lidorsystems/integralui-web

Version:

IntegralUI Web - Advanced UI Components for Angular

15 lines (12 loc) 13.6 kB
/* filename: integralui.listgroup.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 n(){this.constructor=t}t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();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"),integralui_groupbox_1=require("./integralui.groupbox"),i0=require("@angular/core"),i1=require("../services/integralui.data.service"),i2=require("../services/integralui.common.service"),i3=require("./integralui.core"),i4=require("@angular/common"),_c0=["control"],_c1=["content"],_c2=["header"],_c3=function(e,t){return{height:e,width:t}},_c4=function(e){return{"iui-groupbox-header-animate-select iui-groupbox-header-animate-select-left":e}},_c5=function(e){return{height:e}};function IntegralUIListGroup_span_5_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"span",6);i0.ɵɵelement(1,"span",0);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction2(3,_c3,i.headerSize.height+"px",i.clickPos.x+"px"));i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(6,_c4,i.isClicked))("ngStyle",i0.ɵɵpureFunction1(8,_c5,i.headerSize.height+"px"))}}var _c6=function(e,t,i){return{left:e,height:t,width:i}},_c7=function(e){return{"iui-groupbox-header-animate-select iui-groupbox-header-animate-select-right":e}};function IntegralUIListGroup_span_6_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"span",6);i0.ɵɵelement(1,"span",0);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction3(3,_c6,i.clickPos.x+"px",i.headerSize.height+"px",i.headerSize.width-i.clickPos.x+"px"));i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",i0.ɵɵpureFunction1(7,_c7,i.isClicked))("ngStyle",i0.ɵɵpureFunction1(9,_c5,i.headerSize.height+"px"))}}var _c8=[[["","header",""]],"*"],_c9=function(e,t,i,n){return{"border-width":e,display:t,height:i,opacity:n}},_c10=["[header]","*"],IntegralUIListGroup=function(e){__extends(t,e);function t(t,i,n,a){var r=e.call(this,i,n)||this;r.dataService=t;r.commonService=i;r.cmpResolver=n;r.baseService=a;r.numItems=0;r.itemEventList=[];r.headerExpandBoxClassName="";r.itemClassName="";return r}t.prototype.ngOnInit=function(){this.parentCtrl=this.baseService.getComponent();this.dataService.init([{data:this.items}]);this.generalClassName="iui-listgroup";this.headerClassName=this.generalClassName+"-header";this.headerExpandBoxClassName=this.headerClassName+"-expand-box";this.contentClassName=this.generalClassName+"-content";this.itemClassName=this.generalClassName+"-item";this.defaultStyle={general:{disabled:this.generalClassName+"-disabled",focused:this.generalClassName+"-focused",normal:this.generalClassName,hovered:this.generalClassName+"-hovered",selected:this.generalClassName+"-selected"},header:{general:{disabled:this.headerClassName+"-disabled",focused:this.headerClassName+"-focused",normal:this.headerClassName,hovered:this.headerClassName+"-hovered",selected:this.headerClassName+"-selected"},expandBox:this.headerExpandBoxClassName},content:{general:this.contentClassName,expanded:this.contentClassName+"-expand",collapsed:this.contentClassName+"-collapse"},item:{general:{disabled:this.itemClassName+"-disabled",focused:this.itemClassName+"-focused",normal:this.itemClassName,hovered:this.itemClassName+"-hovered",selected:this.itemClassName+"-selected"}}};this.updateStyle(this.controlStyle);this.updateControlClass();this.updateContentClass()};t.prototype.ngAfterContentInit=function(){var e=this;e.itemList=e.contentList.toArray();e.numItems=e.itemList.length;e.attachItemEvents();var t=setTimeout(function(){if(e.contentElem){var i=e.contentElem.nativeElement.firstElementChild.cloneNode(!0);i.style.position="absolute";i.style.top="-9999999px";e.controlElem.nativeElement.append(i);e.maxBlockHeight=i.offsetHeight;i.remove()}e.headerSize={width:e.headerElem.nativeElement.firstElementChild.offsetWidth,height:e.headerElem.nativeElement.firstElementChild.offsetHeight};clearTimeout(t)},100)};t.prototype.ngOnDestroy=function(){};t.prototype.ngAfterContentChecked=function(){if(this.contentList){this.itemList=this.contentList.toArray();if(this.numItems!=this.itemList.length){this.attachItemEvents();this.numItems=this.itemList.length}}};t.prototype.onHeaderClick=function(e){var t=this;if(t.isEnabled&&1==e.buttons){t.selected=!0;if(!t.supressCallback&&t.parentCtrl&&t.parentCtrl.invokeMethod)t.parentCtrl.invokeMethod("SELECT_GROUP",t);if(!t.supressCallback&&!t.expanded)t.expanded=!0;t.isClicked=!0;t.clickPos=t.commonService.getClientPos(e,t.headerElem.nativeElement.firstElementChild);var i=setTimeout(function(){t.isClicked=!1;clearTimeout(i)},500)}};t.prototype.onHeaderExpand=function(e){this.supressCallback=!0;this.expanded=!this.expanded;e.event.stopPropagation()};t.prototype.toggleContent=function(){var e=this,t=0,i=0;e.data;if(e.expanded){e.contentDisplay="block";if(e.allowAnimation)var n=setInterval(function(){if(t<e.maxBlockHeight){t+=i=0==i?1:i+2;e.contentHeight=t+"px"}else{e.contentHeight="auto";e.expandState="none";e.callAfterEvent(!0,e.supressCallback);e.supressCallback=!1;clearInterval(n)}},25);else{e.contentHeight="auto";e.expandState="none";e.callAfterEvent(!0,e.supressCallback);e.supressCallback=!1}}else{e.maxBlockHeight=e.contentElem.nativeElement.offsetHeight;t=e.maxBlockHeight;if(e.allowAnimation)var a=setInterval(function(){if(t>0){t-=i=0==i?1:i+2;e.contentHeight=t+"px"}else{e.contentDisplay="none";e.contentHeight="0";e.expandState="none";e.callAfterEvent();e.supressCallback=!1;clearInterval(a)}},25);else{e.contentDisplay="none";e.contentHeight="0";e.expandState="none";e.callAfterEvent();e.supressCallback=!1}}};t.prototype.getComponentData=function(e){if(e)if(e.data)return e.data;else{var t=this.getItemDataIndex(e);if(this.items&&t>=0&&t<this.items.length)return this.items[t]}return null};t.prototype.getItemCurrentIndex=function(e){this.itemList=this.contentList.toArray();return e&&this.itemList?this.itemList.indexOf(e):-1};t.prototype.getItemDataIndex=function(e){if(e){var t=this.getItemCurrentIndex(e);if(this.items&&t>=0&&t<this.items.length)return t}return-1};t.prototype.attachItemEvents=function(){var e=this;this.itemList=this.contentList.toArray();if(e.itemEventList){e.itemEventList.forEach(function(e){e.forEach(function(e){e.unsubscribe()})});e.itemEventList.length=0}if(this.itemList&&this.itemList.length>0)this.itemList.forEach(function(t){var i=[];i.push(t.mouseDown.subscribe(function(i){if(t){e.clearSelection();t.state|=integralui_core_1.IntegralUIObjectState.selected;e.selected=!0;e.updateSelectedItemFromComponent(t);e.afterSelect.emit({group:e.data,item:e.getComponentData(t)})}}));e.itemEventList.push(i)})};t.prototype.updateSelectedItemFromComponent=function(e){if(this.itemList&&this.itemList.length>0){if(e)this.itemList.indexOf(e)}};t.prototype.clearSelection=function(e){this.itemList=this.contentList.toArray();this.itemList.forEach(function(t){if(t!=e)t.state&=~integralui_core_1.IntegralUIObjectState.selected})};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.getItemGeneralStyle=function(e){if(this.commonService.isString(e))return e;else if(e)return{disabled:this.commonService.isFieldAvailable(e.disabled,this.itemClassName+"-disabled"),focused:this.commonService.isFieldAvailable(e.focused,this.itemClassName+"-focused"),hovered:this.commonService.isFieldAvailable(e.hovered,this.itemClassName+"-hovered"),normal:this.commonService.isFieldAvailable(e.normal,this.itemClassName),selected:this.commonService.isFieldAvailable(e.selected,this.itemClassName+"-selected")};else return{disabled:this.defaultStyle.item.general.disabled,focused:this.defaultStyle.item.general.focused,hovered:this.defaultStyle.item.general.hovered,normal:this.defaultStyle.item.general.normal,selected:this.defaultStyle.item.general.selected}};t.prototype.getItemStyle=function(e){return{general:this.getItemGeneralStyle(e.general)}};t.prototype.updateStyle=function(e){if(e)this.options.currentStyle={general:this.getGeneralStyle(e.general),header:this.getHeaderStyle(e.header),content:this.getContentStyle(e.content),item:this.getItemStyle(e.item)};else this.options.currentStyle={general:{disabled:this.defaultStyle.general.disabled,focused:this.defaultStyle.general.focused,hovered:this.defaultStyle.general.hovered,normal:this.defaultStyle.general.normal,selected:this.defaultStyle.general.selected},header:{general:{disabled:this.defaultStyle.header.general.disabled,focused:this.defaultStyle.header.general.focused,hovered:this.defaultStyle.header.general.hovered,normal:this.defaultStyle.header.general.normal,selected:this.defaultStyle.header.general.selected},expandBox:this.defaultStyle.header.expandBox},content:{general:this.defaultStyle.content.general,expanded:this.defaultStyle.content.expanded,collapsed:this.defaultStyle.content.collapsed},item:{general:{disabled:this.defaultStyle.item.general.disabled,focused:this.defaultStyle.item.general.focused,hovered:this.defaultStyle.item.general.hovered,normal:this.defaultStyle.item.general.normal,selected:this.defaultStyle.item.general.selected}}}};t.ɵfac=function(e){return new(e||t)(i0.ɵɵdirectiveInject(i1.IntegralUIDataService),i0.ɵɵdirectiveInject(i2.IntegralUICommonService),i0.ɵɵdirectiveInject(i0.ComponentFactoryResolver),i0.ɵɵdirectiveInject(i3.IntegralUIBaseService))};t.ɵcmp=i0.ɵɵdefineComponent({type:t,selectors:[["iui-listgroup"]],contentQueries:function(e,t,i){if(1&e)i0.ɵɵcontentQuery(i,integralui_core_1.IntegralUIItem,!0);if(2&e){var n;i0.ɵɵqueryRefresh(n=i0.ɵɵloadQuery())&&(t.contentList=n)}},viewQuery:function(e,t){if(1&e){i0.ɵɵviewQuery(_c0,!0,core_1.ElementRef);i0.ɵɵviewQuery(_c1,!0,core_1.ViewContainerRef);i0.ɵɵviewQuery(_c1,!0,core_1.ElementRef);i0.ɵɵviewQuery(_c2,!0)}if(2&e){var i;i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.controlElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.contentRef=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.contentElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.header=i.first)}},inputs:{controlStyle:"controlStyle",data:"data",enabled:"enabled",expandBoxType:"expandBoxType",icon:"icon",name:"name",size:"size",state:"state",text:"text",items:"items"},outputs:{afterCollapse:"afterCollapse",afterExpand:"afterExpand",afterSelect:"afterSelect",beforeCollapse:"beforeCollapse",beforeExpand:"beforeExpand",beforeSelect:"beforeSelect",selectedChanged:"selectedChanged"},features:[i0.ɵɵProvidersFeature([integralui_data_service_1.IntegralUIDataService]),i0.ɵɵInheritDefinitionFeature],ngContentSelectors:_c10,decls:10,vars:16,consts:[[3,"ngClass","ngStyle"],["control",""],[3,"controlStyle","enabled","icon","text","animationType","mouseDown","expandClicked"],["header",""],["class","iui-groupbox-header-animate-select-block",3,"ngStyle",4,"ngIf"],["content",""],[1,"iui-groupbox-header-animate-select-block",3,"ngStyle"]],template:function(e,t){if(1&e){i0.ɵɵprojectionDef(_c8);i0.ɵɵelementStart(0,"div",0,1);i0.ɵɵelementStart(2,"iui-header",2,3);i0.ɵɵlistener("mouseDown",function(e){return t.onHeaderClick(e)})("expandClicked",function(e){return t.onHeaderExpand(e)});i0.ɵɵprojection(4);i0.ɵɵtemplate(5,IntegralUIListGroup_span_5_Template,2,10,"span",4);i0.ɵɵtemplate(6,IntegralUIListGroup_span_6_Template,2,11,"span",4);i0.ɵɵelementEnd();i0.ɵɵelementStart(7,"div",0,5);i0.ɵɵprojection(9,1);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){i0.ɵɵproperty("ngClass",t.getControlClass())("ngStyle",t.getControlStyle());i0.ɵɵadvance(2);i0.ɵɵproperty("controlStyle",t.getCurrentHeaderStyle())("enabled",t.enabled)("icon",t.icon)("text",t.text)("animationType",t.expandBoxType);i0.ɵɵadvance(3);i0.ɵɵproperty("ngIf",t.allowAnimation&&t.isClicked);i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",t.allowAnimation&&t.isClicked);i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",t.getContentClass())("ngStyle",i0.ɵɵpureFunction4(11,_c9,t.expanded?"1px":"0px",t.contentDisplay,t.contentHeight,t.contentOpacity))}},directives:[i4.NgClass,i4.NgStyle,i3.IntegralUIHeaderItem,i4.NgIf],encapsulation:2});return t}(integralui_groupbox_1.IntegralUIGroupBox);exports.IntegralUIListGroup=IntegralUIListGroup;