UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

25 lines 14.9 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[35873],{2226:function(e,o,t){t(89463),t(18111),t(61701),t(62953);var a=t(40445),i=t(35211),l=t(5124),r=t(67576),s=t(6412),n=t(63672),d=t(89784),c=t(1087),h=t(15638),u=t(22792);t(64013),t(92677);let p,v,g,b,m,f=e=>e;class y extends l.WF{render(){var e;const o=null!==(e=this.maxColumns)&&void 0!==e?e:3,t=Math.min(o,this.options.length);return(0,l.qy)(p||(p=f` <ha-radio-group class="list" style="${0}" .value="${0}" @change="${0}"> ${0} </ha-radio-group> `),(0,d.W)({"--columns":t}),this.value,this._radioChanged,this.options.map(e=>this._renderOption(e)))}_renderOption(e){var o;const t=1===this.maxColumns&&!this.stackedImage,a=1===this.maxColumns&&this.stackedImage,i=e.disabled||this.disabled||!1,r=e.value===this.value,d=(null===(o=this._ui)||void 0===o?void 0:o.themes.darkMode)||!1,c=!!this._i18n&&(0,h.qC)(this._i18n.language,this._i18n.translationMetadata.translations),u="object"==typeof e.image?d&&e.image.src_dark||e.image.src:e.image,p="object"==typeof e.image&&(c&&e.image.flip_rtl);return(0,l.qy)(v||(v=f` <label class="option ${0}" ?disabled="${0}"> <div class="content"> <ha-radio-option aria-describedby="${0}" aria-labelledby="${0}" .value="${0}" .disabled="${0}"></ha-radio-option> <div class="text"> <span id="${0}" class="label">${0}</span> ${0} </div> </div> ${0} </label> `),(0,s.H)({horizontal:t,stacked:a,selected:r}),i,(0,n.J)(e.description?`desc-${e.value}`:void 0),`label-${e.value}`,e.value,i,`label-${e.value}`,e.label,e.description?(0,l.qy)(g||(g=f`<span class="description" id="desc-${0}">${0}</span>`),e.value,e.description):l.s6,u?(0,l.qy)(b||(b=f` <img class="${0}" alt="" src="${0}"> `),p?"flipped":"",u):l.s6)}_radioChanged(e){var o;e.stopPropagation();const t=e.currentTarget.value;this.disabled||void 0===t||t===(null!==(o=this.value)&&void 0!==o?o:"")||(0,c.r)(this,"value-changed",{value:t})}constructor(...e){super(...e),this.options=[],this.stackedImage=!1}}y.styles=(0,l.AH)(m||(m=f`.list::part(form-control-input){display:grid;grid-template-columns:repeat(var(--columns,1),minmax(0,1fr));gap:var(--ha-space-3)}.option{position:relative;display:block;border:1px solid var(--divider-color);border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg));display:flex;flex-direction:column;align-items:center;justify-content:space-between;padding:12px;gap:var(--ha-space-2);overflow:hidden;cursor:pointer}.option .content{position:relative;display:flex;flex-direction:row;gap:var(--ha-space-2);min-width:0;width:100%}.option .content ha-radio-option{--ha-radio-option-control-margin:0;margin:0;flex:none}.option .content .text{display:flex;flex-direction:column;gap:var(--ha-space-1);min-width:0;flex:1;justify-content:center}.option .content .text .label{color:var(--primary-text-color);font-size:var(--ha-font-size-m);font-weight:var(--ha-font-weight-normal);line-height:var(--ha-line-height-condensed);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.option .content .text .description{color:var(--secondary-text-color);font-size:var(--ha-font-size-s);font-weight:var(--ha-font-weight-normal);line-height:var(--ha-line-height-condensed)}img{position:relative;max-width:var(--ha-select-box-image-size,96px);max-height:var(--ha-select-box-image-size,96px);margin:auto}.flipped{transform:scaleX(-1)}.option.horizontal{flex-direction:row;align-items:flex-start}.option.horizontal img{margin:0}.option.stacked{align-items:stretch}.option.stacked img{max-width:100%;max-height:var(--ha-select-box-image-size,96px);margin:0}.option:before{content:"";display:block;inset:0;position:absolute;background-color:transparent;pointer-events:none;opacity:.2;transition:background-color 180ms ease-in-out,opacity 180ms ease-in-out}.option:hover:before{background-color:var(--divider-color)}.option.selected:before{background-color:var(--primary-color)}.option[disabled]{cursor:not-allowed}.option[disabled] .content,.option[disabled] img{opacity:.5}.option[disabled]:before{background-color:var(--disabled-color);opacity:.05}`)),(0,a.Cg)([(0,r.MZ)({attribute:!1})],y.prototype,"options",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],y.prototype,"value",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],y.prototype,"disabled",void 0),(0,a.Cg)([(0,r.MZ)({type:Number,attribute:"max_columns"})],y.prototype,"maxColumns",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean,attribute:"stacked_image"})],y.prototype,"stackedImage",void 0),(0,a.Cg)([(0,r.wk)(),(0,i.Fg)({context:u.D5,subscribe:!0})],y.prototype,"_i18n",void 0),(0,a.Cg)([(0,r.wk)(),(0,i.Fg)({context:u.EK,subscribe:!0})],y.prototype,"_ui",void 0),y=(0,a.Cg)([(0,r.EM)("ha-select-box")],y)},856:function(e,o,t){t.a(e,async function(e,a){try{t.r(o),t.d(o,{HaSelectSelector:function(){return I}});t(74423),t(26910),t(18111),t(22489),t(20116),t(7588),t(61701),t(3362),t(62953);var i=t(40445),l=t(5124),r=t(67576),s=t(75751),n=t(22786),d=t(44537),c=t(1087),h=t(52220),u=(t(5745),t(13467),t(9503),t(70947),t(6),t(38508)),p=(t(3449),t(606)),v=(t(2226),t(85938),t(64013),t(92677),e([u,p]));[u,p]=v.then?(await v)():v;let g,b,m,f,y,$,x,k,_,C,w,q,M,z,H=e=>e;const Z="M21 11H3V9H21V11M21 13H3V15H21V13Z";class I extends l.WF{_itemMoved(e){e.stopPropagation();const{oldIndex:o,newIndex:t}=e.detail;this._move(o,t)}_move(e,o){const t=this.value.concat(),a=t.splice(e,1)[0];t.splice(o,0,a),this.value=t,(0,c.r)(this,"value-changed",{value:t})}render(){var e,o,t,a,i,r,n,c,u,p,v;const M=this._getOptions(this.selector),z=null===(e=this.selector.select)||void 0===e?void 0:e.translation_key;var I;if(this.localizeValue&&z&&M.forEach(e=>{const o=this.localizeValue(`${z}.options.${e.value}`);o&&(e.label=o)}),null!==(o=this.selector.select)&&void 0!==o&&o.sort&&M.sort((e,o)=>(0,h.SH)(e.label,o.label,this.hass.locale.language)),!(null!==(t=this.selector.select)&&void 0!==t&&t.multiple||null!==(a=this.selector.select)&&void 0!==a&&a.reorder||null!==(i=this.selector.select)&&void 0!==i&&i.custom_value||"box"!==this._mode))return(0,l.qy)(g||(g=H` ${0} <ha-select-box .options="${0}" .value="${0}" @value-changed="${0}" .maxColumns="${0}"></ha-select-box> ${0} `),this.label?(0,l.qy)(b||(b=H`<span class="label">${0}</span>`),this.label):l.s6,M,this.value,this._selectChanged,null===(I=this.selector.select)||void 0===I?void 0:I.box_max_columns,this._renderHelper());if(!(null!==(r=this.selector.select)&&void 0!==r&&r.custom_value||null!==(n=this.selector.select)&&void 0!==n&&n.reorder||"list"!==this._mode)){var V;if(null===(V=this.selector.select)||void 0===V||!V.multiple)return(0,l.qy)(m||(m=H` <ha-radio-group .label="${0}" .disabled="${0}" .value="${0}" @change="${0}"> ${0} </ha-radio-group> ${0} `),this.label,this.disabled,this.value,this._radioChanged,M.map(e=>(0,l.qy)(f||(f=H` <ha-radio-option .value="${0}" .disabled="${0}"> ${0} </ha-radio-option> `),e.value,!!e.disabled,e.label)),this._renderHelper());const e=this.value&&""!==this.value?(0,d.e)(this.value):[];return(0,l.qy)(y||(y=H` <div> ${0} ${0} </div> ${0} `),this.label,M.map(o=>(0,l.qy)($||($=H` <ha-checkbox .checked="${0}" .value="${0}" .disabled="${0}" @change="${0}"> ${0} </ha-checkbox> `),e.includes(o.value),o.value,o.disabled||this.disabled,this._checkboxChanged,o.label)),this._renderHelper())}if(null!==(c=this.selector.select)&&void 0!==c&&c.multiple){var A;const e=this.value&&""!==this.value?(0,d.e)(this.value):[];return(0,l.qy)(x||(x=H` ${0} <ha-generic-picker no-sort .hass="${0}" .helper="${0}" .disabled="${0}" .required="${0}" .value="${0}" .addButtonLabel="${0}" .getItems="${0}" .allowCustomValue="${0}" @value-changed="${0}"></ha-generic-picker> `),null!=e&&e.length?(0,l.qy)(k||(k=H` <ha-sortable no-style .disabled="${0}" @item-moved="${0}" handle-selector="button.primary.action"> <ha-chip-set> ${0} </ha-chip-set> </ha-sortable> `),!this.selector.select.reorder,this._itemMoved,(0,s.u)(e,e=>e,(e,o)=>{var t,a,i;const r=(null===(t=M.find(o=>o.value===e))||void 0===t?void 0:t.label)||e;return(0,l.qy)(_||(_=H` <ha-input-chip .idx="${0}" @remove="${0}" .label="${0}" selected="selected"> ${0} ${0} </ha-input-chip> `),o,this._removeItem,r,null!==(a=this.selector.select)&&void 0!==a&&a.reorder?(0,l.qy)(C||(C=H` <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> `),Z):l.s6,(null===(i=M.find(o=>o.value===e))||void 0===i?void 0:i.label)||e)})):l.s6,this.hass,this.helper,this.disabled,this.required&&!e.length,"",this.label,this._getItems(M,e,!0),null!==(A=this.selector.select.custom_value)&&void 0!==A&&A,this._comboBoxValueChanged)}return null!==(u=this.selector.select)&&void 0!==u&&u.custom_value?(0,l.qy)(w||(w=H` <ha-generic-picker no-sort .hass="${0}" .label="${0}" .helper="${0}" .disabled="${0}" .required="${0}" .getItems="${0}" .value="${0}" @value-changed="${0}" allow-custom-value></ha-generic-picker> `),this.hass,this.label,this.helper,this.disabled,this.required,this._getItems(M),"string"==typeof this.value?this.value:void 0,this._comboBoxValueChanged):(0,l.qy)(q||(q=H` <ha-select .label="${0}" .value="${0}" .helper="${0}" .disabled="${0}" .required="${0}" clearable @selected="${0}" .options="${0}"> </ha-select> `),null!==(p=this.label)&&void 0!==p?p:"",["string","number"].includes(typeof this.value)?this.value:"",null!==(v=this.helper)&&void 0!==v?v:"",this.disabled,this.required,this._selectChanged,M)}_renderHelper(){return this.helper?(0,l.qy)(M||(M=H`<ha-input-helper-text .disabled="${0}">${0}</ha-input-helper-text>`),this.disabled,this.helper):""}get _mode(){var e,o;return(null===(e=this.selector.select)||void 0===e?void 0:e.mode)||(((null===(o=this.selector.select)||void 0===o||null===(o=o.options)||void 0===o?void 0:o.length)||0)<6?"list":"dropdown")}_radioChanged(e){e.stopPropagation(),this._valueChanged(e)}_selectChanged(e){var o;e.stopPropagation(),void 0!==(null===(o=e.detail)||void 0===o?void 0:o.value)||void 0===this.value?this._valueChanged(e):(0,c.r)(this,"value-changed",{value:void 0})}_valueChanged(e){var o,t,a;const i=null!==(o=null===(t=e.detail)||void 0===t?void 0:t.value)&&void 0!==o?o:e.target.value;this.disabled||void 0===i||i===(null!==(a=this.value)&&void 0!==a?a:"")||(0,c.r)(this,"value-changed",{value:i})}_checkboxChanged(e){if(e.stopPropagation(),this.disabled)return;let o;const t=e.target.value,a=e.target.checked,i=this.value&&""!==this.value?(0,d.e)(this.value):[];if(a){if(i.includes(t))return;o=[...i,t]}else{if(null==i||!i.includes(t))return;o=i.filter(e=>e!==t)}(0,c.r)(this,"value-changed",{value:o})}async _removeItem(e){e.stopPropagation();const o=[...(0,d.e)(this.value)];o.splice(e.target.idx,1),(0,c.r)(this,"value-changed",{value:o})}_comboBoxValueChanged(e){var o;e.stopPropagation();const t=e.detail.value;if(this.disabled||""===t)return;if(null===(o=this.selector.select)||void 0===o||!o.multiple)return void(0,c.r)(this,"value-changed",{value:t});const a=this.value?(0,d.e)(this.value):[];void 0!==t&&a.includes(t)||(0,c.r)(this,"value-changed",{value:[...a,t]})}constructor(...e){super(...e),this.disabled=!1,this.required=!0,this._getOptions=(0,n.A)(e=>{var o;return(null===(o=e.select)||void 0===o||null===(o=o.options)||void 0===o?void 0:o.map(e=>"object"==typeof e?e:{value:String(e),label:e}))||[]}),this._getItems=(0,n.A)((e,o,t=!1)=>{const a=e.filter(e=>!e.disabled&&!t||!(null!=o&&o.includes(e.value)));return()=>a.map(e=>({id:e.value,primary:e.label,sorting_label:e.label}))})}}I.styles=(0,l.AH)(z||(z=H`:host{position:relative}ha-formfield,ha-select{display:block}ha-checkbox{display:flex;min-height:40px;justify-content:center}ha-dropdown-item[disabled]{--mdc-theme-text-primary-on-background:var(--disabled-text-color)}ha-chip-set{padding:8px 0}.label{display:block;margin:0 0 8px}ha-select-box+ha-input-helper-text{margin-top:4px}.sortable-fallback{display:none;opacity:0}.sortable-ghost{opacity:.4}.sortable-drag{cursor:grabbing}`)),(0,i.Cg)([(0,r.MZ)({attribute:!1})],I.prototype,"hass",void 0),(0,i.Cg)([(0,r.MZ)({attribute:!1})],I.prototype,"selector",void 0),(0,i.Cg)([(0,r.MZ)()],I.prototype,"value",void 0),(0,i.Cg)([(0,r.MZ)()],I.prototype,"label",void 0),(0,i.Cg)([(0,r.MZ)()],I.prototype,"helper",void 0),(0,i.Cg)([(0,r.MZ)({attribute:!1})],I.prototype,"localizeValue",void 0),(0,i.Cg)([(0,r.MZ)({type:Boolean})],I.prototype,"disabled",void 0),(0,i.Cg)([(0,r.MZ)({type:Boolean})],I.prototype,"required",void 0),I=(0,i.Cg)([(0,r.EM)("ha-selector-select")],I),a()}catch(g){a(g)}})},64013:function(e,o,t){var a=t(40445),i=t(97086),l=t(5124),r=t(67576);let s,n=e=>e;class d extends i.A{static get styles(){return[i.A.styles,(0,l.AH)(s||(s=n`:host{--wa-form-control-required-content:var( --ha-radio-group-required-marker, var(--ha-input-required-marker, "*") );--wa-form-control-required-content-offset:var( --ha-radio-group-required-marker-offset, 0.1rem )}`))]}constructor(){super(),this.radioTag="ha-radio-option"}}d=(0,a.Cg)([(0,r.EM)("ha-radio-group")],d)},92677:function(e,o,t){var a=t(40445),i=t(17010),l=t(5124),r=t(67576);let s,n=e=>e;class d extends i.A{static get styles(){return[i.A.styles,(0,l.AH)(s||(s=n`:host{--wa-form-control-activated-color:var( --ha-radio-option-active-color, var(--ha-color-fill-primary-loud-resting) );--wa-form-control-height:var(--ha-radio-option-height, 40px);--wa-form-control-toggle-size:var( --ha-radio-option-toggle-size, 20px );--wa-form-control-border-width:var( --ha-radio-option-border-width, var(--ha-border-width-md) );--wa-form-control-border-color:var( --ha-radio-option-border-color, var(--ha-color-border-neutral-normal) );--wa-form-control-background-color:var( --ha-radio-option-background-color, var(--wa-form-control-background-color) );--checked-icon-color:var( --ha-radio-option-checked-icon-color, var(--wa-form-control-activated-color) );--checked-icon-scale:var(--ha-radio-option-checked-icon-scale, 0.7)}:host([appearance=default]) .control{margin:var(--ha-radio-option-control-margin,var(--ha-space-3) var(--ha-space-2) var(--ha-space-3) var(--ha-space-3))}:host(:not([aria-checked=true],[aria-disabled=true]):hover) .control{border-color:var(--ha-radio-option-border-color-hover,var(--ha-radio-option-border-color,var(--ha-color-border-neutral-loud)));background-color:var(--ha-radio-option-background-color-hover,var(--ha-color-fill-neutral-quiet-hover))}:host([aria-checked=true]) .control{background-color:var(--ha-radio-option-checked-background-color,var(--ha-color-fill-primary-normal-resting));color:var(--checked-icon-color);border-color:var(--checked-icon-color)}[part~=label]{display:inline-flex;align-items:center;cursor:pointer}:host([disabled]) [part~=label]{cursor:not-allowed}`))]}}d=(0,a.Cg)([(0,r.EM)("ha-radio-option")],d)}}]);