UNPKG

iobroker.lovelace

Version:

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

1 lines 3.13 kB
export const __rspack_esm_id=74981;export const __rspack_esm_ids=[74981];export const __webpack_modules__={98852(e,t,i){i.a(e,async function(e,n){try{i.r(t),i.d(t,{HuiConditionalElementEditor:()=>u});var o=i(62826),s=i(5124),a=i(22441),c=i(63533),h=i(1087),l=i(52763),d=i(13898),g=i(37258),r=i(81287),m=e([l,d,g,r]);[l,d,g,r]=m.then?(await m)():m;const _=(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)())}),f=[{name:"title",selector:{text:{}}}];class u extends s.WF{setConfig(e){(0,c.vA)(e,_),this._config=e}render(){return this.hass&&this._config?this._subElementEditorConfig?s.qy` <hui-sub-element-editor .hass="${this.hass}" .config="${this._subElementEditorConfig}" @go-back="${this._goBack}" @config-changed="${this._handleSubElementChanged}"> </hui-sub-element-editor> `:s.qy` <ha-form .hass="${this.hass}" .data="${this._config}" .schema="${f}" .computeLabel="${this._computeLabelCallback}" @value-changed="${this._formChanged}"></ha-form> <ha-card-conditions-editor .hass="${this.hass}" .conditions="${this._config.conditions||[]}" @value-changed="${this._conditionChanged}"> </ha-card-conditions-editor> <hui-picture-elements-card-row-editor .hass="${this.hass}" .elements="${this._config.elements||[]}" @elements-changed="${this._elementsChanged}" @edit-detail-element="${this._editDetailElement}"></hui-picture-elements-card-row-editor> `:s.s6}_formChanged(e){(0,h.r)(this,"config-changed",{config:e.detail.value})}_conditionChanged(e){if(e.stopPropagation(),!this._config)return;const t=e.detail.value;this._config={...this._config,conditions:t},(0,h.r)(this,"config-changed",{config:this._config})}_elementsChanged(e){e.stopPropagation();const t=this._config?.elements?.length||0,i={...this._config,elements:e.detail.elements};(0,h.r)(this,"config-changed",{config:i});const n=e.detail.elements?.length||0;if(n===t+1){const t=n-1;this._subElementEditorConfig={index:t,type:"element",elementConfig:{...e.detail.elements[t]}}}}_handleSubElementChanged(e){if(e.stopPropagation(),!this._config||!this.hass)return;const t=this._subElementEditorConfig?.type,i=e.detail.config;if("element"===t){const e=this._config.elements.concat();i?e[this._subElementEditorConfig.index]=i:(e.splice(this._subElementEditorConfig.index,1),this._goBack()),this._config={...this._config,elements:e}}this._subElementEditorConfig={...this._subElementEditorConfig,elementConfig:i},(0,h.r)(this,"config-changed",{config:this._config})}_editDetailElement(e){this._subElementEditorConfig=e.detail.subElementConfig}_goBack(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,o.Cg)([(0,a.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,o.Cg)([(0,a.wk)()],u.prototype,"_config",void 0),(0,o.Cg)([(0,a.wk)()],u.prototype,"_subElementEditorConfig",void 0),u=(0,o.Cg)([(0,a.EM)("hui-conditional-element-editor")],u),n()}catch(e){n(e)}})}};