iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
6 lines • 11 kB
JavaScript
/*! For license information please see 90678.d5a0d5deae510d9b.js.LICENSE.txt */
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["90678"],{82238:function(e,t,i){i.d(t,{s:()=>b});i(71695),i(19423),i(47021);var o=i(9065),s=i(6374),a=i(50778),r=i(11911),n=i(44491),l=i(84266),d=i(57243),c=i(35359);let h,p,u,v=e=>e;const m=n.Vq?{passive:!0}:void 0;class g extends r.H{constructor(){super(...arguments),this.centerTitle=!1,this.handleTargetScroll=()=>{this.mdcFoundation.handleTargetScroll()},this.handleNavigationClick=()=>{this.mdcFoundation.handleNavigationClick()}}get scrollTarget(){return this._scrollTarget||window}set scrollTarget(e){this.unregisterScrollListener();const t=this.scrollTarget;this._scrollTarget=e,this.updateRootPosition(),this.requestUpdate("scrollTarget",t),this.registerScrollListener()}updateRootPosition(){if(this.mdcRoot){const e=this.scrollTarget===window;this.mdcRoot.style.position=e?"":"absolute"}}render(){let e=(0,d.dy)(h||(h=v`<span class="mdc-top-app-bar__title"><slot name="title"></slot></span>`));return this.centerTitle&&(e=(0,d.dy)(p||(p=v`<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-center">${0}</section>`),e)),(0,d.dy)(u||(u=v` <header class="mdc-top-app-bar ${0}"> <div class="mdc-top-app-bar__row"> <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start" id="navigation"> <slot name="navigationIcon" ="${0}"></slot> ${0} </section> ${0} <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end" id="actions" role="toolbar"> <slot name="actionItems"></slot> </section> </div> </header> <div class="${0}"> <slot></slot> </div> `),(0,c.$)(this.barClasses()),this.handleNavigationClick,this.centerTitle?null:e,this.centerTitle?e:null,(0,c.$)(this.contentClasses()))}createAdapter(){return Object.assign(Object.assign({},(0,r.q)(this.mdcRoot)),{setStyle:(e,t)=>this.mdcRoot.style.setProperty(e,t),getTopAppBarHeight:()=>this.mdcRoot.clientHeight,notifyNavigationIconClicked:()=>{this.dispatchEvent(new Event(l.j2.NAVIGATION_EVENT,{bubbles:!0,cancelable:!0}))},getViewportScrollY:()=>this.scrollTarget instanceof Window?this.scrollTarget.pageYOffset:this.scrollTarget.scrollTop,getTotalActionItems:()=>this._actionItemsSlot.assignedNodes({flatten:!0}).length})}registerListeners(){this.registerScrollListener()}unregisterListeners(){this.unregisterScrollListener()}registerScrollListener(){this.scrollTarget.addEventListener("scroll",this.handleTargetScroll,m)}unregisterScrollListener(){this.scrollTarget.removeEventListener("scroll",this.handleTargetScroll)}firstUpdated(){super.firstUpdated(),this.updateRootPosition(),this.registerListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unregisterListeners()}}(0,o.__decorate)([(0,a.IO)(".mdc-top-app-bar")],g.prototype,"mdcRoot",void 0),(0,o.__decorate)([(0,a.IO)('slot[name="actionItems"]')],g.prototype,"_actionItemsSlot",void 0),(0,o.__decorate)([(0,a.Cb)({type:Boolean})],g.prototype,"centerTitle",void 0),(0,o.__decorate)([(0,a.Cb)({type:Object})],g.prototype,"scrollTarget",null);class _ extends g{constructor(){super(...arguments),this.mdcFoundationClass=s.Z,this.prominent=!1,this.dense=!1,this.handleResize=()=>{this.mdcFoundation.handleWindowResize()}}barClasses(){return{"mdc-top-app-bar--dense":this.dense,"mdc-top-app-bar--prominent":this.prominent,"center-title":this.centerTitle}}contentClasses(){return{"mdc-top-app-bar--fixed-adjust":!this.dense&&!this.prominent,"mdc-top-app-bar--dense-fixed-adjust":this.dense&&!this.prominent,"mdc-top-app-bar--prominent-fixed-adjust":!this.dense&&this.prominent,"mdc-top-app-bar--dense-prominent-fixed-adjust":this.dense&&this.prominent}}registerListeners(){super.registerListeners(),window.addEventListener("resize",this.handleResize,m)}unregisterListeners(){super.unregisterListeners(),window.removeEventListener("resize",this.handleResize)}}(0,o.__decorate)([(0,a.Cb)({type:Boolean,reflect:!0})],_.prototype,"prominent",void 0),(0,o.__decorate)([(0,a.Cb)({type:Boolean,reflect:!0})],_.prototype,"dense",void 0);var f=i(82823);class b extends _{constructor(){super(...arguments),this.mdcFoundationClass=f.Z}barClasses(){return Object.assign(Object.assign({},super.barClasses()),{"mdc-top-app-bar--fixed":!0})}registerListeners(){this.scrollTarget.addEventListener("scroll",this.handleTargetScroll,m)}unregisterListeners(){this.scrollTarget.removeEventListener("scroll",this.handleTargetScroll)}}},85366:function(e,t,i){var o=i(61701),s=(i(71695),i(47021),i(82238)),a=i(66575),r=i(57243),n=i(50778);let l,d=e=>e;(0,o.Z)([(0,n.Mo)("ha-top-app-bar-fixed")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",static:!0,key:"styles",value(){return[a.W,(0,r.iv)(l||(l=d`.mdc-top-app-bar__row{height:var(--header-height);border-bottom:var(--app-header-border-bottom)}.mdc-top-app-bar--fixed-adjust{padding-top:var(--header-height)}.mdc-top-app-bar{--mdc-typography-headline6-font-weight:400;color:var(--app-header-text-color,var(--mdc-theme-on-primary,#fff));background-color:var(--app-header-background-color,var(--mdc-theme-primary))}.mdc-top-app-bar__title{font-size:20px;padding-inline-start:24px;padding-inline-end:initial}`))]}}]}}),s.s)},59207:function(e,t,i){i.a(e,(async function(e,o){try{i.r(t);var s=i(61701),a=i(72621),r=(i(71695),i(40251),i(47021),i(8877)),n=(i(31622),i(76848)),l=i(57243),d=i(50778),c=i(35359),h=i(62900),p=i(48045),u=(i(68325),i(23334),i(76131)),v=i(28008),m=i(72473),g=(i(85366),i(48977)),_=e([r]);r=(_.then?(await _)():_)[0];let f,b,w=e=>e;const y="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",k=(0,h.dt)({title:(0,h.jt)((0,h.Z_)()),views:(0,h.IX)((0,h.Ry)())}),x=(0,h.dt)({strategy:(0,h.dt)({type:(0,h.Z_)()})});(0,s.Z)([(0,d.Mo)("hui-editor")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,d.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,d.Cb)({attribute:!1})],key:"lovelace",value:void 0},{kind:"field",decorators:[(0,d.Cb)({attribute:!1})],key:"closeEditor",value:void 0},{kind:"field",decorators:[(0,d.SB)()],key:"_saving",value:void 0},{kind:"field",decorators:[(0,d.SB)()],key:"_changed",value:void 0},{kind:"method",key:"render",value:function(){return(0,l.dy)(f||(f=w` <ha-top-app-bar-fixed> <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> <mwc-button raised slot="actionItems" ="${0}" .disabled="${0}">${0}</mwc-button> <div class="content"> <ha-code-editor mode="yaml" autofocus autocomplete-entities autocomplete-icons .hass="${0}" -changed="${0}" -save="${0}" dir="ltr"> </ha-code-editor> </div> </ha-top-app-bar-fixed> `),y,this._closeEditor,this.hass.localize("ui.common.close"),this.hass.localize("ui.panel.lovelace.editor.raw_editor.header"),(0,c.$)({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.hass,this._yamlChanged,this._handleSave)}},{kind:"method",key:"firstUpdated",value:function(e){(0,a.Z)(i,"firstUpdated",this,3)([e]),this.yamlEditor.value=(0,n.dump)(this.lovelace.rawConfig)}},{kind:"method",key:"updated",value:function(e){const t=e.get("lovelace");!this._saving&&t&&this.lovelace&&t.rawConfig!==this.lovelace.rawConfig&&!(0,p.v)(t.rawConfig,this.lovelace.rawConfig)&&(0,m.C)(this,{message:this.hass.localize("ui.panel.lovelace.editor.raw_editor.lovelace_changed"),action:{action:()=>{this.yamlEditor.value=(0,n.dump)(this.lovelace.rawConfig)},text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.reload")},duration:-1,dismissable:!1})}},{kind:"get",static:!0,key:"styles",value:function(){return[v.Qx,(0,l.iv)(b||(b=w`: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)}mwc-button[disabled]{background-color:var(--mdc-theme-on-primary);border-radius:4px}.content{height:calc(100vh - var(--header-height))}.comments{font-size:16px}.save-button{opacity:0;font-size:14px;padding:0px 10px}.saved{opacity:1}`))]}},{kind:"method",key:"_yamlChanged",value:function(){this._changed=(0,r.of)(this.yamlEditor.codemirror.state)>0,this._changed&&!window.onbeforeunload?window.onbeforeunload=()=>!0:!this._changed&&window.onbeforeunload&&(window.onbeforeunload=null)}},{kind:"method",key:"_closeEditor",value:async function(){this._changed&&!(await(0,u.showConfirmationDialog)(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())}},{kind:"method",key:"_removeConfig",value:async function(){try{await this.lovelace.deleteConfig()}catch(e){(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_remove",{error:e})})}window.onbeforeunload=null,this.closeEditor&&this.closeEditor()}},{kind:"method",key:"_handleSave",value:async function(){this._saving=!0;const e=this.yamlEditor.value;if(!e)return void(0,u.showConfirmationDialog)(this,{title:this.hass.localize("ui.panel.lovelace.editor.raw_editor.confirm_delete_config_title"),text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.confirm_delete_config_text"),confirmText:this.hass.localize("ui.common.delete"),dismissText:this.hass.localize("ui.common.cancel"),confirm:()=>this._removeConfig(),destructive:!0});if(this.yamlEditor.hasComments&&!confirm(this.hass.localize("ui.panel.lovelace.editor.raw_editor.confirm_unsaved_comments")))return;let t;try{t=(0,n.load)(e)}catch(i){return(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_parse_yaml",{error:i})}),void(this._saving=!1)}try{(0,g.Tx)(t)?(0,h.hu)(t,x):(0,h.hu)(t,k)}catch(i){return void(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_invalid_config",{error:i})})}t.resources&&(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.resources_moved")});try{await this.lovelace.saveConfig(t)}catch(i){(0,u.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_save_yaml",{error:i})})}window.onbeforeunload=null,this._changed=!1,this._saving=!1}},{kind:"get",key:"yamlEditor",value:function(){return this.shadowRoot.querySelector("ha-code-editor")}}]}}),l.oi);o()}catch(f){o(f)}}))}}]);
//# sourceMappingURL=90678.d5a0d5deae510d9b.js.map