UNPKG

integralui-web-tabstrip

Version:

IntegralUI Web Lite - TabStrip is a native Web Component that consists of multiple panels with tabs that share the same space.

15 lines (12 loc) 6.89 kB
/* filename: integralui.base.js version : 20.2.0 Copyright © 2020 Lidor Systems. All rights reserved. This file is part of the "IntegralUI Web Lite" Library. The contents of this file are subject to the IntegralUI Web Lite 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/lite/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. */ import{L as LitElement,c as css}from"../external/lit-element.js";import IntegralUICommonService from"../services/integralui.common.service.js";import{IntegralUIObjectState,IntegralUITheme}from"./integralui.enums.js";class IntegralUIBase extends LitElement{constructor(){super();this._ini();this._iniStyle()}_ini(){this._cmnSrv=new IntegralUICommonService();this._anAlw=!1;this._ctrDt=null;this._ctrNm="";this._ctrSt=IntegralUIObjectState.Normal;this._enbl=!0;this._opt={currentStyle:null};this._clRc={width:0,height:0};this._ctrSz={width:0,height:0};this._prvClRc={width:0,height:0};this._eRf=null;this._cRsPt="../icons";this._cCmSty=[];this._cThm=IntegralUITheme.None;this._cThmSettings=css``;this._dfSty={};this._ctrCs={};this._gnrCsNm="iui-control"}_iniStyle(){this._dfSty={general:{disabled:this._gnrCsNm+"-disabled",focused:this._gnrCsNm+"-focused",normal:this._gnrCsNm,hovered:this._gnrCsNm+"-hovered",selected:this._gnrCsNm+"-selected"}};this.refresh()}attributeChangedCallback(t,e,s){super.attributeChangedCallback(t,e,s)}static get properties(){return{allowAnimation:{type:Boolean,attribute:"allow-animation",relect:!0},controlStyle:{type:Object,attribute:"control-style"},customStyle:{type:Array,attribute:"custom-style"},data:{type:Object},enabled:{type:Boolean,relect:!0},name:{type:String,relect:!0},resourcePath:{type:String,attribute:"resource-path",relect:!0},size:{type:Object},state:{type:Number,relect:!0},theme:{converter:{fromAttribute:t=>{switch((t=t.replace(/"|'/,"").replace(/"|'/,"")).toLowerCase()){case"office":return IntegralUITheme.Office;case"midnight":return IntegralUITheme.Midnight;default:return IntegralUITheme.None}},toAttribute:t=>{switch(t){case IntegralUITheme.Office:return"Office";case IntegralUITheme.Midnight:return"Midnight";default:return"None"}}},reflect:!0}}}get allowAnimation(){return this._anAlw}set allowAnimation(t){if(this._anAlw!==t){const e=this._anAlw;this._anAlw=t;this.requestUpdate("allowAnimation",e)}}get controlStyle(){return this._ctrlStyle}set controlStyle(t){if(this._ctrlStyle!==t){const e=this._ctrlStyle;this._ctrlStyle=t;this.requestUpdate("controlStyle",e);this.refresh()}}get customStyle(){return this._cCmSty}set customStyle(t){if(this._cCmSty!==t){const e=this._cCmSty;this._cCmSty=t;this.requestUpdate("customStyle",e);this.refresh()}}get data(){return this._ctrDt}set data(t){if(this._ctrDt!==t){const e=this._ctrDt;this._ctrDt=t;this.requestUpdate("data",e)}}get enabled(){return this._enbl}set enabled(t){if(void 0!==t&&this._enbl!==t){const e=this._enbl;this._enbl=t;this._inkEv("enabledChanged",{enabled:t});this.requestUpdate("enabled",e);if(t)this.state&=~IntegralUIObjectState.Disabled;else this.state|=IntegralUIObjectState.Disabled}}get name(){return this._ctrNm}set name(t){if(this._ctrNm!==t){const e=this._ctrNm;this._ctrNm=t;this.requestUpdate("name",e)}}get resourcePath(){return this._cRsPt}set resourcePath(t){if(this._cRsPt!==t){const e=this._cRsPt;this._cRsPt=t;this._uCtrStyStt(t);this.requestUpdate("resourcePath",e)}}get size(){return this._ctrSz}set size(t){if(t){let e=!1;const s=this._ctrSz;if(void 0!==t.width&&this._ctrSz.width!==t.width){this._ctrSz.width=t.width;e=!0}if(void 0!==t.height&&this._ctrSz.height!==t.height){this._ctrSz.height=t.height;e=!0}if(e){this._inkEv("sizeChanged",{size:this._ctrSz});this.requestUpdate("size",s);this.updateLayout()}}}get state(){return this._ctrSt}set state(t){if(this._ctrSt!==t){const e=this._ctrSt;this._ctrSt=t;this._uCtrCs();this._prcStCh();this.requestUpdate("state",e);this._inkEv("stateChanged",{state:t});this.update()}}get theme(){return this._cThm}set theme(t){if(this._cThm!==t){const e=this._cThm;this._cThm=t;this._uThSt(t);this.requestUpdate("theme",e);this.refresh()}}_inkEv(t,e,s,i){let r=new CustomEvent(t,{detail:e,bubbles:void 0!==s?s:!1,composed:void 0!==i?i:!0});this.dispatchEvent(r);return e}_cDftFunc(){}_prcStCh(){}_uThSt(){this._cThmSettings=css``}refresh(){this._uSty(this.controlStyle);this._uCtrCs();this.update();this._uRf()}_uCtrCs(){this._ctrCs={};this._ctrCs[this._gnrCsNm]=!0;if(this._opt.currentStyle&&this._opt.currentStyle.general){this._ctrCs[this._opt.currentStyle.general.normal]=!0;if(this.state&IntegralUIObjectState.Disabled)this._ctrCs[this._opt.currentStyle.general.disabled]=!0;else if(this.state&IntegralUIObjectState.Focused)this._ctrCs[this._opt.currentStyle.general.focused]=!0;else if(this.state&IntegralUIObjectState.Selected)this._ctrCs[this._opt.currentStyle.general.selected]=!0;else if(this.state&IntegralUIObjectState.Hovered)this._ctrCs[this._opt.currentStyle.general.hovered]=!0;if(this.allowAnimation)if(this.state&IntegralUIObjectState.Hovered)this._ctrCs[this._dfSty.general.normal+"-enter"]=!0;else this._ctrCs[this._dfSty.general.normal+"-leave"]=!0}}_gCtrCs(){return this._ctrCs}_gCtrSty(){let t={};if(this._ctrSz.width>0)t.width=this._ctrSz.width+"px";if(this._ctrSz.height>0)t.height=this._ctrSz.height+"px";return t}_gDfSty(){return{general:this._gDfGnSty()}}_gDfGnSty(){return this._dfSty&&this._dfSty.general?{disabled:this._dfSty.general.disabled,focused:this._dfSty.general.focused,hovered:this._dfSty.general.hovered,normal:this._dfSty.general.normal,selected:this._dfSty.general.selected}:{}}_gGnSty(t){if(this._cmnSrv)if(this._cmnSrv.isString(t))return t;else if(t)return{disabled:this._cmnSrv.isFieldAvailable(t.disabled,this.generalClassName+"-disabled"),focused:this._cmnSrv.isFieldAvailable(t.focused,this.generalClassName+"-focused"),hovered:this._cmnSrv.isFieldAvailable(t.hovered,this.generalClassName+"-hovered"),normal:this._cmnSrv.isFieldAvailable(t.normal,this.generalClassName),selected:this._cmnSrv.isFieldAvailable(t.selected,this.generalClassName+"-selected")};return this._gDfGnSty()}_uCtrStyStt(t){}_uSty(t){if(t)this._opt.currentStyle={general:this._gGnSty(t.general)};else this._opt.currentStyle=this._gDfSty()}async shouldUpdate(t){t.forEach((t,e)=>{});return!0}async updateLayout(){this.update()}_uRf(){}}export default IntegralUIBase;