1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
var __runInitializers=this&&this.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=this&&this.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(void 0!==f&&"function"!=typeof f)throw new TypeError("Function expected");return f}for(var _,kind=contextIn.kind,key="getter"===kind?"get":"setter"===kind?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]="access"===p?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])("accessor"===kind?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if("accessor"===kind){if(void 0===result)continue;if(null===result||"object"!=typeof result)throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&("field"===kind?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};import{Control as TcHmiButton}from"../TcHmiButton/TcHmiButton.esm.js";let TcHmiToggleButton=(()=>{let ___onPropertyIsEnabledChanged_decorators,___onMouseDown_decorators,___onMouseUp_decorators,___onMouseEnter_decorators,___onMouseLeave_decorators,___onTouchStart_decorators,___onTouchEndOrCancel_decorators,___onToggleGroupToggled_decorators,_classSuper=TcHmiButton,_instanceExtraInitializers=[];return class extends _classSuper{static{const _metadata="function"==typeof Symbol&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;___onPropertyIsEnabledChanged_decorators=[TcHmi.EventHandler()],___onMouseDown_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkIsReadOnly:!0,checkAccess:"operate"})],___onMouseUp_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkIsReadOnly:!0,checkAccess:"operate"})],___onMouseEnter_decorators=[TcHmi.EventHandler()],___onMouseLeave_decorators=[TcHmi.EventHandler()],___onTouchStart_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkIsReadOnly:!0,checkAccess:"operate"})],___onTouchEndOrCancel_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkIsReadOnly:!0,checkAccess:"operate"})],___onToggleGroupToggled_decorators=[TcHmi.EventHandler()],__esDecorate(this,null,___onPropertyIsEnabledChanged_decorators,{kind:"method",name:"__onPropertyIsEnabledChanged",static:!1,private:!1,access:{has:obj=>"__onPropertyIsEnabledChanged"in obj,get:obj=>obj.__onPropertyIsEnabledChanged},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onMouseDown_decorators,{kind:"method",name:"__onMouseDown",static:!1,private:!1,access:{has:obj=>"__onMouseDown"in obj,get:obj=>obj.__onMouseDown},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onMouseUp_decorators,{kind:"method",name:"__onMouseUp",static:!1,private:!1,access:{has:obj=>"__onMouseUp"in obj,get:obj=>obj.__onMouseUp},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onMouseEnter_decorators,{kind:"method",name:"__onMouseEnter",static:!1,private:!1,access:{has:obj=>"__onMouseEnter"in obj,get:obj=>obj.__onMouseEnter},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onMouseLeave_decorators,{kind:"method",name:"__onMouseLeave",static:!1,private:!1,access:{has:obj=>"__onMouseLeave"in obj,get:obj=>obj.__onMouseLeave},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onTouchStart_decorators,{kind:"method",name:"__onTouchStart",static:!1,private:!1,access:{has:obj=>"__onTouchStart"in obj,get:obj=>obj.__onTouchStart},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onTouchEndOrCancel_decorators,{kind:"method",name:"__onTouchEndOrCancel",static:!1,private:!1,access:{has:obj=>"__onTouchEndOrCancel"in obj,get:obj=>obj.__onTouchEndOrCancel},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onToggleGroupToggled_decorators,{kind:"method",name:"__onToggleGroupToggled",static:!1,private:!1,access:{has:obj=>"__onToggleGroupToggled"in obj,get:obj=>obj.__onToggleGroupToggled},metadata:_metadata},null,_instanceExtraInitializers),_metadata&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static#tchmiFQN="TcHmi.Controls.Beckhoff."+this.name;constructor(element,pcElement,attrs){super(element,pcElement,attrs)}__toggleGroup=__runInitializers(this,_instanceExtraInitializers);__toggleState;__toggleLock=!1;__onToggleGroupToggledEventDestroyEvent=null;__previnit(){super.__previnit()}__init(){super.__init()}__attach(){super.__attach()}__detach(){super.__detach()}destroy(){this.__keepAlive||(null!==this.__onToggleGroupToggledEventDestroyEvent&&(this.__onToggleGroupToggledEventDestroyEvent(),this.__onToggleGroupToggledEventDestroyEvent=null),super.destroy())}__setInternalState(state,source){this.__state!==state?(this.__setToggleState(state?"Active":"Normal",!0,!1),state&&null!==this.__toggleGroup&&TcHmi.EventProvider.raise(this.__toggleGroup+".toggled",{ActiveElementId:this.__id,source}),super.__setInternalState(state,source)):this.__setIsDown(this.__state)}__onPropertyIsEnabledChanged(_event,data){data&&(this.getIsEnabled()?!this.__destroyStateSymbolWatch&&this.__stateSymbol&&(this.__destroyStateSymbolWatch=this.__stateSymbol.watch(this.__onStateSymbolWatch)):(this.__destroyStateSymbolWatch&&(this.__destroyStateSymbolWatch(),this.__destroyStateSymbolWatch=null),this.__mousedown=!1,this.__stateLock=!1,this.__touches=[]))}__onMouseDown(event){if(!this.__touchLock&&0===event.button&&(this.__mousedown=!0,!this.__stateLock))if(this.__state)this.__toggleLock=!1;else{this.__toggleLock=!0,this.__stateLock=!0,this.__interactionLock=!0,this.__interactionLockRefCount++,this.__writeState(!0,"userInteraction").finally(()=>{this.__interactionLockRefCount>0&&(this.__interactionLockRefCount--,0===this.__interactionLockRefCount&&(this.__interactionLock=!1))})}}__onMouseUp(event){if(!this.__touchLock&&0===event.button&&this.__mousedown){if(this.__mousedown=!1,!this.__toggleLock){this.__writeState(!1,"userInteraction").finally(()=>{this.__interactionLockRefCount>0&&(this.__interactionLockRefCount--,0===this.__interactionLockRefCount&&(this.__interactionLock=!1))})}this.__stateLock=!1}}__onMouseEnter(){}__onMouseLeave(event){this.__mousedown&&(1!==event.buttons&&(this.__mousedown=!1),this.getIsEnabled()&&!this.__isReadOnly&&TcHmi.Access.checkAccess(this,"operate")&&(this.__mousedown=!1,this.__toggleLock||this.__writeState(!1,"userInteraction"),this.__stateLock=!1))}__onTouchStart(event){let changedTouches=Array.from(event.changedTouches).filter(touch=>touch.target===event.target);if(0!==changedTouches.length){if(this.__touches=this.__touches.concat(changedTouches),!this.__stateLock)if(this.__state)this.__toggleLock=!1;else{this.__toggleLock=!0,this.__stateLock=!0,this.__interactionLock=!0,this.__interactionLockRefCount++,this.__writeState(!0,"userInteraction").finally(()=>{this.__interactionLockRefCount>0&&(this.__interactionLockRefCount--,0===this.__interactionLockRefCount&&(this.__interactionLock=!1))})}this.__touchLockTimeoutId&&(clearTimeout(this.__touchLockTimeoutId),this.__touchLockTimeoutId=0),this.__touchLock=!0}}__onTouchEndOrCancel(event){if(0===this.__touches.length)return;const activeTouchIds=Array.from(event.touches).map(touch=>touch.identifier);if(this.__touches=this.__touches.filter(touch=>activeTouchIds.includes(touch.identifier)),0===this.__touches.length){if(!this.__toggleLock){this.__writeState(!1,"userInteraction").finally(()=>{this.__interactionLockRefCount>0&&(this.__interactionLockRefCount--,0===this.__interactionLockRefCount&&(this.__interactionLock=!1))})}this.__stateLock=!1}this.__touchLockTimeoutId&&(clearTimeout(this.__touchLockTimeoutId),this.__touchLockTimeoutId=0),this.__touchLockTimeoutId=setTimeout(()=>{this.__touchLock=!1},500)}__onToggleGroupToggled(_event,data){data&&data.ActiveElementId&&data.ActiveElementId!==this.__id&&(this.__stateSymbol&&this.__stateSymbol.getExpression().toString()===data.source||this.__writeState(!1,"toggleGroup"))}setToggleGroup(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("ToggleGroup")),convertedValue!==this.__toggleGroup&&(this.__toggleGroup=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"ToggleGroup"}),this.__processToggleGroup())}getToggleGroup(){return this.__toggleGroup}__processToggleGroup(){null!==this.__onToggleGroupToggledEventDestroyEvent&&(this.__onToggleGroupToggledEventDestroyEvent(),this.__onToggleGroupToggledEventDestroyEvent=null),null!==this.__toggleGroup&&(this.__onToggleGroupToggledEventDestroyEvent=TcHmi.EventProvider.register(this.__toggleGroup+".toggled",this.__onToggleGroupToggled))}__setToggleState(valueNew,forwardStateSymbol=!0,process=!1){let convertedValue=TcHmi.ValueConverter.toToggleState(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("ToggleState")),convertedValue!==this.__toggleState&&(this.__toggleState=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"ToggleState"}),TcHmi.EventProvider.raise(this.__id+".onToggleStateChanged"),process&&this.__processToggleState())}setToggleState(valueNew){this.__setToggleState(valueNew,!0,!0)}getToggleState(){return this.__toggleState}__processToggleState(forwardStateSymbol=!0){this.__writeState("Active"===this.__toggleState,"attribute")}}})();TcHmi.Controls.registerEx("TcHmiToggleButton","TcHmi.Controls.Beckhoff",TcHmiToggleButton,{injectInGlobalObject:!0});export{TcHmiToggleButton as Control}; |