UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

2 lines 5.5 kB
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["24065"],{64331:function(e,i,t){t.r(i),t.d(i,{SideBarView:()=>u});var d=t(61701),a=t(72621),n=(t(71695),t(9359),t(31526),t(19423),t(40251),t(47021),t(57243)),l=t(50778),o=t(36522),s=(t(52293),t(27353));let r,c,h,v=e=>e;let u=(0,d.Z)(null,(function(e,i){class d extends i{constructor(...i){super(...i),e(this)}}return{F:d,d:[{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"lovelace",value:void 0},{kind:"field",decorators:[(0,l.Cb)({type:Number})],key:"index",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"isStrategy",value(){return!1}},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"cards",value(){return[]}},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"badges",value(){return[]}},{kind:"field",decorators:[(0,l.SB)()],key:"_config",value:void 0},{kind:"field",key:"_mqlListenerRef",value:void 0},{kind:"field",key:"_mql",value:void 0},{kind:"method",key:"connectedCallback",value:function(){(0,a.Z)(d,"connectedCallback",this,3)([]),this._mql=window.matchMedia("(min-width: 760px)"),this._mqlListenerRef=this._createCards.bind(this),this._mql.addListener(this._mqlListenerRef)}},{kind:"method",key:"disconnectedCallback",value:function(){var e;(0,a.Z)(d,"disconnectedCallback",this,3)([]),null===(e=this._mql)||void 0===e||e.removeListener(this._mqlListenerRef),this._mqlListenerRef=void 0,this._mql=void 0}},{kind:"method",key:"setConfig",value:function(e){this._config=e}},{kind:"method",key:"willUpdate",value:function(e){var i,n,l;if((0,a.Z)(d,"willUpdate",this,3)([e]),null!==(i=this.lovelace)&&void 0!==i&&i.editMode&&Promise.all([t.e("41103"),t.e("39341")]).then(t.bind(t,14370)),e.has("cards")&&this._createCards(),!e.has("lovelace")&&!e.has("_config"))return;const o=e.get("lovelace");(!e.has("cards")&&(null==o?void 0:o.config)!==(null===(n=this.lovelace)||void 0===n?void 0:n.config)||o&&(null==o?void 0:o.editMode)!==(null===(l=this.lovelace)||void 0===l?void 0:l.editMode))&&this._createCards()}},{kind:"method",key:"render",value:function(){var e,i;return(0,n.dy)(r||(r=v` <hui-view-badges .hass="${0}" .badges="${0}" .lovelace="${0}" .viewIndex="${0}" show-add-label></hui-view-badges> <div class="container ${0}"></div> ${0} `),this.hass,this.badges,this.lovelace,this.index,null!==(e=this.lovelace)&&void 0!==e&&e.editMode?"edit-mode":"",null!==(i=this.lovelace)&&void 0!==i&&i.editMode?(0,n.dy)(c||(c=v` <ha-fab .label="${0}" extended @click="${0}"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-fab> `),this.hass.localize("ui.panel.lovelace.editor.edit_card.add"),this._addCard,"M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"):"")}},{kind:"method",key:"_addCard",value:function(){(0,o.B)(this,"ll-create-card")}},{kind:"method",key:"_createCards",value:function(){var e;const i=document.createElement("div");let t;if(i.id="main",null!==(e=this._mql)&&void 0!==e&&e.matches?(t=document.createElement("div"),t.id="sidebar"):t=i,this.hasUpdated){const e=this.renderRoot.querySelector("#main"),d=this.renderRoot.querySelector("#sidebar"),a=this.renderRoot.querySelector(".container");e&&a.removeChild(e),d&&a.removeChild(d),a.appendChild(i),a.appendChild(t)}else this.updateComplete.then((()=>{const e=this.renderRoot.querySelector(".container");e.appendChild(i),e.appendChild(t)}));this.cards.forEach(((e,d)=>{var a,n,l;const o=null===(a=this._config)||void 0===a||null===(a=a.cards)||void 0===a?void 0:a[d];let r;if(this.isStrategy||null===(n=this.lovelace)||void 0===n||!n.editMode)e.preview=!1,r=e;else{var c;r=document.createElement("hui-card-options"),r.hass=this.hass,r.lovelace=this.lovelace,r.path=[this.index,d],e.preview=!0;const i=document.createElement("ha-icon-button");i.slot="buttons";const t=document.createElement("ha-svg-icon");t.path="sidebar"!==(null==o||null===(c=o.view_layout)||void 0===c?void 0:c.position)?"M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z":"M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z",i.appendChild(t),i.addEventListener("click",(()=>{var e;this.lovelace.saveConfig((0,s.LG)(this.lovelace.config,[this.index,d],Object.assign(Object.assign({},o),{},{view_layout:{position:"sidebar"!==(null==o||null===(e=o.view_layout)||void 0===e?void 0:e.position)?"sidebar":"main"}})))})),r.appendChild(i),r.appendChild(e)}"sidebar"!==(null==o||null===(l=o.view_layout)||void 0===l?void 0:l.position)?i.appendChild(r):t.appendChild(r)}))}},{kind:"field",static:!0,key:"styles",value(){return(0,n.iv)(h||(h=v`:host{display:block;padding-top:4px}hui-view-badges{display:block;margin:4px 8px 4px 8px;font-size:85%}.container{display:flex;justify-content:center;margin-left:4px;margin-right:4px}.container.edit-mode{margin-bottom:72px}#main{max-width:1620px;flex-grow:2}#sidebar{flex-grow:1;flex-shrink:0;max-width:380px}.container>div{min-width:0;box-sizing:border-box}.container>div>:not([hidden]){display:block;margin:var(--masonry-view-card-margin,4px 4px 8px)}@media (max-width:500px){.container>div>*{margin-left:0;margin-right:0}}ha-fab{position:fixed;right:calc(16px + env(safe-area-inset-right));bottom:calc(16px + env(safe-area-inset-bottom));inset-inline-end:calc(16px + env(safe-area-inset-right));inset-inline-start:initial;z-index:1}`))}}]}}),n.oi);customElements.define("hui-sidebar-view",u)}}]); //# sourceMappingURL=24065.c9817cbc345a335e.js.map