iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 6.75 kB
JavaScript
export const __rspack_esm_id=2540;export const __rspack_esm_ids=[2540];export const __webpack_modules__={44423(e,i,t){t.a(e,async function(e,a){try{t.r(i),t.d(i,{HuiDialogEditViewHeader:()=>b});var s=t(62826),o=t(5124),d=t(22441),l=t(6412),r=t(1087),n=t(19459),h=t(18350),_=(t(93444),t(72554)),c=t(29823),g=(t(70947),t(65829)),p=t(10763),m=t(65063),v=t(14503),u=t(67901),w=e([h,_,c,g,p,u]);[h,_,c,g,p,u]=w.then?(await w)():w;const y="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",f="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 b extends o.WF{updated(e){if(this._yamlMode&&e.has("_yamlMode")){const e={...this._config};this._editor?.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,r.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._params||!this.hass)return o.s6;let e;e=this._yamlMode?o.qy` <ha-yaml-editor autofocus in-dialog -changed="${this._viewYamlChanged}"></ha-yaml-editor> `:o.qy` <hui-view-header-settings-editor .hass="${this.hass}" .config="${this._config}" -changed="${this._configChanged}"></hui-view-header-settings-editor> `;const i=this.hass.localize("ui.panel.lovelace.editor.edit_view_header.header");return o.qy` <ha-dialog .open="${this._open}" header-title="${i}" width="large" prevent-scrim-close ="${this._dialogClosed}" class="${(0,l.H)({"yaml-mode":this._yamlMode})}"> <ha-dropdown slot="headerActionItems" placement="bottom-end" -select="${this._handleAction}"> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${y}"></ha-icon-button> <ha-dropdown-item value="toggle-mode"> ${this.hass.localize("ui.panel.lovelace.editor.edit_view_header.edit_"+(this._yamlMode?"ui":"yaml"))} <ha-svg-icon slot="icon" .path="${f}"></ha-svg-icon> </ha-dropdown-item> </ha-dropdown> ${e} <ha-dialog-footer slot="footer"> <ha-button slot="primaryAction" .disabled="${!this._config||this._saving||!this._dirty}" ="${this._save}" .loading="${this._saving}"> ${this.hass.localize("ui.common.save")}</ha-button> </ha-dialog-footer> </ha-dialog> `}async _handleAction(e){"toggle-mode"===e.detail.item.value&&(this._yamlMode=!this._yamlMode)}_configChanged(e){e.detail&&e.detail.config&&!(0,n.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,m.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[v.nA,v.kO,o.AH`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,d.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,s.Cg)([(0,d.wk)()],b.prototype,"_params",void 0),(0,s.Cg)([(0,d.wk)()],b.prototype,"_config",void 0),(0,s.Cg)([(0,d.wk)()],b.prototype,"_saving",void 0),(0,s.Cg)([(0,d.wk)()],b.prototype,"_dirty",void 0),(0,s.Cg)([(0,d.wk)()],b.prototype,"_yamlMode",void 0),(0,s.Cg)([(0,d.P)("ha-yaml-editor")],b.prototype,"_editor",void 0),(0,s.Cg)([(0,d.wk)()],b.prototype,"_open",void 0),b=(0,s.Cg)([(0,d.EM)("hui-dialog-edit-view-header")],b),a()}catch(e){a(e)}})},67901(e,i,t){t.a(e,async function(e,i){try{var a=t(62826),s=t(5124),o=t(22441),d=t(22786),l=t(1087),r=t(15638),n=t(52763),h=t(98440),_=t(71769),c=e([n,h]);[n,h]=c.then?(await c)():c;class g extends s.WF{connectedCallback(){super.connectedCallback(),this._unsubMql=(0,_.m)("(max-width: 600px)",e=>{this.narrow=e})}disconnectedCallback(){super.disconnectedCallback(),this._unsubMql?.(),this._unsubMql=void 0}render(){if(!this.hass)return s.s6;const e={layout:this.config?.layout||"center",badges_position:this.config?.badges_position||"bottom",badges_wrap:this.config?.badges_wrap||"wrap"},i=this.narrow,t=(0,r.qC)(this.hass.language,this.hass.translationMetadata.translations),a=this._schema(this.hass.localize,t,i);return s.qy` <ha-form .hass="${this.hass}" .data="${e}" .schema="${a}" .computeLabel="${this._computeLabel}" -changed="${this._valueChanged}"></ha-form> `}_valueChanged(e){e.stopPropagation();const i=e.detail.value,t={...this.config,...i};(0,l.r)(this,"config-changed",{config:t})}constructor(...e){super(...e),this.narrow=!1,this._schema=(0,d.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=>({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})],g.prototype,"hass",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"config",void 0),(0,a.Cg)([(0,o.wk)({attribute:!1})],g.prototype,"narrow",void 0),g=(0,a.Cg)([(0,o.EM)("hui-view-header-settings-editor")],g),i()}catch(e){i(e)}})}};