UNPKG

iobroker.lovelace

Version:

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

1 lines 6.16 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[51277],{16988:function(e,t,i){i.a(e,async function(e,n){try{i.r(t),i.d(t,{HuiPictureElementsCardEditor:function(){return $}});i(62953);var s=i(40445),a=i(22786),o=i(5124),l=i(67576),c=i(63533),r=i(1087),d=i(38962),m=(i(76776),i(52763)),h=(i(47680),i(59646)),g=i(55810),_=i(81287),u=i(84698),f=i(7382),p=i(37258),b=e([d,m,h,_,p]);[d,m,h,_,p]=b.then?(await b)():b;let C,v,E,k=e=>e;const y=(0,c.NW)({type:(0,c.Yj)()}),j=(0,c.kp)(u.H,(0,c.Ik)({image:(0,c.lq)((0,c.KC)([(0,c.Yj)(),(0,c.Ik)()])),camera_image:(0,c.lq)((0,c.Yj)()),camera_view:(0,c.lq)((0,c.Yj)()),elements:(0,c.YO)(y),title:(0,c.lq)((0,c.Yj)()),state_filter:(0,c.lq)((0,c.bz)()),theme:(0,c.lq)((0,c.Yj)()),dark_mode_image:(0,c.lq)((0,c.KC)([(0,c.Yj)(),(0,c.Ik)()])),dark_mode_filter:(0,c.lq)((0,c.bz)())}));class $ extends o.WF{setConfig(e){(0,c.vA)(e,j),this._config=e}_handlePositionClick(e,t){var i,n;if(null===(i=this._subElementEditorConfig)||void 0===i||!i.elementConfig||"element"!==this._subElementEditorConfig.type||"conditional"===this._subElementEditorConfig.elementConfig.type)return;const s=this._subElementEditorConfig.elementConfig,a=null===(n=s.style)||void 0===n?void 0:n.position;if(a&&"absolute"!==a)return;const o=Object.assign(Object.assign({},s),{},{style:Object.assign(Object.assign({},s.style||{}),{},{left:`${Math.round(e)}%`,top:`${Math.round(t)}%`})}),l=new CustomEvent("config-changed",{detail:{config:o}});this._handleSubElementChanged(l)}render(){return this.hass&&this._config?this._subElementEditorConfig?(0,o.qy)(C||(C=k` ${0} <hui-sub-element-editor .hass="${0}" .config="${0}" @go-back="${0}" @config-changed="${0}"> </hui-sub-element-editor> `),"element"===this._subElementEditorConfig.type&&"conditional"!==(null===(e=this._subElementEditorConfig.elementConfig)||void 0===e?void 0:e.type)?(0,o.qy)(v||(v=k` <ha-alert alert-type="info"> ${0} </ha-alert> `),this.hass.localize("ui.panel.lovelace.editor.card.picture-elements.position_hint")):o.s6,this.hass,this._subElementEditorConfig,this._goBack,this._handleSubElementChanged):(0,o.qy)(E||(E=k` <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeLabel="${0}" @value-changed="${0}"></ha-form> <hui-picture-elements-card-row-editor .hass="${0}" .elements="${0}" @elements-changed="${0}" @edit-detail-element="${0}"></hui-picture-elements-card-row-editor> `),this.hass,this._processData(this._config),this._schema(this.hass.localize),this._computeLabelCallback,this._formChanged,this.hass,this._config.elements,this._elementsChanged,this._editDetailElement):o.s6;var e}_formChanged(e){e.stopPropagation(),this._config&&this.hass&&(0,r.r)(this,"config-changed",{config:e.detail.value})}_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,[g.c]:this._onPreviewClick});(0,r.r)(this,"config-changed",{config:s});const a=(null===(i=e.detail.elements)||void 0===i?void 0:i.length)||0;if(a===n+1){const t=a-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,r.r)(this,"config-changed",{config:Object.assign(Object.assign({},this._config),{},{[g.c]:this._onPreviewClick})})}_editDetailElement(e){this._subElementEditorConfig=e.detail.subElementConfig}_goBack(){this._subElementEditorConfig=void 0}static get styles(){return[f.U]}constructor(...e){super(...e),this._onPreviewClick=(e,t)=>{var i;"element"===(null===(i=this._subElementEditorConfig)||void 0===i?void 0:i.type)&&this._handlePositionClick(e,t)},this._schema=(0,a.A)(e=>[{name:"",type:"expandable",title:e("ui.panel.lovelace.editor.card.picture-elements.card_options"),schema:[{name:"title",selector:{text:{}}},{name:"image",selector:{media:{accept:["image/*"],clearable:!0,image_upload:!0,hide_content_type:!0,content_id_helper:e("ui.panel.lovelace.editor.card.picture.content_id_helper")}}},{name:"dark_mode_image",selector:{media:{accept:["image/*"],clearable:!0,image_upload:!0,hide_content_type:!0,content_id_helper:e("ui.panel.lovelace.editor.card.picture.content_id_helper")}}},{name:"camera_image",selector:{entity:{domain:"camera"}}},{name:"camera_view",selector:{select:{options:["auto","live"].map(t=>({value:t,label:e(`ui.panel.lovelace.editor.card.generic.camera_view_options.${t}`)})),mode:"dropdown"}}},{name:"theme",selector:{theme:{}}},{name:"state_filter",selector:{object:{}}},{name:"dark_mode_filter",selector:{object:{}}}]}]),this._processData=(0,a.A)(e=>Object.assign(Object.assign(Object.assign({},e),"string"==typeof e.image?{image:{media_content_id:e.image}}:{}),"string"==typeof e.dark_mode_image?{dark_mode_image:{media_content_id:e.dark_mode_image}}:{})),this._computeLabelCallback=e=>{switch(e.name){case"dark_mode_image":case"state_filter":case"dark_mode_filter":return this.hass.localize(`ui.panel.lovelace.editor.card.picture-elements.${e.name}`)||e.name;default:return this.hass.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`)||e.name}}}}(0,s.Cg)([(0,l.MZ)({attribute:!1})],$.prototype,"hass",void 0),(0,s.Cg)([(0,l.wk)()],$.prototype,"_config",void 0),(0,s.Cg)([(0,l.wk)()],$.prototype,"_subElementEditorConfig",void 0),$=(0,s.Cg)([(0,l.EM)("hui-picture-elements-card-editor")],$),n()}catch(C){n(C)}})},84698:function(e,t,i){i.d(t,{H:function(){return s}});var n=i(63533);const s=(0,n.Ik)({type:(0,n.Yj)(),view_layout:(0,n.bz)(),layout_options:(0,n.bz)(),grid_options:(0,n.bz)(),visibility:(0,n.bz)(),disabled:(0,n.lq)((0,n.zM)())})}}]);