iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 11 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[54234],{19459:function(e,t,r){r.d(t,{b:function(){return o}});r(45367),r(92731),r(84864),r(57465),r(27495),r(69479),r(17642),r(58004),r(33853),r(45876),r(32475),r(15024),r(31698),r(62953);const o=(e,t,r)=>{if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;let i,a;if(Array.isArray(e)){if(a=e.length,a!==t.length)return!1;for(i=a;0!==i--;)if(!o(e[i],t[i],r))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(i of e.entries())if(!t.has(i[0]))return!1;for(i of e.entries())if(!o(i[1],t.get(i[0]),r))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(i of e.entries())if(!t.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(a=e.length,a!==t.length)return!1;for(i=a;0!==i--;)if(e[i]!==t[i])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();const n=Object.keys(e);if(a=n.length,a!==Object.keys(t).length)return!1;for(i=a;0!==i--;)if(!Object.prototype.hasOwnProperty.call(t,n[i]))return!1;for(i=a;0!==i--;){const a=n[i];if(!o(e[a],t[a],r))return!1}if(null!=r&&r.compareSymbols){const i=Object.getOwnPropertySymbols(e),a=Object.getOwnPropertySymbols(t);if(i.length!==a.length)return!1;for(const n of i){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!o(e[n],t[n],r))return!1}}return!0}return e!=e&&t!=t}},52763:function(e,t,r){r.a(e,async function(e,o){try{r.d(t,{U:function(){return M}});r(74423),r(18111),r(7588),r(61701),r(3362),r(62953);var i=r(40445),a=r(5124),n=r(67576),s=r(69558),l=r(1087),c=r(38962),d=(r(11399),e([c]));c=(d.then?(await d)():d)[0];let p,h,u,f,m,b,y,g,v,_=e=>e;const C={boolean:()=>r.e(81347).then(r.bind(r,46990)),constant:()=>r.e(65733).then(r.bind(r,90820)),float:()=>Promise.all([r.e(72850),r.e(39763),r.e(32450),r.e(51868),r.e(62574),r.e(16113)]).then(r.bind(r,20676)),grid:()=>r.e(60761).then(r.bind(r,70208)),expandable:()=>r.e(45001).then(r.bind(r,40003)),integer:()=>Promise.all([r.e(72850),r.e(39763),r.e(32450),r.e(21543),r.e(86712),r.e(62574),r.e(12145)]).then(r.bind(r,20036)),multi_select:()=>Promise.all([r.e(72850),r.e(39763),r.e(46095),r.e(34995),r.e(80131),r.e(58303),r.e(71739),r.e(78219)]).then(r.bind(r,36182)),positive_time_period_dict:()=>Promise.all([r.e(72850),r.e(39763),r.e(32450),r.e(46095),r.e(34995),r.e(67943),r.e(62574),r.e(16508),r.e(21486)]).then(r.bind(r,89422)),select:()=>Promise.all([r.e(72850),r.e(39763),r.e(32450),r.e(46095),r.e(7305),r.e(92769),r.e(34995),r.e(3283),r.e(81034),r.e(99463),r.e(62574),r.e(26092),r.e(39005),r.e(35873),r.e(63577)]).then(r.bind(r,63804)),string:()=>Promise.all([r.e(72850),r.e(39763),r.e(32450),r.e(84725),r.e(62574),r.e(6762)]).then(r.bind(r,54753)),optional_actions:()=>Promise.all([r.e(72850),r.e(39763),r.e(34995),r.e(67395)]).then(r.bind(r,8456))},$=(e,t)=>e?!t.name||t.flatten?e:e[t.name]:void 0,w=(e,t)=>e&&t.name?e[t.name]:null,O=(e,t)=>e&&t.name?e[t.name]:null;class M extends a.WF{getFormProperties(){return{}}reportValidity(){const e=this._root;if(!e)return!0;const t=[...e.children].filter(e=>"ha-alert"!==e.localName);let r,o=!0;var i,a;(this.schema.forEach((e,i)=>{var a;const n=t[i];if(!n)return;let s=!0;if("reportValidity"in n&&"function"==typeof n.reportValidity)s=n.reportValidity();else if(e.required&&(!("type"in e)||!["boolean","constant"].includes(null!==(a=e.type)&&void 0!==a?a:""))&&(!("selector"in e)||!("boolean"in e.selector)&&!("constant"in e.selector))){const t=$(this.data,e);s=null!=t&&""!==t}s||(o=!1,r||(r=n))}),r)&&(null===(i=(a=r).focus)||void 0===i||i.call(a));return o}willUpdate(e){e.has("schema")&&this.schema&&this.schema.forEach(e=>{var t;"selector"in e||null===(t=C[e.type])||void 0===t||t.call(C)})}render(){return(0,a.qy)(p||(p=_` <div class="root" part="root"> ${0} ${0} </div> `),this.error&&this.error.base?(0,a.qy)(h||(h=_` <ha-alert alert-type="error"> ${0} </ha-alert> `),this._computeError(this.error.base,this.schema)):"",this.schema.map(e=>{var t;const r=w(this.error,e),o=O(this.warning,e);return(0,a.qy)(u||(u=_` ${0} ${0} `),r?(0,a.qy)(f||(f=_` <ha-alert own-margin alert-type="error"> ${0} </ha-alert> `),this._computeError(r,e)):o?(0,a.qy)(m||(m=_` <ha-alert own-margin alert-type="warning"> ${0} </ha-alert> `),this._computeWarning(o,e)):"","selector"in e?(0,a.qy)(b||(b=_`<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,$(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,s._)(this.fieldElementName(e.type),Object.assign({schema:e,data:$(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[r,o]of Object.entries(e.context))t[r]=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 r=!t.name||"flatten"in t&&t.flatten?e.detail.value:{[t.name]:e.detail.value};this.data=Object.assign(Object.assign({},this.data),r),(0,l.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,a.qy)(y||(y=_`<ul> ${0} </ul>`),e.map(e=>(0,a.qy)(g||(g=_`<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}}M.shadowRootOptions={mode:"open",delegatesFocus:!0},M.styles=(0,a.AH)(v||(v=_`.root>*{display:block}.root>:not([own-margin]):not(:last-child){margin-bottom:24px}ha-alert[own-margin]{margin-bottom:4px}`)),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"hass",void 0),(0,i.Cg)([(0,n.MZ)({type:Boolean})],M.prototype,"narrow",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"data",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"schema",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"error",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"warning",void 0),(0,i.Cg)([(0,n.MZ)({type:Boolean})],M.prototype,"disabled",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"computeError",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"computeWarning",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"computeLabel",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"computeHelper",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"localizeValue",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"context",void 0),(0,i.Cg)([(0,n.P)(".root")],M.prototype,"_root",void 0),M=(0,i.Cg)([(0,n.EM)("ha-form")],M),o()}catch(p){o(p)}})},40929:function(e,t,r){r.a(e,async function(e,o){try{r.r(t),r.d(t,{HaPeriodSelector:function(){return b}});r(74423),r(18111),r(22489),r(61701),r(53921),r(62953);var i=r(40445),a=r(5124),n=r(67576),s=r(22786),l=r(1087),c=r(19459),d=r(52763),p=e([d]);d=(p.then?(await p)():p)[0];let h,u,f=e=>e;const m={none:void 0,today:{calendar:{period:"day"}},yesterday:{calendar:{period:"day",offset:-1}},tomorrow:{calendar:{period:"day",offset:1}},this_week:{calendar:{period:"week"}},last_week:{calendar:{period:"week",offset:-1}},next_week:{calendar:{period:"week",offset:1}},this_month:{calendar:{period:"month"}},last_month:{calendar:{period:"month",offset:-1}},next_month:{calendar:{period:"month",offset:1}},this_year:{calendar:{period:"year"}},last_year:{calendar:{period:"year",offset:-1}},next_7d:{calendar:{period:"day",offset:7}},next_30d:{calendar:{period:"day",offset:30}}};class b extends a.WF{render(){const e=this._data(this.value,this.selector),t=this._schema("string"==typeof e.period?e.period:void 0,this.selector,this.hass.localize);return(0,a.qy)(h||(h=f` <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeHelper="${0}" .computeLabel="${0}" .disabled="${0}" -changed="${0}"></ha-form> `),this.hass,e,t,this._computeHelperCallback,this._computeLabelCallback,this.disabled,this._valueChanged)}_valueChanged(e){e.stopPropagation();const t=e.detail.value;if("string"==typeof t.period){const e=this._periods(this.selector);if(t.period in e){const e=this._periods(this.selector)[t.period];(0,l.r)(this,"value-changed",{value:e})}}else(0,l.r)(this,"value-changed",{value:t.period})}constructor(...e){super(...e),this.disabled=!1,this.required=!0,this._schema=(0,s.A)((e,t,r)=>[{name:"period",required:this.required,selector:e&&e in this._periods(t)?{select:{multiple:!1,options:Object.keys(this._periods(t)).map(e=>({value:e,label:r(`ui.components.selectors.period.periods.${e}`)||e}))}}:{object:{}}}]),this._periods=(0,s.A)(e=>Object.fromEntries(Object.entries(m).filter(([t])=>{var r;return null===(r=e.period)||void 0===r||null===(r=r.options)||void 0===r?void 0:r.includes(t)}))),this._data=(0,s.A)((e,t)=>{for(const[r,o]of Object.entries(this._periods(t)))if((0,c.b)(o,e))return{period:r};return{period:e}}),this._computeHelperCallback=()=>this.helper,this._computeLabelCallback=()=>this.label}}b.styles=(0,a.AH)(u||(u=f`:host{position:relative}`)),(0,i.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"selector",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"value",void 0),(0,i.Cg)([(0,n.MZ)()],b.prototype,"label",void 0),(0,i.Cg)([(0,n.MZ)()],b.prototype,"helper",void 0),(0,i.Cg)([(0,n.MZ)({type:Boolean})],b.prototype,"disabled",void 0),(0,i.Cg)([(0,n.MZ)({type:Boolean})],b.prototype,"required",void 0),b=(0,i.Cg)([(0,n.EM)("ha-selector-period")],b),o()}catch(h){o(h)}})},53921:function(e,t,r){var o=r(46518),i=r(72652),a=r(97040);o({target:"Object",stat:!0},{fromEntries:function(e){var t={};return i(e,function(e,r){a(t,e,r)},{AS_ENTRIES:!0}),t}})},69479:function(e,t,r){var o=r(43724),i=r(62106),a=r(65213),n=r(67979);o&&!a.correct&&(i(RegExp.prototype,"flags",{configurable:!0,get:n}),a.correct=!0)}}]);