iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
3 lines • 11.5 kB
JavaScript
/*! For license information please see 59985.a1d45e75530b2f6f.js.LICENSE.txt */
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["59985"],{16815:function(e,t,i){i.a(e,(async function(e,t){try{var n=i(61701),o=(i(71695),i(40251),i(47021),i(50778)),s=i(28421),r=i(6973),a=e([r]);r=(a.then?(await a)():a)[0];(0,n.Z)([(0,o.Mo)("hui-dashboard-strategy-element-editor")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"method",key:"getConfigElement",value:async function(){const e=await(0,s.lN)("dashboard",this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}}]}}),r.k);t()}catch(d){t(d)}}))},32012:function(e,t,i){i.d(t,{e:()=>n});i(52247);class n extends Error{constructor(e,t,i){super(e),this.warnings=void 0,this.errors=void 0,this.name="GUISupportError",this.warnings=t,this.errors=i}}},43299:function(e,t,i){i.a(e,(async function(e,n){try{i.d(t,{O:()=>B});var o=i(61701),s=i(72621),r=(i(71695),i(9359),i(31526),i(70104),i(19423),i(40251),i(47021),i(57243)),a=i(50778),d=i(67064),l=i(36522),h=i(22381),u=i(41680),c=i(48045),g=(i(99426),i(17170)),f=(i(64889),i(32012)),m=e([g]);g=(m.then?(await m)():m)[0];let _,v,y,p,k,E,C,b,w,$,S,Y,x=e=>e,B=(0,o.Z)(null,(function(e,t){class n extends t{constructor(...t){super(...t),e(this)}}return{F:n,d:[{kind:"field",decorators:[(0,a.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,a.Cb)({attribute:!1})],key:"lovelace",value:void 0},{kind:"field",decorators:[(0,a.Cb)({attribute:!1})],key:"context",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_config",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_configElement",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_subElementEditorConfig",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_guiMode",value(){return!0}},{kind:"field",decorators:[(0,a.SB)()],key:"_errors",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_pendingYamlError",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_yamlError",value(){return!1}},{kind:"field",decorators:[(0,a.SB)()],key:"_warnings",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_guiSupported",value:void 0},{kind:"field",decorators:[(0,a.SB)()],key:"_loading",value(){return!1}},{kind:"field",decorators:[(0,a.IO)("ha-yaml-editor")],key:"_yamlEditor",value:void 0},{kind:"get",key:"value",value:function(){return this._config}},{kind:"set",key:"value",value:function(e){this._config&&(0,c.v)(e,this._config)||(this._config=e,this._errors=void 0,this._setConfig())}},{kind:"method",key:"_setConfig",value:function(){if(!this._errors)try{this._updateConfigElement()}catch(e){this._errors=[e.message]}this.updateComplete.then((()=>{var e;(0,l.B)(this,"config-changed",{config:this.value,error:null===(e=this._errors)||void 0===e?void 0:e.join(", "),guiModeAvailable:!(this.hasWarning||this.hasError||!1===this._guiSupported)})}))}},{kind:"get",key:"hasWarning",value:function(){return void 0!==this._warnings&&this._warnings.length>0}},{kind:"get",key:"hasError",value:function(){return void 0!==this._errors&&this._errors.length>0}},{kind:"get",key:"GUImode",value:function(){return this._guiMode}},{kind:"set",key:"GUImode",value:function(e){this._guiMode=e,this.updateComplete.then((()=>{(0,l.B)(this,"GUImode-changed",{guiMode:e,guiModeAvailable:!(this.hasWarning||this.hasError||!1===this._guiSupported)})}))}},{kind:"method",key:"toggleMode",value:function(){this.GUImode=!this.GUImode}},{kind:"method",key:"focusYamlEditor",value:function(){var e;null!==(e=this._configElement)&&void 0!==e&&e.focusYamlEditor&&this._configElement.focusYamlEditor(),this._yamlEditor&&this._yamlEditor.focus()}},{kind:"method",key:"getConfigElement",value:async function(){}},{kind:"method",key:"getConfigForm",value:async function(){}},{kind:"method",key:"renderConfigElement",value:function(){return(0,r.dy)(_||(_=x`${0}`),this._configElement)}},{kind:"method",key:"_renderSubElement",value:function(){return(0,r.dy)(v||(v=x` <hui-sub-element-editor .hass="${0}" .config="${0}" -back="${0}" -changed="${0}"> </hui-sub-element-editor> `),this.hass,this._subElementEditorConfig,this._goBack,this._subElementChanged)}},{kind:"method",key:"_subElementChanged",value:function(e){var t,i;e.stopPropagation();const n=e.detail.config;this._subElementEditorConfig=Object.assign(Object.assign({},this._subElementEditorConfig),{},{elementConfig:n}),null===(t=(i=this._subElementEditorConfig).saveElementConfig)||void 0===t||t.call(i,n)}},{kind:"method",key:"_goBack",value:function(e){e.stopPropagation(),this._subElementEditorConfig=void 0}},{kind:"method",key:"_editSubElement",value:async function(e){e.stopPropagation(),await Promise.all([i.e("91552"),i.e("78456"),i.e("56898"),i.e("35671"),i.e("92139"),i.e("32146"),i.e("47399"),i.e("51717"),i.e("18865"),i.e("44959"),i.e("79931"),i.e("44251"),i.e("65005"),i.e("60487"),i.e("3371"),i.e("38326"),i.e("10745"),i.e("80809"),i.e("92368"),i.e("37457"),i.e("95444"),i.e("29477"),i.e("8136")]).then(i.bind(i,50357)),this._subElementEditorConfig={type:e.detail.type,elementConfig:e.detail.config,context:e.detail.context,saveElementConfig:e.detail.saveConfig}}},{kind:"method",key:"render",value:function(){return(0,r.dy)(y||(y=x` <div class="wrapper"> ${0} ${0} ${0} ${0} </div> `),this.GUImode?(0,r.dy)(p||(p=x` <div class="gui-editor" -sub-element="${0}"> ${0} </div> `),this._editSubElement,this._loading?(0,r.dy)(k||(k=x` <ha-spinner class="center margin-bot"></ha-spinner> `)):(0,d.F)(this._subElementEditorConfig?this._renderSubElement():this.renderConfigElement())):(0,r.dy)(E||(E=x` <div class="yaml-editor"> <ha-yaml-editor .defaultValue="${0}" autofocus .hass="${0}" -changed="${0}" ="${0}" ="${0}" dir="ltr"></ha-yaml-editor> </div> `),this._config,this.hass,this._handleYAMLChanged,this._onBlurYaml,this._ignoreKeydown),!1===this._guiSupported&&!1===this._loading?(0,r.dy)(C||(C=x` <ha-alert alert-type="info" .title="${0}"> ${0} <br> ${0} </ha-alert> `),this.hass.localize("ui.errors.config.visual_editor_not_supported"),this.hass.localize("ui.errors.config.visual_editor_not_supported_reason_type"),this.hass.localize("ui.errors.config.edit_in_yaml_supported")):r.Ld,this.hasError?(0,r.dy)(b||(b=x` <ha-alert alert-type="error" .title="${0}"> <ul> ${0} </ul> </ha-alert> `),this.hass.localize("ui.errors.config.configuration_error"),this._errors.map((e=>(0,r.dy)(w||(w=x`<li>${0}</li>`),e)))):r.Ld,this.hasWarning?(0,r.dy)($||($=x` <ha-alert alert-type="warning" .title="${0}"> <ul> ${0} </ul> ${0} </ha-alert> `),this.hass.localize("ui.errors.config.visual_editor_not_supported"),this._warnings.map((e=>(0,r.dy)(S||(S=x`<li>${0}</li>`),e))),this.hass.localize("ui.errors.config.edit_in_yaml_supported")):r.Ld)}},{kind:"method",key:"updated",value:function(e){(0,s.Z)(n,"updated",this,3)([e]),this._configElement&&e.has("hass")&&(this._configElement.hass=this.hass),this._configElement&&"lovelace"in this._configElement&&e.has("lovelace")&&(this._configElement.lovelace=this.lovelace),this._configElement&&e.has("context")&&(this._configElement.context=this.context)}},{kind:"method",key:"_handleUIConfigChanged",value:function(e){if(e.stopPropagation(),!this.GUImode)return;const t=e.detail.config;Object.keys(t).forEach((e=>{void 0===t[e]&&delete t[e]})),this.value=t}},{kind:"method",key:"_handleYAMLChanged",value:function(e){e.stopPropagation();const t=e.detail.value;e.detail.isValid?(this._config=t,this._errors=void 0,this._pendingYamlError=void 0,this._yamlError=!1,this._debounceYamlError.cancel(),this._setConfig()):this._yamlError?this._errors=[e.detail.errorMsg]:(this._pendingYamlError=e.detail.errorMsg,this._debounceYamlError())}},{kind:"field",key:"_debounceYamlError",value(){return(0,h.D)((()=>{this._pendingYamlError&&(this._yamlError=!0,this._errors=[this._pendingYamlError],this._pendingYamlError=void 0,this._setConfig())}),2e3)}},{kind:"method",key:"_onBlurYaml",value:function(){this._debounceYamlError.cancel(),this._pendingYamlError&&(this._yamlError=!0,this._errors=[this._pendingYamlError],this._pendingYamlError=void 0,this._setConfig())}},{kind:"method",key:"unloadConfigElement",value:async function(){this._configElement=void 0,this._guiSupported=void 0}},{kind:"method",key:"loadConfigElement",value:async function(){if(this._configElement)return;let e=await this.getConfigElement();if(!e){const t=await this.getConfigForm();if(t){await i.e("10106").then(i.bind(i,66374)),e=document.createElement("hui-form-editor");const{schema:n,assertConfig:o,computeLabel:s,computeHelper:r}=t;e.schema=n,s&&(e.computeLabel=s),r&&(e.computeHelper=r),o&&(e.assertConfig=o)}}e?(e.hass=this.hass,"lovelace"in e&&(e.lovelace=this.lovelace),e.context=this.context,e.addEventListener("config-changed",(e=>this._handleUIConfigChanged(e))),this._guiSupported=!0):this._guiSupported=!1,this._configElement=e}},{kind:"method",key:"_updateConfigElement",value:async function(){if(this.value)try{if(this._errors=void 0,this._warnings=void 0,await this.loadConfigElement(),this._configElement)try{this._configElement.setConfig(this.value)}catch(t){const e=(0,u.p)(this.hass,t);throw new f.e("Config is not supported",e.warnings,e.errors)}else this._guiSupported=!1,this.GUImode=!1}catch(t){var e;if(t instanceof f.e)this._warnings=null!==(e=t.warnings)&&void 0!==e?e:[t.message],this._errors=t.errors||void 0;else this._errors=[t.message];this.GUImode=!1}finally{this._loading=!1}}},{kind:"method",key:"_ignoreKeydown",value:function(e){e.stopPropagation()}},{kind:"field",static:!0,key:"styles",value(){return(0,r.iv)(Y||(Y=x`:host{display:flex}.wrapper{width:100%}.gui-editor,.yaml-editor{padding:8px 0px}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}ha-spinner{display:block;margin:auto}`))}}]}}),r.oi);n()}catch(_){n(_)}}))},6973:function(e,t,i){i.a(e,(async function(e,n){try{i.d(t,{k:()=>l});var o=i(61701),s=i(72621),r=(i(52247),i(71695),i(40251),i(47021),i(50778)),a=i(43299),d=e([a]);a=(d.then?(await d)():d)[0];let l=(0,o.Z)(null,(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,r.SB)()],key:"_configElementType",value:void 0},{kind:"get",key:"configElementType",value:function(){return this.value?this.value.type:void 0}},{kind:"method",key:"loadConfigElement",value:async function(){if(this._configElementType!==this.configElementType){if(this.unloadConfigElement(),!this.configElementType)throw new Error(this.hass.localize("ui.errors.config.no_type_provided"));this._configElementType=this.configElementType}return(0,s.Z)(i,"loadConfigElement",this,3)([])}}]}}),a.O);n()}catch(l){n(l)}}))},67064:function(e,t,i){i.d(t,{F:()=>a});i(71695),i(46692),i(47021);var n=i(2841),o=i(45779),s=i(53232);const r=e=>(0,s.dZ)(e)?e._$litType$.h:e.strings,a=(0,o.XM)(class extends o.Xe{constructor(e){super(e),this.tt=new WeakMap}render(e){return[e]}update(e,[t]){const i=(0,s.hN)(this.et)?r(this.et):null,o=(0,s.hN)(t)?r(t):null;if(null!==i&&(null===o||i!==o)){const t=(0,s.i9)(e).pop();let o=this.tt.get(i);if(void 0===o){const e=document.createDocumentFragment();o=(0,n.sY)(n.Ld,e),o.setConnected(!1),this.tt.set(i,o)}(0,s.hl)(o,[t]),(0,s._Y)(o,void 0,t)}if(null!==o){if(null===i||i!==o){const t=this.tt.get(o);if(void 0!==t){const i=(0,s.i9)(t).pop();(0,s.E_)(e),(0,s._Y)(e,void 0,i),(0,s.hl)(e,[i])}}this.et=t}else this.et=void 0;return this.render(t)}})}}]);
//# sourceMappingURL=59985.a1d45e75530b2f6f.js.map