iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 9.64 kB
JavaScript
export const __rspack_esm_id=77810;export const __rspack_esm_ids=[77810];export const __webpack_modules__={52763(e,t,o){o.a(e,async function(e,a){try{o.d(t,{U:()=>b});o(74423),o(18111),o(7588),o(61701);var r=o(62826),i=o(5124),n=o(22441),l=o(69558),s=o(1087),c=o(38962),p=(o(11399),e([c]));c=(p.then?(await p)():p)[0];const m={boolean:()=>o.e(81347).then(o.bind(o,46990)),constant:()=>o.e(65733).then(o.bind(o,90820)),float:()=>Promise.all([o.e(4801),o.e(39763),o.e(32450),o.e(51868),o.e(27585)]).then(o.bind(o,20676)),grid:()=>o.e(60761).then(o.bind(o,70208)),expandable:()=>o.e(45001).then(o.bind(o,40003)),integer:()=>Promise.all([o.e(4801),o.e(39763),o.e(32450),o.e(21543),o.e(86712),o.e(49985)]).then(o.bind(o,20036)),multi_select:()=>Promise.all([o.e(4801),o.e(39763),o.e(46095),o.e(34995),o.e(80131),o.e(58303),o.e(71739),o.e(24407)]).then(o.bind(o,36182)),positive_time_period_dict:()=>Promise.all([o.e(4801),o.e(39763),o.e(32450),o.e(46095),o.e(34995),o.e(67943),o.e(16508),o.e(85462)]).then(o.bind(o,89422)),select:()=>Promise.all([o.e(4801),o.e(39763),o.e(32450),o.e(46095),o.e(7305),o.e(92769),o.e(34995),o.e(3283),o.e(81034),o.e(99463),o.e(26092),o.e(4809)]).then(o.bind(o,63804)),string:()=>Promise.all([o.e(4801),o.e(39763),o.e(32450),o.e(84725),o.e(95926)]).then(o.bind(o,54753)),optional_actions:()=>Promise.all([o.e(4801),o.e(39763),o.e(34995),o.e(85351)]).then(o.bind(o,8456))},d=(e,t)=>e?!t.name||t.flatten?e:e[t.name]:void 0,h=(e,t)=>e&&t.name?e[t.name]:null,u=(e,t)=>e&&t.name?e[t.name]:null;class b extends i.WF{getFormProperties(){return{}}reportValidity(){const e=this._root;if(!e)return!0;const t=[...e.children].filter(e=>"ha-alert"!==e.localName);let o,a=!0;return this.schema.forEach((e,r)=>{const i=t[r];if(!i)return;let n=!0;if("reportValidity"in i&&"function"==typeof i.reportValidity)n=i.reportValidity();else if(e.required&&(!("type"in e)||!["boolean","constant"].includes(e.type??""))&&(!("selector"in e)||!("boolean"in e.selector)&&!("constant"in e.selector))){const t=d(this.data,e);n=null!=t&&""!==t}n||(a=!1,o||(o=i))}),o&&o.focus?.(),a}willUpdate(e){e.has("schema")&&this.schema&&this.schema.forEach(e=>{"selector"in e||m[e.type]?.()})}render(){return i.qy` <div class="root" part="root"> ${this.error&&this.error.base?i.qy` <ha-alert alert-type="error"> ${this._computeError(this.error.base,this.schema)} </ha-alert> `:""} ${this.schema.map(e=>{const t=h(this.error,e),o=u(this.warning,e);return i.qy` ${t?i.qy` <ha-alert own-margin alert-type="error"> ${this._computeError(t,e)} </ha-alert> `:o?i.qy` <ha-alert own-margin alert-type="warning"> ${this._computeWarning(o,e)} </ha-alert> `:""} ${"selector"in e?i.qy`<ha-selector .schema="${e}" .hass="${this.hass}" .narrow="${this.narrow}" .name="${e.name}" .selector="${e.selector}" .value="${d(this.data,e)}" .label="${this._computeLabel(e,this.data)}" .disabled="${e.disabled||this.disabled||!1}" .placeholder="${e.required?void 0:e.default}" .helper="${this._computeHelper(e)}" .localizeValue="${this.localizeValue}" .required="${e.required||!1}" .context="${this._generateContext(e)}"></ha-selector>`:(0,l._)(this.fieldElementName(e.type),{schema:e,data:d(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> `}fieldElementName(e){return`ha-form-${e}`}_generateContext(e){if(!e.context&&!this.context)return;const t={...this.context};if(e.context)for(const[o,a]of Object.entries(e.context))t[o]=this.data[a];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 o=!t.name||"flatten"in t&&t.flatten?e.detail.value:{[t.name]:e.detail.value};this.data={...this.data,...o},(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)?i.qy`<ul> ${e.map(e=>i.qy`<li> ${this.computeError?this.computeError(e,t):e} </li>`)} </ul>`: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}}b.shadowRootOptions={mode:"open",delegatesFocus:!0},b.styles=i.AH`.root>*{display:block}.root>:not([own-margin]):not(:last-child){margin-bottom:24px}ha-alert[own-margin]{margin-bottom:4px}`,(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,r.Cg)([(0,n.MZ)({type:Boolean})],b.prototype,"narrow",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"data",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"schema",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"error",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"warning",void 0),(0,r.Cg)([(0,n.MZ)({type:Boolean})],b.prototype,"disabled",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"computeError",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"computeWarning",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"computeLabel",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"computeHelper",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"localizeValue",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"context",void 0),(0,r.Cg)([(0,n.P)(".root")],b.prototype,"_root",void 0),b=(0,r.Cg)([(0,n.EM)("ha-form")],b),a()}catch(e){a(e)}})},13897(e,t,o){o.a(e,async function(e,a){try{o.r(t),o.d(t,{HaSelectorSelector:()=>h});o(18111),o(61701);var r=o(62826),i=o(5124),n=o(22441),l=o(22786),s=o(1087),c=o(52763),p=e([c]);c=(p.then?(await p)():p)[0];const m={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:{}}},{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 h extends i.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 o=Object.values(this.value)[0];e={type:t,..."object"==typeof o?o:[]}}const o=this._schema(t,this.hass.localize);return i.qy`<div> <p>${this.label?this.label:""}</p> <ha-form .hass="${this.hass}" .data="${e}" .schema="${o}" .computeLabel="${this._computeLabelCallback}" -changed="${this._valueChanged}" .narrow="${this.narrow}"></ha-form> </div>`}_valueChanged(e){e.stopPropagation();const t=e.detail.value,o=t.type;if(!o||"object"!=typeof t||0===Object.keys(t).length)return;const a=Object.keys(this.value)[0];if("manual"===o&&!this._yamlMode)return this._yamlMode=!0,void this.requestUpdate();if("manual"===o&&void 0===t.manual)return;let r;"manual"!==o&&(this._yamlMode=!1),delete t.type,r="manual"===o?t.manual:o===a?{[o]:{...t.manual?t.manual[a]:t}}:{[o]:{...m[o]}},(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(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]:[]]),this._computeLabelCallback=e=>this.hass.localize(`ui.components.selectors.selector.${e.name}`)||e.name}}h.styles=i.AH`.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,n.MZ)({attribute:!1})],h.prototype,"hass",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],h.prototype,"value",void 0),(0,r.Cg)([(0,n.MZ)()],h.prototype,"label",void 0),(0,r.Cg)([(0,n.MZ)()],h.prototype,"helper",void 0),(0,r.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],h.prototype,"disabled",void 0),(0,r.Cg)([(0,n.MZ)({type:Boolean})],h.prototype,"narrow",void 0),(0,r.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],h.prototype,"required",void 0),h=(0,r.Cg)([(0,n.EM)("ha-selector-selector")],h),a()}catch(e){a(e)}})}};