diff --git a/www/mushroom.js b/www/mushroom.js index 9bc7a81..4e087b9 100644 --- a/www/mushroom.js +++ b/www/mushroom.js @@ -1329,7 +1329,7 @@ const aa="important",la=" !"+aa,sa=He(class extends Ye{constructor(t){var e;if(s .primary=${a} .secondary=${l} > - `}}n([vt()],Dl.prototype,"_config",void 0),n([_t({attribute:"in-grid",reflect:!0,type:Boolean})],Dl.prototype,"_inGrid",void 0);const Ll=h` + `}}n([vt()],Dl.prototype,"_config",void 0),n([_t({reflect:!0,type:String})],Dl.prototype,"layout",void 0),n([_t({attribute:"in-grid",reflect:!0,type:Boolean})],Dl.prototype,"_inGrid",void 0);const Ll=h` ha-card { box-sizing: border-box; padding: var(--spacing); @@ -1341,9 +1341,11 @@ const aa="important",la=" !"+aa,sa=He(class extends Ye{constructor(t){var e;if(s ha-card.fill-container { height: 100%; } + :host([layout="grid"]) ha-card, :host([in-grid]) ha-card { height: 100%; } + :host([layout="grid"]) ha-card mushroom-card, :host([in-grid]) ha-card mushroom-card { height: 100%; } @@ -1795,7 +1797,7 @@ const aa="important",la=" !"+aa,sa=He(class extends Ye{constructor(t){var e;if(s align-items: flex-start; justify-content: flex-start; flex-wrap: wrap; - margin-bottom: calc(-1 * var(--chip-spacing)); + gap: var(--chip-spacing); } .chip-container.align-end { justify-content: flex-end; @@ -1806,16 +1808,6 @@ const aa="important",la=" !"+aa,sa=He(class extends Ye{constructor(t){var e;if(s .chip-container.align-justify { justify-content: space-between; } - .chip-container * { - margin-bottom: var(--chip-spacing); - } - .chip-container *:not(:last-child) { - margin-right: var(--chip-spacing); - } - .chip-container[rtl] *:not(:last-child) { - margin-right: initial; - margin-left: var(--chip-spacing); - } `]}};n([_t()],Is.prototype,"editMode",void 0),n([vt()],Is.prototype,"_config",void 0),Is=n([pt(As)],Is);const Ts=`${Nl}-climate-card`,Os=`${Ts}-editor`,zs=["climate"],Ms={auto:"var(--rgb-state-climate-auto)",cool:"var(--rgb-state-climate-cool)",dry:"var(--rgb-state-climate-dry)",fan_only:"var(--rgb-state-climate-fan-only)",heat:"var(--rgb-state-climate-heat)",heat_cool:"var(--rgb-state-climate-heat-cool)",off:"var(--rgb-state-climate-off)"},js={cooling:"var(--rgb-state-climate-cool)",drying:"var(--rgb-state-climate-dry)",heating:"var(--rgb-state-climate-heat)",idle:"var(--rgb-state-climate-idle)",off:"var(--rgb-state-climate-off)"},Ds={auto:"mdi:calendar-sync",cool:"mdi:snowflake",dry:"mdi:water-percent",fan_only:"mdi:fan",heat:"mdi:fire",heat_cool:"mdi:autorenew",off:"mdi:power"},Ls={cooling:"mdi:snowflake",drying:"mdi:water-percent",heating:"mdi:fire",idle:"mdi:clock-outline",off:"mdi:power"};function Ps(t){var e;return null!==(e=Ms[t])&&void 0!==e?e:Ms.off}let Ns=class extends ht{constructor(){super(...arguments),this.fill=!1}callService(t){t.stopPropagation();const e=t.target.mode;this.hass.callService("climate","set_hvac_mode",{entity_id:this.entity.entity_id,hvac_mode:e})}render(){const t=Ie(this.hass),e=this.entity.attributes.hvac_modes.filter((t=>{var e;return(null!==(e=this.modes)&&void 0!==e?e:[]).includes(t)})).sort(je);return Y` ${e.map((t=>this.renderModeButton(t)))} @@ -2716,7 +2708,7 @@ const aa="important",la=" !"+aa,sa=He(class extends Ye{constructor(t){var e;if(s } `}};n([_t({attribute:!1})],Gc.prototype,"hass",void 0),n([_t({attribute:!1})],Gc.prototype,"entity",void 0),n([_t({type:Boolean})],Gc.prototype,"fill",void 0),n([_t({attribute:!1})],Gc.prototype,"controls",void 0),Gc=n([pt("mushroom-media-player-volume-control")],Gc);const qc={media_control:"mdi:play-pause",volume_control:"mdi:volume-high"};Pl({type:Bc,name:"Mushroom Media Card",description:"Card for media player entity"});let Zc=class extends Dl{static async getConfigElement(){return await Promise.resolve().then((function(){return Bf})),document.createElement(Uc)}static async getStubConfig(t){const e=Object.keys(t.states).filter((t=>Hc.includes(t.split(".")[0])));return{type:`custom:${Bc}`,entity:e[0]}}get hasControls(){var t,e,i,o;return Boolean(null===(e=null===(t=this._config)||void 0===t?void 0:t.media_controls)||void 0===e?void 0:e.length)||Boolean(null===(o=null===(i=this._config)||void 0===i?void 0:i.volume_controls)||void 0===o?void 0:o.length)}get _controls(){if(!this._config||!this._stateObj)return[];const t=this._stateObj,e=[];return((t,e)=>Wc(t,null!=e?e:[]).length>0)(t,this._config.media_controls)&&e.push("media_control"),((t,e)=>(null==e?void 0:e.includes("volume_buttons"))&&Wt(t,1024)||(null==e?void 0:e.includes("volume_mute"))&&Wt(t,8)||(null==e?void 0:e.includes("volume_set"))&&Wt(t,4))(t,this._config.volume_controls)&&e.push("volume_control"),e}_onControlTap(t,e){e.stopPropagation(),this._activeControl=t}setConfig(t){super.setConfig(t),this.updateActiveControl(),this.updateVolume()}updated(t){super.updated(t),this.hass&&t.has("hass")&&(this.updateActiveControl(),this.updateVolume())}updateVolume(){this.volume=void 0;const t=this._stateObj;if(!t)return;const e=Yc(t);this.volume=null!=e?Math.round(e):e}onCurrentVolumeChange(t){null!=t.detail.value&&(this.volume=t.detail.value)}updateActiveControl(){const t=!!this._activeControl&&this._controls.includes(this._activeControl);this._activeControl=t?this._activeControl:this._controls[0]}_handleAction(t){Ke(this,this.hass,this._config,t.detail.action)}render(){if(!this._config||!this.hass||!this._config.entity)return K;const t=this._stateObj;if(!t)return this.renderNotFound(this._config);const e=function(t,e){var i,o=t.icon;if(![Nt,Rt,Ft].includes(e.state)&&t.use_media_info)switch(null===(i=e.attributes.app_name)||void 0===i?void 0:i.toLowerCase()){case"spotify":return"mdi:spotify";case"google podcasts":return"mdi:google-podcast";case"plex":return"mdi:plex";case"soundcloud":return"mdi:soundcloud";case"youtube":return"mdi:youtube";case"oto music":return"mdi:music-circle";case"netflix":return"mdi:netflix";default:return}return o}(this._config,t),i=function(t,e){let i=t.name||e.attributes.friendly_name||"";return![Nt,Rt,Ft].includes(e.state)&&t.use_media_info&&e.attributes.media_title&&(i=e.attributes.media_title),i}(this._config,t),o=function(t,e,i){let o=i.formatEntityState?i.formatEntityState(e):ne(i.localize,e,i.locale,i.config,i.entities);return![Nt,Rt,Ft].includes(e.state)&&t.use_media_info&&(t=>{let e;switch(t.attributes.media_content_type){case"music":case"image":e=t.attributes.media_artist;break;case"playlist":e=t.attributes.media_playlist;break;case"tvshow":e=t.attributes.media_series_title,t.attributes.media_season&&(e+=" S"+t.attributes.media_season,t.attributes.media_episode&&(e+="E"+t.attributes.media_episode));break;default:e=t.attributes.app_name||""}return e})(e)||o}(this._config,t,this.hass),n=$l(this._config),r=rl(t,n.icon_type),a=null!=this.volume&&this._config.show_volume_level?`${o} - ${this.volume}${oe(this.hass.locale)}%`:o,l=Ie(this.hass),s=(!this._config.collapsible_controls||Bt(t))&&this._controls.length;return Y` {var i;(null===(i=this._config)||void 0===i?void 0:i[e])!==t[e]&&this._tryDisconnectKey(e)})),this._config=Object.assign({title_tap_action:{action:"none"},subtitle_tap_action:{action:"none"}},t)}connectedCallback(){super.connectedCallback(),this._tryConnect()}disconnectedCallback(){this._tryDisconnect()}isTemplate(t){var e;const i=null===(e=this._config)||void 0===e?void 0:e[t];return null==i?void 0:i.includes("{")}getValue(t){var e,i,o;return this.isTemplate(t)?null===(i=null===(e=this._templateResults[t])||void 0===e?void 0:e.result)||void 0===i?void 0:i.toString():null===(o=this._config)||void 0===o?void 0:o[t]}_handleTitleAction(t){const e={tap_action:this._config.title_tap_action};Ke(this,this.hass,e,t.detail.action)}_handleSubtitleAction(t){const e={tap_action:this._config.subtitle_tap_action};Ke(this,this.hass,e,t.detail.action)}render(){if(!this._config||!this.hass)return K;const t=this.getValue("title"),e=this.getValue("subtitle");let i="";this._config.alignment&&(i=`align-${this._config.alignment}`);const o=Boolean(this._config.title_tap_action&&"none"!==this._config.title_tap_action.action),n=Boolean(this._config.subtitle_tap_action&&"none"!==this._config.subtitle_tap_action.action),r=Ie(this.hass);return Y` + `]}};n([vt()],ud.prototype,"_config",void 0),n([vt()],ud.prototype,"_templateResults",void 0),n([vt()],ud.prototype,"_unsubRenderTemplates",void 0),n([_t({reflect:!0,type:String})],ud.prototype,"layout",void 0),n([_t({attribute:"in-grid",reflect:!0,type:Boolean})],ud.prototype,"_inGrid",void 0),ud=n([pt(sd)],ud);const hd=`${Nl}-title-card`,md=`${hd}-editor`;Pl({type:hd,name:"Mushroom Title Card",description:"Title and subtitle to separate sections"});const pd=["title","subtitle"];let fd=class extends jl{constructor(){super(...arguments),this._templateResults={},this._unsubRenderTemplates=new Map}static async getConfigElement(){return await Promise.resolve().then((function(){return ig})),document.createElement(md)}static async getStubConfig(t){return{type:`custom:${hd}`,title:"Hello, {{ user }} !"}}getCardSize(){return 1}setConfig(t){pd.forEach((e=>{var i;(null===(i=this._config)||void 0===i?void 0:i[e])!==t[e]&&this._tryDisconnectKey(e)})),this._config=Object.assign({title_tap_action:{action:"none"},subtitle_tap_action:{action:"none"}},t)}connectedCallback(){super.connectedCallback(),this._tryConnect()}disconnectedCallback(){this._tryDisconnect()}isTemplate(t){var e;const i=null===(e=this._config)||void 0===e?void 0:e[t];return null==i?void 0:i.includes("{")}getValue(t){var e,i,o;return this.isTemplate(t)?null===(i=null===(e=this._templateResults[t])||void 0===e?void 0:e.result)||void 0===i?void 0:i.toString():null===(o=this._config)||void 0===o?void 0:o[t]}_handleTitleAction(t){const e={tap_action:this._config.title_tap_action};Ke(this,this.hass,e,t.detail.action)}_handleSubtitleAction(t){const e={tap_action:this._config.subtitle_tap_action};Ke(this,this.hass,e,t.detail.action)}render(){if(!this._config||!this.hass)return K;const t=this.getValue("title"),e=this.getValue("subtitle");let i="";this._config.alignment&&(i=`align-${this._config.alignment}`);const o=Boolean(this._config.title_tap_action&&"none"!==this._config.title_tap_action.action),n=Boolean(this._config.subtitle_tap_action&&"none"!==this._config.subtitle_tap_action.action),r=Ie(this.hass);return Y` ${t?Y`
[{name:"tap_action",selector:{"ui-action":{actions:t}}},{name:"hold_action",selector:{"ui-action":{actions:t}}},{name:"double_tap_action",selector:{"ui-action":{actions:t}}}],jd=Ce({layout:$e(Se([we("horizontal"),we("vertical"),we("default")])),fill_container:$e(ye()),primary_info:$e(xe(il)),secondary_info:$e(xe(il)),icon_type:$e(xe(ol))}),Dd=[{type:"grid",name:"",schema:[{name:"layout",selector:{mush_layout:{}}},{name:"fill_container",selector:{boolean:{}}}]},{type:"grid",name:"",schema:[{name:"primary_info",selector:{mush_info:{}}},{name:"secondary_info",selector:{mush_info:{}}},{name:"icon_type",selector:{mush_icon_type:{}}}]}],Ld=["icon_color","layout","fill_container","primary_info","secondary_info","icon_type","content_info","use_entity_picture","collapsible_controls","icon_animation"],Pd=Ce({entity:$e(Ee()),name:$e(Ee()),icon:$e(Ee())}),Nd=Ce({index:$e(ke()),view_index:$e(ke()),view_layout:ve(),type:Ee(),layout_options:ve(),visibility:ve()}),Rd=fe(Nd,fe(Pd,jd,zd),Ce({states:$e(be()),show_keypad:(Fd=$e(ye()),Vd=(t,e)=>{console.warn(`🍄 "${e.path}" option is deprecated and no longer available. Remove it from your YAML configuration or use the built-in Home Assistant alarm panel card if you want keypad.`)},new he({...Fd,refiner:(t,e)=>void 0===t||Fd.refiner(t,e),validator:(t,e)=>void 0===t||(Vd(t,e),Fd.validator(t,e))}))}));var Fd,Vd;const Bd=["more-info","navigate","url","call-service","assist","none"],Ud=["armed_home","armed_away","armed_night","armed_vacation","armed_custom_bypass"],Hd=Tt((t=>[{name:"entity",selector:{entity:{domain:Vl}}},{name:"name",selector:{text:{}}},{name:"icon",selector:{icon:{}},context:{icon_entity:"entity"}},...Dd,{type:"multi_select",name:"states",options:Ud.map((e=>[e,t(`ui.card.alarm_control_panel.${e.replace("armed","arm")}`)]))},...Md(Bd)]));let Yd=class extends jl{constructor(){super(...arguments),this._computeLabel=t=>{const e=Oo(this.hass);return Ld.includes(t.name)?e(`editor.card.generic.${t.name}`):"states"===t.name?this.hass.localize("ui.panel.lovelace.editor.card.alarm-panel.available_states"):this.hass.localize(`ui.panel.lovelace.editor.card.generic.${t.name}`)}}connectedCallback(){super.connectedCallback(),fs()}setConfig(t){me(t,Rd),this._config=t}render(){if(!this.hass||!this._config)return K;const t=Hd(this.hass.localize);return Y` + `]}};Od=n([pt(wd)],Od),console.info("%c🍄 Mushroom 🍄 - 3.6.3","color: #ef5350; font-weight: 700;");const zd=Ce({tap_action:$e(ni),hold_action:$e(ni),double_tap_action:$e(ni)}),Md=t=>[{name:"tap_action",selector:{"ui-action":{actions:t}}},{name:"hold_action",selector:{"ui-action":{actions:t}}},{name:"double_tap_action",selector:{"ui-action":{actions:t}}}],jd=Ce({layout:$e(Se([we("horizontal"),we("vertical"),we("default")])),fill_container:$e(ye()),primary_info:$e(xe(il)),secondary_info:$e(xe(il)),icon_type:$e(xe(ol))}),Dd=[{type:"grid",name:"",schema:[{name:"layout",selector:{mush_layout:{}}},{name:"fill_container",selector:{boolean:{}}}]},{type:"grid",name:"",schema:[{name:"primary_info",selector:{mush_info:{}}},{name:"secondary_info",selector:{mush_info:{}}},{name:"icon_type",selector:{mush_icon_type:{}}}]}],Ld=["icon_color","layout","fill_container","primary_info","secondary_info","icon_type","content_info","use_entity_picture","collapsible_controls","icon_animation"],Pd=Ce({entity:$e(Ee()),name:$e(Ee()),icon:$e(Ee())}),Nd=Ce({index:$e(ke()),view_index:$e(ke()),view_layout:ve(),type:Ee(),layout_options:ve(),visibility:ve()}),Rd=fe(Nd,fe(Pd,jd,zd),Ce({states:$e(be()),show_keypad:(Fd=$e(ye()),Vd=(t,e)=>{console.warn(`🍄 "${e.path}" option is deprecated and no longer available. Remove it from your YAML configuration or use the built-in Home Assistant alarm panel card if you want keypad.`)},new he({...Fd,refiner:(t,e)=>void 0===t||Fd.refiner(t,e),validator:(t,e)=>void 0===t||(Vd(t,e),Fd.validator(t,e))}))}));var Fd,Vd;const Bd=["more-info","navigate","url","call-service","assist","none"],Ud=["armed_home","armed_away","armed_night","armed_vacation","armed_custom_bypass"],Hd=Tt((t=>[{name:"entity",selector:{entity:{domain:Vl}}},{name:"name",selector:{text:{}}},{name:"icon",selector:{icon:{}},context:{icon_entity:"entity"}},...Dd,{type:"multi_select",name:"states",options:Ud.map((e=>[e,t(`ui.card.alarm_control_panel.${e.replace("armed","arm")}`)]))},...Md(Bd)]));let Yd=class extends jl{constructor(){super(...arguments),this._computeLabel=t=>{const e=Oo(this.hass);return Ld.includes(t.name)?e(`editor.card.generic.${t.name}`):"states"===t.name?this.hass.localize("ui.panel.lovelace.editor.card.alarm-panel.available_states"):this.hass.localize(`ui.panel.lovelace.editor.card.generic.${t.name}`)}}connectedCallback(){super.connectedCallback(),fs()}setConfig(t){me(t,Rd),this._config=t}render(){if(!this.hass||!this._config)return K;const t=Hd(this.hass.localize);return Y`