iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 4.81 kB
JavaScript
export const __webpack_ids__=["24065"];export const __webpack_modules__={64331:function(e,i,t){t.r(i),t.d(i,{SideBarView:()=>r});var a=t(44249),d=t(72621),n=(t(9359),t(31526),t(57243)),o=t(15093),s=t(36522),l=(t(52293),t(27353));let r=(0,a.Z)(null,(function(e,i){class a extends i{constructor(...i){super(...i),e(this)}}return{F:a,d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"lovelace",value:void 0},{kind:"field",decorators:[(0,o.Cb)({type:Number})],key:"index",value:void 0},{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"isStrategy",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"cards",value:()=>[]},{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"badges",value:()=>[]},{kind:"field",decorators:[(0,o.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,d.Z)(a,"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(){(0,d.Z)(a,"disconnectedCallback",this,3)([]),this._mql?.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){if((0,d.Z)(a,"willUpdate",this,3)([e]),this.lovelace?.editMode&&Promise.all([t.e("41103"),t.e("39341")]).then(t.bind(t,70419)),e.has("cards")&&this._createCards(),!e.has("lovelace")&&!e.has("_config"))return;const i=e.get("lovelace");(!e.has("cards")&&i?.config!==this.lovelace?.config||i&&i?.editMode!==this.lovelace?.editMode)&&this._createCards()}},{kind:"method",key:"render",value:function(){return n.dy` <hui-view-badges .hass="${this.hass}" .badges="${this.badges}" .lovelace="${this.lovelace}" .viewIndex="${this.index}" show-add-label></hui-view-badges> <div class="container ${this.lovelace?.editMode?"edit-mode":""}"></div> ${this.lovelace?.editMode?n.dy` <ha-fab .label="${this.hass.localize("ui.panel.lovelace.editor.edit_card.add")}" extended ="${this._addCard}"> <ha-svg-icon slot="icon" .path="${"M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"}"></ha-svg-icon> </ha-fab> `:""} `}},{kind:"method",key:"_addCard",value:function(){(0,s.B)(this,"ll-create-card")}},{kind:"method",key:"_createCards",value:function(){const e=document.createElement("div");let i;if(e.id="main",this._mql?.matches?(i=document.createElement("div"),i.id="sidebar"):i=e,this.hasUpdated){const t=this.renderRoot.querySelector("#main"),a=this.renderRoot.querySelector("#sidebar"),d=this.renderRoot.querySelector(".container");t&&d.removeChild(t),a&&d.removeChild(a),d.appendChild(e),d.appendChild(i)}else this.updateComplete.then((()=>{const t=this.renderRoot.querySelector(".container");t.appendChild(e),t.appendChild(i)}));this.cards.forEach(((t,a)=>{const d=this._config?.cards?.[a];let n;if(this.isStrategy||!this.lovelace?.editMode)t.preview=!1,n=t;else{n=document.createElement("hui-card-options"),n.hass=this.hass,n.lovelace=this.lovelace,n.path=[this.index,a],t.preview=!0;const e=document.createElement("ha-icon-button");e.slot="buttons";const i=document.createElement("ha-svg-icon");i.path="sidebar"!==d?.view_layout?.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",e.appendChild(i),e.addEventListener("click",(()=>{this.lovelace.saveConfig((0,l.LG)(this.lovelace.config,[this.index,a],{...d,view_layout:{position:"sidebar"!==d?.view_layout?.position?"sidebar":"main"}}))})),n.appendChild(e),n.appendChild(t)}"sidebar"!==d?.view_layout?.position?e.appendChild(n):i.appendChild(n)}))}},{kind:"field",static:!0,key:"styles",value:()=>n.iv`: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)} (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",r)}};
//# sourceMappingURL=24065.323ebcc8d5a430b6.js.map