iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
4 lines • 9.48 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[36584],{27330:function(e,t,a){a.d(t,{L:function(){return m},p:function(){return _}});a(62953);var i=a(40445),o=a(5124),s=a(67576),r=a(6412);let n,l,d,c,h,p,g,v,u=e=>e;const f={passive:!0},_=(0,o.AH)(n||(n=u`:host{display:block}.top-app-bar{box-sizing:border-box;color:var(--app-header-text-color,#fff);background-color:var(--app-header-background-color,var(--primary-color));position:fixed;top:0;inset-inline-end:0;width:var(--ha-top-app-bar-width,100%);z-index:4;padding-top:var(--safe-area-inset-top);padding-right:var(--safe-area-inset-right);transition:box-shadow var(--ha-animation-duration-normal) ease,width var(--ha-animation-duration-normal) ease,padding-left var(--ha-animation-duration-normal) ease,padding-right var(--ha-animation-duration-normal) ease}:host([narrow]) .top-app-bar{padding-left:var(--safe-area-inset-left)}.top-app-bar.scrolled:not(.pane-header){box-shadow:var(--ha-box-shadow-s)}.row{display:flex;align-items:center;box-sizing:border-box;width:100%;height:var(--header-height);border-bottom:var(--app-header-border-bottom)}.section{display:flex;align-items:center;box-sizing:border-box;min-width:0;height:100%;padding:0 var(--ha-space-3)}#navigation{flex:1 1 auto}.section.center{flex:1 1 auto;justify-content:center;text-align:center}.section.end{flex:none;justify-content:flex-end}.title{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ha-font-size-xl);font-weight:var(--ha-font-weight-normal);line-height:var(--header-height);padding-inline-start:var(--ha-space-6)}:host([narrow]) .title{padding-inline-start:var(--ha-space-2)}.top-app-bar-fixed-adjust{padding-top:calc(var(--header-height,0px) + var(--safe-area-inset-top,0px));padding-bottom:var(--safe-area-inset-bottom);padding-right:var(--safe-area-inset-right)}:host([narrow]) .top-app-bar-fixed-adjust{padding-left:var(--safe-area-inset-left)}`));class m extends o.WF{get scrollTarget(){return this._scrollTarget||window}set scrollTarget(e){const t=this.scrollTarget;this._unregisterListeners(),this._scrollTarget=e,this._updateBarPosition(),this.requestUpdate("scrollTarget",t),this.isConnected&&(this._registerListeners(),this._syncScrollState())}_isPaneHeader(){return!1}render(){return(0,o.qy)(l||(l=u`${0}${0}`),this._renderHeader(),this._renderContent())}connectedCallback(){super.connectedCallback(),this.hasUpdated&&(this._updateBarPosition(),this._registerListeners(),this._syncScrollState())}_renderHeader(){const e=(0,o.qy)(d||(d=u`<span class="title"> <slot name="title"></slot> </span>`)),t=this._isPaneHeader();return(0,o.qy)(c||(c=u` <header class="top-app-bar ${0}"> <div class="row"> ${0} <section class="section" id="navigation"> ${0} </section> ${0} <section class="section end" id="actions" role="toolbar"> <slot name="actionItems"></slot> </section> </div> </header> `),(0,r.H)({"pane-header":t}),t?(0,o.qy)(h||(h=u`<section class="section" id="title"> <slot name="navigationIcon"></slot> ${0} </section>`),e):o.s6,t?o.s6:(0,o.qy)(p||(p=u`<slot name="navigationIcon"></slot> ${0}`),this.centerTitle?o.s6:e),!t&&this.centerTitle?(0,o.qy)(g||(g=u`<section class="section center">${0}</section>`),e):o.s6)}_renderContent(){return(0,o.qy)(v||(v=u`<div class="top-app-bar-fixed-adjust"> <slot></slot> </div>`))}firstUpdated(e){super.firstUpdated(e),this._updateBarPosition(),this._registerListeners(),this._syncScrollState()}disconnectedCallback(){super.disconnectedCallback(),this._unregisterListeners()}_updateBarPosition(){this._barElement&&(this._barElement.style.position=this.scrollTarget===window?"":"absolute")}_registerListeners(){this.scrollTarget.addEventListener("scroll",this._syncScrollState,f)}_unregisterListeners(){this.scrollTarget.removeEventListener("scroll",this._syncScrollState)}constructor(...e){super(...e),this.narrow=!1,this.centerTitle=!1,this._syncScrollState=()=>{var e;const t=this.scrollTarget instanceof Window?this.scrollTarget.pageYOffset:this.scrollTarget.scrollTop;null===(e=this._barElement)||void 0===e||e.classList.toggle("scrolled",t>0)}}}m.styles=_,(0,i.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],m.prototype,"narrow",void 0),(0,i.Cg)([(0,s.MZ)({attribute:"center-title",type:Boolean})],m.prototype,"centerTitle",void 0),(0,i.Cg)([(0,s.P)(".top-app-bar")],m.prototype,"_barElement",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"scrollTarget",null),m=(0,i.Cg)([(0,s.EM)("ha-top-app-bar-fixed")],m)},5435:function(e,t,a){a.a(e,async function(e,i){try{a.r(t);a(3362),a(62953);var o=a(40445),s=a(9657),r=a(5124),n=a(67576),l=a(6412),d=a(63533),c=a(19459),h=a(18350),p=a(10763),g=a(26300),v=(a(27330),a(35952)),u=a(65063),f=a(14503),_=e([h,p,g,s]);[h,p,g,s]=_.then?(await _)():_;let m,w,y=e=>e;const b="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",x=(0,d.NW)({title:(0,d.lq)((0,d.Yj)()),views:(0,d.YO)((0,d.Ik)())}),C=(0,d.NW)({strategy:(0,d.NW)({type:(0,d.Yj)()})});class z extends r.WF{render(){return(0,r.qy)(m||(m=y` <ha-top-app-bar-fixed .narrow="${0}"> <ha-icon-button slot="navigationIcon" .path="${0}" ="${0}" .label="${0}"></ha-icon-button> <div slot="title"> ${0} </div> <div slot="actionItems" class="save-button ${0}"> ${0} </div> <ha-button slot="actionItems" ="${0}" .disabled="${0}">${0}</ha-button> <div class="content"> <ha-yaml-editor autofocus -changed="${0}" -save="${0}" disable-fullscreen> </ha-yaml-editor> </div> </ha-top-app-bar-fixed> `),this.narrow,b,this._closeEditor,this.hass.localize("ui.common.close"),this.hass.localize("ui.panel.lovelace.editor.raw_editor.header"),(0,l.H)({saved:!1===this._saving||!0===this._changed}),this._changed?this.hass.localize("ui.panel.lovelace.editor.raw_editor.unsaved_changes"):this.hass.localize("ui.panel.lovelace.editor.raw_editor.saved"),this._handleSave,!this._changed,this.hass.localize("ui.panel.lovelace.editor.raw_editor.save"),this._yamlChanged,this._handleSave)}firstUpdated(e){super.firstUpdated(e),this.yamlEditor.setValue(this.lovelace.rawConfig)}updated(e){const t=e.get("lovelace");!this._saving&&t&&this.lovelace&&t.rawConfig!==this.lovelace.rawConfig&&!(0,c.b)(t.rawConfig,this.lovelace.rawConfig)&&this.yamlEditor.setValue(this.lovelace.rawConfig)}static get styles(){return[f.RF,(0,r.AH)(w||(w=y`:host{--code-mirror-height:100%;--app-header-background-color:var(
--app-header-edit-background-color,
#455a64
);--app-header-text-color:var(--app-header-edit-text-color, #fff)}.content{height:calc(100vh - var(--header-height))}.comments{font-size:var(--ha-font-size-l)}ha-yaml-editor{display:flex;flex-direction:column;height:100%;min-height:0}.save-button{opacity:0;font-size:var(--ha-font-size-m);padding:0px 10px}.saved{opacity:1}`))]}_yamlChanged(e){this._config=e.detail.isValid?e.detail.value:void 0,this._yamlError=e.detail.errorMsg,this._changed=(0,s.mk)(this.yamlEditor.codemirror.state)>0,this._changed&&!window.onbeforeunload?window.onbeforeunload=()=>!0:!this._changed&&window.onbeforeunload&&(window.onbeforeunload=null)}async _closeEditor(){this._changed&&!(await(0,u.dk)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.confirm_unsaved_changes"),dismissText:this.hass.localize("ui.common.stay"),confirmText:this.hass.localize("ui.common.leave")}))||(window.onbeforeunload=null,this.closeEditor&&this.closeEditor())}async _resetConfig(){try{await this.lovelace.deleteConfig()}catch(e){return void(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_save_yaml",{error:e})})}window.onbeforeunload=null,this.closeEditor&&this.closeEditor()}async _handleSave(){if(this._saving=!0,!this.yamlEditor.yaml)return void(0,u.dk)(this,{title:this.hass.localize("ui.panel.lovelace.editor.raw_editor.confirm_reset_config_title"),text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.confirm_reset_config_text"),confirmText:this.hass.localize("ui.common.reset"),dismissText:this.hass.localize("ui.common.cancel"),confirm:()=>this._resetConfig(),destructive:!0});if(this._yamlError)return(0,u.showAlertDialog)(this,{text:this._yamlError}),void(this._saving=!1);if(this.yamlEditor.hasComments&&!confirm(this.hass.localize("ui.panel.lovelace.editor.raw_editor.confirm_unsaved_comments")))return;const e=this._config;try{(0,v.Wu)(e)?(0,d.vA)(e,C):(0,d.vA)(e,x)}catch(t){return void(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_invalid_config",{error:t})})}e.resources&&(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.resources_moved")});try{await this.lovelace.saveConfig(e)}catch(t){(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_save_yaml",{error:t})})}window.onbeforeunload=null,this._changed=!1,this._saving=!1}get yamlEditor(){return this.shadowRoot.querySelector("ha-yaml-editor")}constructor(...e){super(...e),this.narrow=!1}}(0,o.Cg)([(0,n.MZ)({type:Boolean})],z.prototype,"narrow",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],z.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],z.prototype,"lovelace",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],z.prototype,"closeEditor",void 0),(0,o.Cg)([(0,n.wk)()],z.prototype,"_saving",void 0),(0,o.Cg)([(0,n.wk)()],z.prototype,"_changed",void 0),z=(0,o.Cg)([(0,n.EM)("hui-editor")],z),i()}catch(m){i(m)}})}}]);