UNPKG

iobroker.lovelace

Version:

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

2 lines 13 kB
/*! For license information please see 79151.f4c8eb7af9af623a.js.LICENSE.txt */ export const __rspack_esm_id=79151;export const __rspack_esm_ids=[79151];export const __webpack_modules__={64138(e,t,i){i.a(e,async function(e,o){try{i.r(t),i.d(t,{HaIconPicker:()=>m});i(74423),i(44114),i(18111),i(22489),i(7588),i(61701),i(13579);var s=i(62826),a=i(5124),r=i(22441),l=i(22786),n=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=!1;const g=(e,t)=>{const i=`${t}:${e.name}`,o=e.name,s=o.split("-"),a=e.keywords??[],r={iconName:o};return s.forEach((e,t)=>{r[`part${t}`]=e}),a.forEach((e,t)=>{r[`keyword${t}`]=e}),{id:i,primary:i,icon:i,search_labels:r,sorting_label:i}},v=async()=>{u=!0;const e=await i.e(81340).then(i.t.bind(i,25143,19));p=e.default.map(e=>g(e,"mdi"));const t=[];Object.keys(d.y).forEach(e=>{t.push(_(e))}),(await Promise.all(t)).forEach(e=>{p.push(...e)})},_=async e=>{try{const t=d.y[e].getIconList;if("function"!=typeof t)return[];return(await t()).map(t=>g(t,e))}catch(t){return console.warn(`Unable to load icon list for ${e} iconset`),[]}},b=e=>a.qy` <ha-combo-box-item type="button"> <ha-icon .icon="${e.id}" slot="start"></ha-icon> ${e.id} </ha-combo-box-item> `;class m extends a.WF{render(){return a.qy` <ha-generic-picker allow-custom-value .getItems="${this._getIconPickerItems}" .helper="${this.helper}" .disabled="${this.disabled}" .required="${this.required}" .errorMessage="${this.errorMessage}" .invalid="${this.invalid}" .rowRenderer="${b}" .icon="${this._icon}" .label="${this.label}" .value="${this._value}" .searchFn="${this._filterIcons}" @value-changed="${this._valueChanged}"> <slot name="start"></slot> </ha-generic-picker> `}firstUpdated(){u||v().then(()=>{this._getIconPickerItems=()=>p,this.requestUpdate()})}_valueChanged(e){e.stopPropagation(),this._setValue(e.detail.value)}_setValue(e){this.value=e,(0,n.r)(this,"value-changed",{value:this._value},{bubbles:!1,composed:!1})}get _icon(){return this.value?.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=()=>p,this._filterIcons=(0,l.A)((e,t,i)=>{const o=e.toLowerCase().replace(/\s+/g,"-"),s=i?.length?i:t;if(!o.length)return s;const a=[];for(const e of s){const t=(e.id.split(":")[1]||e.id).toLowerCase().split("-"),i=e.search_labels?Object.values(e.search_labels).filter(e=>null!==e).map(e=>e.toLowerCase()):[],s=e.id.toLowerCase();t.includes(o)?a.push({item:e,rank:1}):i.includes(o)?a.push({item:e,rank:2}):s.includes(o)?a.push({item:e,rank:3}):i.some(e=>e.includes(o))&&a.push({item:e,rank:4})}return a.sort((e,t)=>e.rank-t.rank).map(e=>e.item)})}}m.styles=a.AH`ha-generic-picker{width:100%;display:block}`,(0,s.Cg)([(0,r.MZ)()],m.prototype,"value",void 0),(0,s.Cg)([(0,r.MZ)()],m.prototype,"label",void 0),(0,s.Cg)([(0,r.MZ)()],m.prototype,"helper",void 0),(0,s.Cg)([(0,r.MZ)()],m.prototype,"placeholder",void 0),(0,s.Cg)([(0,r.MZ)({attribute:"error-message"})],m.prototype,"errorMessage",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],m.prototype,"disabled",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],m.prototype,"required",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],m.prototype,"invalid",void 0),m=(0,s.Cg)([(0,r.EM)("ha-icon-picker")],m),o()}catch(e){o(e)}})},85938(e,t,i){i(18111),i(22489),i(46058);var o=i(62826),s=i(5124),a=i(22441),r=i(1087);class l extends s.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?s.s6:s.qy` <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,o={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&&(o.draggable=this.draggableSelector),this.handleSelector&&(o.handle=this.handleSelector),void 0!==this.invertSwap&&(o.invertSwap=this.invertSwap),this.group&&(o.group=this.group),this.filter&&(o.filter=this.filter),this._sortable=new t(e,o)}_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,o.Cg)([(0,a.MZ)({type:Boolean})],l.prototype,"disabled",void 0),(0,o.Cg)([(0,a.MZ)({type:Boolean,attribute:"no-style"})],l.prototype,"noStyle",void 0),(0,o.Cg)([(0,a.MZ)({type:String,attribute:"draggable-selector"})],l.prototype,"draggableSelector",void 0),(0,o.Cg)([(0,a.MZ)({type:String,attribute:"handle-selector"})],l.prototype,"handleSelector",void 0),(0,o.Cg)([(0,a.MZ)({type:String,attribute:"filter"})],l.prototype,"filter",void 0),(0,o.Cg)([(0,a.MZ)({type:String})],l.prototype,"group",void 0),(0,o.Cg)([(0,a.MZ)({type:Boolean,attribute:"invert-swap"})],l.prototype,"invertSwap",void 0),(0,o.Cg)([(0,a.MZ)({attribute:!1})],l.prototype,"options",void 0),(0,o.Cg)([(0,a.MZ)({type:Boolean})],l.prototype,"rollback",void 0),l=(0,o.Cg)([(0,a.EM)("ha-sortable")],l)},22514(e,t,i){i.a(e,async function(e,o){try{i.r(t);var s=i(62826),a=i(5124),r=i(22441),l=i(75751),n=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;const _="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",b="M21 11H3V9H21V11M21 13H3V15H21V13Z",m="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z";class y extends a.WF{_optionMoved(e){e.stopPropagation();const{oldIndex:t,newIndex:i}=e.detail,o=this._options.concat(),s=o.splice(t,1)[0];o.splice(i,0,s),(0,n.r)(this,"value-changed",{value:{...this._item,options:o}})}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(()=>this._focusElement?.focus())}render(){return this.hass?a.qy` <div class="form"> <ha-input dialogInitialFocus auto-validate required .validationMessage="${this.hass.localize("ui.dialogs.helper_settings.required_error_msg")}" .value="${this._name}" .label="${this.hass.localize("ui.dialogs.helper_settings.generic.name")}" .configValue="${"name"}" @input="${this._valueChanged}" .disabled="${this.disabled}"></ha-input> <ha-icon-picker .value="${this._icon}" .configValue="${"icon"}" @value-changed="${this._valueChanged}" .label="${this.hass.localize("ui.dialogs.helper_settings.generic.icon")}" .disabled="${this.disabled}"></ha-icon-picker> <div class="header"> ${this.hass.localize("ui.dialogs.helper_settings.input_select.options")}: </div> <ha-sortable @item-moved="${this._optionMoved}" handle-selector=".handle" .disabled="${this.disabled}"> <ha-list class="options"> ${this._options.length?(0,l.u)(this._options,e=>e,(e,t)=>a.qy` <ha-list-item class="option" hasMeta> <div class="optioncontent"> <div class="handle"> <ha-svg-icon .path="${b}"></ha-svg-icon> </div> ${e} </div> <ha-icon-button slot="meta" .index="${t}" .label="${this.hass.localize("ui.dialogs.helper_settings.input_select.remove_option")}" @click="${this._removeOption}" .disabled="${this.disabled}" .path="${_}"></ha-icon-button> </ha-list-item> `):a.s6} </ha-list> </ha-sortable> <div class="layout horizontal center"> <ha-input class="flex-auto" id="option_input" .label="${this.hass.localize("ui.dialogs.helper_settings.input_select.add_option")}" @keydown="${this._handleKeyAdd}" .disabled="${this.disabled}"></ha-input> <ha-button size="small" appearance="filled" @click="${this._addOption}" .disabled="${this.disabled}">${this.hass.localize("ui.dialogs.helper_settings.input_select.add")} <ha-svg-icon slot="start" .path="${m}"></ha-svg-icon> </ha-button> </div> </div> `:a.s6}_handleKeyAdd(e){e.stopPropagation(),"Enter"===e.key&&this._addOption()}_addOption(){const e=this._optionInput;e?.value&&((0,n.r)(this,"value-changed",{value:{...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,n.r)(this,"value-changed",{value:{...this._item,options:i}})}_valueChanged(e){if(!this.new&&!this._item)return;e.stopPropagation();const t=e.target.configValue,i=e.detail?.value||e.target.value;if(this[`_${t}`]===i)return;const o={...this._item};i?o[t]=i:delete o[t],(0,n.r)(this,"value-changed",{value:o})}static get styles(){return[g.RF,a.AH`.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,s.Cg)([(0,r.MZ)({attribute:!1})],y.prototype,"hass",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],y.prototype,"new",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],y.prototype,"disabled",void 0),(0,s.Cg)([(0,r.wk)()],y.prototype,"_name",void 0),(0,s.Cg)([(0,r.wk)()],y.prototype,"_icon",void 0),(0,s.Cg)([(0,r.wk)()],y.prototype,"_options",void 0),(0,s.Cg)([(0,r.P)("#option_input",!0)],y.prototype,"_optionInput",void 0),(0,s.Cg)([(0,r.P)("[dialogInitialFocus]")],y.prototype,"_focusElement",void 0),y=(0,s.Cg)([(0,r.EM)("ha-input_select-form")],y),o()}catch(e){o(e)}})},75751(e,t,i){i.d(t,{u:()=>l});i(45367),i(92731);var o=i(5055),s=i(42017),a=i(63937);const r=(e,t,i)=>{const o=new Map;for(let s=t;s<=i;s++)o.set(e[s],s);return o},l=(0,s.u$)(class extends s.WL{dt(e,t,i){let o;void 0===i?i=t:void 0!==t&&(o=t);const s=[],a=[];let r=0;for(const t of e)s[r]=o?o(t,r):r,a[r]=i(t,r),r++;return{values:a,keys:s}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,s]){const l=(0,a.cN)(e),{values:n,keys:d}=this.dt(t,i,s);if(!Array.isArray(l))return this.ut=d,n;const h=this.ut??=[],c=[];let p,u,g=0,v=l.length-1,_=0,b=n.length-1;for(;g<=v&&_<=b;)if(null===l[g])g++;else if(null===l[v])v--;else if(h[g]===d[_])c[_]=(0,a.lx)(l[g],n[_]),g++,_++;else if(h[v]===d[b])c[b]=(0,a.lx)(l[v],n[b]),v--,b--;else if(h[g]===d[b])c[b]=(0,a.lx)(l[g],n[b]),(0,a.Dx)(e,c[b+1],l[g]),g++,b--;else if(h[v]===d[_])c[_]=(0,a.lx)(l[v],n[_]),(0,a.Dx)(e,l[g],l[v]),v--,_++;else if(void 0===p&&(p=r(d,_,b),u=r(h,g,v)),p.has(h[g]))if(p.has(h[v])){const t=u.get(d[_]),i=void 0!==t?l[t]:null;if(null===i){const t=(0,a.Dx)(e,l[g]);(0,a.lx)(t,n[_]),c[_]=t}else c[_]=(0,a.lx)(i,n[_]),(0,a.Dx)(e,l[g],i),l[t]=null;_++}else(0,a.KO)(l[v]),v--;else(0,a.KO)(l[g]),g++;for(;_<=b;){const t=(0,a.Dx)(e,c[b+1]);(0,a.lx)(t,n[_]),c[_++]=t}for(;g<=v;){const e=l[g++];null!==e&&(0,a.KO)(e)}return this.ut=d,(0,a.mY)(e,c),o.c0}constructor(e){if(super(e),e.type!==s.OA.CHILD)throw Error("repeat() can only be used in text expressions")}})}};