UNPKG

iobroker.lovelace

Version:

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

7 lines 13.3 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[66201],{13467:function(e,t,i){var a=i(40445),l=i(41216),o=i(78960),s=i(75640),r=i(91735),n=i(43826),d=i(5124),c=i(67576);let h;class p extends l.R{}p.styles=[r.R,n.R,s.R,o.R,(0,d.AH)(h||(h=(e=>e)`:host{--md-sys-color-primary:var(--primary-text-color);--md-sys-color-on-surface:var(--primary-text-color);--md-sys-color-on-surface-variant:var(--primary-text-color);--md-sys-color-on-secondary-container:var(--primary-text-color);--md-input-chip-container-shape:16px;--md-input-chip-outline-color:var(--outline-color);--md-input-chip-selected-container-color:rgba( var(--rgb-primary-text-color), 0.15 );--ha-input-chip-selected-container-opacity:1;--md-input-chip-label-text-font:Roboto,sans-serif}::slotted([slot=icon]){display:flex;--mdc-icon-size:var(--md-input-chip-icon-size, 18px)}.selected::before{opacity:var(--ha-input-chip-selected-container-opacity)}`))],p=(0,a.Cg)([(0,c.EM)("ha-input-chip")],p)},81789:function(e,t,i){i.a(e,async function(e,a){try{i.d(t,{p:function(){return L}});i(74423),i(18111),i(22489),i(61701),i(13579),i(3362),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(62953);var l=i(40445),o=i(35211),s=i(5124),r=i(67576),n=i(89784),d=i(22786),c=i(78870),h=i(1087),p=i(22792),u=i(5904),b=i(92557),v=i(65063),y=i(69569),g=i(38508),m=i(49639),_=(i(67094),e([g,m]));[g,m]=_.then?(await _)():_;let f,C,$,k,M,x=e=>e;const Z="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",w="___ADD_NEW___",L=e=>(0,s.qy)(f||(f=x`<div style="${0}"></div>`),(0,n.W)({backgroundColor:e?(0,c.MP)(e):void 0,borderRadius:"var(--ha-border-radius-md)",border:"1px solid var(--outline-color)",boxSizing:"border-box",width:"var(--ha-space-5)",height:"var(--ha-space-5)"}));class A extends s.WF{willUpdate(e){var t;this._pendingLabelId&&e.has("_labels")&&null!==(t=this._labels)&&void 0!==t&&t.some(e=>e.label_id===this._pendingLabelId)&&(this._setValue(this._pendingLabelId),this._pendingLabelId=void 0)}async open(){var e;await this.updateComplete,await(null===(e=this._picker)||void 0===e?void 0:e.open())}render(){var e,t;const i=null!==(e=this.placeholder)&&void 0!==e?e:this.hass.localize("ui.components.label-picker.label");return(0,s.qy)(C||(C=x` <ha-generic-picker .disabled="${0}" .hass="${0}" .autofocus="${0}" .label="${0}" .helper="${0}" .notFoundLabel="${0}" .emptyLabel="${0}" .addButtonLabel="${0}" .placeholder="${0}" .value="${0}" .getItems="${0}" .getAdditionalItems="${0}" .rowRenderer="${0}" .searchKeys="${0}" @value-changed="${0}"> <slot @slotchange="${0}" .slot="${0}"></slot> </ha-generic-picker> `),this.disabled,this.hass,this.autofocus,this.label,this.helper,this._notFoundLabel,this.hass.localize("ui.components.label-picker.no_labels"),this.hass.localize("ui.components.label-picker.add"),i,this.value,this._getItems,this._getAdditionalItems,this._rowRenderer,u.u,this._valueChanged,this._handleSlotChange,null!==(t=this._slotNodes)&&void 0!==t&&t.length?"field":void 0)}_valueChanged(e){e.stopPropagation();const t=e.detail.value;if(t){if(t.startsWith(w)){this.hass.loadFragmentTranslation("config");const e=t.substring(w.length);return void(0,y.f)(this,{suggestedName:e,createEntry:async e=>{try{var t;const i=await(0,b._9)(this.hass,e);null!==(t=this._labels)&&void 0!==t&&t.some(e=>e.label_id===i.label_id)?this._setValue(i.label_id):this._pendingLabelId=i.label_id}catch(i){(0,v.showAlertDialog)(this,{title:this.hass.localize("ui.components.label-picker.failed_create_label"),text:i.message})}}})}this._setValue(t)}else this._setValue(void 0)}_setValue(e){this.value=e,setTimeout(()=>{(0,h.r)(this,"value-changed",{value:e}),(0,h.r)(this,"change")},0)}_handleSlotChange(){this.requestUpdate()}constructor(...e){super(...e),this.noAdd=!1,this.disabled=!1,this.required=!1,this._rowRenderer=e=>(0,s.qy)($||($=x`<ha-combo-box-item type="button" compact="compact"> ${0} ${0} </ha-combo-box-item>`),(0,m.LE)(e),e.id!==w?(0,s.qy)(k||(k=x`<div slot="trailing-supporting-text"> ${0} </div>`),L(e.color)):s.s6),this._getLabelsMemoized=(0,d.A)(u.I),this._getItems=()=>this._getLabelsMemoized(this.hass.states,this.hass.areas,this.hass.devices,this.hass.entities,this._labels,this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.deviceFilter,this.entityFilter,this.excludeLabels),this._allLabelNames=(0,d.A)(e=>e?[...new Set(e.map(e=>e.name.toLowerCase()).filter(Boolean))]:[]),this._getAdditionalItems=e=>{if(this.noAdd)return[];const t=this._allLabelNames(this._labels);return e&&!t.includes(e.toLowerCase())?[{id:w+e,primary:this.hass.localize("ui.components.label-picker.add_new_suggestion",{name:e}),icon_path:Z}]:[{id:w,primary:this.hass.localize("ui.components.label-picker.add_new"),icon_path:Z}]},this._notFoundLabel=e=>this.hass.localize("ui.components.label-picker.no_match",{term:(0,s.qy)(M||(M=x`<b>‘${0}’</b>`),e)})}}(0,l.Cg)([(0,r.MZ)({attribute:!1})],A.prototype,"hass",void 0),(0,l.Cg)([(0,r.MZ)()],A.prototype,"label",void 0),(0,l.Cg)([(0,r.MZ)()],A.prototype,"value",void 0),(0,l.Cg)([(0,r.MZ)()],A.prototype,"helper",void 0),(0,l.Cg)([(0,r.MZ)()],A.prototype,"placeholder",void 0),(0,l.Cg)([(0,r.MZ)({type:Boolean,attribute:"no-add"})],A.prototype,"noAdd",void 0),(0,l.Cg)([(0,r.MZ)({type:Array,attribute:"include-domains"})],A.prototype,"includeDomains",void 0),(0,l.Cg)([(0,r.MZ)({type:Array,attribute:"exclude-domains"})],A.prototype,"excludeDomains",void 0),(0,l.Cg)([(0,r.MZ)({type:Array,attribute:"include-device-classes"})],A.prototype,"includeDeviceClasses",void 0),(0,l.Cg)([(0,r.MZ)({type:Array,attribute:"exclude-label"})],A.prototype,"excludeLabels",void 0),(0,l.Cg)([(0,r.MZ)({attribute:!1})],A.prototype,"deviceFilter",void 0),(0,l.Cg)([(0,r.MZ)({attribute:!1})],A.prototype,"entityFilter",void 0),(0,l.Cg)([(0,r.MZ)({type:Boolean})],A.prototype,"disabled",void 0),(0,l.Cg)([(0,r.MZ)({type:Boolean})],A.prototype,"required",void 0),(0,l.Cg)([(0,o.Fg)({context:p.HD,subscribe:!0}),(0,r.wk)()],A.prototype,"_labels",void 0),(0,l.Cg)([(0,r.KN)({flatten:!0})],A.prototype,"_slotNodes",void 0),(0,l.Cg)([(0,r.P)("ha-generic-picker")],A.prototype,"_picker",void 0),(0,l.Cg)([(0,r.wk)()],A.prototype,"_pendingLabelId",void 0),A=(0,l.Cg)([(0,r.EM)("ha-label-picker")],A),a()}catch(f){a(f)}})},50176:function(e,t,i){i.a(e,async function(e,t){try{i(89463),i(74423),i(26910),i(18111),i(22489),i(20116),i(61701),i(3362),i(42762),i(62953);var a=i(40445),l=i(35211),o=i(5124),s=i(67576),r=i(75751),n=i(22786),d=i(1087),c=i(52220),h=i(22792),p=i(92557),u=i(69569),b=(i(5745),i(13467),i(23430)),v=i(81789),y=i(34127),g=e([v,y,b]);[v,y,b]=g.then?(await g)():g;let m,_,f,C,$,k=e=>e;const M="M3 16H10V14H3M18 14V10H16V14H12V16H16V20H18V16H22V14M14 6H3V8H14M14 10H3V12H14V10Z";class x extends o.WF{async open(){var e;await this.updateComplete,await(null===(e=this.labelPicker)||void 0===e?void 0:e.open())}async focus(){var e;await this.updateComplete,await(null===(e=this.labelPicker)||void 0===e?void 0:e.focus())}render(){const e=this._sortedLabels(this.value,this._labels,this.hass.locale.language);return(0,o.qy)(m||(m=k` ${0} <ha-label-picker .hass="${0}" .helper="${0}" .disabled="${0}" .required="${0}" .placeholder="${0}" .excludeLabels="${0}" @value-changed="${0}"> <ha-chip-set> ${0} <ha-button id="picker" size="small" appearance="filled" @click="${0}" .disabled="${0}"> <ha-svg-icon .path="${0}" slot="start"></ha-svg-icon> ${0} </ha-button> </ha-chip-set> </ha-label-picker> `),this.label?(0,o.qy)(_||(_=k`<label>${0}</label>`),this.label):o.s6,this.hass,this.helper,this.disabled,this.required,this.placeholder,this.value,this._labelChanged,null!=e&&e.length?(0,r.u)(e,e=>null==e?void 0:e.label_id,e=>{var t;if(!e)return o.s6;const i="label-"+e.label_id;return(0,o.qy)(f||(f=k` <ha-tooltip .for="${0}" .disabled="${0}"> ${0} </ha-tooltip> <ha-input-chip .item="${0}" .id="${0}" @remove="${0}" @click="${0}" .disabled="${0}" .label="${0}" selected="selected" style="${0}"> ${0} </ha-input-chip> `),i,!(null!==(t=e.description)&&void 0!==t&&t.trim()),e.description,e,i,this._removeItem,this._openDetail,this.disabled,e.name,e.style,e.icon?(0,o.qy)(C||(C=k`<ha-icon slot="icon" .icon="${0}"></ha-icon>`),e.icon):o.s6)}):o.s6,this._openPicker,this.disabled,M,this.hass.localize("ui.components.label-picker.add"))}get _value(){return this.value||[]}_removeItem(e){const t=e.currentTarget.item;this._setValue(this._value.filter(e=>e!==t.label_id))}_openDetail(e){const t=e.currentTarget.item;(0,u.f)(this,{entry:t,updateEntry:async e=>{await(0,p.Rp)(this.hass,t.label_id,e)}})}_labelChanged(e){e.stopPropagation();const t=e.detail.value;t&&!this._value.includes(t)&&(this._setValue([...this._value,t]),this.labelPicker.value="")}_setValue(e){this.value=e,setTimeout(()=>{(0,d.r)(this,"value-changed",{value:e}),(0,d.r)(this,"change")},0)}_openPicker(e){e.stopPropagation(),this.labelPicker.open()}constructor(...e){super(...e),this.noAdd=!1,this.disabled=!1,this.required=!1,this._sortedLabels=(0,n.A)((e,t,i)=>null==e?void 0:e.map(e=>null==t?void 0:t.find(t=>t.label_id===e)).filter(e=>void 0!==e).sort((e,t)=>(0,c.xL)(e.name,t.name,i)).map(e=>Object.assign(Object.assign({},e),{},{style:(0,b.l)(e.color)})))}}x.styles=(0,o.AH)($||($=k`ha-chip-set{background-color:var(--mdc-text-field-fill-color);border-bottom:1px solid var(--ha-color-border-neutral-normal);border-top-right-radius:var(--ha-border-radius-sm);border-top-left-radius:var(--ha-border-radius-sm);padding:var(--ha-space-3)}.placeholder{color:var(--mdc-text-field-label-ink-color);display:flex;align-items:center;height:var(--ha-space-8)}ha-input-chip{--md-input-chip-selected-container-color:var( --ha-label-background-color, var(--grey-color) );--md-input-chip-selected-outline-width:1px}label{display:block;margin:0 0 8px}`)),(0,a.Cg)([(0,s.MZ)({attribute:!1})],x.prototype,"hass",void 0),(0,a.Cg)([(0,s.MZ)()],x.prototype,"label",void 0),(0,a.Cg)([(0,s.MZ)({attribute:!1})],x.prototype,"value",void 0),(0,a.Cg)([(0,s.MZ)()],x.prototype,"helper",void 0),(0,a.Cg)([(0,s.MZ)()],x.prototype,"placeholder",void 0),(0,a.Cg)([(0,s.MZ)({type:Boolean,attribute:"no-add"})],x.prototype,"noAdd",void 0),(0,a.Cg)([(0,s.MZ)({type:Array,attribute:"include-domains"})],x.prototype,"includeDomains",void 0),(0,a.Cg)([(0,s.MZ)({type:Array,attribute:"exclude-domains"})],x.prototype,"excludeDomains",void 0),(0,a.Cg)([(0,s.MZ)({type:Array,attribute:"include-device-classes"})],x.prototype,"includeDeviceClasses",void 0),(0,a.Cg)([(0,s.MZ)({type:Array,attribute:"exclude-label"})],x.prototype,"excludeLabels",void 0),(0,a.Cg)([(0,s.MZ)({attribute:!1})],x.prototype,"deviceFilter",void 0),(0,a.Cg)([(0,s.MZ)({attribute:!1})],x.prototype,"entityFilter",void 0),(0,a.Cg)([(0,s.MZ)({type:Boolean})],x.prototype,"disabled",void 0),(0,a.Cg)([(0,s.MZ)({type:Boolean})],x.prototype,"required",void 0),(0,a.Cg)([(0,l.Fg)({context:h.HD,subscribe:!0}),(0,s.wk)()],x.prototype,"_labels",void 0),(0,a.Cg)([(0,s.P)("ha-label-picker",!0)],x.prototype,"labelPicker",void 0),x=(0,a.Cg)([(0,s.EM)("ha-labels-picker")],x),t()}catch(m){t(m)}})},5904:function(e,t,i){i.d(t,{I:function(){return s},u:function(){return o}});i(89463),i(74423),i(18111),i(81148),i(22489),i(7588),i(61701),i(13579),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(62953);var a=i(71727),l=i(58594);const o=[{name:"search_labels.name",weight:10},{name:"search_labels.description",weight:5},{name:"search_labels.id",weight:4}],s=(e,t,i,o,s,r,n,d,c,h,p,u="")=>{if(!s||0===s.length)return[];const b=Object.values(i),v=Object.values(o);let y,g,m={};(r||n||d||c||h)&&(m=(0,l.g2)(v),y=b,g=v.filter(e=>e.labels.length>0),r&&(y=y.filter(e=>{const t=m[e.id];return!(!t||!t.length)&&m[e.id].some(e=>r.includes((0,a.m)(e.entity_id)))}),g=g.filter(e=>r.includes((0,a.m)(e.entity_id)))),n&&(y=y.filter(e=>{const t=m[e.id];return!t||!t.length||v.every(e=>!n.includes((0,a.m)(e.entity_id)))}),g=g.filter(e=>!n.includes((0,a.m)(e.entity_id)))),d&&(y=y.filter(t=>{const i=m[t.id];return!(!i||!i.length)&&m[t.id].some(t=>{const i=e[t.entity_id];return!!i&&(i.attributes.device_class&&d.includes(i.attributes.device_class))})}),g=g.filter(t=>{const i=e[t.entity_id];return i&&i.attributes.device_class&&d.includes(i.attributes.device_class)})),c&&(y=y.filter(e=>c(e))),h&&(y=y.filter(t=>{const i=m[t.id];return!(!i||!i.length)&&m[t.id].some(t=>{const i=e[t.entity_id];return!!i&&h(i)})}),g=g.filter(t=>{const i=e[t.entity_id];return!!i&&h(i)})));let _=s;const f=new Set;let C;y&&(C=y.filter(e=>e.area_id).map(e=>e.area_id),y.forEach(e=>{e.labels.forEach(e=>f.add(e))})),g&&(C=(null!=C?C:[]).concat(g.filter(e=>e.area_id).map(e=>e.area_id)),g.forEach(e=>{e.labels.forEach(e=>f.add(e))})),C&&C.forEach(e=>{const i=t[e];null==i||i.labels.forEach(e=>f.add(e))}),p&&(_=_.filter(e=>!p.includes(e.label_id))),(y||g)&&(_=_.filter(e=>f.has(e.label_id)));return _.map(e=>{var t;return{id:`${u}${e.label_id}`,primary:e.name,secondary:null!==(t=e.description)&&void 0!==t?t:"",icon:e.icon||void 0,icon_path:e.icon?void 0:"M17.63,5.84C17.27,5.33 16.67,5 16,5H5A2,2 0 0,0 3,7V17A2,2 0 0,0 5,19H16C16.67,19 17.27,18.66 17.63,18.15L22,12L17.63,5.84Z",sorting_label:e.name,search_labels:{name:e.name,description:e.description,id:e.label_id},color:e.color||void 0}})}}}]);