UNPKG

iobroker.lovelace

Version:

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

1 lines 5.15 kB
export const __rspack_esm_id=116;export const __rspack_esm_ids=[116];export const __webpack_modules__={64138(e,t,i){i.a(e,async function(e,a){try{i.r(t),i.d(t,{HaIconPicker:()=>y});i(74423),i(44114),i(18111),i(22489),i(7588),i(61701),i(13579);var s=i(62826),o=i(5124),r=i(22441),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=!1;const g=(e,t)=>{const i=`${t}:${e.name}`,a=e.name,s=a.split("-"),o=e.keywords??[],r={iconName:a};return s.forEach((e,t)=>{r[`part${t}`]=e}),o.forEach((e,t)=>{r[`keyword${t}`]=e}),{id:i,primary:i,icon:i,search_labels:r,sorting_label:i}},v=async()=>{p=!0;const e=await i.e(81340).then(i.t.bind(i,25143,19));u=e.default.map(e=>g(e,"mdi"));const t=[];Object.keys(c.y).forEach(e=>{t.push(_(e))}),(await Promise.all(t)).forEach(e=>{u.push(...e)})},_=async e=>{try{const t=c.y[e].getIconList;if("function"!=typeof t)return[];return(await t()).map(t=>g(t,e))}catch(t){return console.warn(`Unable to load icon list for ${e} iconset`),[]}},m=e=>o.qy` <ha-combo-box-item type="button"> <ha-icon .icon="${e.id}" slot="start"></ha-icon> ${e.id} </ha-combo-box-item> `;class y extends o.WF{render(){return o.qy` <ha-generic-picker allow-custom-value .getItems="${this._getIconPickerItems}" .helper="${this.helper}" .disabled="${this.disabled}" .required="${this.required}" .errorMessage="${this.errorMessage}" .invalid="${this.invalid}" .rowRenderer="${m}" .icon="${this._icon}" .label="${this.label}" .value="${this._value}" .searchFn="${this._filterIcons}" @value-changed="${this._valueChanged}"> <slot name="start"></slot> </ha-generic-picker> `}firstUpdated(){p||v().then(()=>{this._getIconPickerItems=()=>u,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(){return this.value?.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=()=>u,this._filterIcons=(0,n.A)((e,t,i)=>{const a=e.toLowerCase().replace(/\s+/g,"-"),s=i?.length?i:t;if(!a.length)return s;const o=[];for(const e of s){const t=(e.id.split(":")[1]||e.id).toLowerCase().split("-"),i=e.search_labels?Object.values(e.search_labels).filter(e=>null!==e).map(e=>e.toLowerCase()):[],s=e.id.toLowerCase();t.includes(a)?o.push({item:e,rank:1}):i.includes(a)?o.push({item:e,rank:2}):s.includes(a)?o.push({item:e,rank:3}):i.some(e=>e.includes(a))&&o.push({item:e,rank:4})}return o.sort((e,t)=>e.rank-t.rank).map(e=>e.item)})}}y.styles=o.AH`ha-generic-picker{width:100%;display:block}`,(0,s.Cg)([(0,r.MZ)()],y.prototype,"value",void 0),(0,s.Cg)([(0,r.MZ)()],y.prototype,"label",void 0),(0,s.Cg)([(0,r.MZ)()],y.prototype,"helper",void 0),(0,s.Cg)([(0,r.MZ)()],y.prototype,"placeholder",void 0),(0,s.Cg)([(0,r.MZ)({attribute:"error-message"})],y.prototype,"errorMessage",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],y.prototype,"disabled",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],y.prototype,"required",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],y.prototype,"invalid",void 0),y=(0,s.Cg)([(0,r.EM)("ha-icon-picker")],y),a()}catch(e){a(e)}})},37018(e,t,i){i.a(e,async function(e,a){try{i.r(t);var s=i(62826),o=i(5124),r=i(22441),n=i(1087),l=i(64138),c=i(91485),h=i(14503),d=e([l,c]);[l,c]=d.then?(await d)():d;class u 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(()=>this._focusElement?.focus())}render(){return this.hass?o.qy` <div class="form"> <ha-input .value="${this._name}" .configValue="${"name"}" @input="${this._valueChanged}" .label="${this.hass.localize("ui.dialogs.helper_settings.generic.name")}" auto-validate required .validationMessage="${this.hass.localize("ui.dialogs.helper_settings.required_error_msg")}" dialogInitialFocus .disabled="${this.disabled}"></ha-input> <ha-icon-picker .hass="${this.hass}" .value="${this._icon}" .configValue="${"icon"}" @value-changed="${this._valueChanged}" .label="${this.hass.localize("ui.dialogs.helper_settings.generic.icon")}" .disabled="${this.disabled}"></ha-icon-picker> </div> `:o.s6}_valueChanged(e){if(!this.new&&!this._item)return;e.stopPropagation();const t=e.target.configValue,i=e.detail?.value||e.target.value;if(this[`_${t}`]===i)return;const a={...this._item};i?a[t]=i:delete a[t],(0,n.r)(this,"value-changed",{value:a})}static get styles(){return[h.RF,o.AH`.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})],u.prototype,"hass",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],u.prototype,"new",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],u.prototype,"disabled",void 0),(0,s.Cg)([(0,r.wk)()],u.prototype,"_name",void 0),(0,s.Cg)([(0,r.wk)()],u.prototype,"_icon",void 0),(0,s.Cg)([(0,r.P)("[dialogInitialFocus]")],u.prototype,"_focusElement",void 0),u=(0,s.Cg)([(0,r.EM)("ha-input_button-form")],u),a()}catch(e){a(e)}})}};