iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 7.68 kB
JavaScript
export const __rspack_esm_id=46621;export const __rspack_esm_ids=[46621];export const __webpack_modules__={45010(e,t,a){a.d(t,{U:()=>i});a(74423),a(18111),a(22489),a(61701);function i(e,t){const a=t.filter(t=>t in e).map(t=>[t,e[t]]),i=Object.entries(e).filter(([e])=>!t.includes(e));return Object.fromEntries([...a,...i])}},17100(e,t,a){a.a(e,async function(e,i){try{a.r(t),a.d(t,{HuiTileCardEditor:()=>k,fieldOrder:()=>x});var o=a(62826),n=a(5124),s=a(22441),c=a(22786),l=a(63533),r=a(1087),_=a(45010),h=(a(11382),a(52763)),u=(a(67094),a(999)),d=a(89969),p=a(91408),f=a(84698),m=a(44155),g=a(7382),b=a(16161),y=e([h,d,u,b]);[h,d,u,b]=y.then?(await y)():y;const v="M10,9A1,1 0 0,1 11,8A1,1 0 0,1 12,9V13.47L13.21,13.6L18.15,15.79C18.68,16.03 19,16.56 19,17.14V21.5C18.97,22.32 18.32,22.97 17.5,23H11C10.62,23 10.26,22.85 10,22.57L5.1,18.37L5.84,17.6C6.03,17.39 6.3,17.28 6.58,17.28H6.8L10,19V9M11,5A4,4 0 0,1 15,9C15,10.5 14.2,11.77 13,12.46V11.24C13.61,10.69 14,9.89 14,9A3,3 0 0,0 11,6A3,3 0 0,0 8,9C8,9.89 8.39,10.69 9,11.24V12.46C7.8,11.77 7,10.5 7,9A4,4 0 0,1 11,5Z",C="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3M7 7H9V9H7V7M7 11H9V13H7V11M7 15H9V17H7V15M17 17H11V15H17V17M17 13H11V11H17V13M17 9H11V7H17V9Z",$="M4,9H20V11H4V9M4,13H14V15H4V13Z",H=(0,l.kp)(f.H,(0,l.Ik)({entity:(0,l.lq)((0,l.Yj)()),name:(0,l.lq)(m.q),icon:(0,l.lq)((0,l.Yj)()),color:(0,l.lq)((0,l.Yj)()),show_entity_picture:(0,l.lq)((0,l.zM)()),hide_state:(0,l.lq)((0,l.zM)()),state_content:(0,l.lq)((0,l.KC)([(0,l.Yj)(),(0,l.YO)((0,l.Yj)())])),vertical:(0,l.lq)((0,l.zM)()),tap_action:(0,l.lq)(p.kn),hold_action:(0,l.lq)(p.kn),double_tap_action:(0,l.lq)(p.kn),icon_tap_action:(0,l.lq)(p.kn),icon_hold_action:(0,l.lq)(p.kn),icon_double_tap_action:(0,l.lq)(p.kn),features:(0,l.lq)((0,l.YO)((0,l.bz)())),features_position:(0,l.lq)((0,l.vP)(["bottom","inline"]))})),x=Object.keys(H.schema);class k extends n.WF{setConfig(e){(0,l.vA)(e,H),this._config=e}render(){if(!this.hass||!this._config)return n.s6;const e=this._config.entity,t=this._schema(this.hass.localize,e,this._config.hide_state??!1),a=this._config.vertical??!1,i=this._featuresSchema(this.hass.localize,a),o={...this._config,content_layout:a?"vertical":"horizontal"};o.features_position&&!a||(o.features_position="bottom");const s=this._featureContext(e),c=this._hasCompatibleFeatures(s),l=(this._config.features?.length??0)>0;return n.qy` <ha-form .hass="${this.hass}" .data="${o}" .schema="${t}" .computeLabel="${this._computeLabelCallback}" .computeHelper="${this._computeHelperCallback}" -changed="${this._valueChanged}"></ha-form> <ha-expansion-panel outlined> <ha-svg-icon slot="leading-icon" .path="${C}"></ha-svg-icon> <h3 slot="header"> ${this.hass.localize("ui.panel.lovelace.editor.card.generic.features")} </h3> <div class="content"> <hui-card-features-editor .hass="${this.hass}" .context="${s}" .features="${this._config.features??[]}" -changed="${this._featuresChanged}" -detail-element="${this._editDetailElement}"></hui-card-features-editor> ${c&&l?n.qy` <ha-form class="features-form" .hass="${this.hass}" .data="${o}" .schema="${i}" .computeLabel="${this._computeLabelCallback}" .computeHelper="${this._computeHelperCallback}" -changed="${this._valueChanged}"></ha-form> `:n.s6} </div> </ha-expansion-panel> `}_valueChanged(e){if(e.stopPropagation(),!this._config||!this.hass)return;const t=e.detail.value;let a={features:this._config.features,...t};a.hide_state&&delete a.state_content,a.state_content||delete a.state_content,a.content_layout&&(a.vertical="vertical"===a.content_layout,delete a.content_layout),a=(0,_.U)(a,x),(0,r.r)(this,"config-changed",{config:a})}_featuresChanged(e){if(e.stopPropagation(),!this._config||!this.hass)return;const t=e.detail.features,a={...this._config,features:t};0===t.length&&delete a.features,(0,r.r)(this,"config-changed",{config:a})}_editDetailElement(e){const t=e.detail.subElementConfig.index,a=this._config.features[t],i=this._featureContext(this._config.entity);(0,r.r)(this,"edit-sub-element",{config:a,saveConfig:e=>this._updateFeature(t,e),context:i,type:"feature"})}_updateFeature(e,t){const a=this._config.features.concat();a[e]=t;let i={...this._config,features:a};i=(0,_.U)(i,x),(0,r.r)(this,"config-changed",{config:i})}static get styles(){return[g.U,n.AH`.container{display:flex;flex-direction:column}ha-form{display:block;margin-bottom:24px}.info{color:var(--secondary-text-color);margin-top:0;margin-bottom:8px}.features-form{margin-top:var(--ha-space-6);margin-bottom:0}`]}constructor(...e){super(...e),this._featureContext=(0,c.A)(e=>({entity_id:e})),this._schema=(0,c.A)((e,t,a)=>[{name:"entity",selector:{entity:{}}},{name:"content",flatten:!0,type:"expandable",iconPath:$,schema:[{name:"name",selector:{entity_name:{}},context:{entity:"entity"}},{name:"",type:"grid",schema:[{name:"icon",selector:{icon:{}},context:{icon_entity:"entity"}},{name:"color",selector:{ui_color:{default_color:"state",include_state:!0}}},{name:"show_entity_picture",selector:{boolean:{}}},{name:"hide_state",selector:{boolean:{}}}]},...a?[]:[{name:"state_content",selector:{ui_state_content:{allow_context:!0}},context:{filter_entity:"entity"}}],{name:"content_layout",required:!0,selector:{select:{mode:"box",options:["horizontal","vertical"].map(t=>({label:e(`ui.panel.lovelace.editor.card.tile.content_layout_options.${t}`),value:t,image:{src:`/static/images/form/tile_content_layout_${t}.svg`,src_dark:`/static/images/form/tile_content_layout_${t}_dark.svg`,flip_rtl:!0}}))}}}]},{name:"interactions",type:"expandable",flatten:!0,iconPath:v,schema:[{name:"tap_action",selector:{ui_action:{default_action:"more-info"}},context:u.Tq},{name:"icon_tap_action",selector:{ui_action:{default_action:t?(0,d.a)(t):"more-info"}},context:u.Tq},{name:"",type:"optional_actions",flatten:!0,schema:["hold_action","icon_hold_action","double_tap_action","icon_double_tap_action"].map(e=>({name:e,selector:{ui_action:{default_action:"none"}},context:u.Tq}))}]}]),this._featuresSchema=(0,c.A)((e,t)=>[{name:"features_position",required:!0,selector:{select:{mode:"box",options:["bottom","inline"].map(a=>({label:e(`ui.panel.lovelace.editor.card.tile.features_position_options.${a}`),description:e(`ui.panel.lovelace.editor.card.tile.features_position_options.${a}_description`),value:a,image:{src:`/static/images/form/tile_features_position_${a}.svg`,src_dark:`/static/images/form/tile_features_position_${a}_dark.svg`,flip_rtl:!0},disabled:t&&"inline"===a}))}}}]),this._hasCompatibleFeatures=(0,c.A)(e=>(0,b.uu)(this.hass,e).length>0),this._computeLabelCallback=e=>{switch(e.name){case"color":case"icon_tap_action":case"icon_hold_action":case"icon_double_tap_action":case"show_entity_picture":case"hide_state":case"state_content":case"content_layout":case"features_position":return this.hass.localize(`ui.panel.lovelace.editor.card.tile.${e.name}`);default:return this.hass.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`)}},this._computeHelperCallback=e=>{switch(e.name){case"color":return this.hass.localize(`ui.panel.lovelace.editor.card.tile.${e.name}_helper`);case"features_position":return this._config?.vertical?this.hass.localize(`ui.panel.lovelace.editor.card.tile.${e.name}_helper_vertical`):void 0;default:return}}}}(0,o.Cg)([(0,s.MZ)({attribute:!1})],k.prototype,"hass",void 0),(0,o.Cg)([(0,s.wk)()],k.prototype,"_config",void 0),k=(0,o.Cg)([(0,s.EM)("hui-tile-card-editor")],k),i()}catch(e){i(e)}})},84698(e,t,a){a.d(t,{H:()=>o});var i=a(63533);const o=(0,i.Ik)({type:(0,i.Yj)(),view_layout:(0,i.bz)(),layout_options:(0,i.bz)(),grid_options:(0,i.bz)(),visibility:(0,i.bz)(),disabled:(0,i.lq)((0,i.zM)())})}};