UNPKG

iobroker.lovelace

Version:

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

6 lines 10.6 kB
/*! For license information please see 90678.7f03550a2f5520b3.js.LICENSE.txt */ export const __webpack_ids__=["90678"];export const __webpack_modules__={82238:function(e,t,i){i.d(t,{s:()=>m});var o=i(9065),s=i(6374),a=i(15093),r=i(11911),n=i(44491),l=i(84266),d=i(57243),c=i(35359);const h=n.Vq?{passive:!0}:void 0;class p 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=d.dy`<span class="mdc-top-app-bar__title"><slot name="title"></slot></span>`;return this.centerTitle&&(e=d.dy`<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-center">${e}</section>`),d.dy` <header class="mdc-top-app-bar ${(0,c.$)(this.barClasses())}"> <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" @click="${this.handleNavigationClick}"></slot> ${this.centerTitle?null:e} </section> ${this.centerTitle?e:null} <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,c.$)(this.contentClasses())}"> <slot></slot> </div> `}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,h)}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")],p.prototype,"mdcRoot",void 0),(0,o.__decorate)([(0,a.IO)('slot[name="actionItems"]')],p.prototype,"_actionItemsSlot",void 0),(0,o.__decorate)([(0,a.Cb)({type:Boolean})],p.prototype,"centerTitle",void 0),(0,o.__decorate)([(0,a.Cb)({type:Object})],p.prototype,"scrollTarget",null);class u extends p{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,h)}unregisterListeners(){super.unregisterListeners(),window.removeEventListener("resize",this.handleResize)}}(0,o.__decorate)([(0,a.Cb)({type:Boolean,reflect:!0})],u.prototype,"prominent",void 0),(0,o.__decorate)([(0,a.Cb)({type:Boolean,reflect:!0})],u.prototype,"dense",void 0);var v=i(82823);class m extends u{constructor(){super(...arguments),this.mdcFoundationClass=v.Z}barClasses(){return Object.assign(Object.assign({},super.barClasses()),{"mdc-top-app-bar--fixed":!0})}registerListeners(){this.scrollTarget.addEventListener("scroll",this.handleTargetScroll,h)}unregisterListeners(){this.scrollTarget.removeEventListener("scroll",this.handleTargetScroll)}}},85366:function(e,t,i){var o=i(44249),s=i(82238),a=i(66575),r=i(57243),n=i(15093);(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:()=>[a.W,r.iv`.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.r(t);var o=i(44249),s=i(72621),a=i(8877),r=(i(31622),i(76848)),n=i(57243),l=i(15093),d=i(35359),c=i(62900),h=i(48045),p=(i(68325),i(23334),i(76131)),u=i(28008),v=i(72473),m=(i(85366),i(48977));const g=(0,c.dt)({title:(0,c.jt)((0,c.Z_)()),views:(0,c.IX)((0,c.Ry)())}),_=(0,c.dt)({strategy:(0,c.dt)({type:(0,c.Z_)()})});(0,o.Z)([(0,l.Mo)("hui-editor")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"lovelace",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"closeEditor",value:void 0},{kind:"field",decorators:[(0,l.SB)()],key:"_saving",value:void 0},{kind:"field",decorators:[(0,l.SB)()],key:"_changed",value:void 0},{kind:"method",key:"render",value:function(){return n.dy` <ha-top-app-bar-fixed> <ha-icon-button slot="navigationIcon" .path="${"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"}" @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,d.$)({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> <mwc-button raised slot="actionItems" @click="${this._handleSave}" .disabled="${!this._changed}">${this.hass.localize("ui.panel.lovelace.editor.raw_editor.save")}</mwc-button> <div class="content"> <ha-code-editor mode="yaml" autofocus autocomplete-entities autocomplete-icons .hass="${this.hass}" @value-changed="${this._yamlChanged}" @editor-save="${this._handleSave}" dir="ltr"> </ha-code-editor> </div> </ha-top-app-bar-fixed> `}},{kind:"method",key:"firstUpdated",value:function(e){(0,s.Z)(i,"firstUpdated",this,3)([e]),this.yamlEditor.value=(0,r.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,h.v)(t.rawConfig,this.lovelace.rawConfig)&&(0,v.C)(this,{message:this.hass.localize("ui.panel.lovelace.editor.raw_editor.lovelace_changed"),action:{action:()=>{this.yamlEditor.value=(0,r.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[u.Qx,n.iv`: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,a.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,p.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,p.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,p.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,r.load)(e)}catch(e){return(0,p.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_parse_yaml",{error:e})}),void(this._saving=!1)}try{(0,m.Tx)(t)?(0,c.hu)(t,_):(0,c.hu)(t,g)}catch(e){return void(0,p.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.error_invalid_config",{error:e})})}t.resources&&(0,p.showAlertDialog)(this,{text:this.hass.localize("ui.panel.lovelace.editor.raw_editor.resources_moved")});try{await this.lovelace.saveConfig(t)}catch(e){(0,p.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}},{kind:"get",key:"yamlEditor",value:function(){return this.shadowRoot.querySelector("ha-code-editor")}}]}}),n.oi)}}; //# sourceMappingURL=90678.7f03550a2f5520b3.js.map