iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
7 lines • 12.4 kB
JavaScript
export const __rspack_esm_id=66201;export const __rspack_esm_ids=[66201];export const __webpack_modules__={13467(e,t,i){var a=i(62826),s=i(41216),l=i(78960),o=i(75640),r=i(91735),d=i(43826),n=i(5124),c=i(22441);class h extends s.R{}h.styles=[r.R,d.R,o.R,l.R,n.AH`: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)}`],h=(0,a.Cg)([(0,c.EM)("ha-input-chip")],h)},81789(e,t,i){i.a(e,async function(e,a){try{i.d(t,{p:()=>$});i(74423),i(18111),i(22489),i(61701),i(13579),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);var s=i(62826),l=i(35211),o=i(5124),r=i(22441),d=i(89784),n=i(22786),c=i(78870),h=i(1087),p=i(22792),u=i(5904),b=i(92557),_=i(65063),y=i(69569),v=i(38508),g=i(49639),m=(i(67094),e([v,g]));[v,g]=m.then?(await m)():m;const f="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",C="___ADD_NEW___",$=e=>o.qy`<div style="${(0,d.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)"})}"></div>`;class x extends o.WF{willUpdate(e){this._pendingLabelId&&e.has("_labels")&&this._labels?.some(e=>e.label_id===this._pendingLabelId)&&(this._setValue(this._pendingLabelId),this._pendingLabelId=void 0)}async open(){await this.updateComplete,await(this._picker?.open())}render(){const e=this.placeholder??this.hass.localize("ui.components.label-picker.label");return o.qy` <ha-generic-picker .disabled="${this.disabled}" .hass="${this.hass}" .autofocus="${this.autofocus}" .label="${this.label}" .helper="${this.helper}" .notFoundLabel="${this._notFoundLabel}" .emptyLabel="${this.hass.localize("ui.components.label-picker.no_labels")}" .addButtonLabel="${this.hass.localize("ui.components.label-picker.add")}" .placeholder="${e}" .value="${this.value}" .getItems="${this._getItems}" .getAdditionalItems="${this._getAdditionalItems}" .rowRenderer="${this._rowRenderer}" .searchKeys="${u.u}" -changed="${this._valueChanged}"> <slot ="${this._handleSlotChange}" .slot="${this._slotNodes?.length?"field":void 0}"></slot> </ha-generic-picker> `}_valueChanged(e){e.stopPropagation();const t=e.detail.value;if(t){if(t.startsWith(C)){this.hass.loadFragmentTranslation("config");const e=t.substring(C.length);return void(0,y.f)(this,{suggestedName:e,createEntry:async e=>{try{const t=await(0,b._9)(this.hass,e);this._labels?.some(e=>e.label_id===t.label_id)?this._setValue(t.label_id):this._pendingLabelId=t.label_id}catch(e){(0,_.showAlertDialog)(this,{title:this.hass.localize("ui.components.label-picker.failed_create_label"),text:e.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=>o.qy`<ha-combo-box-item type="button" compact="compact"> ${(0,g.LE)(e)} ${e.id!==C?o.qy`<div slot="trailing-supporting-text"> ${$(e.color)} </div>`:o.s6} </ha-combo-box-item>`,this._getLabelsMemoized=(0,n.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,n.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:C+e,primary:this.hass.localize("ui.components.label-picker.add_new_suggestion",{name:e}),icon_path:f}]:[{id:C,primary:this.hass.localize("ui.components.label-picker.add_new"),icon_path:f}]},this._notFoundLabel=e=>this.hass.localize("ui.components.label-picker.no_match",{term:o.qy`<b>‘${e}’</b>`})}}(0,s.Cg)([(0,r.MZ)({attribute:!1})],x.prototype,"hass",void 0),(0,s.Cg)([(0,r.MZ)()],x.prototype,"label",void 0),(0,s.Cg)([(0,r.MZ)()],x.prototype,"value",void 0),(0,s.Cg)([(0,r.MZ)()],x.prototype,"helper",void 0),(0,s.Cg)([(0,r.MZ)()],x.prototype,"placeholder",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean,attribute:"no-add"})],x.prototype,"noAdd",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"include-domains"})],x.prototype,"includeDomains",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"exclude-domains"})],x.prototype,"excludeDomains",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"include-device-classes"})],x.prototype,"includeDeviceClasses",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"exclude-label"})],x.prototype,"excludeLabels",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],x.prototype,"deviceFilter",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],x.prototype,"entityFilter",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],x.prototype,"disabled",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],x.prototype,"required",void 0),(0,s.Cg)([(0,l.Fg)({context:p.HD,subscribe:!0}),(0,r.wk)()],x.prototype,"_labels",void 0),(0,s.Cg)([(0,r.KN)({flatten:!0})],x.prototype,"_slotNodes",void 0),(0,s.Cg)([(0,r.P)("ha-generic-picker")],x.prototype,"_picker",void 0),(0,s.Cg)([(0,r.wk)()],x.prototype,"_pendingLabelId",void 0),x=(0,s.Cg)([(0,r.EM)("ha-label-picker")],x),a()}catch(e){a(e)}})},50176(e,t,i){i.a(e,async function(e,t){try{i(74423),i(18111),i(22489),i(20116),i(61701);var a=i(62826),s=i(35211),l=i(5124),o=i(22441),r=i(75751),d=i(22786),n=i(1087),c=i(52220),h=i(22792),p=i(92557),u=i(69569),b=(i(5745),i(13467),i(23430)),_=i(81789),y=i(34127),v=e([_,y,b]);[_,y,b]=v.then?(await v)():v;const g="M3 16H10V14H3M18 14V10H16V14H12V16H16V20H18V16H22V14M14 6H3V8H14M14 10H3V12H14V10Z";class m extends l.WF{async open(){await this.updateComplete,await(this.labelPicker?.open())}async focus(){await this.updateComplete,await(this.labelPicker?.focus())}render(){const e=this._sortedLabels(this.value,this._labels,this.hass.locale.language);return l.qy` ${this.label?l.qy`<label>${this.label}</label>`:l.s6} <ha-label-picker .hass="${this.hass}" .helper="${this.helper}" .disabled="${this.disabled}" .required="${this.required}" .placeholder="${this.placeholder}" .excludeLabels="${this.value}" -changed="${this._labelChanged}"> <ha-chip-set> ${e?.length?(0,r.u)(e,e=>e?.label_id,e=>{if(!e)return l.s6;const t="label-"+e.label_id;return l.qy` <ha-tooltip .for="${t}" .disabled="${!e.description?.trim()}"> ${e.description} </ha-tooltip> <ha-input-chip .item="${e}" .id="${t}" ="${this._removeItem}" ="${this._openDetail}" .disabled="${this.disabled}" .label="${e.name}" selected="selected" style="${e.style}"> ${e.icon?l.qy`<ha-icon slot="icon" .icon="${e.icon}"></ha-icon>`:l.s6} </ha-input-chip> `}):l.s6} <ha-button id="picker" size="small" appearance="filled" ="${this._openPicker}" .disabled="${this.disabled}"> <ha-svg-icon .path="${g}" slot="start"></ha-svg-icon> ${this.hass.localize("ui.components.label-picker.add")} </ha-button> </ha-chip-set> </ha-label-picker> `}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,n.r)(this,"value-changed",{value:e}),(0,n.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,d.A)((e,t,i)=>e?.map(e=>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=>({...e,style:(0,b.l)(e.color)})))}}m.styles=l.AH`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,o.MZ)({attribute:!1})],m.prototype,"hass",void 0),(0,a.Cg)([(0,o.MZ)()],m.prototype,"label",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"value",void 0),(0,a.Cg)([(0,o.MZ)()],m.prototype,"helper",void 0),(0,a.Cg)([(0,o.MZ)()],m.prototype,"placeholder",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean,attribute:"no-add"})],m.prototype,"noAdd",void 0),(0,a.Cg)([(0,o.MZ)({type:Array,attribute:"include-domains"})],m.prototype,"includeDomains",void 0),(0,a.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-domains"})],m.prototype,"excludeDomains",void 0),(0,a.Cg)([(0,o.MZ)({type:Array,attribute:"include-device-classes"})],m.prototype,"includeDeviceClasses",void 0),(0,a.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-label"})],m.prototype,"excludeLabels",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"deviceFilter",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"entityFilter",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],m.prototype,"disabled",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],m.prototype,"required",void 0),(0,a.Cg)([(0,s.Fg)({context:h.HD,subscribe:!0}),(0,o.wk)()],m.prototype,"_labels",void 0),(0,a.Cg)([(0,o.P)("ha-label-picker",!0)],m.prototype,"labelPicker",void 0),m=(0,a.Cg)([(0,o.EM)("ha-labels-picker")],m),t()}catch(e){t(e)}})},5904(e,t,i){i.d(t,{I:()=>o,u:()=>l});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);var a=i(71727),s=i(58594);const l=[{name:"search_labels.name",weight:10},{name:"search_labels.description",weight:5},{name:"search_labels.id",weight:4}],o=(e,t,i,l,o,r,d,n,c,h,p,u="")=>{if(!o||0===o.length)return[];const b=Object.values(i),_=Object.values(l);let y,v,g={};(r||d||n||c||h)&&(g=(0,s.g2)(_),y=b,v=_.filter(e=>e.labels.length>0),r&&(y=y.filter(e=>{const t=g[e.id];return!(!t||!t.length)&&g[e.id].some(e=>r.includes((0,a.m)(e.entity_id)))}),v=v.filter(e=>r.includes((0,a.m)(e.entity_id)))),d&&(y=y.filter(e=>{const t=g[e.id];return!t||!t.length||_.every(e=>!d.includes((0,a.m)(e.entity_id)))}),v=v.filter(e=>!d.includes((0,a.m)(e.entity_id)))),n&&(y=y.filter(t=>{const i=g[t.id];return!(!i||!i.length)&&g[t.id].some(t=>{const i=e[t.entity_id];return!!i&&(i.attributes.device_class&&n.includes(i.attributes.device_class))})}),v=v.filter(t=>{const i=e[t.entity_id];return i&&i.attributes.device_class&&n.includes(i.attributes.device_class)})),c&&(y=y.filter(e=>c(e))),h&&(y=y.filter(t=>{const i=g[t.id];return!(!i||!i.length)&&g[t.id].some(t=>{const i=e[t.entity_id];return!!i&&h(i)})}),v=v.filter(t=>{const i=e[t.entity_id];return!!i&&h(i)})));let m=o;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))})),v&&(C=(C??[]).concat(v.filter(e=>e.area_id).map(e=>e.area_id)),v.forEach(e=>{e.labels.forEach(e=>f.add(e))})),C&&C.forEach(e=>{const i=t[e];i?.labels.forEach(e=>f.add(e))}),p&&(m=m.filter(e=>!p.includes(e.label_id))),(y||v)&&(m=m.filter(e=>f.has(e.label_id)));return m.map(e=>({id:`${u}${e.label_id}`,primary:e.name,secondary:e.description??"",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}))}}};