iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 7.79 kB
JavaScript
/*! For license information please see 46095.4da2aa191037adbc.js.LICENSE.txt */
export const __rspack_esm_id=46095;export const __rspack_esm_ids=[46095];export const __webpack_modules__={76482(t,e,i){i.d(e,{i:()=>n});var r=i(5124);const s=Symbol("attachableController");let o;r.S$||(o=new MutationObserver(t=>{for(const e of t)e.target[s]?.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()}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}constructor(t,e){this.host=t,this.onControlChange=e,this.currentControl=null,t.addController(this),t[s]=this,o?.observe(t,{attributeFilter:["for"]})}}},76610(t,e,i){i.d(e,{Ux:()=>r,du:()=>s});i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);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:()=>(t?.abort(),t=new AbortController,t.signal),finish(){t=null}}}},96245(t,e,i){i.d(e,{R:()=>r});const r=i(5124).AH`: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}`},91382(t,e,i){i.d(e,{n:()=>p});var r=i(62826),s=i(5124),o=i(22441),n=i(6412),a=i(76482),h=i(76610);var l;!function(t){t[t.INACTIVE=0]="INACTIVE",t[t.TOUCH_DELAY=1]="TOUCH_DELAY",t[t.HOLDING=2]="HOLDING",t[t.WAITING_FOR_CLICK=3]="WAITING_FOR_CLICK"}(l||(l={}));const c=["click","contextmenu","pointercancel","pointerdown","pointerenter","pointerleave","pointerup"],d=s.S$?null:window.matchMedia("(forced-colors: active)");class p extends s.WF{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 s.qy`<div class="surface ${(0,n.H)(t)}"></div>`}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!==l.INACTIVE&&this.endPressAnimation())}handlePointerup(t){if(this.shouldReactToEvent(t)){if(this.state!==l.HOLDING)return this.state===l.TOUCH_DELAY?(this.state=l.WAITING_FOR_CLICK,void this.startPressAnimation(this.rippleStartEvent)):void 0;this.state=l.WAITING_FOR_CLICK}}async handlePointerdown(t){if(this.shouldReactToEvent(t)){if(this.rippleStartEvent=t,!this.isTouch(t))return this.state=l.WAITING_FOR_CLICK,void this.startPressAnimation(t);this.state=l.TOUCH_DELAY,await new Promise(t=>{setTimeout(t,150)}),this.state===l.TOUCH_DELAY&&(this.state=l.HOLDING,this.startPressAnimation(t))}}handleClick(){this.disabled||(this.state!==l.WAITING_FOR_CLICK?this.state===l.INACTIVE&&(this.startPressAnimation(),this.endPressAnimation()):this.endPressAnimation())}handlePointercancel(t){this.shouldReactToEvent(t)&&this.endPressAnimation()}handleContextmenu(){this.disabled||this.endPressAnimation()}determineRippleSize(){const{height:t,width:e}=this.getBoundingClientRect(),i=Math.max(t,e),r=Math.max(.35*i,75),s=this.currentCSSZoom??1,o=Math.floor(.2*i/s),n=Math.sqrt(e**2+t**2)+10;this.initialSize=o;const a=(n+r)/o;this.rippleScale=""+a/s,this.rippleSize=`${o}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,l=this.currentCSSZoom??1;return{x:(a-o)/l,y:(h-n)/l}}getTranslationCoordinates(t){const{height:e,width:i}=this.getBoundingClientRect(),r=this.currentCSSZoom??1,s={x:(i/r-this.initialSize)/2,y:(e/r-this.initialSize)/2};let o;return o=t instanceof PointerEvent?this.getNormalizedPointerEventCoords(t):{x:i/r/2,y:e/r/2},o={x:o.x-this.initialSize/2,y:o.y-this.initialSize/2},{startPoint:o,endPoint:s}}startPressAnimation(t){if(!this.mdRoot)return;this.pressed=!0,this.growAnimation?.cancel(),this.determineRippleSize();const{startPoint:e,endPoint:i}=this.getTranslationCoordinates(t),r=`${e.x}px, ${e.y}px`,s=`${i.x}px, ${i.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(${r}) scale(1)`,`translate(${s}) scale(${this.rippleScale})`]},{pseudoElement:"::after",duration:450,easing:h.Ux.STANDARD,fill:"forwards"})}async endPressAnimation(){this.rippleStartEvent=void 0,this.state=l.INACTIVE;const t=this.growAnimation;let e=1/0;"number"==typeof t?.currentTime?e=t.currentTime: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}isTouch({pointerType:t}){return"touch"===t}async handleEvent(t){if(!d?.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(!s.S$)for(const i of c)t?.removeEventListener(i,this),e?.addEventListener(i,this)}constructor(){super(...arguments),this.disabled=!1,this.hovered=!1,this.pressed=!1,this.rippleSize="",this.rippleScale="",this.initialSize=0,this.state=l.INACTIVE,this.attachableController=new a.i(this,this.onControlChange.bind(this))}}(0,r.Cg)([(0,o.MZ)({type:Boolean,reflect:!0})],p.prototype,"disabled",void 0),(0,r.Cg)([(0,o.wk)()],p.prototype,"hovered",void 0),(0,r.Cg)([(0,o.wk)()],p.prototype,"pressed",void 0),(0,r.Cg)([(0,o.P)(".surface")],p.prototype,"mdRoot",void 0)}};