iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 10 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[59457],{99028:function(t,e,i){i.a(t,async function(t,a){try{i.r(e),i.d(e,{HaIconButtonArrowNext:function(){return _}});i(62953);var o=i(40445),s=i(5124),n=i(67576),c=i(63091),d=i(26300),r=t([d]);d=(r.then?(await r)():r)[0];let l,h=t=>t;const g="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z",u="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z";class _ extends s.WF{render(){var t;return(0,s.qy)(l||(l=h` <ha-icon-button .disabled="${0}" .label="${0}" .path="${0}"></ha-icon-button> `),this.disabled,this.label||(null===(t=this.hass)||void 0===t?void 0:t.localize("ui.common.next"))||"Next",this._icon)}constructor(...t){super(...t),this.disabled=!1,this._icon="rtl"===c.G.document.dir?g:u}}(0,o.Cg)([(0,n.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)({type:Boolean})],_.prototype,"disabled",void 0),(0,o.Cg)([(0,n.MZ)()],_.prototype,"label",void 0),(0,o.Cg)([(0,n.wk)()],_.prototype,"_icon",void 0),_=(0,o.Cg)([(0,n.EM)("ha-icon-button-arrow-next")],_),a()}catch(l){a(l)}})},42520:function(t,e,i){i.a(t,async function(t,a){try{i.r(e),i.d(e,{HuiGridCardEditor:function(){return u}});i(62953);var o=i(40445),s=i(67576),n=i(63533),c=i(84698),d=i(59008),r=i(63577),l=t([r,d]);[r,d]=l.then?(await l)():l;const h=(0,n.kp)(c.H,(0,n.Ik)({cards:(0,n.YO)((0,n.bz)()),title:(0,n.lq)((0,n.Yj)()),square:(0,n.lq)((0,n.zM)()),columns:(0,n.lq)((0,n.ai)())})),g=[{type:"grid",name:"",schema:[{name:"title",selector:{text:{}}},{name:"columns",default:3,selector:{number:{min:1,mode:"box"}}},{name:"square",selector:{boolean:{}}}]}];class u extends d.HuiStackCardEditor{setConfig(t){(0,n.vA)(t,h),this._config=t}formData(){return Object.assign({square:!0},this._config)}constructor(...t){super(...t),this._schema=g,this._computeLabelCallback=t=>this.hass.localize(`ui.panel.lovelace.editor.card.grid.${t.name}`)}}u=(0,o.Cg)([(0,s.EM)("hui-grid-card-editor")],u),a()}catch(h){a(h)}})},59008:function(t,e,i){i.a(t,async function(t,a){try{i.r(e),i.d(e,{HuiStackCardEditor:function(){return Z}});i(18111),i(61701),i(45367),i(92731),i(3362),i(62953);var o=i(40445),s=i(34271),n=i(5124),c=i(67576),d=i(19771),r=i(63533),l=i(93905),h=i(1087),g=i(26300),u=i(99028),_=i(90248),p=i(66289),b=(i(62647),i(97962)),f=i(81797),C=i(84698),v=i(7382),m=t([g,u,_,p,b,f]);[g,u,_,p,b,f]=m.then?(await m)():m;let H,M,y,$,V,A,k=t=>t;const L="M8,3A2,2 0 0,0 6,5V9A2,2 0 0,1 4,11H3V13H4A2,2 0 0,1 6,15V19A2,2 0 0,0 8,21H10V19H8V14A2,2 0 0,0 6,12A2,2 0 0,0 8,10V5H10V3M16,3A2,2 0 0,1 18,5V9A2,2 0 0,0 20,11H21V13H20A2,2 0 0,0 18,15V19A2,2 0 0,1 16,21H14V19H16V14A2,2 0 0,1 18,12A2,2 0 0,1 16,10V5H14V3H16Z",w="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z",x="M19,3L13,9L15,11L22,4V3M12,12.5A0.5,0.5 0 0,1 11.5,12A0.5,0.5 0 0,1 12,11.5A0.5,0.5 0 0,1 12.5,12A0.5,0.5 0 0,1 12,12.5M6,20A2,2 0 0,1 4,18C4,16.89 4.9,16 6,16A2,2 0 0,1 8,18C8,19.11 7.1,20 6,20M6,8A2,2 0 0,1 4,6C4,4.89 4.9,4 6,4A2,2 0 0,1 8,6C8,7.11 7.1,8 6,8M9.64,7.64C9.87,7.14 10,6.59 10,6A4,4 0 0,0 6,2A4,4 0 0,0 2,6A4,4 0 0,0 6,10C6.59,10 7.14,9.87 7.64,9.64L10,12L7.64,14.36C7.14,14.13 6.59,14 6,14A4,4 0 0,0 2,18A4,4 0 0,0 6,22A4,4 0 0,0 10,18C10,17.41 9.87,16.86 9.64,16.36L12,14L19,21H22V20L9.64,7.64Z",z="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",E="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z",j="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",q=(0,r.kp)(C.H,(0,r.Ik)({cards:(0,r.YO)((0,r.bz)()),title:(0,r.lq)((0,r.Yj)())})),I=[{name:"title",selector:{text:{}}}];class Z extends n.WF{setConfig(t){(0,r.vA)(t,q),this._config=t}focusYamlEditor(){var t;null===(t=this._cardEditorEl)||void 0===t||t.focusYamlEditor()}formData(){return this._config}render(){if(!this.hass||!this._config)return n.s6;const t=this._selectedCard,e=this._config.cards.length,i=!this._cardEditorEl||this._GUImode;return(0,n.qy)(H||(H=k` <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeLabel="${0}" -changed="${0}"></ha-form> <div class="card-config"> <div class="toolbar"> <ha-tab-group -tab-show="${0}"> ${0} </ha-tab-group> <ha-icon-button ="${0}" .path="${0}"></ha-icon-button> </div> <div id="editor"> ${0} </div> </div> `),this.hass,this.formData(),this._schema,this._computeLabelCallback,this._valueChanged,this._handleSelectedCard,this._config.cards.map((e,i)=>(0,n.qy)(M||(M=k`<ha-tab-group-tab slot="nav" .panel="${0}" .active="${0}"> ${0} </ha-tab-group-tab>`),i,i===t,i+1)),this._handleAddCard,j,t<e?(0,n.qy)(y||(y=k` <div id="card-options"> <ha-icon-button class="gui-mode-button" ="${0}" .disabled="${0}" .label="${0}" .path="${0}"></ha-icon-button> <ha-icon-button-arrow-prev .disabled="${0}" .label="${0}" ="${0}" .move="${0}"></ha-icon-button-arrow-prev> <ha-icon-button-arrow-next .label="${0}" .disabled="${0}" ="${0}" .move="${0}"></ha-icon-button-arrow-next> <ha-icon-button .label="${0}" .path="${0}" ="${0}"></ha-icon-button> <ha-icon-button .label="${0}" .path="${0}" ="${0}"></ha-icon-button> <ha-icon-button .label="${0}" .path="${0}" ="${0}"></ha-icon-button> </div> ${0} `),this._toggleMode,!this._guiModeAvailable,this.hass.localize(i?"ui.panel.lovelace.editor.edit_card.show_code_editor":"ui.panel.lovelace.editor.edit_card.show_visual_editor"),i?L:E,0===t,this.hass.localize("ui.panel.lovelace.editor.edit_card.move_before"),this._handleMove,-1,this.hass.localize("ui.panel.lovelace.editor.edit_card.move_after"),t===e-1,this._handleMove,1,this.hass.localize("ui.panel.lovelace.editor.edit_card.copy"),w,this._handleCopyCard,this.hass.localize("ui.panel.lovelace.editor.edit_card.cut"),x,this._handleCutCard,this.hass.localize("ui.panel.lovelace.editor.edit_card.delete"),z,this._handleDeleteCard,(0,d.D)(this._getKey(this._config.cards,t),(0,n.qy)($||($=k`<hui-card-element-editor .hass="${0}" .value="${0}" .lovelace="${0}" -changed="${0}" -changed="${0}"></hui-card-element-editor>`),this.hass,this._config.cards[t],this.lovelace,this._handleConfigChanged,this._handleGUIModeChanged))):(0,n.qy)(V||(V=k` <hui-card-picker .hass="${0}" .lovelace="${0}" -changed="${0}"></hui-card-picker> `),this.hass,this.lovelace,this._handleCardPicked))}_getKey(t,e){const i=`${e}-${t.length}`;return this._keys.has(i)||this._keys.set(i,Math.random().toString()),this._keys.get(i)}async _handleAddCard(){this._selectedCard=this._config.cards.length}_handleSelectedCard(t){this._GUImode=!0,this._guiModeAvailable=!0,this._selectedCard=parseInt(t.detail.name,10)}_handleConfigChanged(t){if(t.stopPropagation(),!this._config)return;const e=[...this._config.cards],i=t.detail.config;e[this._selectedCard]=i,this._config=Object.assign(Object.assign({},this._config),{},{cards:e}),this._guiModeAvailable=t.detail.guiModeAvailable,(0,h.r)(this,"config-changed",{config:this._config})}_handleCardPicked(t){if(t.stopPropagation(),!this._config)return;const e=t.detail.config,i=[...this._config.cards,e];this._config=Object.assign(Object.assign({},this._config),{},{cards:i}),this._keys.clear(),(0,h.r)(this,"config-changed",{config:this._config})}_handleCopyCard(){this._config&&(this._clipboard=(0,s.A)(this._config.cards[this._selectedCard]))}_handleCutCard(){this._handleCopyCard(),this._handleDeleteCard()}_handleDeleteCard(){if(!this._config)return;const t=[...this._config.cards];t.splice(this._selectedCard,1),this._config=Object.assign(Object.assign({},this._config),{},{cards:t}),this._selectedCard=Math.max(0,this._selectedCard-1),this._keys.clear(),(0,h.r)(this,"config-changed",{config:this._config})}_handleMove(t){if(!this._config)return;const e=t.currentTarget.move,i=this._selectedCard+e,a=[...this._config.cards],o=a.splice(this._selectedCard,1)[0];a.splice(i,0,o),this._config=Object.assign(Object.assign({},this._config),{},{cards:a}),this._selectedCard=i,this._keys.clear(),(0,h.r)(this,"config-changed",{config:this._config})}_handleGUIModeChanged(t){t.stopPropagation(),this._GUImode=t.detail.guiMode,this._guiModeAvailable=t.detail.guiModeAvailable}_toggleMode(){var t;null===(t=this._cardEditorEl)||void 0===t||t.toggleMode()}_valueChanged(t){(0,h.r)(this,"config-changed",{config:t.detail.value})}static get styles(){return[v.U,(0,n.AH)(A||(A=k`.toolbar{display:flex;justify-content:space-between;align-items:center}ha-tab-group{flex-grow:1;min-width:0;--ha-tab-track-color:var(--card-background-color)}#card-options{display:flex;justify-content:flex-end;width:100%}#editor{border:1px solid var(--divider-color);padding:12px} (max-width:450px){#editor{margin:0 -12px}}.gui-mode-button{margin-right:auto;margin-inline-end:auto;margin-inline-start:initial}`))]}constructor(...t){super(...t),this._selectedCard=0,this._GUImode=!0,this._guiModeAvailable=!0,this._keys=new Map,this._schema=I,this._computeLabelCallback=t=>this.hass.localize(`ui.panel.lovelace.editor.card.${this._config.type}.${t.name}`)}}(0,o.Cg)([(0,c.MZ)({attribute:!1})],Z.prototype,"hass",void 0),(0,o.Cg)([(0,c.MZ)({attribute:!1})],Z.prototype,"lovelace",void 0),(0,o.Cg)([(0,l.I)({key:"dashboardCardClipboard",state:!1,subscribe:!1,storage:"sessionStorage"})],Z.prototype,"_clipboard",void 0),(0,o.Cg)([(0,c.wk)()],Z.prototype,"_config",void 0),(0,o.Cg)([(0,c.wk)()],Z.prototype,"_selectedCard",void 0),(0,o.Cg)([(0,c.wk)()],Z.prototype,"_GUImode",void 0),(0,o.Cg)([(0,c.wk)()],Z.prototype,"_guiModeAvailable",void 0),(0,o.Cg)([(0,c.P)("hui-card-element-editor")],Z.prototype,"_cardEditorEl",void 0),Z=(0,o.Cg)([(0,c.EM)("hui-stack-card-editor")],Z),a()}catch(H){a(H)}})},84698:function(t,e,i){i.d(e,{H:function(){return o}});var a=i(63533);const o=(0,a.Ik)({type:(0,a.Yj)(),view_layout:(0,a.bz)(),layout_options:(0,a.bz)(),grid_options:(0,a.bz)(),visibility:(0,a.bz)(),disabled:(0,a.lq)((0,a.zM)())})}}]);