iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 10 kB
JavaScript
export const __webpack_ids__=["94377"];export const __webpack_modules__={29073:function(e,t,a){a.d(t,{u:()=>u});var o=a(44249),i=a(72621),n=(a(9359),a(31526),a(70104),a(57243)),l=a(15093),r=a(29567),s=a(36522);a(99426),a(66671);const d={boolean:()=>Promise.all([a.e("29570"),a.e("79350")]).then(a.bind(a,8353)),constant:()=>a.e("69654").then(a.bind(a,5606)),float:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("62022")]).then(a.bind(a,53203)),grid:()=>a.e("45036").then(a.bind(a,20018)),expandable:()=>a.e("42653").then(a.bind(a,91624)),integer:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("42950"),a.e("29570"),a.e("65505"),a.e("92139"),a.e("94320"),a.e("42849")]).then(a.bind(a,96116)),multi_select:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("91552"),a.e("78456"),a.e("56898"),a.e("42950"),a.e("29570"),a.e("65505"),a.e("5080"),a.e("50408"),a.e("13204"),a.e("99562")]).then(a.bind(a,84545)),positive_time_period_dict:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("91552"),a.e("78456"),a.e("41258"),a.e("56898"),a.e("35671"),a.e("71139"),a.e("31352")]).then(a.bind(a,15063)),select:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("91552"),a.e("78456"),a.e("24199"),a.e("41258"),a.e("56898"),a.e("27506"),a.e("35671"),a.e("42950"),a.e("29570"),a.e("65505"),a.e("7010"),a.e("62524"),a.e("5409"),a.e("47818"),a.e("69638")]).then(a.bind(a,62706)),string:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("36620")]).then(a.bind(a,8327)),optional_actions:()=>a.e("85230").then(a.bind(a,26709))},c=(e,t)=>e?!t.name||t.flatten?e:e[t.name]:null;let u=(0,o.Z)([(0,l.Mo)("ha-form")],(function(e,t){class a extends t{constructor(...t){super(...t),e(this)}}return{F:a,d:[{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"data",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"schema",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"error",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"warning",value:void 0},{kind:"field",decorators:[(0,l.Cb)({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"computeError",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"computeWarning",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"computeLabel",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"computeHelper",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"localizeValue",value:void 0},{kind:"method",key:"getFormProperties",value:function(){return{}}},{kind:"method",key:"focus",value:async function(){await this.updateComplete;const e=this.renderRoot.querySelector(".root");if(e)for(const t of e.children)if("HA-ALERT"!==t.tagName){t instanceof n.fl&&await t.updateComplete,t.focus();break}}},{kind:"method",key:"willUpdate",value:function(e){e.has("schema")&&this.schema&&this.schema.forEach((e=>{"selector"in e||d[e.type]?.()}))}},{kind:"method",key:"render",value:function(){return n.dy` <div class="root" part="root"> ${this.error&&this.error.base?n.dy` <ha-alert alert-type="error"> ${this._computeError(this.error.base,this.schema)} </ha-alert> `:""} ${this.schema.map((e=>{const t=((e,t)=>e&&t.name?e[t.name]:null)(this.error,e),a=((e,t)=>e&&t.name?e[t.name]:null)(this.warning,e);return n.dy` ${t?n.dy` <ha-alert own-margin alert-type="error"> ${this._computeError(t,e)} </ha-alert> `:a?n.dy` <ha-alert own-margin alert-type="warning"> ${this._computeWarning(a,e)} </ha-alert> `:""} ${"selector"in e?n.dy`<ha-selector .schema="${e}" .hass="${this.hass}" .name="${e.name}" .selector="${e.selector}" .value="${c(this.data,e)}" .label="${this._computeLabel(e,this.data)}" .disabled="${e.disabled||this.disabled||!1}" .placeholder="${e.required?"":e.default}" .helper="${this._computeHelper(e)}" .localizeValue="${this.localizeValue}" .required="${e.required||!1}" .context="${this._generateContext(e)}"></ha-selector>`:(0,r.h)(this.fieldElementName(e.type),{schema:e,data:c(this.data,e),label:this._computeLabel(e,this.data),helper:this._computeHelper(e),disabled:this.disabled||e.disabled||!1,hass:this.hass,localize:this.hass?.localize,computeLabel:this.computeLabel,computeHelper:this.computeHelper,localizeValue:this.localizeValue,context:this._generateContext(e),...this.getFormProperties()})} `}))} </div> `}},{kind:"method",key:"fieldElementName",value:function(e){return`ha-form-${e}`}},{kind:"method",key:"_generateContext",value:function(e){if(!e.context)return;const t={};for(const[a,o]of Object.entries(e.context))t[a]=this.data[o];return t}},{kind:"method",key:"createRenderRoot",value:function(){const e=(0,i.Z)(a,"createRenderRoot",this,3)([]);return this.addValueChangedListener(e),e}},{kind:"method",key:"addValueChangedListener",value:function(e){e.addEventListener("value-changed",(e=>{e.stopPropagation();const t=e.target.schema;if(e.target===this)return;const a=!t.name||"flatten"in t&&t.flatten?e.detail.value:{[t.name]:e.detail.value};this.data={...this.data,...a},(0,s.B)(this,"value-changed",{value:this.data})}))}},{kind:"method",key:"_computeLabel",value:function(e,t){return this.computeLabel?this.computeLabel(e,t):e?e.name:""}},{kind:"method",key:"_computeHelper",value:function(e){return this.computeHelper?this.computeHelper(e):""}},{kind:"method",key:"_computeError",value:function(e,t){return Array.isArray(e)?n.dy`<ul> ${e.map((e=>n.dy`<li> ${this.computeError?this.computeError(e,t):e} </li>`))} </ul>`:this.computeError?this.computeError(e,t):e}},{kind:"method",key:"_computeWarning",value:function(e,t){return this.computeWarning?this.computeWarning(e,t):e}},{kind:"field",static:!0,key:"styles",value:()=>n.iv`.root>*{display:block}.root>:not([own-margin]):not(:last-child){margin-bottom:24px}ha-alert[own-margin]{margin-bottom:4px}`}]}}),n.oi)},61320:function(e,t,a){a.r(t),a.d(t,{HaSelectorSelector:()=>c});var o=a(44249),i=(a(9359),a(70104),a(57243)),n=a(15093),l=a(27486),r=a(36522);a(99426),a(29073);const s={number:{min:1,max:100}},d={action:[],area:[{name:"multiple",selector:{boolean:{}}}],attribute:[{name:"entity_id",selector:{entity:{}}}],boolean:[],color_temp:[{name:"unit",selector:{select:{options:["kelvin","mired"]}}},{name:"min",selector:{number:{mode:"box"}}},{name:"max",selector:{number:{mode:"box"}}}],condition:[],date:[],datetime:[],device:[{name:"multiple",selector:{boolean:{}}}],duration:[{name:"enable_day",selector:{boolean:{}}},{name:"enable_millisecond",selector:{boolean:{}}}],entity:[{name:"multiple",selector:{boolean:{}}}],floor:[{name:"multiple",selector:{boolean:{}}}],icon:[],location:[],media:[],number:[{name:"min",selector:{number:{mode:"box",step:"any"}}},{name:"max",selector:{number:{mode:"box",step:"any"}}},{name:"step",selector:{number:{mode:"box",step:"any"}}}],object:[],color_rgb:[],select:[{name:"options",selector:{object:{}}},{name:"multiple",selector:{boolean:{}}}],state:[{name:"entity_id",selector:{entity:{}}}],target:[],template:[],text:[{name:"multiple",selector:{boolean:{}}},{name:"multiline",selector:{boolean:{}}},{name:"prefix",selector:{text:{}}},{name:"suffix",selector:{text:{}}}],theme:[],time:[]};let c=(0,o.Z)([(0,n.Mo)("ha-selector-selector")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"value",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"label",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"helper",value:void 0},{kind:"field",decorators:[(0,n.Cb)({type:Boolean,reflect:!0})],key:"disabled",value:()=>!1},{kind:"field",decorators:[(0,n.Cb)({type:Boolean,reflect:!0})],key:"required",value:()=>!0},{kind:"field",key:"_yamlMode",value:()=>!1},{kind:"method",key:"shouldUpdate",value:function(e){return 1!==e.size||!e.has("hass")}},{kind:"field",key:"_schema",value:()=>(0,l.Z)(((e,t)=>[{name:"type",selector:{select:{mode:"dropdown",required:!0,options:Object.keys(d).concat("manual").map((e=>({label:t(`ui.components.selectors.selector.types.${e}`)||e,value:e})))}}},..."manual"===e?[{name:"manual",selector:{object:{}}}]:[],...d[e]?d[e].length>1?[{name:"",type:"expandable",title:t("ui.components.selectors.selector.options"),schema:d[e]}]:d[e]:[]]))},{kind:"method",key:"render",value:function(){let e,t;if(this._yamlMode)t="manual",e={type:t,manual:this.value};else{t=Object.keys(this.value)[0];const a=Object.values(this.value)[0];e={type:t,..."object"==typeof a?a:[]}}const a=this._schema(t,this.hass.localize);return i.dy`<ha-card> <div class="card-content"> <p>${this.label?this.label:""}</p> <ha-form .hass="${this.hass}" .data="${e}" .schema="${a}" .computeLabel="${this._computeLabelCallback}" -changed="${this._valueChanged}"></ha-form></div></ha-card>`}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value,a=t.type;if(!a||"object"!=typeof t||0===Object.keys(t).length)return;const o=Object.keys(this.value)[0];if("manual"===a&&!this._yamlMode)return this._yamlMode=!0,void this.requestUpdate();if("manual"===a&&void 0===t.manual)return;let i;"manual"!==a&&(this._yamlMode=!1),delete t.type,i="manual"===a?t.manual:a===o?{[a]:{...t.manual?t.manual[o]:t}}:{[a]:{...s[a]}},(0,r.B)(this,"value-changed",{value:i})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.components.selectors.selector.${e.name}`)||e.name}},{kind:"field",static:!0,key:"styles",value:()=>i.iv`:host{--expansion-panel-summary-padding:0 16px}ha-alert{display:block;margin-bottom:16px}ha-card{margin:0 0 16px 0}ha-card.disabled{pointer-events:none;color:var(--disabled-text-color)}.card-content{padding:0px 16px 16px 16px}.title{font-size:16px;padding-top:16px;overflow:hidden;text-overflow:ellipsis;margin-bottom:16px;padding-left:16px;padding-right:4px;padding-inline-start:16px;padding-inline-end:4px;white-space:nowrap}`}]}}),i.oi)}};
//# sourceMappingURL=94377.289cf94c3c682e98.js.map