iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 10.3 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[77810],{52763:function(e,t,a){a.a(e,async function(e,o){try{a.d(t,{U:function(){return w}});a(74423),a(18111),a(7588),a(61701),a(3362),a(62953);var r=a(40445),n=a(5124),i=a(67576),l=a(69558),s=a(1087),c=a(38962),p=(a(11399),e([c]));c=(p.then?(await p)():p)[0];let m,d,h,u,b,y,g,v,f,_=e=>e;const x={boolean:()=>a.e(81347).then(a.bind(a,46990)),constant:()=>a.e(65733).then(a.bind(a,90820)),float:()=>Promise.all([a.e(72850),a.e(39763),a.e(32450),a.e(51868),a.e(62574),a.e(16113)]).then(a.bind(a,20676)),grid:()=>a.e(60761).then(a.bind(a,70208)),expandable:()=>a.e(45001).then(a.bind(a,40003)),integer:()=>Promise.all([a.e(72850),a.e(39763),a.e(32450),a.e(21543),a.e(86712),a.e(62574),a.e(12145)]).then(a.bind(a,20036)),multi_select:()=>Promise.all([a.e(72850),a.e(39763),a.e(46095),a.e(34995),a.e(80131),a.e(58303),a.e(71739),a.e(78219)]).then(a.bind(a,36182)),positive_time_period_dict:()=>Promise.all([a.e(72850),a.e(39763),a.e(32450),a.e(46095),a.e(34995),a.e(67943),a.e(62574),a.e(16508),a.e(21486)]).then(a.bind(a,89422)),select:()=>Promise.all([a.e(72850),a.e(39763),a.e(32450),a.e(46095),a.e(7305),a.e(92769),a.e(34995),a.e(3283),a.e(81034),a.e(99463),a.e(62574),a.e(26092),a.e(39005),a.e(35873),a.e(63577)]).then(a.bind(a,63804)),string:()=>Promise.all([a.e(72850),a.e(39763),a.e(32450),a.e(84725),a.e(62574),a.e(6762)]).then(a.bind(a,54753)),optional_actions:()=>Promise.all([a.e(72850),a.e(39763),a.e(34995),a.e(67395)]).then(a.bind(a,8456))},C=(e,t)=>e?!t.name||t.flatten?e:e[t.name]:void 0,$=(e,t)=>e&&t.name?e[t.name]:null,M=(e,t)=>e&&t.name?e[t.name]:null;class w extends n.WF{getFormProperties(){return{}}reportValidity(){const e=this._root;if(!e)return!0;const t=[...e.children].filter(e=>"ha-alert"!==e.localName);let a,o=!0;var r,n;(this.schema.forEach((e,r)=>{var n;const i=t[r];if(!i)return;let l=!0;if("reportValidity"in i&&"function"==typeof i.reportValidity)l=i.reportValidity();else if(e.required&&(!("type"in e)||!["boolean","constant"].includes(null!==(n=e.type)&&void 0!==n?n:""))&&(!("selector"in e)||!("boolean"in e.selector)&&!("constant"in e.selector))){const t=C(this.data,e);l=null!=t&&""!==t}l||(o=!1,a||(a=i))}),a)&&(null===(r=(n=a).focus)||void 0===r||r.call(n));return o}willUpdate(e){e.has("schema")&&this.schema&&this.schema.forEach(e=>{var t;"selector"in e||null===(t=x[e.type])||void 0===t||t.call(x)})}render(){return(0,n.qy)(m||(m=_` <div class="root" part="root"> ${0} ${0} </div> `),this.error&&this.error.base?(0,n.qy)(d||(d=_` <ha-alert alert-type="error"> ${0} </ha-alert> `),this._computeError(this.error.base,this.schema)):"",this.schema.map(e=>{var t;const a=$(this.error,e),o=M(this.warning,e);return(0,n.qy)(h||(h=_` ${0} ${0} `),a?(0,n.qy)(u||(u=_` <ha-alert own-margin alert-type="error"> ${0} </ha-alert> `),this._computeError(a,e)):o?(0,n.qy)(b||(b=_` <ha-alert own-margin alert-type="warning"> ${0} </ha-alert> `),this._computeWarning(o,e)):"","selector"in e?(0,n.qy)(y||(y=_`<ha-selector .schema="${0}" .hass="${0}" .narrow="${0}" .name="${0}" .selector="${0}" .value="${0}" .label="${0}" .disabled="${0}" .placeholder="${0}" .helper="${0}" .localizeValue="${0}" .required="${0}" .context="${0}"></ha-selector>`),e,this.hass,this.narrow,e.name,e.selector,C(this.data,e),this._computeLabel(e,this.data),e.disabled||this.disabled||!1,e.required?void 0:e.default,this._computeHelper(e),this.localizeValue,e.required||!1,this._generateContext(e)):(0,l._)(this.fieldElementName(e.type),Object.assign({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:null===(t=this.hass)||void 0===t?void 0:t.localize,computeLabel:this.computeLabel,computeHelper:this.computeHelper,localizeValue:this.localizeValue,context:this._generateContext(e)},this.getFormProperties())))}))}fieldElementName(e){return`ha-form-${e}`}_generateContext(e){if(!e.context&&!this.context)return;const t=Object.assign({},this.context);if(e.context)for(const[a,o]of Object.entries(e.context))t[a]=this.data[o];return t}createRenderRoot(){const e=super.createRenderRoot();return this.addValueChangedListener(e),e}addValueChangedListener(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=Object.assign(Object.assign({},this.data),a),(0,s.r)(this,"value-changed",{value:this.data})})}_computeLabel(e,t){return this.computeLabel?this.computeLabel(e,t):e?e.name:""}_computeHelper(e){return this.computeHelper?this.computeHelper(e):""}_computeError(e,t){return Array.isArray(e)?(0,n.qy)(g||(g=_`<ul> ${0} </ul>`),e.map(e=>(0,n.qy)(v||(v=_`<li> ${0} </li>`),this.computeError?this.computeError(e,t):e))):this.computeError?this.computeError(e,t):e}_computeWarning(e,t){return this.computeWarning?this.computeWarning(e,t):e}constructor(...e){super(...e),this.narrow=!1,this.disabled=!1}}w.shadowRootOptions={mode:"open",delegatesFocus:!0},w.styles=(0,n.AH)(f||(f=_`.root>*{display:block}.root>:not([own-margin]):not(:last-child){margin-bottom:24px}ha-alert[own-margin]{margin-bottom:4px}`)),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"hass",void 0),(0,r.Cg)([(0,i.MZ)({type:Boolean})],w.prototype,"narrow",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"data",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"schema",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"error",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"warning",void 0),(0,r.Cg)([(0,i.MZ)({type:Boolean})],w.prototype,"disabled",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"computeError",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"computeWarning",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"computeLabel",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"computeHelper",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"localizeValue",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],w.prototype,"context",void 0),(0,r.Cg)([(0,i.P)(".root")],w.prototype,"_root",void 0),w=(0,r.Cg)([(0,i.EM)("ha-form")],w),o()}catch(m){o(m)}})},13897:function(e,t,a){a.a(e,async function(e,o){try{a.r(t),a.d(t,{HaSelectorSelector:function(){return y}});a(18111),a(61701),a(62953);var r=a(40445),n=a(5124),i=a(67576),l=a(22786),s=a(1087),c=a(52763),p=e([c]);c=(p.then?(await p)():p)[0];let m,d,h=e=>e;const u={number:{min:1,max:100}},b={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:{}}},{name:"enable_second",default:!0,selector:{boolean:{}}},{name:"allow_negative",selector:{boolean:{}}}],entity:[{name:"multiple",selector:{boolean:{}}}],floor:[{name:"multiple",selector:{boolean:{}}}],icon:[],location:[],media:[{name:"accept",selector:{text:{multiple:!0}}}],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:{}}},{name:"multiple",selector:{boolean:{}}}],target:[],template:[],text:[{name:"multiple",selector:{boolean:{}}},{name:"multiline",selector:{boolean:{}}},{name:"prefix",selector:{text:{}}},{name:"suffix",selector:{text:{}}}],theme:[],time:[]};class y extends n.WF{shouldUpdate(e){return 1!==e.size||!e.has("hass")}render(){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=Object.assign({type:t},"object"==typeof a?a:[])}const a=this._schema(t,this.hass.localize);return(0,n.qy)(m||(m=h`<div> <p>${0}</p> <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeLabel="${0}" -changed="${0}" .narrow="${0}"></ha-form> </div>`),this.label?this.label:"",this.hass,e,a,this._computeLabelCallback,this._valueChanged,this.narrow)}_valueChanged(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 r;"manual"!==a&&(this._yamlMode=!1),delete t.type,r="manual"===a?t.manual:a===o?{[a]:Object.assign({},t.manual?t.manual[o]:t)}:{[a]:Object.assign({},u[a])},(0,s.r)(this,"value-changed",{value:r})}constructor(...e){super(...e),this.disabled=!1,this.narrow=!1,this.required=!0,this._yamlMode=!1,this._schema=(0,l.A)((e,t)=>[{name:"type",required:!0,selector:{select:{mode:"dropdown",options:Object.keys(b).concat("manual").map(e=>({label:t(`ui.components.selectors.selector.types.${e}`)||e,value:e}))}}},..."manual"===e?[{name:"manual",selector:{object:{}}}]:[],...b[e]?b[e].length>1?[{name:"",type:"expandable",title:t("ui.components.selectors.selector.options"),schema:b[e]}]:b[e]:[]]),this._computeLabelCallback=e=>this.hass.localize(`ui.components.selectors.selector.${e.name}`)||e.name}}y.styles=(0,n.AH)(d||(d=h`.title{font-size:var(--ha-font-size-l);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}`)),(0,r.Cg)([(0,i.MZ)({attribute:!1})],y.prototype,"hass",void 0),(0,r.Cg)([(0,i.MZ)({attribute:!1})],y.prototype,"value",void 0),(0,r.Cg)([(0,i.MZ)()],y.prototype,"label",void 0),(0,r.Cg)([(0,i.MZ)()],y.prototype,"helper",void 0),(0,r.Cg)([(0,i.MZ)({type:Boolean,reflect:!0})],y.prototype,"disabled",void 0),(0,r.Cg)([(0,i.MZ)({type:Boolean})],y.prototype,"narrow",void 0),(0,r.Cg)([(0,i.MZ)({type:Boolean,reflect:!0})],y.prototype,"required",void 0),y=(0,r.Cg)([(0,i.EM)("ha-selector-selector")],y),o()}catch(m){o(m)}})}}]);