UNPKG

iobroker.lovelace

Version:

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

1 lines 11.3 kB
(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[51746],{34370:function(e,i,t){t(18111),t(7588),e.exports=function e(i){return Object.freeze(i),Object.getOwnPropertyNames(i).forEach(function(t){!i.hasOwnProperty(t)||null===i[t]||"object"!=typeof i[t]&&"function"!=typeof i[t]||Object.isFrozen(i[t])||e(i[t])}),i}},98489:function(e,i,t){"use strict";t.a(e,async function(e,a){try{t.r(i),t.d(i,{HuiDialogEditCard:function(){return H}});var o=t(86518),n=(t(3362),t(62953),t(40445)),r=t(34370),s=t.n(r),d=t(5124),c=t(67576),l=t(22786),h=t(1087),g=t(15638),p=t(64481),u=t(18350),_=t(72554),m=(t(93444),t(26300)),y=t(65829),v=t(45291),f=t(65063),b=t(14503),C=t(81619),w=t(92255),x=t(46856),$=t(26004),k=t(77859),A=t(97962),M=e([u,_,m,y,x,$,A]);[u,_,m,y,x,$,A]=M.then?(await M)():M;const L=["cards","title"];let z,E,I,U,O,P,j,G,R=e=>e;const q="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",D="M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z";class H extends d.WF{async showDialog(e){this._params=e,this._GUImode=!0,this._guiModeAvailable=!0,this._open=!0,this._sectionConfig=this._params.sectionConfig,this._cardConfig=e.cardConfig,this._dirty=Boolean(this._params.isNew),this.large=!1,this._cardConfig&&!Object.isFrozen(this._cardConfig)&&(this._cardConfig=s()(this._cardConfig))}closeDialog(){return this._dirty?(this._confirmCancel(),!1):(this._open=!1,!0)}_dialogClosed(){this._open=!1,this._params=void 0,this._cardConfig=void 0,this._error=void 0,this._documentationURL=void 0,this._dirty=!1,(0,h.r)(this,"dialog-closed",{dialog:this.localName})}updated(e){if(!this._cardConfig||!e.has("_cardConfig"))return;const i=e.get("_cardConfig");(null==i?void 0:i.type)!==this._cardConfig.type&&(this._documentationURL=(0,k.W)(this.hass,this._cardConfig.type))}render(){if(!this._params||!this._cardConfig)return d.s6;let e;if(this._cardConfig.type){let a;var i,t;if((0,v.c8)(this._cardConfig.type))a=null===(i=(0,v.wi)((0,v.Iu)(this._cardConfig.type)))||void 0===i?void 0:i.name,null!==(t=a)&&void 0!==t&&t.toLowerCase().endsWith(" card")&&(a=a.substring(0,a.length-5));else a=this.hass.localize(`ui.panel.lovelace.editor.card.${this._cardConfig.type}.name`);e=this.hass.localize("ui.panel.lovelace.editor.edit_card.typed_header",{type:a})}else e=this.hass.localize("ui.panel.lovelace.editor.edit_card.header");return(0,d.qy)(z||(z=R` <ha-dialog .open="${0}" .width="${0}" prevent-scrim-close @keydown="${0}" @closed="${0}" @opened="${0}"> <ha-icon-button slot="headerNavigationIcon" @click="${0}" .label="${0}" .path="${0}"></ha-icon-button> <span slot="headerTitle" class="title-enlargeable" @click="${0}">${0}</span> ${0} <div class="content"> <div class="element-editor ha-scrollbar"> <hui-card-element-editor autofocus .showVisibilityTab="${0}" .sectionConfig="${0}" .hass="${0}" .lovelace="${0}" .value="${0}" in-dialog @config-changed="${0}" @GUImode-changed="${0}" @editor-save="${0}"></hui-card-element-editor> </div> <div class="element-preview ha-scrollbar"> ${0} ${0} </div> </div> <ha-dialog-footer slot="footer"> ${0} <ha-button appearance="plain" slot="secondaryAction" @click="${0}"> ${0} </ha-button> ${0} </ha-dialog-footer> </ha-dialog> `),this._open,this.large?"full":"large",this._ignoreKeydown,this._dialogClosed,this._opened,this._cancel,this.hass.localize("ui.common.close"),q,this._enlarge,e,void 0!==this._documentationURL?(0,d.qy)(E||(E=R` <ha-icon-button .path="${0}" slot="headerActionItems" href="${0}" title="${0}" target="_blank" rel="noreferrer" dir="${0}"></ha-icon-button> `),D,this._documentationURL,this.hass.localize("ui.panel.lovelace.menu.help"),(0,g.Vc)(this.hass)):d.s6,"conditional"!==this._cardConfig.type,this._sectionConfig,this.hass,this._params.lovelaceConfig,this._cardConfig,this._handleConfigChanged,this._handleGUIModeChanged,this._save,this._sectionConfig?(0,d.qy)(I||(I=R` <hui-section .hass="${0}" .config="${0}" preview class="${0}"></hui-section> `),this.hass,this._cardConfigInSection(this._cardConfig),this._error?"blur":""):(0,d.qy)(U||(U=R` <hui-card .hass="${0}" .config="${0}" preview class="${0}"></hui-card> `),this.hass,this._cardConfig,this._error?"blur":""),this._error?(0,d.qy)(O||(O=R` <ha-spinner aria-label="Can't update card"></ha-spinner> `)):"",void 0!==this._cardConfig?(0,d.qy)(P||(P=R` <ha-button slot="secondaryAction" @click="${0}" .disabled="${0}" class="gui-mode-button" appearance="plain"> ${0} </ha-button> `),this._toggleMode,!this._guiModeAvailable,this.hass.localize(!this._cardEditorEl||this._GUImode?"ui.panel.lovelace.editor.edit_card.show_code_editor":"ui.panel.lovelace.editor.edit_card.show_visual_editor")):"",this._cancel,this.hass.localize("ui.common.cancel"),void 0!==this._cardConfig&&this._dirty?(0,d.qy)(j||(j=R` <ha-button slot="primaryAction" ?disabled="${0}" @click="${0}" .loading="${0}"> ${0} </ha-button> `),!this._canSave,this._save,this._saving,this.hass.localize("ui.common.save")):"")}_enlarge(){(0,p.J)(()=>{this.large=!this.large})}_ignoreKeydown(e){e.stopPropagation()}_handleConfigChanged(e){this._cardConfig=s()(e.detail.config),this._error=e.detail.error,this._guiModeAvailable=e.detail.guiModeAvailable,this._dirty=!0}_handleGUIModeChanged(e){e.stopPropagation(),this._GUImode=e.detail.guiMode,this._guiModeAvailable=e.detail.guiModeAvailable}_toggleMode(){(0,p.J)(()=>{var e;null===(e=this._cardEditorEl)||void 0===e||e.toggleMode()})}_opened(){var e;null===(e=this._cardEditorEl)||void 0===e||e.focusYamlEditor()}get _canSave(){return!this._saving&&(void 0!==this._cardConfig&&(!this._cardEditorEl||!this._cardEditorEl.hasError))}async _confirmCancel(){await new Promise(e=>{setTimeout(e,0)});await(0,f.dk)(this,{title:this.hass.localize("ui.panel.lovelace.editor.edit_card.unsaved_changes"),text:this.hass.localize("ui.panel.lovelace.editor.edit_card.confirm_cancel"),dismissText:this.hass.localize("ui.common.stay"),confirmText:this.hass.localize("ui.common.leave")})&&this._cancel()}_cancel(e){e&&e.stopPropagation(),this._dirty=!1,this.closeDialog()}async _save(){if(this._canSave)if(this._dirty){this._saving=!0;try{await this._params.saveCardConfig(this._cardConfig),this._saving=!1,this._dirty=!1,(0,w.f)(this,this.hass),this.closeDialog()}catch(e){(0,C.P)(this,{message:e.message}),this._saving=!1}}else this.closeDialog()}static get styles(){return[b.nA,b.kO,b.dp,(0,d.AH)(G||(G=R`:host{--code-mirror-max-height:calc(100vh - 209px)}ha-dialog{--dialog-z-index:6;--dialog-content-padding:var(--ha-space-2)}.content{width:100%;max-width:100%}@media all and (max-width:450px),all and (max-height:500px){.content{width:100%;max-width:100%;gap:var(--ha-space-3)}}@media all and (min-width:451px) and (min-height:501px){:host([large]) .content{max-width:none}}.center{margin-left:auto;margin-right:auto}.content{display:flex;flex-direction:column}.content hui-card{display:block;padding:4px;margin:0 auto;max-width:390px}.content hui-section{display:block;padding:4px;margin:0 auto;max-width:var(--ha-view-sections-column-max-width,500px)}.content .element-editor{padding-inline-end:var(--ha-space-2);margin-inline-start:var(--ha-space-1);margin-bottom:0}@media (min-width:1000px){.content{flex-direction:row;max-height:var(--code-mirror-max-height)}.content>.element-editor{padding-inline-end:var(--ha-space-4)}.content>.element-editor,.content>.element-preview{flex-basis:0;flex-grow:1;flex-shrink:1;min-width:0;height:auto}.content hui-card{padding:8px 10px;margin:auto 0px;max-width:500px}.content hui-section{padding:8px 10px;margin:auto 0px;max-width:var(--ha-view-sections-column-max-width,500px)}}.hidden{display:none}.element-editor{margin-bottom:8px}.blur{filter:blur(2px) grayscale(100%)}.element-preview{position:relative;height:max-content;background:var(--primary-background-color);padding:4px;border-radius:var(--ha-border-radius-sm)}.element-preview ha-spinner{top:calc(50% - 24px);left:calc(50% - 24px);position:absolute;z-index:10}hui-card{padding-top:8px;margin-bottom:4px;display:block;width:100%;box-sizing:border-box}.gui-mode-button{margin-right:auto;margin-inline-end:auto;margin-inline-start:initial}ha-dialog ha-icon-button[slot=headerActionItems]{color:var(--secondary-text-color)}.title-enlargeable{display:block}`))]}constructor(...e){super(...e),this.large=!1,this._open=!1,this._saving=!1,this._guiModeAvailable=!0,this._GUImode=!0,this._dirty=!1,this._cardConfigInSection=(0,l.A)(e=>{const i=this._sectionConfig,{cards:t,title:a}=i,n=(0,o.A)(i,L);return Object.assign(Object.assign({},n),{},{cards:e?[e]:[]})})}}(0,n.Cg)([(0,c.MZ)({attribute:!1})],H.prototype,"hass",void 0),(0,n.Cg)([(0,c.MZ)({type:Boolean,reflect:!0})],H.prototype,"large",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_params",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_open",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_cardConfig",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_sectionConfig",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_saving",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_error",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_guiModeAvailable",void 0),(0,n.Cg)([(0,c.P)("hui-card-element-editor")],H.prototype,"_cardEditorEl",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_GUImode",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_documentationURL",void 0),(0,n.Cg)([(0,c.wk)()],H.prototype,"_dirty",void 0),H=(0,n.Cg)([(0,c.EM)("hui-dialog-edit-card")],H),a()}catch(L){a(L)}})},77859:function(e,i,t){"use strict";t.d(i,{R:function(){return d},W:function(){return s}});var a=t(45291),o=t(36918);const n={"energy-date-selection":"energy/#energy-date-picker","energy-compare":"energy/#energy-compare-alert","energy-usage-graph":"energy/#energy-usage-graph","energy-solar-graph":"energy/#solar-production-graph","energy-gas-graph":"energy/#gas-consumption-graph","energy-water-graph":"energy/#water-consumption-graph","energy-distribution":"energy/#energy-distribution","energy-sources-table":"energy/#energy-sources-table","energy-grid-balance":"energy/#grid-energy-balance","energy-grid-neutrality-gauge":"energy/#grid-neutrality-gauge","energy-solar-consumed-gauge":"energy/#solar-consumed-gauge","energy-carbon-consumed-gauge":"energy/#carbon-consumed-gauge","energy-self-sufficiency-gauge":"energy/#self-sufficiency-gauge","energy-devices-graph":"energy/#devices-energy-graph","energy-devices-detail-graph":"energy/#detail-devices-energy-graph","energy-sankey":"energy/#sankey-energy-graph","power-sources-graph":"energy/#power-sources-graph"},r=59509==t.j?{"power-total":"energy/#power-consumption-badge","water-total":"energy/#water-flow-rate-badge","gas-total":"energy/#gas-flow-rate-badge"}:null,s=(e,i)=>{var t;return(0,a.c8)(i)?null===(t=(0,a.wi)((0,a.Iu)(i)))||void 0===t?void 0:t.documentationURL:`${(0,o.o)(e,"/dashboards/")}${n[i]||i}`},d=(e,i)=>{var t;return(0,a.c8)(i)?null===(t=(0,a.b$)((0,a.Iu)(i)))||void 0===t?void 0:t.documentationURL:`${(0,o.o)(e,"/dashboards/")}${r[i]||"badges"}`}},92255:function(e,i,t){"use strict";t.d(i,{f:function(){return o}});var a=t(81619);const o=(e,i)=>(0,a.P)(e,{message:i.localize("ui.common.successfully_saved")})}}]);