UNPKG

iobroker.lovelace

Version:

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

1 lines 5.57 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[116],{64138:function(e,t,i){i.a(e,async function(e,a){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 s=i(40445),o=i(5124),r=i(67576),n=i(22786),l=i(1087),c=i(700),h=(i(75064),i(38508)),u=(i(47680),e([h]));h=(u.then?(await u)():u)[0];let d,p,g,v=e=>e,m=[],_=!1;const y=(e,t)=>{var i;const a=`${t}:${e.name}`,s=e.name,o=s.split("-"),r=null!==(i=e.keywords)&&void 0!==i?i:[],n={iconName:s};return o.forEach((e,t)=>{n[`part${t}`]=e}),r.forEach((e,t)=>{n[`keyword${t}`]=e}),{id:a,primary:a,icon:a,search_labels:n,sorting_label:a}},f=async()=>{_=!0;const e=await i.e(81340).then(i.t.bind(i,25143,19));m=e.default.map(e=>y(e,"mdi"));const t=[];Object.keys(c.y).forEach(e=>{t.push(b(e))}),(await Promise.all(t)).forEach(e=>{m.push(...e)})},b=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`),[]}},$=e=>(0,o.qy)(d||(d=v` <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 o.WF{render(){return(0,o.qy)(p||(p=v` <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,$,this._icon,this.label,this._value,this._filterIcons,this._valueChanged)}firstUpdated(){_||f().then(()=>{this._getIconPickerItems=()=>m,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=()=>m,this._filterIcons=(0,n.A)((e,t,i)=>{const a=e.toLowerCase().replace(/\s+/g,"-"),s=null!=i&&i.length?i:t;if(!a.length)return s;const o=[];for(const r of s){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(a)?o.push({item:r,rank:1}):t.includes(a)?o.push({item:r,rank:2}):i.includes(a)?o.push({item:r,rank:3}):t.some(e=>e.includes(a))&&o.push({item:r,rank:4})}return o.sort((e,t)=>e.rank-t.rank).map(e=>e.item)})}}C.styles=(0,o.AH)(g||(g=v`ha-generic-picker{width:100%;display:block}`)),(0,s.Cg)([(0,r.MZ)()],C.prototype,"value",void 0),(0,s.Cg)([(0,r.MZ)()],C.prototype,"label",void 0),(0,s.Cg)([(0,r.MZ)()],C.prototype,"helper",void 0),(0,s.Cg)([(0,r.MZ)()],C.prototype,"placeholder",void 0),(0,s.Cg)([(0,r.MZ)({attribute:"error-message"})],C.prototype,"errorMessage",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"disabled",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"required",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"invalid",void 0),C=(0,s.Cg)([(0,r.EM)("ha-icon-picker")],C),a()}catch(d){a(d)}})},37018:function(e,t,i){i.a(e,async function(e,a){try{i.r(t);i(62953);var s=i(40445),o=i(5124),r=i(67576),n=i(1087),l=i(64138),c=i(91485),h=i(14503),u=e([l,c]);[l,c]=u.then?(await u)():u;let d,p,g=e=>e;class v extends o.WF{set item(e){this._item=e,e?(this._name=e.name||"",this._icon=e.icon||""):(this._name="",this._icon="")}focus(){this.updateComplete.then(()=>{var e;return null===(e=this._focusElement)||void 0===e?void 0:e.focus()})}render(){return this.hass?(0,o.qy)(d||(d=g` <div class="form"> <ha-input .value="${0}" .configValue="${0}" @input="${0}" .label="${0}" auto-validate required .validationMessage="${0}" dialogInitialFocus .disabled="${0}"></ha-input> <ha-icon-picker .hass="${0}" .value="${0}" .configValue="${0}" @value-changed="${0}" .label="${0}" .disabled="${0}"></ha-icon-picker> </div> `),this._name,"name",this._valueChanged,this.hass.localize("ui.dialogs.helper_settings.generic.name"),this.hass.localize("ui.dialogs.helper_settings.required_error_msg"),this.disabled,this.hass,this._icon,"icon",this._valueChanged,this.hass.localize("ui.dialogs.helper_settings.generic.icon"),this.disabled):o.s6}_valueChanged(e){var t;if(!this.new&&!this._item)return;e.stopPropagation();const i=e.target.configValue,a=(null===(t=e.detail)||void 0===t?void 0:t.value)||e.target.value;if(this[`_${i}`]===a)return;const s=Object.assign({},this._item);a?s[i]=a:delete s[i],(0,n.r)(this,"value-changed",{value:s})}static get styles(){return[h.RF,(0,o.AH)(p||(p=g`.form{color:var(--primary-text-color)}.row{padding:var(--ha-space-4) 0}ha-input{margin:var(--ha-space-2) 0}`))]}constructor(...e){super(...e),this.new=!1,this.disabled=!1}}(0,s.Cg)([(0,r.MZ)({attribute:!1})],v.prototype,"hass",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],v.prototype,"new",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],v.prototype,"disabled",void 0),(0,s.Cg)([(0,r.wk)()],v.prototype,"_name",void 0),(0,s.Cg)([(0,r.wk)()],v.prototype,"_icon",void 0),(0,s.Cg)([(0,r.P)("[dialogInitialFocus]")],v.prototype,"_focusElement",void 0),v=(0,s.Cg)([(0,r.EM)("ha-input_button-form")],v),a()}catch(d){a(d)}})}}]);