iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 7.21 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[2540],{44423:function(e,i,t){t.a(e,async function(e,a){try{t.r(i),t.d(i,{HuiDialogEditViewHeader:function(){return A}});t(3362),t(62953);var s=t(40445),o=t(5124),n=t(67576),l=t(6412),d=t(1087),r=t(19459),h=t(18350),c=(t(93444),t(72554)),_=t(29823),g=(t(70947),t(65829)),p=t(10763),v=t(65063),u=t(14503),m=t(67901),f=e([h,c,_,g,p,m]);[h,c,_,g,p,m]=f.then?(await f)():f;let w,y,b,$,C=e=>e;const M="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",k="M3 6V8H14V6H3M3 10V12H14V10H3M20 10.1C19.9 10.1 19.7 10.2 19.6 10.3L18.6 11.3L20.7 13.4L21.7 12.4C21.9 12.2 21.9 11.8 21.7 11.6L20.4 10.3C20.3 10.2 20.2 10.1 20 10.1M18.1 11.9L12 17.9V20H14.1L20.2 13.9L18.1 11.9M3 14V16H10V14H3Z";class A extends o.WF{updated(e){if(this._yamlMode&&e.has("_yamlMode")){var i;const e=Object.assign({},this._config);null===(i=this._editor)||void 0===i||i.setValue(e)}}showDialog(e){this._params=e,this._dirty=!1,this._config=this._params.config,this._open=!0}closeDialog(){this._open=!1}_dialogClosed(){this._params=void 0,this._config=void 0,this._yamlMode=!1,this._dirty=!1,this._saving=!1,(0,d.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._params||!this.hass)return o.s6;let e;e=this._yamlMode?(0,o.qy)(w||(w=C` <ha-yaml-editor autofocus in-dialog -changed="${0}"></ha-yaml-editor> `),this._viewYamlChanged):(0,o.qy)(y||(y=C` <hui-view-header-settings-editor .hass="${0}" .config="${0}" -changed="${0}"></hui-view-header-settings-editor> `),this.hass,this._config,this._configChanged);const i=this.hass.localize("ui.panel.lovelace.editor.edit_view_header.header");return(0,o.qy)(b||(b=C` <ha-dialog .open="${0}" header-title="${0}" width="large" prevent-scrim-close ="${0}" class="${0}"> <ha-dropdown slot="headerActionItems" placement="bottom-end" -select="${0}"> <ha-icon-button slot="trigger" .label="${0}" .path="${0}"></ha-icon-button> <ha-dropdown-item value="toggle-mode"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> </ha-dropdown> ${0} <ha-dialog-footer slot="footer"> <ha-button slot="primaryAction" .disabled="${0}" ="${0}" .loading="${0}"> ${0}</ha-button> </ha-dialog-footer> </ha-dialog> `),this._open,i,this._dialogClosed,(0,l.H)({"yaml-mode":this._yamlMode}),this._handleAction,this.hass.localize("ui.common.menu"),M,this.hass.localize("ui.panel.lovelace.editor.edit_view_header.edit_"+(this._yamlMode?"ui":"yaml")),k,e,!this._config||this._saving||!this._dirty,this._save,this._saving,this.hass.localize("ui.common.save"))}async _handleAction(e){"toggle-mode"===e.detail.item.value&&(this._yamlMode=!this._yamlMode)}_configChanged(e){e.detail&&e.detail.config&&!(0,r.b)(this._config,e.detail.config)&&(this._config=e.detail.config,this._dirty=!0)}_viewYamlChanged(e){e.stopPropagation(),e.detail.isValid&&(this._config=e.detail.value,this._dirty=!0)}async _save(){if(this._params&&this._config){this._saving=!0;try{await this._params.saveConfig(this._config),this.closeDialog()}catch(e){(0,v.showAlertDialog)(this,{text:`${this.hass.localize("ui.panel.lovelace.editor.edit_view_header.saving_failed")}: ${e.message}`})}finally{this._saving=!1}}}static get styles(){return[u.nA,u.kO,(0,o.AH)($||($=C`ha-dialog.yaml-mode{--dialog-content-padding:0}`))]}constructor(...e){super(...e),this._saving=!1,this._dirty=!1,this._yamlMode=!1,this._open=!1}}(0,s.Cg)([(0,n.MZ)({attribute:!1})],A.prototype,"hass",void 0),(0,s.Cg)([(0,n.wk)()],A.prototype,"_params",void 0),(0,s.Cg)([(0,n.wk)()],A.prototype,"_config",void 0),(0,s.Cg)([(0,n.wk)()],A.prototype,"_saving",void 0),(0,s.Cg)([(0,n.wk)()],A.prototype,"_dirty",void 0),(0,s.Cg)([(0,n.wk)()],A.prototype,"_yamlMode",void 0),(0,s.Cg)([(0,n.P)("ha-yaml-editor")],A.prototype,"_editor",void 0),(0,s.Cg)([(0,n.wk)()],A.prototype,"_open",void 0),A=(0,s.Cg)([(0,n.EM)("hui-dialog-edit-view-header")],A),a()}catch(w){a(w)}})},67901:function(e,i,t){t.a(e,async function(e,i){try{t(62953);var a=t(40445),s=t(5124),o=t(67576),n=t(22786),l=t(1087),d=t(15638),r=t(52763),h=t(98440),c=t(71769),_=e([r,h]);[r,h]=_.then?(await _)():_;let g,p=e=>e;class v extends s.WF{connectedCallback(){super.connectedCallback(),this._unsubMql=(0,c.m)("(max-width: 600px)",e=>{this.narrow=e})}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._unsubMql)||void 0===e||e.call(this),this._unsubMql=void 0}render(){var e,i,t;if(!this.hass)return s.s6;const a={layout:(null===(e=this.config)||void 0===e?void 0:e.layout)||"center",badges_position:(null===(i=this.config)||void 0===i?void 0:i.badges_position)||"bottom",badges_wrap:(null===(t=this.config)||void 0===t?void 0:t.badges_wrap)||"wrap"},o=this.narrow,n=(0,d.qC)(this.hass.language,this.hass.translationMetadata.translations),l=this._schema(this.hass.localize,n,o);return(0,s.qy)(g||(g=p` <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeLabel="${0}" -changed="${0}"></ha-form> `),this.hass,a,l,this._computeLabel,this._valueChanged)}_valueChanged(e){e.stopPropagation();const i=e.detail.value,t=Object.assign(Object.assign({},this.config),i);(0,l.r)(this,"config-changed",{config:t})}constructor(...e){super(...e),this.narrow=!1,this._schema=(0,n.A)((e,i,t)=>[{name:"layout",selector:{select:{mode:"box",box_max_columns:t?1:3,options:["responsive","start","center"].map(t=>({value:t,label:e(`ui.panel.lovelace.editor.edit_view_header.settings.layout_options.${"start"===t&&i?`${t}_rtl`:t}`),description:e(`ui.panel.lovelace.editor.edit_view_header.settings.layout_options.${t}_description`),image:{src:`/static/images/form/view_header_layout_${t}.svg`,src_dark:`/static/images/form/view_header_layout_${t}_dark.svg`,flip_rtl:!0}}))}}},{name:"badges_position",selector:{select:{mode:"box",options:["bottom","top"].map(i=>({value:i,label:e(`ui.panel.lovelace.editor.edit_view_header.settings.badges_position_options.${i}`),image:{src:`/static/images/form/view_header_badges_position_${i}.svg`,src_dark:`/static/images/form/view_header_badges_position_${i}_dark.svg`,flip_rtl:!0}}))}}},{name:"badges_wrap",selector:{select:{mode:"box",options:["wrap","scroll"].map(i=>Object.assign(Object.assign({value:i,label:e(`ui.panel.lovelace.editor.edit_view_header.settings.badges_wrap_options.${i}`)},"scroll"===i&&{description:e(`ui.panel.lovelace.editor.edit_view_header.settings.badges_wrap_options.${i}_description`)}),{},{image:{src:`/static/images/form/view_header_badges_wrap_${i}.svg`,src_dark:`/static/images/form/view_header_badges_wrap_${i}_dark.svg`,flip_rtl:!0}}))}}}]),this._computeLabel=e=>{switch(e.name){case"layout":case"badges_position":case"badges_wrap":return this.hass.localize(`ui.panel.lovelace.editor.edit_view_header.settings.${e.name}`);default:return""}}}}(0,a.Cg)([(0,o.MZ)({attribute:!1})],v.prototype,"hass",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],v.prototype,"config",void 0),(0,a.Cg)([(0,o.wk)({attribute:!1})],v.prototype,"narrow",void 0),v=(0,a.Cg)([(0,o.EM)("hui-view-header-settings-editor")],v),i()}catch(g){i(g)}})}}]);