iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
3 lines • 8.47 kB
JavaScript
/*! For license information please see 42950.6627034067400b13.js.LICENSE.txt */
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["42950"],{19799:function(t,e,i){i.d(e,{J:()=>n});i(63721),i(71695),i(47021);var r=i(57243);const s=Symbol("attachableController");let o;r.sk||(o=new MutationObserver((t=>{for(const i of t){var e;null===(e=i.target[s])||void 0===e||e.hostConnected()}})));class n{get htmlFor(){return this.host.getAttribute("for")}set htmlFor(t){null===t?this.host.removeAttribute("for"):this.host.setAttribute("for",t)}get control(){return this.host.hasAttribute("for")?this.htmlFor&&this.host.isConnected?this.host.getRootNode().querySelector(`#${this.htmlFor}`):null:this.currentControl||this.host.parentElement}set control(t){t?this.attach(t):this.detach()}constructor(t,e){var i;this.host=t,this.onControlChange=e,this.currentControl=null,t.addController(this),t[s]=this,null===(i=o)||void 0===i||i.observe(t,{attributeFilter:["for"]})}attach(t){t!==this.currentControl&&(this.setCurrentControl(t),this.host.removeAttribute("for"))}detach(){this.setCurrentControl(null),this.host.setAttribute("for","")}hostConnected(){this.setCurrentControl(this.control)}hostDisconnected(){this.setCurrentControl(null)}setCurrentControl(t){this.onControlChange(this.currentControl,t),this.currentControl=t}}},43921:function(t,e,i){i.d(e,{L7:()=>s,Xt:()=>r});i(71695),i(40251),i(19134),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(44495),i(81804),i(47021);const r={STANDARD:"cubic-bezier(0.2, 0, 0, 1)",STANDARD_ACCELERATE:"cubic-bezier(.3,0,1,1)",STANDARD_DECELERATE:"cubic-bezier(0,0,0,1)",EMPHASIZED:"cubic-bezier(.3,0,0,1)",EMPHASIZED_ACCELERATE:"cubic-bezier(.3,0,.8,.15)",EMPHASIZED_DECELERATE:"cubic-bezier(.05,.7,.1,1)"};function s(){let t=null;return{start(){var e;return null===(e=t)||void 0===e||e.abort(),t=new AbortController,t.signal},finish(){t=null}}}},23111:function(t,e,i){i.d(e,{M:()=>f});var r=i(9065),s=i(50778),o=(i(71695),i(40251),i(47021),i(57243)),n=i(35359),a=i(19799),h=i(43921);let l,c=t=>t;var d,u;(u=d||(d={}))[u.INACTIVE=0]="INACTIVE",u[u.TOUCH_DELAY=1]="TOUCH_DELAY",u[u.HOLDING=2]="HOLDING",u[u.WAITING_FOR_CLICK=3]="WAITING_FOR_CLICK";const p=["click","contextmenu","pointercancel","pointerdown","pointerenter","pointerleave","pointerup"],C=o.sk?null:window.matchMedia("(forced-colors: active)");class m extends o.oi{constructor(){super(...arguments),this.disabled=!1,this.hovered=!1,this.pressed=!1,this.rippleSize="",this.rippleScale="",this.initialSize=0,this.state=d.INACTIVE,this.checkBoundsAfterContextMenu=!1,this.attachableController=new a.J(this,this.onControlChange.bind(this))}get htmlFor(){return this.attachableController.htmlFor}set htmlFor(t){this.attachableController.htmlFor=t}get control(){return this.attachableController.control}set control(t){this.attachableController.control=t}attach(t){this.attachableController.attach(t)}detach(){this.attachableController.detach()}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-hidden","true")}render(){const t={hovered:this.hovered,pressed:this.pressed};return(0,o.dy)(l||(l=c`<div class="surface ${0}"></div>`),(0,n.$)(t))}update(t){t.has("disabled")&&this.disabled&&(this.hovered=!1,this.pressed=!1),super.update(t)}handlePointerenter(t){this.shouldReactToEvent(t)&&(this.hovered=!0)}handlePointerleave(t){this.shouldReactToEvent(t)&&(this.hovered=!1,this.state!==d.INACTIVE&&this.endPressAnimation())}handlePointerup(t){if(this.shouldReactToEvent(t)){if(this.state!==d.HOLDING)return this.state===d.TOUCH_DELAY?(this.state=d.WAITING_FOR_CLICK,void this.startPressAnimation(this.rippleStartEvent)):void 0;this.state=d.WAITING_FOR_CLICK}}async handlePointerdown(t){if(this.shouldReactToEvent(t)){if(this.rippleStartEvent=t,!this.isTouch(t))return this.state=d.WAITING_FOR_CLICK,void this.startPressAnimation(t);this.checkBoundsAfterContextMenu&&!this.inBounds(t)||(this.checkBoundsAfterContextMenu=!1,this.state=d.TOUCH_DELAY,await new Promise((t=>{setTimeout(t,150)})),this.state===d.TOUCH_DELAY&&(this.state=d.HOLDING,this.startPressAnimation(t)))}}handleClick(){this.disabled||(this.state!==d.WAITING_FOR_CLICK?this.state===d.INACTIVE&&(this.startPressAnimation(),this.endPressAnimation()):this.endPressAnimation())}handlePointercancel(t){this.shouldReactToEvent(t)&&this.endPressAnimation()}handleContextmenu(){this.disabled||(this.checkBoundsAfterContextMenu=!0,this.endPressAnimation())}determineRippleSize(){const{height:t,width:e}=this.getBoundingClientRect(),i=Math.max(t,e),r=Math.max(.35*i,75),s=Math.floor(.2*i),o=Math.sqrt(e**2+t**2)+10;this.initialSize=s,this.rippleScale=""+(o+r)/s,this.rippleSize=`${s}px`}getNormalizedPointerEventCoords(t){const{scrollX:e,scrollY:i}=window,{left:r,top:s}=this.getBoundingClientRect(),o=e+r,n=i+s,{pageX:a,pageY:h}=t;return{x:a-o,y:h-n}}getTranslationCoordinates(t){const{height:e,width:i}=this.getBoundingClientRect(),r={x:(i-this.initialSize)/2,y:(e-this.initialSize)/2};let s;return s=t instanceof PointerEvent?this.getNormalizedPointerEventCoords(t):{x:i/2,y:e/2},s={x:s.x-this.initialSize/2,y:s.y-this.initialSize/2},{startPoint:s,endPoint:r}}startPressAnimation(t){var e;if(!this.mdRoot)return;this.pressed=!0,null===(e=this.growAnimation)||void 0===e||e.cancel(),this.determineRippleSize();const{startPoint:i,endPoint:r}=this.getTranslationCoordinates(t),s=`${i.x}px, ${i.y}px`,o=`${r.x}px, ${r.y}px`;this.growAnimation=this.mdRoot.animate({top:[0,0],left:[0,0],height:[this.rippleSize,this.rippleSize],width:[this.rippleSize,this.rippleSize],transform:[`translate(${s}) scale(1)`,`translate(${o}) scale(${this.rippleScale})`]},{pseudoElement:"::after",duration:450,easing:h.Xt.STANDARD,fill:"forwards"})}async endPressAnimation(){this.rippleStartEvent=void 0,this.state=d.INACTIVE;const t=this.growAnimation;let e=1/0;"number"==typeof(null==t?void 0:t.currentTime)?e=t.currentTime:null!=t&&t.currentTime&&(e=t.currentTime.to("ms").value),e>=225?this.pressed=!1:(await new Promise((t=>{setTimeout(t,225-e)})),this.growAnimation===t&&(this.pressed=!1))}shouldReactToEvent(t){if(this.disabled||!t.isPrimary)return!1;if(this.rippleStartEvent&&this.rippleStartEvent.pointerId!==t.pointerId)return!1;if("pointerenter"===t.type||"pointerleave"===t.type)return!this.isTouch(t);const e=1===t.buttons;return this.isTouch(t)||e}inBounds({x:t,y:e}){const{top:i,left:r,bottom:s,right:o}=this.getBoundingClientRect();return t>=r&&t<=o&&e>=i&&e<=s}isTouch({pointerType:t}){return"touch"===t}async handleEvent(t){if(null==C||!C.matches)switch(t.type){case"click":this.handleClick();break;case"contextmenu":this.handleContextmenu();break;case"pointercancel":this.handlePointercancel(t);break;case"pointerdown":await this.handlePointerdown(t);break;case"pointerenter":this.handlePointerenter(t);break;case"pointerleave":this.handlePointerleave(t);break;case"pointerup":this.handlePointerup(t)}}onControlChange(t,e){if(!o.sk)for(const i of p)null==t||t.removeEventListener(i,this),null==e||e.addEventListener(i,this)}}(0,r.__decorate)([(0,s.Cb)({type:Boolean,reflect:!0})],m.prototype,"disabled",void 0),(0,r.__decorate)([(0,s.SB)()],m.prototype,"hovered",void 0),(0,r.__decorate)([(0,s.SB)()],m.prototype,"pressed",void 0),(0,r.__decorate)([(0,s.IO)(".surface")],m.prototype,"mdRoot",void 0);let v;const b=(0,o.iv)(v||(v=(t=>t)`:host{display:flex;margin:auto;pointer-events:none}:host([disabled]){display:none}{:host{display:none}}.surface,:host{border-radius:inherit;position:absolute;inset:0;overflow:hidden}.surface{-webkit-tap-highlight-color:transparent}.surface::after,.surface::before{content:"";opacity:0;position:absolute}.surface::before{background-color:var(--md-ripple-hover-color,var(--md-sys-color-on-surface,#1d1b20));inset:0;transition:opacity 15ms linear,background-color 15ms linear}.surface::after{background:radial-gradient(closest-side,var(--md-ripple-pressed-color,var(--md-sys-color-on-surface,#1d1b20)) max(100% - 70px,65%),transparent 100%);transform-origin:center center;transition:opacity 375ms linear}.hovered::before{background-color:var(--md-ripple-hover-color,var(--md-sys-color-on-surface,#1d1b20));opacity:var(--md-ripple-hover-opacity, .08)}.pressed::after{opacity:var(--md-ripple-pressed-opacity, .12);transition-duration:105ms}`));let f=class extends m{};f.styles=[b],f=(0,r.__decorate)([(0,s.Mo)("md-ripple")],f)}}]);
//# sourceMappingURL=42950.6627034067400b13.js.map