UNPKG

iobroker.lovelace

Version:

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

5 lines 12.3 kB
export const __webpack_ids__=["89790"];export const __webpack_modules__={18756:function(e,i,t){var a=t(44249),l=t(72621),s=t(74514),o=t(57243),d=t(15093);(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),o.iv`: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)},47314:function(e,i,t){var a=t(44249),l=(t(9359),t(56475),t(31526),t(70104),t(57243)),s=t(15093),o=t(91583),d=t(27486),n=t(75011),r=t(36522),c=t(1416),u=t(63860),h=t(6736),b=t(26345),v=(t(74666),t(18756),t(68107),t(1331),t(52924),t(92519),t(42179),t(89256),t(24931),t(88463),t(57449),t(19814),t(35359)),p=t(73850),k=t(24360),y=t(46329);t(94279),t(23334),t(7285),t(37583);const m="___ADD_NEW___",_="___NO_LABELS___",f="___ADD_NEW_SUGGESTION___",g=e=>l.dy`<ha-list-item graphic="icon" class="${(0,v.$)({"add-new":e.label_id===m})}"> ${e.icon?l.dy`<ha-icon slot="graphic" .icon="${e.icon}"></ha-icon>`:l.Ld} ${e.name} </ha-list-item>`;(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:()=>!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:()=>!1},{kind:"field",decorators:[(0,s.Cb)({type:Boolean})],key:"required",value:()=>!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:()=>!1},{kind:"method",key:"open",value:async function(){await this.updateComplete,await(this.comboBox?.open())}},{kind:"method",key:"focus",value:async function(){await this.updateComplete,await(this.comboBox?.focus())}},{kind:"method",key:"hassSubscribe",value:function(){return[(0,u.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,r,c)=>{let u,h,b={};(l||s||o||d||n)&&(b=(0,y.R6)(a),u=t,h=a.filter((e=>e.labels.length>0)),l&&(u=u.filter((e=>{const i=b[e.id];return!(!i||!i.length)&&b[e.id].some((e=>l.includes((0,p.M)(e.entity_id))))})),h=h.filter((e=>l.includes((0,p.M)(e.entity_id))))),s&&(u=u.filter((e=>{const i=b[e.id];return!i||!i.length||a.every((e=>!s.includes((0,p.M)(e.entity_id))))})),h=h.filter((e=>!s.includes((0,p.M)(e.entity_id))))),o&&(u=u.filter((e=>{const i=b[e.id];return!(!i||!i.length)&&b[e.id].some((e=>{const i=this.hass.states[e.entity_id];return!!i&&(i.attributes.device_class&&o.includes(i.attributes.device_class))}))})),h=h.filter((e=>{const i=this.hass.states[e.entity_id];return i.attributes.device_class&&o.includes(i.attributes.device_class)}))),d&&(u=u.filter((e=>d(e)))),n&&(u=u.filter((e=>{const i=b[e.id];return!(!i||!i.length)&&b[e.id].some((e=>{const i=this.hass.states[e.entity_id];return!!i&&n(i)}))})),h=h.filter((e=>{const i=this.hass.states[e.entity_id];return!!i&&n(i)}))));let v=e;const k=new Set;let f;return u&&(f=u.filter((e=>e.area_id)).map((e=>e.area_id)),u.forEach((e=>{e.labels.forEach((e=>k.add(e)))}))),h&&(f=(f??[]).concat(h.filter((e=>e.area_id)).map((e=>e.area_id))),h.forEach((e=>{e.labels.forEach((e=>k.add(e)))}))),f&&f.forEach((e=>{i[e].labels.forEach((e=>k.add(e)))})),c&&(v=v.filter((e=>!c.includes(e.label_id)))),(u||h)&&(v=v.filter((e=>k.has(e.label_id)))),v.length||(v=[{label_id:_,name:this.hass.localize("ui.components.label-picker.no_match"),icon:null,color:null,description:null,created_at:0,modified_at:0}]),r?v:[...v,{label_id:m,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=>({...e,strings:[e.label_id,e.name]})));this.comboBox.items=e,this.comboBox.filteredItems=e}}},{kind:"method",key:"render",value:function(){return l.dy` <ha-combo-box .hass="${this.hass}" .helper="${this.helper}" item-value-path="label_id" item-id-path="label_id" item-label-path="name" .value="${this._value}" .disabled="${this.disabled}" .required="${this.required}" .label="${void 0===this.label&&this.hass?this.hass.localize("ui.components.label-picker.label"):this.label}" .placeholder="${this.placeholder?this._labels?.find((e=>e.label_id===this.placeholder))?.name:void 0}" .renderer="${g}" @filter-changed="${this._filterChanged}" @opened-changed="${this._openedChanged}" @value-changed="${this._labelChanged}"> </ha-combo-box> `}},{kind:"method",key:"_filterChanged",value:function(e){const i=e.target,t=e.detail.value;if(!t)return void(this.comboBox.filteredItems=this.comboBox.items);const a=(0,k.q)(t,i.items?.filter((e=>![_,m].includes(e.label_id)))||[]);0===a.length?this.noAdd?this.comboBox.filteredItems=[{label_id:_,name:this.hass.localize("ui.components.label-picker.no_match"),icon:null,color:null}]:(this._suggestion=t,this.comboBox.filteredItems=[{label_id:f,name:this.hass.localize("ui.components.label-picker.add_new_sugestion",{name:this._suggestion}),icon:"mdi:plus",color:null}]):this.comboBox.filteredItems=a}},{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===_)return i="",void this.comboBox.setInputValue("");[f,m].includes(i)?(e.target.value=this._value,this.hass.loadFragmentTranslation("config"),(0,b.T)(this,{entry:void 0,suggestedName:i===f?this._suggestion:"",createEntry:async e=>{const i=await(0,u.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,r.B)(this,"value-changed",{value:e}),(0,r.B)(this,"change")}),0)}}]}}),(0,h.f)(l.oi)),(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:()=>!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:()=>!1},{kind:"field",decorators:[(0,s.Cb)({type:Boolean})],key:"required",value:()=>!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(){await this.updateComplete,await(this.labelPicker?.open())}},{kind:"method",key:"focus",value:async function(){await this.updateComplete,await(this.labelPicker?.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:()=>(0,d.Z)(((e,i,t)=>e?.map((e=>i?.[e])).sort(((e,i)=>(0,c.$K)(e?.name||"",i?.name||"",t)))))},{kind:"method",key:"render",value:function(){const e=this._sortedLabels(this.value,this._labels,this.hass.locale.language);return l.dy` ${e?.length?l.dy`<ha-chip-set> ${(0,o.r)(e,(e=>e?.label_id),(e=>{const i=e?.color?(0,n.I)(e.color):void 0;return l.dy` <ha-input-chip .item="${e}" @remove="${this._removeItem}" @click="${this._openDetail}" .label="${e?.name}" selected="selected" style="${i?`--color: ${i}`:""}"> ${e?.icon?l.dy`<ha-icon slot="icon" .icon="${e.icon}"></ha-icon>`:l.Ld} </ha-input-chip> `}))} </ha-chip-set>`:l.Ld} <ha-label-picker .hass="${this.hass}" .helper="${this.helper}" .disabled="${this.disabled}" .required="${this.required}" .label="${void 0===this.label&&this.hass?this.hass.localize("ui.components.label-picker.add_label"):this.label}" .placeholder="${this.placeholder}" .excludeLabels="${this.value}" @value-changed="${this._labelChanged}"> </ha-label-picker> `}},{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,b.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:()=>l.iv`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))}}; //# sourceMappingURL=89790.2cb2c1a2e94bcc5a.js.map