iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 10.7 kB
JavaScript
export const __rspack_esm_id=54234;export const __rspack_esm_ids=[54234];export const __webpack_modules__={19459(e,t,r){r.d(t,{b:()=>o});r(45367),r(92731),r(69479),r(17642),r(58004),r(33853),r(45876),r(32475),r(15024),r(31698);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 s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(i=a;0!==i--;)if(!Object.prototype.hasOwnProperty.call(t,s[i]))return!1;for(i=a;0!==i--;){const a=s[i];if(!o(e[a],t[a],r))return!1}if(r?.compareSymbols){const i=Object.getOwnPropertySymbols(e),a=Object.getOwnPropertySymbols(t);if(i.length!==a.length)return!1;for(const a of i){if(!Object.prototype.hasOwnProperty.call(t,a))return!1;if(!o(e[a],t[a],r))return!1}}return!0}return e!=e&&t!=t}},52763(e,t,r){r.a(e,async function(e,o){try{r.d(t,{U:()=>m});r(74423),r(18111),r(7588),r(61701);var i=r(62826),a=r(5124),s=r(22441),n=r(69558),l=r(1087),c=r(38962),p=(r(11399),e([c]));c=(p.then?(await p)():p)[0];const d={boolean:()=>r.e(81347).then(r.bind(r,46990)),constant:()=>r.e(65733).then(r.bind(r,90820)),float:()=>Promise.all([r.e(4801),r.e(39763),r.e(32450),r.e(51868),r.e(27585)]).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(4801),r.e(39763),r.e(32450),r.e(21543),r.e(86712),r.e(49985)]).then(r.bind(r,20036)),multi_select:()=>Promise.all([r.e(4801),r.e(39763),r.e(46095),r.e(34995),r.e(80131),r.e(58303),r.e(71739),r.e(24407)]).then(r.bind(r,36182)),positive_time_period_dict:()=>Promise.all([r.e(4801),r.e(39763),r.e(32450),r.e(46095),r.e(34995),r.e(67943),r.e(16508),r.e(85462)]).then(r.bind(r,89422)),select:()=>Promise.all([r.e(4801),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(26092),r.e(4809)]).then(r.bind(r,63804)),string:()=>Promise.all([r.e(4801),r.e(39763),r.e(32450),r.e(84725),r.e(95926)]).then(r.bind(r,54753)),optional_actions:()=>Promise.all([r.e(4801),r.e(39763),r.e(34995),r.e(85351)]).then(r.bind(r,8456))},h=(e,t)=>e?!t.name||t.flatten?e:e[t.name]:void 0,u=(e,t)=>e&&t.name?e[t.name]:null,f=(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;return this.schema.forEach((e,i)=>{const a=t[i];if(!a)return;let s=!0;if("reportValidity"in a&&"function"==typeof a.reportValidity)s=a.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=h(this.data,e);s=null!=t&&""!==t}s||(o=!1,r||(r=a))}),r&&r.focus?.(),o}willUpdate(e){e.has("schema")&&this.schema&&this.schema.forEach(e=>{"selector"in e||d[e.type]?.()})}render(){return a.qy` <div class="root" part="root"> ${this.error&&this.error.base?a.qy` <ha-alert alert-type="error"> ${this._computeError(this.error.base,this.schema)} </ha-alert> `:""} ${this.schema.map(e=>{const t=u(this.error,e),r=f(this.warning,e);return a.qy` ${t?a.qy` <ha-alert own-margin alert-type="error"> ${this._computeError(t,e)} </ha-alert> `:r?a.qy` <ha-alert own-margin alert-type="warning"> ${this._computeWarning(r,e)} </ha-alert> `:""} ${"selector"in e?a.qy`<ha-selector .schema="${e}" .hass="${this.hass}" .narrow="${this.narrow}" .name="${e.name}" .selector="${e.selector}" .value="${h(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,n._)(this.fieldElementName(e.type),{schema:e,data:h(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[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={...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)?a.qy`<ul> ${e.map(e=>a.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}}m.shadowRootOptions={mode:"open",delegatesFocus:!0},m.styles=a.AH`.root>*{display:block}.root>:not([own-margin]):not(:last-child){margin-bottom:24px}ha-alert[own-margin]{margin-bottom:4px}`,(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"hass",void 0),(0,i.Cg)([(0,s.MZ)({type:Boolean})],m.prototype,"narrow",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"data",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"schema",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"error",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"warning",void 0),(0,i.Cg)([(0,s.MZ)({type:Boolean})],m.prototype,"disabled",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"computeError",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"computeWarning",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"computeLabel",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"computeHelper",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"localizeValue",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],m.prototype,"context",void 0),(0,i.Cg)([(0,s.P)(".root")],m.prototype,"_root",void 0),m=(0,i.Cg)([(0,s.EM)("ha-form")],m),o()}catch(e){o(e)}})},40929(e,t,r){r.a(e,async function(e,o){try{r.r(t),r.d(t,{HaPeriodSelector:()=>u});r(74423),r(18111),r(22489),r(61701);var i=r(62826),a=r(5124),s=r(22441),n=r(22786),l=r(1087),c=r(19459),p=r(52763),d=e([p]);p=(d.then?(await d)():d)[0];const h={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 u 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 a.qy` <ha-form .hass="${this.hass}" .data="${e}" .schema="${t}" .computeHelper="${this._computeHelperCallback}" .computeLabel="${this._computeLabelCallback}" .disabled="${this.disabled}" -changed="${this._valueChanged}"></ha-form> `}_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,n.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,n.A)(e=>Object.fromEntries(Object.entries(h).filter(([t])=>e.period?.options?.includes(t)))),this._data=(0,n.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}}u.styles=a.AH`:host{position:relative}`,(0,i.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"selector",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"value",void 0),(0,i.Cg)([(0,s.MZ)()],u.prototype,"label",void 0),(0,i.Cg)([(0,s.MZ)()],u.prototype,"helper",void 0),(0,i.Cg)([(0,s.MZ)({type:Boolean})],u.prototype,"disabled",void 0),(0,i.Cg)([(0,s.MZ)({type:Boolean})],u.prototype,"required",void 0),u=(0,i.Cg)([(0,s.EM)("ha-selector-period")],u),o()}catch(e){o(e)}})},65213(e,t,r){var o=r(44576),i=r(79039),a=o.RegExp,s=!i(function(){var e=!0;try{a(".","d")}catch(t){e=!1}var t={},r="",o=e?"dgimsy":"gimsy",i=function(e,o){Object.defineProperty(t,e,{get:function(){return r+=o,!0}})},s={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var n in e&&(s.hasIndices="d"),s)i(n,s[n]);return Object.getOwnPropertyDescriptor(a.prototype,"flags").get.call(t)!==o||r!==o});e.exports={correct:s}},67979(e,t,r){var o=r(28551);e.exports=function(){var e=o(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t}},69479(e,t,r){var o=r(43724),i=r(62106),a=r(65213),s=r(67979);o&&!a.correct&&(i(RegExp.prototype,"flags",{configurable:!0,get:s}),a.correct=!0)}};