UNPKG

iobroker.lovelace

Version:

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

2 lines 3.86 kB
export const __webpack_ids__=["7844"];export const __webpack_modules__={13245:function(e,t,n){n.d(t,{$y:()=>i,fs:()=>o,j:()=>r});const s=(e,t,n)=>new Promise(((s,r)=>{const o=document.createElement(e);let i="src",l="body";switch(o.onload=()=>s(t),o.onerror=()=>r(t),e){case"script":o.async=!0,n&&(o.type=n);break;case"link":o.type="text/css",o.rel="stylesheet",i="href",l="head"}o[i]=t,document[l].appendChild(o)})),r=e=>s("link",e),o=e=>s("script",e),i=e=>s("script",e,"module")},22304:function(e,t,n){n.r(t),n.d(t,{HaPanelCustom:()=>m});var s=n(44249),r=n(72621),o=n(57243),i=n(15093),l=n(83523),a=n(48045);var c=n(13245);const u={},d=e=>e.html_url?{type:"html",url:e.html_url}:e.module_url&&e.js_url||e.module_url?{type:"module",url:e.module_url}:{type:"js",url:e.js_url};n(9359),n(31526);const h=(e,t)=>{"setProperties"in e?e.setProperties(t):Object.keys(t).forEach((n=>{e[n]=t[n]}))};let m=(0,s.Z)(null,(function(e,t){class n extends t{constructor(...t){super(...t),e(this)}}return{F:n,d:[{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,i.Cb)({type:Boolean})],key:"narrow",value:()=>!1},{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"route",value:void 0},{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"panel",value:void 0},{kind:"field",key:"_setProperties",value:void 0},{kind:"method",key:"createRenderRoot",value:function(){return this}},{kind:"field",key:"navigate",value:()=>(e,t)=>(0,l.c)(e,t)},{kind:"method",key:"registerIframe",value:function(e,t){e(this.panel,{hass:this.hass,narrow:this.narrow,route:this.route}),this._setProperties=t}},{kind:"method",key:"disconnectedCallback",value:function(){(0,r.Z)(n,"disconnectedCallback",this,3)([]),this._cleanupPanel()}},{kind:"method",key:"update",value:function(e){if((0,r.Z)(n,"update",this,3)([e]),e.has("panel")){const t=e.get("panel");if(!(0,a.v)(t,this.panel))return t&&this._cleanupPanel(),void this._createPanel(this.panel)}if(!this._setProperties)return;const t={};for(const n of e.keys())t[n]=this[n];this._setProperties(t)}},{kind:"method",key:"_cleanupPanel",value:function(){for(delete window.customPanel,this._setProperties=void 0;this.lastChild;)this.removeChild(this.lastChild)}},{kind:"method",key:"_createPanel",value:function(e){const t=e.config._panel_custom,n=d(t),s=document.createElement("a");if(s.href=n.url,!t.trust_external&&!["localhost","127.0.0.1",location.hostname].includes(s.hostname)&&!confirm(`${this.hass.localize("ui.panel.custom.external_panel.question_trust",{name:t.name,link:s.href})}\n\n ${this.hass.localize("ui.panel.custom.external_panel.complete_access")}\n\n (${this.hass.localize("ui.panel.custom.external_panel.hide_message")})`))return;if(!t.embed_iframe)return void(e=>{const t=d(e);return"js"===t.type?(t.url in u||(u[t.url]=(0,c.fs)(t.url)),u[t.url]):"module"===t.type?(0,c.$y)(t.url):Promise.reject("No valid url found in panel config.")})(t).then((()=>{const n=(e=>{const t="html_url"in e?`ha-panel-${e.name}`:e.name;return document.createElement(t)})(t);this._setProperties=e=>h(n,e),h(n,{panel:e,hass:this.hass,narrow:this.narrow,route:this.route}),this.appendChild(n)}),(()=>{alert(`Unable to load custom panel from ${s.href}`)}));window.customPanel=this;const r=this.panel.title?`title="${this.panel.title}"`:"";this.innerHTML=`\n <style>\n iframe {\n border: 0;\n width: 100%;\n height: 100%;\n display: block;\n background-color: var(--primary-background-color);\n }\n </style>\n <iframe ${r}></iframe>`.trim();const o=this.querySelector("iframe").contentWindow.document;o.open(),o.write(`<!doctype html><script src='${window.customPanelJS}'><\/script>`),o.close()}}]}}),o.fl);customElements.define("ha-panel-custom",m)}}; //# sourceMappingURL=7844.8cbf8e60dae38738.js.map