iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 10.7 kB
JavaScript
export const __rspack_esm_id=51746;export const __rspack_esm_ids=[51746];export const __webpack_modules__={34370(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(e,i,t){t.a(e,async function(e,a){try{t.r(i),t.d(i,{HuiDialogEditCard:()=>z});var o=t(62826),n=t(34370),r=t.n(n),s=t(5124),d=t(22441),c=t(22786),l=t(1087),h=t(15638),g=t(64481),p=t(18350),_=t(72554),u=(t(93444),t(26300)),m=t(65829),y=t(45291),v=t(65063),f=t(14503),b=t(81619),C=t(92255),w=t(46856),x=t(26004),$=t(77859),k=t(97962),A=e([p,_,u,m,w,x,k]);[p,_,u,m,w,x,k]=A.then?(await A)():A;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",L="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 z extends s.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=r()(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,l.r)(this,"dialog-closed",{dialog:this.localName})}updated(e){if(!this._cardConfig||!e.has("_cardConfig"))return;const i=e.get("_cardConfig");i?.type!==this._cardConfig.type&&(this._documentationURL=(0,$.W)(this.hass,this._cardConfig.type))}render(){if(!this._params||!this._cardConfig)return s.s6;let e;if(this._cardConfig.type){let i;(0,y.c8)(this._cardConfig.type)?(i=(0,y.wi)((0,y.Iu)(this._cardConfig.type))?.name,i?.toLowerCase().endsWith(" card")&&(i=i.substring(0,i.length-5))):i=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:i})}else e=this.hass.localize("ui.panel.lovelace.editor.edit_card.header");return s.qy` <ha-dialog .open="${this._open}" .width="${this.large?"full":"large"}" prevent-scrim-close ="${this._ignoreKeydown}" ="${this._dialogClosed}" ="${this._opened}"> <ha-icon-button slot="headerNavigationIcon" ="${this._cancel}" .label="${this.hass.localize("ui.common.close")}" .path="${M}"></ha-icon-button> <span slot="headerTitle" class="title-enlargeable" ="${this._enlarge}">${e}</span> ${void 0!==this._documentationURL?s.qy` <ha-icon-button .path="${L}" slot="headerActionItems" href="${this._documentationURL}" title="${this.hass.localize("ui.panel.lovelace.menu.help")}" target="_blank" rel="noreferrer" dir="${(0,h.Vc)(this.hass)}"></ha-icon-button> `:s.s6} <div class="content"> <div class="element-editor ha-scrollbar"> <hui-card-element-editor autofocus .showVisibilityTab="${"conditional"!==this._cardConfig.type}" .sectionConfig="${this._sectionConfig}" .hass="${this.hass}" .lovelace="${this._params.lovelaceConfig}" .value="${this._cardConfig}" in-dialog -changed="${this._handleConfigChanged}" -changed="${this._handleGUIModeChanged}" -save="${this._save}"></hui-card-element-editor> </div> <div class="element-preview ha-scrollbar"> ${this._sectionConfig?s.qy` <hui-section .hass="${this.hass}" .config="${this._cardConfigInSection(this._cardConfig)}" preview class="${this._error?"blur":""}"></hui-section> `:s.qy` <hui-card .hass="${this.hass}" .config="${this._cardConfig}" preview class="${this._error?"blur":""}"></hui-card> `} ${this._error?s.qy` <ha-spinner aria-label="Can't update card"></ha-spinner> `:""} </div> </div> <ha-dialog-footer slot="footer"> ${void 0!==this._cardConfig?s.qy` <ha-button slot="secondaryAction" ="${this._toggleMode}" .disabled="${!this._guiModeAvailable}" class="gui-mode-button" appearance="plain"> ${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")} </ha-button> `:""} <ha-button appearance="plain" slot="secondaryAction" ="${this._cancel}"> ${this.hass.localize("ui.common.cancel")} </ha-button> ${void 0!==this._cardConfig&&this._dirty?s.qy` <ha-button slot="primaryAction" ?disabled="${!this._canSave}" ="${this._save}" .loading="${this._saving}"> ${this.hass.localize("ui.common.save")} </ha-button> `:""} </ha-dialog-footer> </ha-dialog> `}_enlarge(){(0,g.J)(()=>{this.large=!this.large})}_ignoreKeydown(e){e.stopPropagation()}_handleConfigChanged(e){this._cardConfig=r()(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,g.J)(()=>{this._cardEditorEl?.toggleMode()})}_opened(){this._cardEditorEl?.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,v.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,C.f)(this,this.hass),this.closeDialog()}catch(e){(0,b.P)(this,{message:e.message}),this._saving=!1}}else this.closeDialog()}static get styles(){return[f.nA,f.kO,f.dp,s.AH`: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%} all and (max-width:450px),all and (max-height:500px){.content{width:100%;max-width:100%;gap:var(--ha-space-3)}} 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} (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,c.A)(e=>{const{cards:i,title:t,...a}=this._sectionConfig;return{...a,cards:e?[e]:[]}})}}(0,o.Cg)([(0,d.MZ)({attribute:!1})],z.prototype,"hass",void 0),(0,o.Cg)([(0,d.MZ)({type:Boolean,reflect:!0})],z.prototype,"large",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_params",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_open",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_cardConfig",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_sectionConfig",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_saving",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_error",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_guiModeAvailable",void 0),(0,o.Cg)([(0,d.P)("hui-card-element-editor")],z.prototype,"_cardEditorEl",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_GUImode",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_documentationURL",void 0),(0,o.Cg)([(0,d.wk)()],z.prototype,"_dirty",void 0),z=(0,o.Cg)([(0,d.EM)("hui-dialog-edit-card")],z),a()}catch(e){a(e)}})},77859(e,i,t){t.d(i,{R:()=>d,W:()=>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)=>(0,a.c8)(i)?(0,a.wi)((0,a.Iu)(i))?.documentationURL:`${(0,o.o)(e,"/dashboards/")}${n[i]||i}`,d=(e,i)=>(0,a.c8)(i)?(0,a.b$)((0,a.Iu)(i))?.documentationURL:`${(0,o.o)(e,"/dashboards/")}${r[i]||"badges"}`},92255(e,i,t){t.d(i,{f:()=>o});var a=t(81619);const o=(e,i)=>(0,a.P)(e,{message:i.localize("ui.common.successfully_saved")})}};