UNPKG

iobroker.lovelace

Version:

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

5 lines 13.5 kB
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["84958"],{18756:function(e,i,t){var a=t(61701),l=t(72621),s=(t(71695),t(47021),t(74514)),o=t(57243),d=t(50778);let n,r=e=>e;(0,a.Z)([(0,d.Mo)("ha-input-chip")],(function(e,i){class t extends i{constructor(...i){super(...i),e(this)}}return{F:t,d:[{kind:"field",static:!0,key:"styles",value(){return[...(0,l.Z)(t,"styles",this),(0,o.iv)(n||(n=r`: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)}`))]}}]}}),s.W)},75773:function(e,i,t){t.a(e,(async function(e,i){try{var a=t(61701),l=(t(19083),t(71695),t(9359),t(68107),t(56475),t(1331),t(31526),t(70104),t(52924),t(19423),t(40251),t(92519),t(42179),t(89256),t(24931),t(88463),t(57449),t(19814),t(61006),t(47021),t(57243)),s=t(50778),o=t(35359),d=t(27486),n=t(36522),r=t(73850),c=t(24360),u=t(71857),h=t(63860),v=t(6736),b=t(26345),p=t(94279),k=(t(23334),t(7285),t(37583),e([p]));p=(k.then?(await k)():k)[0];let y,m,f,_=e=>e;const g="___ADD_NEW___",C="___NO_LABELS___",x="___ADD_NEW_SUGGESTION___",$=e=>(0,l.dy)(y||(y=_`<ha-list-item graphic="icon" class="${0}"> ${0} ${0} </ha-list-item>`),(0,o.$)({"add-new":e.label_id===g}),e.icon?(0,l.dy)(m||(m=_`<ha-icon slot="graphic" .icon="${0}"></ha-icon>`),e.icon):l.Ld,e.name);(0,a.Z)([(0,s.Mo)("ha-label-picker")],(function(e,i){return{F:class extends i{constructor(...i){super(...i),e(this)}},d:[{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"label",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"value",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"helper",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"placeholder",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"no-add"})],key:"noAdd",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Array,attribute:"exclude-label"})],key:"excludeLabels",value:void 0},{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"deviceFilter",value:void 0},{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"entityFilter",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Boolean})],key:"disabled",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Boolean})],key:"required",value(){return!1}},{kind:"field",decorators:[(0,s.SB)()],key:"_opened",value:void 0},{kind:"field",decorators:[(0,s.SB)()],key:"_labels",value:void 0},{kind:"field",decorators:[(0,s.IO)("ha-combo-box",!0)],key:"comboBox",value:void 0},{kind:"field",key:"_suggestion",value:void 0},{kind:"field",key:"_init",value(){return!1}},{kind:"method",key:"open",value:async function(){var e;await this.updateComplete,await(null===(e=this.comboBox)||void 0===e?void 0:e.open())}},{kind:"method",key:"focus",value:async function(){var e;await this.updateComplete,await(null===(e=this.comboBox)||void 0===e?void 0:e.focus())}},{kind:"method",key:"hassSubscribe",value:function(){return[(0,h.f4)(this.hass.connection,(e=>{this._labels=e}))]}},{kind:"field",key:"_getLabels",value(){return(0,d.Z)(((e,i,t,a,l,s,o,d,n,c,h)=>{let v,b,p={};(l||s||o||d||n)&&(p=(0,u.R6)(a),v=t,b=a.filter((e=>e.labels.length>0)),l&&(v=v.filter((e=>{const i=p[e.id];return!(!i||!i.length)&&p[e.id].some((e=>l.includes((0,r.M)(e.entity_id))))})),b=b.filter((e=>l.includes((0,r.M)(e.entity_id))))),s&&(v=v.filter((e=>{const i=p[e.id];return!i||!i.length||a.every((e=>!s.includes((0,r.M)(e.entity_id))))})),b=b.filter((e=>!s.includes((0,r.M)(e.entity_id))))),o&&(v=v.filter((e=>{const i=p[e.id];return!(!i||!i.length)&&p[e.id].some((e=>{const i=this.hass.states[e.entity_id];return!!i&&(i.attributes.device_class&&o.includes(i.attributes.device_class))}))})),b=b.filter((e=>{const i=this.hass.states[e.entity_id];return i.attributes.device_class&&o.includes(i.attributes.device_class)}))),d&&(v=v.filter((e=>d(e)))),n&&(v=v.filter((e=>{const i=p[e.id];return!(!i||!i.length)&&p[e.id].some((e=>{const i=this.hass.states[e.entity_id];return!!i&&n(i)}))})),b=b.filter((e=>{const i=this.hass.states[e.entity_id];return!!i&&n(i)}))));let k=e;const y=new Set;let m;return v&&(m=v.filter((e=>e.area_id)).map((e=>e.area_id)),v.forEach((e=>{e.labels.forEach((e=>y.add(e)))}))),b&&(m=(null!=m?m:[]).concat(b.filter((e=>e.area_id)).map((e=>e.area_id))),b.forEach((e=>{e.labels.forEach((e=>y.add(e)))}))),m&&m.forEach((e=>{i[e].labels.forEach((e=>y.add(e)))})),h&&(k=k.filter((e=>!h.includes(e.label_id)))),(v||b)&&(k=k.filter((e=>y.has(e.label_id)))),k.length||(k=[{label_id:C,name:this.hass.localize("ui.components.label-picker.no_match"),icon:null,color:null,description:null,created_at:0,modified_at:0}]),c?k:[...k,{label_id:g,name:this.hass.localize("ui.components.label-picker.add_new"),icon:"mdi:plus",color:null,description:null,created_at:0,modified_at:0}]}))}},{kind:"method",key:"updated",value:function(e){if(!this._init&&this.hass&&this._labels||this._init&&e.has("_opened")&&this._opened){this._init=!0;const e=this._getLabels(this._labels,this.hass.areas,Object.values(this.hass.devices),Object.values(this.hass.entities),this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.deviceFilter,this.entityFilter,this.noAdd,this.excludeLabels).map((e=>Object.assign(Object.assign({},e),{},{strings:[e.label_id,e.name]})));this.comboBox.items=e,this.comboBox.filteredItems=e}}},{kind:"method",key:"render",value:function(){var e;return(0,l.dy)(f||(f=_` <ha-combo-box .hass="${0}" .helper="${0}" item-value-path="label_id" item-id-path="label_id" item-label-path="name" .value="${0}" .disabled="${0}" .required="${0}" .label="${0}" .placeholder="${0}" .renderer="${0}" @filter-changed="${0}" @opened-changed="${0}" @value-changed="${0}"> </ha-combo-box> `),this.hass,this.helper,this._value,this.disabled,this.required,void 0===this.label&&this.hass?this.hass.localize("ui.components.label-picker.label"):this.label,this.placeholder?null===(e=this._labels)||void 0===e||null===(e=e.find((e=>e.label_id===this.placeholder)))||void 0===e?void 0:e.name:void 0,$,this._filterChanged,this._openedChanged,this._labelChanged)}},{kind:"method",key:"_filterChanged",value:function(e){var i;const t=e.target,a=e.detail.value;if(!a)return void(this.comboBox.filteredItems=this.comboBox.items);const l=(0,c.q)(a,(null===(i=t.items)||void 0===i?void 0:i.filter((e=>![C,g].includes(e.label_id))))||[]);0===l.length?this.noAdd?this.comboBox.filteredItems=[{label_id:C,name:this.hass.localize("ui.components.label-picker.no_match"),icon:null,color:null}]:(this._suggestion=a,this.comboBox.filteredItems=[{label_id:x,name:this.hass.localize("ui.components.label-picker.add_new_sugestion",{name:this._suggestion}),icon:"mdi:plus",color:null}]):this.comboBox.filteredItems=l}},{kind:"get",key:"_value",value:function(){return this.value||""}},{kind:"method",key:"_openedChanged",value:function(e){this._opened=e.detail.value}},{kind:"method",key:"_labelChanged",value:function(e){e.stopPropagation();let i=e.detail.value;if(i===C)return i="",void this.comboBox.setInputValue("");[x,g].includes(i)?(e.target.value=this._value,this.hass.loadFragmentTranslation("config"),(0,b.T)(this,{entry:void 0,suggestedName:i===x?this._suggestion:"",createEntry:async e=>{const i=await(0,h.jo)(this.hass,e),t=[...this._labels,i];return this.comboBox.filteredItems=this._getLabels(t,this.hass.areas,Object.values(this.hass.devices),Object.values(this.hass.entities),this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.deviceFilter,this.entityFilter,this.noAdd,this.excludeLabels),await this.updateComplete,await this.comboBox.updateComplete,this._setValue(i.label_id),i}}),this._suggestion=void 0,this.comboBox.setInputValue("")):i!==this._value&&this._setValue(i)}},{kind:"method",key:"_setValue",value:function(e){this.value=e,setTimeout((()=>{(0,n.B)(this,"value-changed",{value:e}),(0,n.B)(this,"change")}),0)}}]}}),(0,v.f)(l.oi));i()}catch(y){i(y)}}))},73422:function(e,i,t){t.a(e,(async function(e,i){try{var a=t(61701),l=(t(19083),t(71695),t(61893),t(9359),t(56475),t(31526),t(70104),t(40251),t(61006),t(47021),t(57243)),s=t(50778),o=t(91583),d=t(27486),n=t(75011),r=t(36522),c=t(1416),u=t(63860),h=t(6736),v=t(26345),b=(t(74666),t(18756),t(75773)),p=e([b]);b=(p.then?(await p)():p)[0];let k,y,m,f,_,g=e=>e;(0,a.Z)([(0,s.Mo)("ha-labels-picker")],(function(e,i){return{F:class extends i{constructor(...i){super(...i),e(this)}},d:[{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"label",value:void 0},{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"value",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"helper",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"placeholder",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,attribute:"no-add"})],key:"noAdd",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Array,attribute:"exclude-label"})],key:"excludeLabels",value:void 0},{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"deviceFilter",value:void 0},{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"entityFilter",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Boolean})],key:"disabled",value(){return!1}},{kind:"field",decorators:[(0,s.Cb)({type:Boolean})],key:"required",value(){return!1}},{kind:"field",decorators:[(0,s.SB)()],key:"_labels",value:void 0},{kind:"field",decorators:[(0,s.IO)("ha-label-picker",!0)],key:"labelPicker",value:void 0},{kind:"method",key:"open",value:async function(){var e;await this.updateComplete,await(null===(e=this.labelPicker)||void 0===e?void 0:e.open())}},{kind:"method",key:"focus",value:async function(){var e;await this.updateComplete,await(null===(e=this.labelPicker)||void 0===e?void 0:e.focus())}},{kind:"method",key:"hassSubscribe",value:function(){return[(0,u.f4)(this.hass.connection,(e=>{const i={};e.forEach((e=>{i[e.label_id]=e})),this._labels=i}))]}},{kind:"field",key:"_sortedLabels",value(){return(0,d.Z)(((e,i,t)=>null==e?void 0:e.map((e=>null==i?void 0:i[e])).sort(((e,i)=>(0,c.$K)((null==e?void 0:e.name)||"",(null==i?void 0:i.name)||"",t)))))}},{kind:"method",key:"render",value:function(){const e=this._sortedLabels(this.value,this._labels,this.hass.locale.language);return(0,l.dy)(k||(k=g` ${0} <ha-label-picker .hass="${0}" .helper="${0}" .disabled="${0}" .required="${0}" .label="${0}" .placeholder="${0}" .excludeLabels="${0}" @value-changed="${0}"> </ha-label-picker> `),null!=e&&e.length?(0,l.dy)(y||(y=g`<ha-chip-set> ${0} </ha-chip-set>`),(0,o.r)(e,(e=>null==e?void 0:e.label_id),(e=>{const i=null!=e&&e.color?(0,n.I)(e.color):void 0;return(0,l.dy)(m||(m=g` <ha-input-chip .item="${0}" @remove="${0}" @click="${0}" .label="${0}" selected="selected" style="${0}"> ${0} </ha-input-chip> `),e,this._removeItem,this._openDetail,null==e?void 0:e.name,i?`--color: ${i}`:"",null!=e&&e.icon?(0,l.dy)(f||(f=g`<ha-icon slot="icon" .icon="${0}"></ha-icon>`),e.icon):l.Ld)}))):l.Ld,this.hass,this.helper,this.disabled,this.required,void 0===this.label&&this.hass?this.hass.localize("ui.components.label-picker.add_label"):this.label,this.placeholder,this.value,this._labelChanged)}},{kind:"get",key:"_value",value:function(){return this.value||[]}},{kind:"method",key:"_removeItem",value:function(e){const i=e.currentTarget.item;this._setValue(this._value.filter((e=>e!==i.label_id)))}},{kind:"method",key:"_openDetail",value:function(e){const i=e.currentTarget.item;(0,v.T)(this,{entry:i,updateEntry:async e=>await(0,u.$0)(this.hass,i.label_id,e)})}},{kind:"method",key:"_labelChanged",value:function(e){e.stopPropagation();const i=e.detail.value;i&&!this._value.includes(i)&&(this._setValue([...this._value,i]),this.labelPicker.value="")}},{kind:"method",key:"_setValue",value:function(e){this.value=e,setTimeout((()=>{(0,r.B)(this,"value-changed",{value:e}),(0,r.B)(this,"change")}),0)}},{kind:"field",static:!0,key:"styles",value(){return(0,l.iv)(_||(_=g`ha-chip-set{margin-bottom:8px}ha-input-chip{--md-input-chip-selected-container-color:var(--color, var(--grey-color));--ha-input-chip-selected-container-opacity:0.5;--md-input-chip-selected-outline-width:1px}`))}}]}}),(0,h.f)(l.oi));i()}catch(k){i(k)}}))}}]); //# sourceMappingURL=84958.4c74a20b49b13d98.js.map