iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 7.44 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[98983],{35930:function(t,e,o){o.a(t,async function(t,i){try{o.r(e);o(3362),o(62953);var s=o(40445),a=o(5124),r=o(67576),n=o(1087),c=o(38962),h=o(18350),l=o(72554),p=(o(93444),o(59241)),g=o(14503),d=o(16536),_=t([c,h,l,d]);[c,h,l,d]=_.then?(await _)():_;let u,y,m,v=t=>t;class C extends a.WF{showDialog(t){this._params=t,this._scope=t.scope,this._category=t.entityReg.categories[t.scope],this._error=void 0,this._open=!0}closeDialog(){this._open=!1}_dialogClosed(){this._error="",this._params=void 0,(0,n.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._params)return a.s6;const t=this._params.entityReg.categories[this._params.scope];return(0,a.qy)(u||(u=v` <ha-dialog .open="${0}" header-title="${0}" ="${0}"> ${0} <div class="form"> <ha-category-picker .hass="${0}" .scope="${0}" .label="${0}" .value="${0}" -changed="${0}" autofocus></ha-category-picker> </div> <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" ="${0}"> ${0} </ha-button> <ha-button slot="primaryAction" ="${0}" .disabled="${0}"> ${0} </ha-button> </ha-dialog-footer> </ha-dialog> `),this._open,t?this.hass.localize("ui.panel.config.category.assign.edit"):this.hass.localize("ui.panel.config.category.assign.assign"),this._dialogClosed,this._error?(0,a.qy)(y||(y=v`<ha-alert alert-type="error">${0}</ha-alert>`),this._error):"",this.hass,this._scope,this.hass.localize("ui.components.category-picker.category"),this._category,this._categoryChanged,this.closeDialog,this.hass.localize("ui.common.cancel"),this._updateEntry,!!this._submitting,this.hass.localize("ui.common.save"))}_categoryChanged(t){t.detail.value||(this._category=void 0),this._category=t.detail.value}async _updateEntry(){this._submitting=!0,this._error=void 0;try{await(0,p.G_)(this.hass,this._params.entityReg.entity_id,{categories:{[this._scope]:this._category||null}}),this.closeDialog()}catch(t){this._error=t.message||this.hass.localize("ui.panel.config.category.assign.unknown_error")}finally{this._submitting=!1}}static get styles(){return[g.nA,(0,a.AH)(m||(m=v`ha-icon-picker{display:block;margin-bottom:16px}`))]}constructor(...t){super(...t),this._open=!1}}(0,s.Cg)([(0,r.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,s.Cg)([(0,r.wk)()],C.prototype,"_scope",void 0),(0,s.Cg)([(0,r.wk)()],C.prototype,"_category",void 0),(0,s.Cg)([(0,r.wk)()],C.prototype,"_error",void 0),(0,s.Cg)([(0,r.wk)()],C.prototype,"_params",void 0),(0,s.Cg)([(0,r.wk)()],C.prototype,"_submitting",void 0),(0,s.Cg)([(0,r.wk)()],C.prototype,"_open",void 0),C=(0,s.Cg)([(0,r.EM)("dialog-assign-category")],C),i()}catch(u){i(u)}})},16536:function(t,e,o){o.a(t,async function(t,e){try{o(74423),o(18111),o(22489),o(61701),o(13579),o(45367),o(92731),o(3362),o(17642),o(58004),o(33853),o(45876),o(32475),o(15024),o(31698),o(62953);var i=o(40445),s=o(5124),a=o(67576),r=o(22786),n=o(1087),c=o(38508),h=(o(67094),o(76570)),l=o(54706),p=o(90986),g=t([c]);c=(g.then?(await g)():g)[0];let d,_,u,y,m,v,C=t=>t;const $="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",k="M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4C2.89,2 2,2.89 2,4V11C2,11.55 2.22,12.05 2.59,12.41L11.58,21.41C11.95,21.77 12.45,22 13,22C13.55,22 14.05,21.77 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.44 21.77,11.94 21.41,11.58Z",b="___ADD_NEW___";class f extends((0,l.E)(s.WF)){willUpdate(t){var e;this._pendingCategoryId&&t.has("_categories")&&null!==(e=this._categories)&&void 0!==e&&e.some(t=>t.category_id===this._pendingCategoryId)&&(this._setValue(this._pendingCategoryId),this._pendingCategoryId=void 0)}async open(){var t;await this.updateComplete,await(null===(t=this._picker)||void 0===t?void 0:t.open())}hassSubscribe(){return[(0,h.Ar)(this.hass.connection,this.scope,t=>{this._categories=t})]}render(){const t=this._computeValueRenderer(this._categories);return(0,s.qy)(d||(d=C` <ha-generic-picker .hass="${0}" .autofocus="${0}" .label="${0}" .placeholder="${0}" .value="${0}" .notFoundLabel="${0}" .emptyLabel="${0}" .getItems="${0}" .getAdditionalItems="${0}" .valueRenderer="${0}" .unknownItemText="${0}" -changed="${0}"> </ha-generic-picker> `),this.hass,this.autofocus,this.label,this.placeholder,this.value,this._notFoundLabel,this.hass.localize("ui.components.category-picker.no_categories"),this._getItems,this._getAdditionalItems,t,this.hass.localize("ui.components.category-picker.unknown"),this._valueChanged)}_valueChanged(t){t.stopPropagation();const e=t.detail.value;if(e){if(e.startsWith(b)){this.hass.loadFragmentTranslation("config");const t=e.substring(b.length);return void(0,p.S)(this,{scope:this.scope,suggestedName:t,createEntry:async t=>{var e;const o=await(0,h.s_)(this.hass,this.scope,t);return null!==(e=this._categories)&&void 0!==e&&e.some(t=>t.category_id===o.category_id)?this._setValue(o.category_id):this._pendingCategoryId=o.category_id,o}})}this._setValue(e)}else this._setValue(void 0)}_setValue(t){this.value=t,setTimeout(()=>{(0,n.r)(this,"value-changed",{value:t}),(0,n.r)(this,"change")},0)}constructor(...t){super(...t),this.noAdd=!1,this.disabled=!1,this.required=!1,this.hassSubscribeRequiredHostProps=["scope"],this._categoryMap=(0,r.A)(t=>t?new Map(t.map(t=>[t.category_id,t])):new Map),this._computeValueRenderer=(0,r.A)(t=>e=>{const o=this._categoryMap(t).get(e);return o?(0,s.qy)(u||(u=C` ${0} <span slot="headline">${0}</span> `),o.icon?(0,s.qy)(y||(y=C`<ha-icon slot="start" .icon="${0}"></ha-icon>`),o.icon):(0,s.qy)(m||(m=C`<ha-svg-icon slot="start" .path="${0}"></ha-svg-icon>`),k),o.name):(0,s.qy)(_||(_=C` <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> <span slot="headline">${0}</span> `),k,e)}),this._getCategories=(0,r.A)(t=>{if(!t)return;return t.map(t=>({id:t.category_id,primary:t.name,icon:t.icon||void 0,icon_path:t.icon?void 0:k,sorting_label:t.name}))}),this._getItems=()=>this._getCategories(this._categories),this._allCategoryNames=(0,r.A)(t=>t?[...new Set(t.map(t=>t.name.toLowerCase()).filter(Boolean))]:[]),this._getAdditionalItems=t=>{if(this.noAdd)return[];const e=this._allCategoryNames(this._categories);return t&&!e.includes(t.toLowerCase())?[{id:b+t,primary:this.hass.localize("ui.components.category-picker.add_new_suggestion",{name:t}),icon_path:$}]:[{id:b,primary:this.hass.localize("ui.components.category-picker.add_new"),icon_path:$}]},this._notFoundLabel=t=>this.hass.localize("ui.components.category-picker.no_match",{term:(0,s.qy)(v||(v=C`<b>‘${0}’</b>`),t)})}}(0,i.Cg)([(0,a.MZ)({attribute:!1})],f.prototype,"hass",void 0),(0,i.Cg)([(0,a.MZ)()],f.prototype,"scope",void 0),(0,i.Cg)([(0,a.MZ)()],f.prototype,"label",void 0),(0,i.Cg)([(0,a.MZ)()],f.prototype,"value",void 0),(0,i.Cg)([(0,a.MZ)()],f.prototype,"helper",void 0),(0,i.Cg)([(0,a.MZ)()],f.prototype,"placeholder",void 0),(0,i.Cg)([(0,a.MZ)({type:Boolean,attribute:"no-add"})],f.prototype,"noAdd",void 0),(0,i.Cg)([(0,a.MZ)({type:Boolean})],f.prototype,"disabled",void 0),(0,i.Cg)([(0,a.MZ)({type:Boolean})],f.prototype,"required",void 0),(0,i.Cg)([(0,a.wk)()],f.prototype,"_categories",void 0),(0,i.Cg)([(0,a.P)("ha-generic-picker")],f.prototype,"_picker",void 0),(0,i.Cg)([(0,a.wk)()],f.prototype,"_pendingCategoryId",void 0),f=(0,i.Cg)([(0,a.EM)("ha-category-picker")],f),e()}catch(d){e(d)}})}}]);