iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.54 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[74981],{98852:function(e,t,i){i.a(e,async function(e,n){try{i.r(t),i.d(t,{HuiConditionalElementEditor:function(){return E}});i(62953);var s=i(40445),o=i(5124),a=i(67576),c=i(63533),l=i(1087),h=i(52763),d=i(13898),g=i(37258),r=i(81287),f=e([h,d,g,r]);[h,d,g,r]=f.then?(await f)():f;let m,u,_=e=>e;const b=(0,c.Ik)({type:(0,c.eu)("conditional"),conditions:(0,c.lq)((0,c.YO)((0,c.bz)())),elements:(0,c.lq)((0,c.YO)((0,c.bz)())),title:(0,c.lq)((0,c.Yj)())}),C=[{name:"title",selector:{text:{}}}];class E extends o.WF{setConfig(e){(0,c.vA)(e,b),this._config=e}render(){return this.hass&&this._config?this._subElementEditorConfig?(0,o.qy)(m||(m=_` <hui-sub-element-editor .hass="${0}" .config="${0}" -back="${0}" -changed="${0}"> </hui-sub-element-editor> `),this.hass,this._subElementEditorConfig,this._goBack,this._handleSubElementChanged):(0,o.qy)(u||(u=_` <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeLabel="${0}" -changed="${0}"></ha-form> <ha-card-conditions-editor .hass="${0}" .conditions="${0}" -changed="${0}"> </ha-card-conditions-editor> <hui-picture-elements-card-row-editor .hass="${0}" .elements="${0}" -changed="${0}" -detail-element="${0}"></hui-picture-elements-card-row-editor> `),this.hass,this._config,C,this._computeLabelCallback,this._formChanged,this.hass,this._config.conditions||[],this._conditionChanged,this.hass,this._config.elements||[],this._elementsChanged,this._editDetailElement):o.s6}_formChanged(e){(0,l.r)(this,"config-changed",{config:e.detail.value})}_conditionChanged(e){if(e.stopPropagation(),!this._config)return;const t=e.detail.value;this._config=Object.assign(Object.assign({},this._config),{},{conditions:t}),(0,l.r)(this,"config-changed",{config:this._config})}_elementsChanged(e){var t,i;e.stopPropagation();const n=(null===(t=this._config)||void 0===t||null===(t=t.elements)||void 0===t?void 0:t.length)||0,s=Object.assign(Object.assign({},this._config),{},{elements:e.detail.elements});(0,l.r)(this,"config-changed",{config:s});const o=(null===(i=e.detail.elements)||void 0===i?void 0:i.length)||0;if(o===n+1){const t=o-1;this._subElementEditorConfig={index:t,type:"element",elementConfig:Object.assign({},e.detail.elements[t])}}}_handleSubElementChanged(e){var t;if(e.stopPropagation(),!this._config||!this.hass)return;const i=null===(t=this._subElementEditorConfig)||void 0===t?void 0:t.type,n=e.detail.config;if("element"===i){const e=this._config.elements.concat();n?e[this._subElementEditorConfig.index]=n:(e.splice(this._subElementEditorConfig.index,1),this._goBack()),this._config=Object.assign(Object.assign({},this._config),{},{elements:e})}this._subElementEditorConfig=Object.assign(Object.assign({},this._subElementEditorConfig),{},{elementConfig:n}),(0,l.r)(this,"config-changed",{config:this._config})}_editDetailElement(e){this._subElementEditorConfig=e.detail.subElementConfig}_goBack(e){null==e||e.stopPropagation(),this._subElementEditorConfig=void 0}constructor(...e){super(...e),this._computeLabelCallback=e=>this.hass.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`)||this.hass.localize(`ui.panel.lovelace.editor.elements.${e.name}`)||e.name}}(0,s.Cg)([(0,a.MZ)({attribute:!1})],E.prototype,"hass",void 0),(0,s.Cg)([(0,a.wk)()],E.prototype,"_config",void 0),(0,s.Cg)([(0,a.wk)()],E.prototype,"_subElementEditorConfig",void 0),E=(0,s.Cg)([(0,a.EM)("hui-conditional-element-editor")],E),n()}catch(m){n(m)}})}}]);