UNPKG

iobroker.lovelace

Version:

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

4 lines 9.14 kB
export const __rspack_esm_id=36584;export const __rspack_esm_ids=[36584];export const __webpack_modules__={27330(e,t,a){a.d(t,{L:()=>d,p:()=>l});var i=a(62826),o=a(5124),s=a(22441),r=a(6412);const n={passive:!0},l=o.AH`: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 d 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 o.qy`${this._renderHeader()}${this._renderContent()}`}connectedCallback(){super.connectedCallback(),this.hasUpdated&&(this._updateBarPosition(),this._registerListeners(),this._syncScrollState())}_renderHeader(){const e=o.qy`<span class="title"> <slot name="title"></slot> </span>`,t=this._isPaneHeader();return o.qy` <header class="top-app-bar ${(0,r.H)({"pane-header":t})}"> <div class="row"> ${t?o.qy`<section class="section" id="title"> <slot name="navigationIcon"></slot> ${e} </section>`:o.s6} <section class="section" id="navigation"> ${t?o.s6:o.qy`<slot name="navigationIcon"></slot> ${this.centerTitle?o.s6:e}`} </section> ${!t&&this.centerTitle?o.qy`<section class="section center">${e}</section>`:o.s6} <section class="section end" id="actions" role="toolbar"> <slot name="actionItems"></slot> </section> </div> </header> `}_renderContent(){return o.qy`<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,n)}_unregisterListeners(){this.scrollTarget.removeEventListener("scroll",this._syncScrollState)}constructor(...e){super(...e),this.narrow=!1,this.centerTitle=!1,this._syncScrollState=()=>{const e=this.scrollTarget instanceof Window?this.scrollTarget.pageYOffset:this.scrollTarget.scrollTop;this._barElement?.classList.toggle("scrolled",e>0)}}}d.styles=l,(0,i.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],d.prototype,"narrow",void 0),(0,i.Cg)([(0,s.MZ)({attribute:"center-title",type:Boolean})],d.prototype,"centerTitle",void 0),(0,i.Cg)([(0,s.P)(".top-app-bar")],d.prototype,"_barElement",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],d.prototype,"scrollTarget",null),d=(0,i.Cg)([(0,s.EM)("ha-top-app-bar-fixed")],d)},5435(e,t,a){a.a(e,async function(e,i){try{a.r(t);var o=a(62826),s=a(9657),r=a(5124),n=a(22441),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),_=a(14503),f=e([h,p,g]);[h,p,g]=f.then?(await f)():f;const m="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",w=(0,d.NW)({title:(0,d.lq)((0,d.Yj)()),views:(0,d.YO)((0,d.Ik)())}),y=(0,d.NW)({strategy:(0,d.NW)({type:(0,d.Yj)()})});class b extends r.WF{render(){return r.qy` <ha-top-app-bar-fixed .narrow="${this.narrow}"> <ha-icon-button slot="navigationIcon" .path="${m}" @click="${this._closeEditor}" .label="${this.hass.localize("ui.common.close")}"></ha-icon-button> <div slot="title"> ${this.hass.localize("ui.panel.lovelace.editor.raw_editor.header")} </div> <div slot="actionItems" class="save-button ${(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")} </div> <ha-button slot="actionItems" @click="${this._handleSave}" .disabled="${!this._changed}">${this.hass.localize("ui.panel.lovelace.editor.raw_editor.save")}</ha-button> <div class="content"> <ha-yaml-editor autofocus @value-changed="${this._yamlChanged}" @editor-save="${this._handleSave}" disable-fullscreen> </ha-yaml-editor> </div> </ha-top-app-bar-fixed> `}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[_.RF,r.AH`: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,y):(0,d.vA)(e,w)}catch(e){return void(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_invalid_config",{error:e})})}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(e){(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_save_yaml",{error:e})})}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})],b.prototype,"narrow",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"lovelace",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"closeEditor",void 0),(0,o.Cg)([(0,n.wk)()],b.prototype,"_saving",void 0),(0,o.Cg)([(0,n.wk)()],b.prototype,"_changed",void 0),b=(0,o.Cg)([(0,n.EM)("hui-editor")],b),i()}catch(e){i(e)}})}};