UNPKG

iobroker.lovelace

Version:

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

2 lines 13.7 kB
/*! For license information please see 79151.f0292dfd90beddbc.js.LICENSE.txt */ "use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[79151],{64138:function(e,t,i){i.a(e,async function(e,s){try{i.r(t),i.d(t,{HaIconPicker:function(){return $}});i(74423),i(44114),i(26910),i(18111),i(22489),i(7588),i(61701),i(13579),i(3362),i(27495),i(25440),i(62953);var a=i(40445),o=i(5124),r=i(67576),n=i(22786),l=i(1087),d=i(700),h=(i(75064),i(38508)),c=(i(47680),e([h]));h=(c.then?(await c)():c)[0];let p,u,g,v=e=>e,b=[],_=!1;const m=(e,t)=>{var i;const s=`${t}:${e.name}`,a=e.name,o=a.split("-"),r=null!==(i=e.keywords)&&void 0!==i?i:[],n={iconName:a};return o.forEach((e,t)=>{n[`part${t}`]=e}),r.forEach((e,t)=>{n[`keyword${t}`]=e}),{id:s,primary:s,icon:s,search_labels:n,sorting_label:s}},y=async()=>{_=!0;const e=await i.e(81340).then(i.t.bind(i,25143,19));b=e.default.map(e=>m(e,"mdi"));const t=[];Object.keys(d.y).forEach(e=>{t.push(f(e))}),(await Promise.all(t)).forEach(e=>{b.push(...e)})},f=async e=>{try{const t=d.y[e].getIconList;if("function"!=typeof t)return[];return(await t()).map(t=>m(t,e))}catch(t){return console.warn(`Unable to load icon list for ${e} iconset`),[]}},k=e=>(0,o.qy)(p||(p=v` <ha-combo-box-item type="button"> <ha-icon .icon="${0}" slot="start"></ha-icon> ${0} </ha-combo-box-item> `),e.id,e.id);class $ extends o.WF{render(){return(0,o.qy)(u||(u=v` <ha-generic-picker allow-custom-value .getItems="${0}" .helper="${0}" .disabled="${0}" .required="${0}" .errorMessage="${0}" .invalid="${0}" .rowRenderer="${0}" .icon="${0}" .label="${0}" .value="${0}" .searchFn="${0}" @value-changed="${0}"> <slot name="start"></slot> </ha-generic-picker> `),this._getIconPickerItems,this.helper,this.disabled,this.required,this.errorMessage,this.invalid,k,this._icon,this.label,this._value,this._filterIcons,this._valueChanged)}firstUpdated(){_||y().then(()=>{this._getIconPickerItems=()=>b,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(){var e;return null!==(e=this.value)&&void 0!==e&&e.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=()=>b,this._filterIcons=(0,n.A)((e,t,i)=>{const s=e.toLowerCase().replace(/\s+/g,"-"),a=null!=i&&i.length?i:t;if(!s.length)return a;const o=[];for(const r of a){const e=(r.id.split(":")[1]||r.id).toLowerCase().split("-"),t=r.search_labels?Object.values(r.search_labels).filter(e=>null!==e).map(e=>e.toLowerCase()):[],i=r.id.toLowerCase();e.includes(s)?o.push({item:r,rank:1}):t.includes(s)?o.push({item:r,rank:2}):i.includes(s)?o.push({item:r,rank:3}):t.some(e=>e.includes(s))&&o.push({item:r,rank:4})}return o.sort((e,t)=>e.rank-t.rank).map(e=>e.item)})}}$.styles=(0,o.AH)(g||(g=v`ha-generic-picker{width:100%;display:block}`)),(0,a.Cg)([(0,r.MZ)()],$.prototype,"value",void 0),(0,a.Cg)([(0,r.MZ)()],$.prototype,"label",void 0),(0,a.Cg)([(0,r.MZ)()],$.prototype,"helper",void 0),(0,a.Cg)([(0,r.MZ)()],$.prototype,"placeholder",void 0),(0,a.Cg)([(0,r.MZ)({attribute:"error-message"})],$.prototype,"errorMessage",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],$.prototype,"disabled",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],$.prototype,"required",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],$.prototype,"invalid",void 0),$=(0,a.Cg)([(0,r.EM)("ha-icon-picker")],$),s()}catch(p){s(p)}})},85938:function(e,t,i){i(18111),i(22489),i(3362),i(46058),i(62953);var s=i(40445),a=i(5124),o=i(67576),r=i(1087);let n,l=e=>e;class d extends a.WF{updated(e){e.has("disabled")&&(this.disabled?this._destroySortable():this._createSortable())}disconnectedCallback(){super.disconnectedCallback(),this._shouldBeDestroy=!0,setTimeout(()=>{this._shouldBeDestroy&&(this._destroySortable(),this._shouldBeDestroy=!1)},1)}connectedCallback(){super.connectedCallback(),this._shouldBeDestroy=!1,this.hasUpdated&&!this.disabled&&this._createSortable()}createRenderRoot(){return this}render(){return this.noStyle?a.s6:(0,a.qy)(n||(n=l` <style>.sortable-fallback{display:none!important}.sortable-ghost{box-shadow:0 0 0 2px var(--primary-color);background:rgba(var(--rgb-primary-color),.25);border-radius:var(--ha-border-radius-sm);opacity:.4}.sortable-drag{border-radius:var(--ha-border-radius-sm);opacity:1;background:var(--card-background-color);box-shadow:0px 4px 8px 3px #00000026;cursor:grabbing}</style> `))}async _createSortable(){if(this._sortable)return;const e=this.children[0];if(!e)return;const t=(await Promise.all([i.e(85283),i.e(70322)]).then(i.bind(i,80745))).default,s=Object.assign(Object.assign({scroll:!0,forceAutoScrollFallback:!0,scrollSpeed:20,animation:150},this.options),{},{onChoose:this._handleChoose,onStart:this._handleStart,onEnd:this._handleEnd,onUpdate:this._handleUpdate,onAdd:this._handleAdd,onRemove:this._handleRemove});this.draggableSelector&&(s.draggable=this.draggableSelector),this.handleSelector&&(s.handle=this.handleSelector),void 0!==this.invertSwap&&(s.invertSwap=this.invertSwap),this.group&&(s.group=this.group),this.filter&&(s.filter=this.filter),this._sortable=new t(e,s)}_destroySortable(){this._sortable&&(this._sortable.destroy(),this._sortable=void 0)}constructor(...e){super(...e),this.disabled=!1,this.noStyle=!1,this.invertSwap=!1,this.rollback=!0,this._shouldBeDestroy=!1,this._handleUpdate=e=>{(0,r.r)(this,"item-moved",{newIndex:e.newIndex,oldIndex:e.oldIndex})},this._handleAdd=e=>{(0,r.r)(this,"item-added",{index:e.newIndex,data:e.item.sortableData,item:e.item})},this._handleRemove=e=>{(0,r.r)(this,"item-removed",{index:e.oldIndex})},this._handleEnd=async e=>{(0,r.r)(this,"drag-end"),this.rollback&&e.item.placeholder&&(e.item.placeholder.replaceWith(e.item),delete e.item.placeholder)},this._handleStart=()=>{(0,r.r)(this,"drag-start")},this._handleChoose=e=>{this.rollback&&(e.item.placeholder=document.createComment("sort-placeholder"),e.item.after(e.item.placeholder))}}}(0,s.Cg)([(0,o.MZ)({type:Boolean})],d.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"no-style"})],d.prototype,"noStyle",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"draggable-selector"})],d.prototype,"draggableSelector",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"handle-selector"})],d.prototype,"handleSelector",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"filter"})],d.prototype,"filter",void 0),(0,s.Cg)([(0,o.MZ)({type:String})],d.prototype,"group",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"invert-swap"})],d.prototype,"invertSwap",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],d.prototype,"options",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],d.prototype,"rollback",void 0),d=(0,s.Cg)([(0,o.EM)("ha-sortable")],d)},22514:function(e,t,i){i.a(e,async function(e,s){try{i.r(t);i(3362),i(62953);var a=i(40445),o=i(5124),r=i(67576),n=i(75751),l=i(1087),d=i(18350),h=i(26300),c=i(64138),p=(i(8630),i(28732),i(85938),i(67094),i(91485)),u=i(65063),g=i(14503),v=e([d,h,c,p]);[d,h,c,p]=v.then?(await v)():v;let b,_,m,y=e=>e;const f="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",k="M21 11H3V9H21V11M21 13H3V15H21V13Z",$="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z";class C extends o.WF{_optionMoved(e){e.stopPropagation();const{oldIndex:t,newIndex:i}=e.detail,s=this._options.concat(),a=s.splice(t,1)[0];s.splice(i,0,a),(0,l.r)(this,"value-changed",{value:Object.assign(Object.assign({},this._item),{},{options:s})})}set item(e){this._item=e,e?(this._name=e.name||"",this._icon=e.icon||"",this._options=e.options||[]):(this._name="",this._icon="",this._options=[])}focus(){this.updateComplete.then(()=>{var e;return null===(e=this._focusElement)||void 0===e?void 0:e.focus()})}render(){return this.hass?(0,o.qy)(b||(b=y` <div class="form"> <ha-input dialogInitialFocus auto-validate required .validationMessage="${0}" .value="${0}" .label="${0}" .configValue="${0}" @input="${0}" .disabled="${0}"></ha-input> <ha-icon-picker .value="${0}" .configValue="${0}" @value-changed="${0}" .label="${0}" .disabled="${0}"></ha-icon-picker> <div class="header"> ${0}: </div> <ha-sortable @item-moved="${0}" handle-selector=".handle" .disabled="${0}"> <ha-list class="options"> ${0} </ha-list> </ha-sortable> <div class="layout horizontal center"> <ha-input class="flex-auto" id="option_input" .label="${0}" @keydown="${0}" .disabled="${0}"></ha-input> <ha-button size="small" appearance="filled" @click="${0}" .disabled="${0}">${0} <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> </ha-button> </div> </div> `),this.hass.localize("ui.dialogs.helper_settings.required_error_msg"),this._name,this.hass.localize("ui.dialogs.helper_settings.generic.name"),"name",this._valueChanged,this.disabled,this._icon,"icon",this._valueChanged,this.hass.localize("ui.dialogs.helper_settings.generic.icon"),this.disabled,this.hass.localize("ui.dialogs.helper_settings.input_select.options"),this._optionMoved,this.disabled,this._options.length?(0,n.u)(this._options,e=>e,(e,t)=>(0,o.qy)(_||(_=y` <ha-list-item class="option" hasMeta> <div class="optioncontent"> <div class="handle"> <ha-svg-icon .path="${0}"></ha-svg-icon> </div> ${0} </div> <ha-icon-button slot="meta" .index="${0}" .label="${0}" @click="${0}" .disabled="${0}" .path="${0}"></ha-icon-button> </ha-list-item> `),k,e,t,this.hass.localize("ui.dialogs.helper_settings.input_select.remove_option"),this._removeOption,this.disabled,f)):o.s6,this.hass.localize("ui.dialogs.helper_settings.input_select.add_option"),this._handleKeyAdd,this.disabled,this._addOption,this.disabled,this.hass.localize("ui.dialogs.helper_settings.input_select.add"),$):o.s6}_handleKeyAdd(e){e.stopPropagation(),"Enter"===e.key&&this._addOption()}_addOption(){const e=this._optionInput;null!=e&&e.value&&((0,l.r)(this,"value-changed",{value:Object.assign(Object.assign({},this._item),{},{options:[...this._options,e.value]})}),e.value="")}async _removeOption(e){const t=e.target.index;if(!(await(0,u.dk)(this,{title:this.hass.localize("ui.dialogs.helper_settings.input_select.confirm_delete.delete"),text:this.hass.localize("ui.dialogs.helper_settings.input_select.confirm_delete.prompt"),destructive:!0})))return;const i=[...this._options];i.splice(t,1),(0,l.r)(this,"value-changed",{value:Object.assign(Object.assign({},this._item),{},{options:i})})}_valueChanged(e){var t;if(!this.new&&!this._item)return;e.stopPropagation();const i=e.target.configValue,s=(null===(t=e.detail)||void 0===t?void 0:t.value)||e.target.value;if(this[`_${i}`]===s)return;const a=Object.assign({},this._item);s?a[i]=s:delete a[i],(0,l.r)(this,"value-changed",{value:a})}static get styles(){return[g.RF,(0,o.AH)(m||(m=y`.form{color:var(--primary-text-color)}.option{border:1px solid var(--divider-color);border-radius:var(--ha-border-radius-sm);margin-top:var(--ha-space-1);--ha-icon-button-size:24px;--mdc-ripple-color:transparent;--mdc-list-side-padding:var(--ha-space-4);cursor:default;background-color:var(--card-background-color)}ha-input{--ha-input-padding-bottom:0}#option_input{margin-top:var(--ha-space-2)}.header{margin-top:var(--ha-space-2)}.handle{cursor:move;cursor:grab;padding-right:var(--ha-space-3);padding-inline-end:var(--ha-space-3);padding-inline-start:initial}.handle ha-svg-icon{pointer-events:none;height:24px}.optioncontent{display:flex;align-items:center}ha-icon-picker{display:block;margin-bottom:var(--ha-space-5)}ha-button{margin-inline-start:var(--ha-space-3);margin-top:var(--ha-space-1)}`))]}constructor(...e){super(...e),this.new=!1,this.disabled=!1,this._options=[]}}(0,a.Cg)([(0,r.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"new",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"disabled",void 0),(0,a.Cg)([(0,r.wk)()],C.prototype,"_name",void 0),(0,a.Cg)([(0,r.wk)()],C.prototype,"_icon",void 0),(0,a.Cg)([(0,r.wk)()],C.prototype,"_options",void 0),(0,a.Cg)([(0,r.P)("#option_input",!0)],C.prototype,"_optionInput",void 0),(0,a.Cg)([(0,r.P)("[dialogInitialFocus]")],C.prototype,"_focusElement",void 0),C=(0,a.Cg)([(0,r.EM)("ha-input_select-form")],C),s()}catch(b){s(b)}})},75751:function(e,t,i){i.d(t,{u:function(){return n}});i(16280),i(45367),i(92731),i(62953);var s=i(5055),a=i(42017),o=i(63937);const r=(e,t,i)=>{const s=new Map;for(let a=t;a<=i;a++)s.set(e[a],a);return s},n=(0,a.u$)(class extends a.WL{dt(e,t,i){let s;void 0===i?i=t:void 0!==t&&(s=t);const a=[],o=[];let r=0;for(const n of e)a[r]=s?s(n,r):r,o[r]=i(n,r),r++;return{values:o,keys:a}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,a]){var n;const l=(0,o.cN)(e),{values:d,keys:h}=this.dt(t,i,a);if(!Array.isArray(l))return this.ut=h,d;const c=null!==(n=this.ut)&&void 0!==n?n:this.ut=[],p=[];let u,g,v=0,b=l.length-1,_=0,m=d.length-1;for(;v<=b&&_<=m;)if(null===l[v])v++;else if(null===l[b])b--;else if(c[v]===h[_])p[_]=(0,o.lx)(l[v],d[_]),v++,_++;else if(c[b]===h[m])p[m]=(0,o.lx)(l[b],d[m]),b--,m--;else if(c[v]===h[m])p[m]=(0,o.lx)(l[v],d[m]),(0,o.Dx)(e,p[m+1],l[v]),v++,m--;else if(c[b]===h[_])p[_]=(0,o.lx)(l[b],d[_]),(0,o.Dx)(e,l[v],l[b]),b--,_++;else if(void 0===u&&(u=r(h,_,m),g=r(c,v,b)),u.has(c[v]))if(u.has(c[b])){const t=g.get(h[_]),i=void 0!==t?l[t]:null;if(null===i){const t=(0,o.Dx)(e,l[v]);(0,o.lx)(t,d[_]),p[_]=t}else p[_]=(0,o.lx)(i,d[_]),(0,o.Dx)(e,l[v],i),l[t]=null;_++}else(0,o.KO)(l[b]),b--;else(0,o.KO)(l[v]),v++;for(;_<=m;){const t=(0,o.Dx)(e,p[m+1]);(0,o.lx)(t,d[_]),p[_++]=t}for(;v<=b;){const e=l[v++];null!==e&&(0,o.KO)(e)}return this.ut=h,(0,o.mY)(e,p),s.c0}constructor(e){if(super(e),e.type!==a.OA.CHILD)throw Error("repeat() can only be used in text expressions")}})}}]);