UNPKG

iobroker.lovelace

Version:

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

1 lines 7.49 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[25291],{64138:function(e,t,i){i.a(e,async function(e,o){try{i.r(t),i.d(t,{HaIconPicker:function(){return C}});i(74423),i(44114),i(26910),i(18111),i(22489),i(7588),i(61701),i(13579),i(3362),i(27495),i(25440),i(62953);var a=i(40445),s=i(5124),r=i(67576),n=i(22786),l=i(1087),c=i(700),h=(i(75064),i(38508)),d=(i(47680),e([h]));h=(d.then?(await d)():d)[0];let u,p,g,m=e=>e,v=[],_=!1;const y=(e,t)=>{var i;const o=`${t}:${e.name}`,a=e.name,s=a.split("-"),r=null!==(i=e.keywords)&&void 0!==i?i:[],n={iconName:a};return s.forEach((e,t)=>{n[`part${t}`]=e}),r.forEach((e,t)=>{n[`keyword${t}`]=e}),{id:o,primary:o,icon:o,search_labels:n,sorting_label:o}},b=async()=>{_=!0;const e=await i.e(81340).then(i.t.bind(i,25143,19));v=e.default.map(e=>y(e,"mdi"));const t=[];Object.keys(c.y).forEach(e=>{t.push(f(e))}),(await Promise.all(t)).forEach(e=>{v.push(...e)})},f=async e=>{try{const t=c.y[e].getIconList;if("function"!=typeof t)return[];return(await t()).map(t=>y(t,e))}catch(t){return console.warn(`Unable to load icon list for ${e} iconset`),[]}},k=e=>(0,s.qy)(u||(u=m` <ha-combo-box-item type="button"> <ha-icon .icon="${0}" slot="start"></ha-icon> ${0} </ha-combo-box-item> `),e.id,e.id);class C extends s.WF{render(){return(0,s.qy)(p||(p=m` <ha-generic-picker allow-custom-value .getItems="${0}" .helper="${0}" .disabled="${0}" .required="${0}" .errorMessage="${0}" .invalid="${0}" .rowRenderer="${0}" .icon="${0}" .label="${0}" .value="${0}" .searchFn="${0}" @value-changed="${0}"> <slot name="start"></slot> </ha-generic-picker> `),this._getIconPickerItems,this.helper,this.disabled,this.required,this.errorMessage,this.invalid,k,this._icon,this.label,this._value,this._filterIcons,this._valueChanged)}firstUpdated(){_||b().then(()=>{this._getIconPickerItems=()=>v,this.requestUpdate()})}_valueChanged(e){e.stopPropagation(),this._setValue(e.detail.value)}_setValue(e){this.value=e,(0,l.r)(this,"value-changed",{value:this._value},{bubbles:!1,composed:!1})}get _icon(){var e;return null!==(e=this.value)&&void 0!==e&&e.length?this.value:this.placeholder}get _value(){return this.value||""}constructor(...e){super(...e),this.disabled=!1,this.required=!1,this.invalid=!1,this._getIconPickerItems=()=>v,this._filterIcons=(0,n.A)((e,t,i)=>{const o=e.toLowerCase().replace(/\s+/g,"-"),a=null!=i&&i.length?i:t;if(!o.length)return a;const s=[];for(const r of a){const e=(r.id.split(":")[1]||r.id).toLowerCase().split("-"),t=r.search_labels?Object.values(r.search_labels).filter(e=>null!==e).map(e=>e.toLowerCase()):[],i=r.id.toLowerCase();e.includes(o)?s.push({item:r,rank:1}):t.includes(o)?s.push({item:r,rank:2}):i.includes(o)?s.push({item:r,rank:3}):t.some(e=>e.includes(o))&&s.push({item:r,rank:4})}return s.sort((e,t)=>e.rank-t.rank).map(e=>e.item)})}}C.styles=(0,s.AH)(g||(g=m`ha-generic-picker{width:100%;display:block}`)),(0,a.Cg)([(0,r.MZ)()],C.prototype,"value",void 0),(0,a.Cg)([(0,r.MZ)()],C.prototype,"label",void 0),(0,a.Cg)([(0,r.MZ)()],C.prototype,"helper",void 0),(0,a.Cg)([(0,r.MZ)()],C.prototype,"placeholder",void 0),(0,a.Cg)([(0,r.MZ)({attribute:"error-message"})],C.prototype,"errorMessage",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"disabled",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"required",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"invalid",void 0),C=(0,a.Cg)([(0,r.EM)("ha-icon-picker")],C),o()}catch(u){o(u)}})},89441:function(e,t,i){i.d(t,{O:function(){return a}});i(3362),i(62953);var o=i(1087);const a=e=>class extends e{closeDialog(e){var t;if(this._closePromise)return this._closePromise;const i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("ha-adaptive-popover, ha-adaptive-dialog, ha-dialog, ha-bottom-sheet");return i&&(this._closePromise=new Promise(e=>{this._closeResolve=e}),i.open=!1),this._closePromise||!0}connectedCallback(){super.connectedCallback(),this.addEventListener("closed",this._removeDialog,{once:!0})}disconnectedCallback(){this._dialogClosedFired||(0,o.r)(this,"dialog-closed",{dialog:this.localName}),this.removeEventListener("closed",this._removeDialog),super.disconnectedCallback()}constructor(...e){super(...e),this.dialogNext=!0,this._dialogClosedFired=!1,this._removeDialog=e=>{var t;e.stopPropagation(),null===(t=this._closeResolve)||void 0===t||t.call(this,!0),this._closePromise=void 0,this._closeResolve=void 0,this._dialogClosedFired=!0,(0,o.r)(this,"dialog-closed",{dialog:this.localName}),this.remove()}}}},81574:function(e,t,i){i.a(e,async function(e,o){try{i.r(t);i(3362),i(42762);var a=i(40445),s=i(35211),r=i(5124),n=i(67576),l=i(38962),c=i(18350),h=i(72554),d=(i(93444),i(64138)),u=i(91485),p=i(22792),g=i(89441),m=i(14503),v=e([l,c,h,d,u]);[l,c,h,d,u]=v.then?(await v)():v;let _,y,b,f=e=>e;class k extends((0,g.O)(r.WF)){connectedCallback(){var e,t;(super.connectedCallback(),null!==(e=this.params)&&void 0!==e&&e.entry)?(this._name=this.params.entry.name||"",this._icon=this.params.entry.icon||null):(this._name=(null===(t=this.params)||void 0===t?void 0:t.suggestedName)||"",this._icon=null)}render(){var e;if(!this.params)return r.s6;const t=this.params.entry,i=!this._isNameValid();return(0,r.qy)(_||(_=f` <ha-dialog open header-title="${0}" prevent-scrim-close> ${0} <div class="form"> <ha-input .value="${0}" @input="${0}" .label="${0}" .validationMessage="${0}" required autofocus></ha-input> <ha-icon-picker .value="${0}" @value-changed="${0}" .label="${0}"></ha-icon-picker> </div> <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" @click="${0}"> ${0} </ha-button> <ha-button slot="primaryAction" @click="${0}" .disabled="${0}"> ${0} </ha-button> </ha-dialog-footer> </ha-dialog> `),t?this._i18n.localize("ui.panel.config.category.editor.edit"):this._i18n.localize("ui.panel.config.category.editor.create"),this._error?(0,r.qy)(y||(y=f`<ha-alert alert-type="error">${0}</ha-alert>`),this._error):"",this._name,this._nameChanged,this._i18n.localize("ui.panel.config.category.editor.name"),this._i18n.localize("ui.panel.config.category.editor.required_error_msg"),null!==(e=this._icon)&&void 0!==e?e:void 0,this._iconChanged,this._i18n.localize("ui.panel.config.category.editor.icon"),this.closeDialog,this._i18n.localize("ui.common.cancel"),this._updateEntry,i||!!this._submitting,t?this._i18n.localize("ui.common.save"):this._i18n.localize("ui.common.add"))}_isNameValid(){return""!==this._name.trim()}_nameChanged(e){var t;this._error=void 0,this._name=null!==(t=e.target.value)&&void 0!==t?t:""}_iconChanged(e){this._error=void 0,this._icon=e.detail.value}async _updateEntry(){const e=!this.params.entry;let t;this._submitting=!0;try{const i={name:this._name.trim(),icon:this._icon||(e?void 0:null)};t=e?await this.params.createEntry(i):await this.params.updateEntry(i),this.closeDialog()}catch(i){this._error=i.message||this._i18n.localize("ui.panel.config.category.editor.unknown_error")}finally{this._submitting=!1}return t}static get styles(){return[m.nA,(0,r.AH)(b||(b=f`ha-icon-picker{margin-bottom:var(--ha-space-3)}`))]}}(0,a.Cg)([(0,n.wk)(),(0,s.Fg)({context:p.D5,subscribe:!0})],k.prototype,"_i18n",void 0),(0,a.Cg)([(0,n.wk)()],k.prototype,"_name",void 0),(0,a.Cg)([(0,n.wk)()],k.prototype,"_icon",void 0),(0,a.Cg)([(0,n.wk)()],k.prototype,"_error",void 0),(0,a.Cg)([(0,n.wk)()],k.prototype,"_submitting",void 0),k=(0,a.Cg)([(0,n.EM)("dialog-category-registry-detail")],k),o()}catch(_){o(_)}})}}]);