Update popup design. Add form popups

This commit is contained in:
thomas committed 2022-08-03 21:21:25 +00:00
1 parent a641617671
commit bb7b7fa6ff
12 files changed
+280 -122

No files matched your search

+53 -42
View File
@@ -1,4 +1,4 @@
function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(n<3?o(r):n>3?o(t,i,r):o(t,i))||r);return n>3&&r&&Object.defineProperty(t,i,r),r}const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new WeakMap;class o{constructor(e,t,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const i=this.t;if(t&&void 0===e){const t=void 0!==i&&1===i.length;t&&(e=s.get(i)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&s.set(i,e))}return e}toString(){return this.cssText}}const n=(e,...t)=>{const s=1===e.length?e[0]:t.reduce(((t,i,s)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[s+1]),e[0]);return new o(s,e,i)},r=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new o("string"==typeof e?e:e+"",void 0,i))(t)})(e):e;var a;const d=window.trustedTypes,l=d?d.emptyScript:"",c=window.reactiveElementPolyfillSupport,h={toAttribute(e,t){switch(t){case Boolean:e=e?l:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},u=(e,t)=>t!==e&&(t==t||e==e),p={attribute:!0,type:String,converter:h,reflect:!1,hasChanged:u};class v extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;null!==(t=this.h)&&void 0!==t||(this.h=[]),this.h.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,i)=>{const s=this._$Ep(i,t);void 0!==s&&(this._$Ev.set(s,i),e.push(s))})),e}static createProperty(e,t=p){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const i="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,i,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(s){const o=this[e];this[t]=s,this.requestUpdate(e,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of t)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(r(e))}else void 0!==e&&t.push(r(e));return t}static _$Ep(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,i;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(i=e.hostConnected)||void 0===i||i.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const i=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,i)=>{t?e.adoptedStyleSheets=i.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):i.forEach((t=>{const i=document.createElement("style"),s=window.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=t.cssText,e.appendChild(i)}))})(i,this.constructor.elementStyles),i}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,i){thisLine truncated function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}const e=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new WeakMap;class o{constructor(t,e,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=s.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&s.set(i,t))}return t}toString(){return this.cssText}}const n=(t,...e)=>{const s=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new o(s,t,i)},r=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new o("string"==typeof t?t:t+"",void 0,i))(e)})(t):t;var a;const d=window.trustedTypes,l=d?d.emptyScript:"",c=window.reactiveElementPolyfillSupport,h={toAttribute(t,e){switch(e){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},u=(t,e)=>e!==t&&(e==e||t==t),p={attribute:!0,type:String,converter:h,reflect:!1,hasChanged:u};class v extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;null!==(e=this.h)&&void 0!==e||(this.h=[]),this.h.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Ep(i,e);void 0!==s&&(this._$Ev.set(s,i),t.push(s))})),t}static createProperty(t,e=p){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(r(t))}else void 0!==t&&e.push(r(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const i=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,i)=>{e?t.adoptedStyleSheets=i.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):i.forEach((e=>{const i=document.createElement("style"),s=window.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=e.cssText,t.appendChild(i)}))})(i,this.constructor.elementStyles),i}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){thisLine truncated
<ha-card> <ha-card>
<div class="card-content"> <div class="card-content">
<ha-icon-button @click=${this.handleMute}> <ha-icon-button @click=${this.handleMute}>
@@ -15,7 +15,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
@change=${this.handleVolumeChange} @change=${this.handleVolumeChange}
></ha-slider> ></ha-slider>
${"stopped"===window.browser_mod.player_state?M`<div class="placeholder"></div>`:M` ${"stopped"===window.browser_mod.player_state?O`<div class="placeholder"></div>`:O`
<ha-icon-button @click=${this.handlePlayPause} highlight> <ha-icon-button @click=${this.handlePlayPause} highlight>
<ha-icon <ha-icon
.icon=${!window.browser_mod.player.src||window.browser_mod.player.ended||window.browser_mod.player.paused?"mdi:play":"mdi:pause"} .icon=${!window.browser_mod.player.src||window.browser_mod.player.ended||window.browser_mod.player.paused?"mdi:play":"mdi:pause"}
@@ -29,7 +29,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
<div class="browser-id">${window.browser_mod.browserID}</div> <div class="browser-id">${window.browser_mod.browserID}</div>
</ha-card> </ha-card>
`:(window.setTimeout((()=>this.requestUpdate()),100),M``)}static get styles(){return n` `:(window.setTimeout((()=>this.requestUpdate()),100),O``)}static get styles(){return n`
paper-icon-button[highlight] { paper-icon-button[highlight] {
color: var(--accent-color); color: var(--accent-color);
} }
@@ -53,7 +53,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
ha-icon-button ha-icon { ha-icon-button ha-icon {
display: flex; display: flex;
} }
`}}e([ee()],ne.prototype,"hass",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((e=>setTimeout(e,1e3)));await window.browser_mod.connectionPromise,customElements.get("browser-player")||customElements.define("browser-player",ne)})();async function re(e){var t;(null===(t=e.localName)||void 0===t?void 0:t.includes("-"))&&await customElements.whenDefined(e.localName),e.updateComplete&&await e.updateComplete}async function ae(e,t,i=!1){let s=[e];for("string"==typeof t&&(t=t.split(/(\$| )/));""===t[t.length-1];)t.pop();for(const[e,i]of t.entries()){const e=s[0];if(!e)return null;i.trim().length&&(re(e),s="$"===i?[e.shadowRoot]:e.querySelectorAll(i))}return i?s:s[0]}async function de(e,t,i=!1,s=1e4){return Promise.race([ae(e,t,i),new Promise(((e,t)=>setTimeout((()=>t(new Error("SELECTTREE-TIMEOUT"))),s)))]).catch((e=>{if(!e.message||"SELECTTREE-TIMEOUT"!==e.message)throw e;return null}))}async function le(){await Promise.race([customElements.whenDefined("home-assistant"),customElements.whenDefined("hc-main")]);const e=customElements.get("home-assistant")?"home-assistant":"hc-main";for(;!document.querySelector(e);)await new Promise((e=>window.setTimeout(e,100)));return document.querySelector(e)}async function ce(e){(await le()).provideHass(e)}const he=async()=>{var e,t,i;if(void 0!==window.loadCardHelpers)return;await customElements.whenDefined("partial-panel-resolver");const s=document.createElement("partial-panel-resolver").getRoutes([{component_name:"lovelace",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==s?void 0:s.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t))},ue=e=>class extends e{constructor(){super(...arguments),this.connected=!1,this.connectionPromise=new Promise((e=>{this._connectionResolve=e})),this.browserEntities={}}LOG(...e){}fireEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}incoming_message(e){var t;e.command?(this.LOG("Command:",e),this.fireEvent(`command-${e.command}`,e)):e.browserEntities?this.browserEntities=e.browserEntities:e.result&&this.update_config(e.result),null===(t=this._connectionResolve)||void 0===t||t.call(this)}update_config(e){var t;this.LOG("Receive:",e);let i=!1;!this.registered&&(null===(t=e.browsers)||void 0===t?void 0:t[this.browserID])&&(i=!0),this._data=e,this.connected||(this.connected=!0,this.fireEvent("browser-mod-connected")),this.fireEvent("browser-mod-config-update"),i&&this.sendUpdate({})}async connect(){const e=(await async function(){const e=await le();for(;!e.hass;)await new Promise((e=>window.setTimeout(e,100)));return e.hass}()).connection;this.connection=e,e.subscribeMessage((e=>this.incoming_message(e)),{type:"browser_mod/connect",browserID:this.browserID}),e.addEventListener("disconnected",(()=>{this.connected=!1,this.fireEvent("browser-mod-disconnected")})),e.addEventListener("ready",(()=>{this.connected=!0,this.fireEvent("browser-mod-connected"),this.sendUpdate({})})),ce(this)}get config(){var e,t;return null!==(t=null===(e=this._data)||void 0===e?void 0:e.config)&&void 0!==t?t:{}}get browsers(){var e,t;return null!==(t=null===(e=this._data)||void 0===e?void 0:e.browsers)&&void 0!==t?t:[]}get registered(){var e;return void 0!==(null===(e=this.browsers)||void 0===e?void 0:e[this.browserID])}set registered(e){(async()=>{if(e){if(this.registered)return;await this.connection.sendMessage({type:"browser_mod/register",browserID:this.browserID})}else{if(!this.registered)return;await this.connection.sendMessage({type:"browser_mod/unregister",browserID:this.browserID})}})()}async _reregister(e={}){await this.connection.sendMessage({type:"browser_mod/register",browserID:this.browserID,data:Object.assign(Object.assign({},this.browsers[this.browserID]),e)})}get global_settings(){var e,t;const i={},s=null!==(t=null===(e=this._data)||void 0===e?void 0:e.settings)&&void 0!==t?t:{};for(const[e,t]of Object.entries(s))null!==t&&(i[e]=t);return i}get user_settings(){var e,t,i,s,o;const n={},r=null!==(o=null===(t=null===(e=this._data)||void 0===e?void 0:e.user_settings)||void 0===t?void 0:t[null===(s=null===(i=this.hass)||void 0===i?void 0:i.user)||void 0===s?void 0:s.id])&&void 0!==o?o:{};for(const[e,t]of Object.entries(r))null!==t&&(n[e]=t);return n}get browser_settings(){var e,t,i;const s={},o=null!==(i=null===(t=null===(e=this.browsers)||void 0===e?void 0:e[this.browserID])||void 0===t?void 0:t.settings)&&void 0!==i?i:{};for(const[e,t]of Object.entries(o))null!==t&&(s[e]=t);return s}get settings(){return Object.assign(Object.assign(Object.assign({},this.global_settings),this.browser_settings),this.user_settings)}set_setting(e,t,i){var s;switch(i){case"global":this.connection.sendMessage({type:"browser_mod/settings",key:e,value:t});break;case"user":{const i=this.hass.user.id;this.connection.sendMessage({type:"browser_mod/settings",user:i,key:e,value:t});break}case"browser":{const i=null===(s=this.browsers[this.browserID])||void 0===s?void 0:s.settings;i[e]=t,this._reregister({settings:i}) Line truncated `}}t([tt()],nt.prototype,"hass",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((t=>setTimeout(t,1e3)));await window.browser_mod.connectionPromise,customElements.get("browser-player")||customElements.define("browser-player",nt)})();async function rt(t){var e;(null===(e=t.localName)||void 0===e?void 0:e.includes("-"))&&await customElements.whenDefined(t.localName),t.updateComplete&&await t.updateComplete}async function at(t,e,i=!1){let s=[t];for("string"==typeof e&&(e=e.split(/(\$| )/));""===e[e.length-1];)e.pop();for(const[t,i]of e.entries()){const t=s[0];if(!t)return null;i.trim().length&&(rt(t),s="$"===i?[t.shadowRoot]:t.querySelectorAll(i))}return i?s:s[0]}async function dt(t,e,i=!1,s=1e4){return Promise.race([at(t,e,i),new Promise(((t,e)=>setTimeout((()=>e(new Error("SELECTTREE-TIMEOUT"))),s)))]).catch((t=>{if(!t.message||"SELECTTREE-TIMEOUT"!==t.message)throw t;return null}))}async function lt(){await Promise.race([customElements.whenDefined("home-assistant"),customElements.whenDefined("hc-main")]);const t=customElements.get("home-assistant")?"home-assistant":"hc-main";for(;!document.querySelector(t);)await new Promise((t=>window.setTimeout(t,100)));return document.querySelector(t)}async function ct(t){(await lt()).provideHass(t)}const ht=async()=>{var t,e,i;if(void 0!==window.loadCardHelpers)return;await customElements.whenDefined("partial-panel-resolver");const s=document.createElement("partial-panel-resolver").getRoutes([{component_name:"lovelace",url_path:"a"}]);await(null===(i=null===(e=null===(t=null==s?void 0:s.routes)||void 0===t?void 0:t.a)||void 0===e?void 0:e.load)||void 0===i?void 0:i.call(e))},ut=async()=>{if(customElements.get("ha-form"))return;await ht();const t=await window.loadCardHelpers();if(!t)return;const e=await t.createCardElement({type:"button"});e&&await e.constructor.getConfigElement()};const pt=t=>class extends t{constructor(){super(...arguments),this.connected=!1,this.connectionPromise=new Promise((t=>{this._connectionResolve=t})),this.browserEntities={}}LOG(...t){}fireEvent(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}incoming_message(t){var e;t.command?(this.LOG("Command:",t),this.fireEvent(`command-${t.command}`,t)):t.browserEntities?this.browserEntities=t.browserEntities:t.result&&this.update_config(t.result),null===(e=this._connectionResolve)||void 0===e||e.call(this)}update_config(t){var e;this.LOG("Receive:",t);let i=!1;!this.registered&&(null===(e=t.browsers)||void 0===e?void 0:e[this.browserID])&&(i=!0),this._data=t,this.connected||(this.connected=!0,this.fireEvent("browser-mod-connected")),this.fireEvent("browser-mod-config-update"),i&&this.sendUpdate({})}async connect(){const t=(await async function(){const t=await lt();for(;!t.hass;)await new Promise((t=>window.setTimeout(t,100)));return t.hass}()).connection;this.connection=t,t.subscribeMessage((t=>this.incoming_message(t)),{type:"browser_mod/connect",browserID:this.browserID}),t.addEventListener("disconnected",(()=>{this.connected=!1,this.fireEvent("browser-mod-disconnected")})),t.addEventListener("ready",(()=>{this.connected=!0,this.fireEvent("browser-mod-connected"),this.sendUpdate({})})),ct(this)}get config(){var t,e;return null!==(e=null===(t=this._data)||void 0===t?void 0:t.config)&&void 0!==e?e:{}}get browsers(){var t,e;return null!==(e=null===(t=this._data)||void 0===t?void 0:t.browsers)&&void 0!==e?e:[]}get registered(){var t;return void 0!==(null===(t=this.browsers)||void 0===t?void 0:t[this.browserID])}set registered(t){(async()=>{if(t){if(this.registered)return;await this.connection.sendMessage({type:"browser_mod/register",browserID:this.browserID})}else{if(!this.registered)return;await this.connection.sendMessage({type:"browser_mod/unregister",browserID:this.browserID})}})()}async _reregister(t={}){await this.connection.sendMessage({type:"browser_mod/register",browserID:this.browserID,data:Object.assign(Object.assign({},this.browsers[this.browserID]),t)})}get global_settings(){var t,e;const i={},s=null!==(e=null===(t=this._data)||void 0===t?void 0:t.settings)&&void 0!==e?e:{};for(const[t,e]of Object.entries(s))null!==e&&(i[t]=e);return i}get user_settings(){var t,e,i,s,o;const n={},r=null!==(o=null===(e=null===(t=this._data)||void 0===t?void 0:t.user_settings)||void 0===e?void 0:e[null===(s=null===(i=this.hass)||void 0===i?void 0:i.user)||void 0===s?void 0:s.id])&&void 0!==o?o:{};for(const[t,e]of Object.entries(r))null!==e&&(n[t]=e);return n}get browser_settings(){var t,e,i;const s={},o=null!==(i=null===(e=null===(t=this.browsers)||void 0===t?void 0:t[this.browserID])||void 0===e?void 0:e.settings)&&void 0!==i?i:{};for(const[t,e]of Object.entries(o))null!==e&&(s[t]=e);return s}get settings(){return Object.assign(Object.assign(Object.assign({},this.global_settings),this.browser_settings),this.user_settings)}set_setting(t,e,i){var s;switch(i){case"global":this.connection.sendMessage({type:"browser_mod/settings",key:t,value:e});break;case"user":{const i=this.hass.user.id;t Line truncated
<ha-dialog <ha-dialog
open open
@closed=${this.closeDialog} @closed=${this.closeDialog}
@@ -63,32 +63,39 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
.scrimClickAction=${this.dismissable?"close":""} .scrimClickAction=${this.dismissable?"close":""}
.escapeKeyAction=${this.dismissable?"close":""} .escapeKeyAction=${this.dismissable?"close":""}
> >
${this.timeout?M` <div slot="heading" class="progress"></div> `:""} ${this.timeout?O` <div slot="heading" class="progress"></div> `:""}
${this.title?M` ${this.title?O`
<app-toolbar slot="heading"> <div slot="heading">
${this.dismissable?M` <ha-header-bar>
<ha-icon-button dialogAction="cancel"> ${this.dismissable?O`
<ha-icon-button
dialogAction="cancel"
slot="navigationIcon"
>
<ha-icon .icon=${"mdi:close"}></ha-icon> <ha-icon .icon=${"mdi:close"}></ha-icon>
</ha-icon-button> </ha-icon-button>
`:""} `:""}
<div class="main-title">${this.title}</div> <div slot="title" class="main-title">${this.title}</div>
</app-toolbar> </ha-header-bar>
`:M``} </div>
`:O``}
<div class="content">${this.content}</div> <div class="content">${this.content}</div>
${void 0!==this.right_button?M` ${void 0!==this.right_button?O`
<mwc-button <mwc-button
slot="primaryAction" slot="primaryAction"
.label=${this.right_button} .label=${this.right_button}
@click=${this._primary} @click=${this._primary}
class="action-button"
></mwc-button> ></mwc-button>
`:""} `:""}
${void 0!==this.left_button?M` ${void 0!==this.left_button?O`
<mwc-button <mwc-button
slot="secondaryAction" slot="secondaryAction"
.label=${this.left_button} .label=${this.left_button}
@click=${this._secondary} @click=${this._secondary}
class="action-button"
></mwc-button> ></mwc-button>
`:""} `:""}
<style> <style>
@@ -97,8 +104,9 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
} }
</style> </style>
</ha-dialog> </ha-dialog>
`:M``}static get styles(){return n` `:O``}static get styles(){return n`
ha-dialog { ha-dialog {
--dialog-backdrop-filter: blur(5px);
z-index: 10; z-index: 10;
--mdc-dialog-min-width: var(--popup-min-width, 400px); --mdc-dialog-min-width: var(--popup-min-width, 400px);
--mdc-dialog-max-width: var(--popup-max-width, 600px); --mdc-dialog-max-width: var(--popup-max-width, 600px);
@@ -106,13 +114,12 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
--mdc-dialog-content-ink-color: var(--primary-text-color); --mdc-dialog-content-ink-color: var(--primary-text-color);
--justify-action-buttons: space-between; --justify-action-buttons: space-between;
--mdc-dialog-box-shadow: 0px 0px 0px --dialog-box-shadow: 0px 0px 0px
var(--popup-border-width, var(--ha-card-border-width, 2px)) var(--popup-border-width, var(--ha-card-border-width, 2px))
var( var(
--popup-border-color, --popup-border-color,
var(--ha-card-border-color, var(--divider-color, #e0e0e0)) var(--ha-card-border-color, var(--divider-color, #e0e0e0))
); );
--ha-dialog-border-radius: var(--popup-border-radius, 8px);
--mdc-theme-surface: var( --mdc-theme-surface: var(
--popup-background-color, --popup-background-color,
var(--ha-card-background, var(--card-background-color, white)) var(--ha-card-background, var(--card-background-color, white))
@@ -128,6 +135,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
--mdc-dialog-max-height: 100%; --mdc-dialog-max-height: 100%;
--mdc-shape-medium: 0px; --mdc-shape-medium: 0px;
--vertial-align-dialog: flex-end; --vertial-align-dialog: flex-end;
--ha-dialog-border-radius: 0px;
} }
.progress::before { .progress::before {
content: ""; content: "";
@@ -140,23 +148,20 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
z-index: 10; z-index: 10;
} }
app-toolbar { ha-header-bar {
--mdc-theme-on-primary: var(--primary-text-color);
--mdc-theme-primary: var(--mdc-theme-surface);
flex-shrink: 0; flex-shrink: 0;
color: var(--primary-text-color); display: block;
background-color: var(
--popup-header-background-color,
var(--popup-background-color, var(--sidebar-background-color))
);
} }
ha-icon-button > * { ha-icon-button > * {
display: flex; display: flex;
} }
.main-title { .main-title {
margin-left: 16px;
line-height: 1.3em;
max-height: 2.6em;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
cursor: default;
} }
.content { .content {
--padding-x: 24px; --padding-x: 24px;
@@ -173,9 +178,11 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
:host([card]) .content { :host([card]) .content {
--padding-x: 0px; --padding-x: 0px;
--padding-y: 0px; --padding-y: 0px;
--ha-card-box-shadow: none;
} }
:host([actions]) .content { :host([actions]) .content {
border-bottom: 1px solid var(--popup-border-color, var(--divider-color)); xborder-bottom: 2px solid
var(--popup-border-color, var(--divider-color));
--footer-height: 54px; --footer-height: 54px;
} }
:host([wide]) .content { :host([wide]) .content {
@@ -184,10 +191,14 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
:host([fullscreen]) .content { :host([fullscreen]) .content {
height: calc( height: calc(
100vh - var(--header-height) - var(--footer-height) - 2 * 100vh - var(--header-height) - var(--footer-height) - 2 *
var(--padding-y) var(--padding-y) - 16px
); );
} }
.action-button {
margin-bottom: -24px;
}
@media all and (max-width: 450px), all and (max-height: 500px) { @media all and (max-width: 450px), all and (max-height: 500px) {
ha-dialog { ha-dialog {
--mdc-dialog-min-width: 100vw; --mdc-dialog-min-width: 100vw;
@@ -198,7 +209,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
--vertial-align-dialog: flex-end; --vertial-align-dialog: flex-end;
} }
} }
`}}e([ee()],Ae.prototype,"open",void 0),e([ee()],Ae.prototype,"content",void 0),e([ee()],Ae.prototype,"title",void 0),e([ee({reflect:!0})],Ae.prototype,"actions",void 0),e([ee({reflect:!0})],Ae.prototype,"card",void 0),e([ee()],Ae.prototype,"right_button",void 0),e([ee()],Ae.prototype,"left_button",void 0),e([ee()],Ae.prototype,"dismissable",void 0),e([ee({reflect:!0})],Ae.prototype,"wide",void 0),e([ee({reflect:!0})],Ae.prototype,"fullscreen",void 0),e([ee()],Ae.prototype,"_style",void 0),e([ie("ha-dialog")],Ae.prototype,"dialog",void 0),customElements.get("browser-mod-popup")||customElements.define("browser-mod-popup",Ae);const xe=e=>class extends e{constructor(){super(),he(),this._popupEl=document.createElement("browser-mod-popup"),document.body.append(this._popupEl)}showPopup(...e){this._popupEl.setupDialog(...e).then((()=>this._popupEl.openDialog()))}closePopup(...e){this._popupEl.closeDialog(),this.showMoreInfo("")}async showMoreInfo(e,t=!1,i){const s=await le();if(s.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:e,ignore_popup_card:i}})),t){await new Promise((e=>setTimeout(e,50)));const e=s.shadowRoot.querySelector("ha-more-info-dialog");e&&(e.large=!0)}}};var Se="2.0.0b2";const Ce=[{name:"entity",label:"Entity",selector:{entity:{}}},{name:"title",label:"Title",selector:{text:{}}},{name:"size",selector:{select:{mode:"dropdown",options:["normal","wide","fullscreen"]}}},{type:"grid",schema:[{name:"right_button",label:"Right button",selector:{text:{}}},{name:"left_button",label:"Left button",selector:{text:{}}}]},{type:"grid",schema:[{name:"right_button_action",label:"Right button action",selector:{object:{}}},{name:"left_button_action",label:"Left button action",selector:{object:{}}}]},{type:"grid",schema:[{name:"dismissable",label:"User dismissable",selector:{boolean:{}}},{name:"timeout",label:"Auto close timeout (ms)",selector:{number:{mode:"box"}}}]},{type:"grid",schema:[{name:"dismiss_action",label:"Dismiss action",selector:{object:{}}},{name:"timeout_action",label:"Timeout action",selector:{object:{}}}]},{name:"style",label:"CSS style",selector:{text:{multiline:!0}}}];class Te extends Q{constructor(){super(...arguments),this._selectedTab=0,this._cardGUIMode=!0,this._cardGUIModeAvailable=!0}setConfig(e){this._config=e}connectedCallback(){super.connectedCallback(),(async()=>{if(customElements.get("ha-form"))return;await he();const e=await window.loadCardHelpers();if(!e)return;const t=await e.createCardElement({type:"entity"});t&&await t.getConfigElement()})()}_handleSwitchTab(e){this._selectedTab=parseInt(e.detail.index,10)}_configChanged(e){e.stopPropagation(),this._config&&(this._config=Object.assign({},e.detail.value),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}})))}_cardConfigChanged(e){if(e.stopPropagation(),!this._config)return;const t=Object.assign({},e.detail.config);this._config=Object.assign(Object.assign({},this._config),{card:t}),this._cardGUIModeAvailable=e.detail.guiModeAvailable,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_toggleCardMode(e){var t;null===(t=this._cardEditorEl)||void 0===t||t.toggleMode()}_deleteCard(e){this._config&&(this._config=Object.assign({},this._config),delete this._config.card,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}})))}_cardGUIModeChanged(e){e.stopPropagation(),this._cardGUIMode=e.detail.guiMode,this._cardGUIModeAvailable=e.detail.guiModeAvailable}render(){return this.hass&&this._config?M` `}}t([tt()],xt.prototype,"open",void 0),t([tt()],xt.prototype,"content",void 0),t([tt()],xt.prototype,"title",void 0),t([tt({reflect:!0})],xt.prototype,"actions",void 0),t([tt({reflect:!0})],xt.prototype,"card",void 0),t([tt()],xt.prototype,"right_button",void 0),t([tt()],xt.prototype,"left_button",void 0),t([tt()],xt.prototype,"dismissable",void 0),t([tt({reflect:!0})],xt.prototype,"wide",void 0),t([tt({reflect:!0})],xt.prototype,"fullscreen",void 0),t([tt()],xt.prototype,"_style",void 0),t([it("ha-dialog")],xt.prototype,"dialog",void 0),customElements.get("browser-mod-popup")||customElements.define("browser-mod-popup",xt);const St=t=>class extends t{constructor(){super(),ht(),this._popupEl=document.createElement("browser-mod-popup"),document.body.append(this._popupEl)}showPopup(...t){this._popupEl.setupDialog(...t).then((()=>this._popupEl.openDialog()))}closePopup(...t){this._popupEl.closeDialog(),this.showMoreInfo("")}async showMoreInfo(t,e=!1,i){const s=await lt();if(s.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:t,ignore_popup_card:i}})),e){await new Promise((t=>setTimeout(t,50)));const t=s.shadowRoot.querySelector("ha-more-info-dialog");t&&(t.large=!0)}}};var Ct="2.0.0b3";const Tt=[{name:"entity",label:"Entity",selector:{entity:{}}},{name:"title",label:"Title",selector:{text:{}}},{name:"size",selector:{select:{mode:"dropdown",options:["normal","wide","fullscreen"]}}},{type:"grid",schema:[{name:"right_button",label:"Right button",selector:{text:{}}},{name:"left_button",label:"Left button",selector:{text:{}}}]},{type:"grid",schema:[{name:"right_button_action",label:"Right button action",selector:{object:{}}},{name:"left_button_action",label:"Left button action",selector:{object:{}}}]},{type:"grid",schema:[{name:"dismissable",label:"User dismissable",selector:{boolean:{}}},{name:"timeout",label:"Auto close timeout (ms)",selector:{number:{mode:"box"}}}]},{type:"grid",schema:[{name:"dismiss_action",label:"Dismiss action",selector:{object:{}}},{name:"timeout_action",label:"Timeout action",selector:{object:{}}}]},{name:"style",label:"CSS style",selector:{text:{multiline:!0}}}];class Pt extends Q{constructor(){super(...arguments),this._selectedTab=0,this._cardGUIMode=!0,this._cardGUIModeAvailable=!0}setConfig(t){this._config=t}connectedCallback(){super.connectedCallback(),ut()}_handleSwitchTab(t){this._selectedTab=parseInt(t.detail.index,10)}_configChanged(t){t.stopPropagation(),this._config&&(this._config=Object.assign({},t.detail.value),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}})))}_cardConfigChanged(t){if(t.stopPropagation(),!this._config)return;const e=Object.assign({},t.detail.config);this._config=Object.assign(Object.assign({},this._config),{card:e}),this._cardGUIModeAvailable=t.detail.guiModeAvailable,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_toggleCardMode(t){var e;null===(e=this._cardEditorEl)||void 0===e||e.toggleMode()}_deleteCard(t){this._config&&(this._config=Object.assign({},this._config),delete this._config.card,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}})))}_cardGUIModeChanged(t){t.stopPropagation(),this._cardGUIMode=t.detail.guiMode,this._cardGUIModeAvailable=t.detail.guiModeAvailable}render(){return this.hass&&this._config?O`
<div class="card-config"> <div class="card-config">
<div class="toolbar"> <div class="toolbar">
<mwc-tab-bar <mwc-tab-bar
@@ -213,17 +224,17 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
${[this._renderSettingsEditor,this._renderCardEditor][this._selectedTab].bind(this)()} ${[this._renderSettingsEditor,this._renderCardEditor][this._selectedTab].bind(this)()}
</div> </div>
</div> </div>
`:M``}_renderSettingsEditor(){return M`<div class="box"> `:O``}_renderSettingsEditor(){return O`<div class="box">
<ha-form <ha-form
.hass=${this.hass} .hass=${this.hass}
.data=${this._config} .data=${this._config}
.schema=${Ce} .schema=${Tt}
.computeLabel=${e=>{var t;return null!==(t=e.label)&&void 0!==t?t:e.name}} .computeLabel=${t=>{var e;return null!==(e=t.label)&&void 0!==e?e:t.name}}
@value-changed=${this._configChanged} @value-changed=${this._configChanged}
></ha-form> ></ha-form>
</div>`}_renderCardEditor(){return M` </div>`}_renderCardEditor(){return O`
<div class="box cards"> <div class="box cards">
${this._config.card?M` ${this._config.card?O`
<div class="toolbar"> <div class="toolbar">
<mwc-button <mwc-button
@click=${this._toggleCardMode} @click=${this._toggleCardMode}
@@ -246,7 +257,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
@config-changed=${this._cardConfigChanged} @config-changed=${this._cardConfigChanged}
@GUImode-changed=${this._cardGUIModeChanged} @GUImode-changed=${this._cardGUIModeChanged}
></hui-card-element-editor> ></hui-card-element-editor>
`:M` `:O`
<hui-card-picker <hui-card-picker
.hass=${this.hass} .hass=${this.hass}
.lovelace=${this.lovelace} .lovelace=${this.lovelace}
@@ -272,9 +283,9 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
.gui-mode-button { .gui-mode-button {
margin-right: auto; margin-right: auto;
} }
`}}e([te()],Te.prototype,"_config",void 0),e([ee()],Te.prototype,"lovelace",void 0),e([ee()],Te.prototype,"hass",void 0),e([te()],Te.prototype,"_selectedTab",void 0),e([te()],Te.prototype,"_cardGUIMode",void 0),e([te()],Te.prototype,"_cardGUIModeAvailable",void 0),e([ie("hui-card-element-editor")],Te.prototype,"_cardEditorEl",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((e=>setTimeout(e,1e3)));await window.browser_mod.connectionPromise,customElements.get("popup-card-editor")||(customElements.define("popup-card-editor",Te),window.customCards=window.customCards||[],window.customCards.push({type:"popup-card",name:"Popup card",preview:!1,description:"Replace the more-info dialog for a given entity in the view that includes this card. (Browser Mod)"}))})();class Pe extends Q{constructor(){super(),this.popup=this.popup.bind(this)}static getConfigElement(){return document.createElement("popup-card-editor")}static getStubConfig(e,t){return{entity:t[0],title:"Custom popup",dismissable:!0,card:{type:"markdown",content:"This replaces the more-info dialog"}}}setConfig(e){this._config=e,(async()=>{const t=await window.loadCardHelpers();this._element=await t.createCardElement(e.card),this._element.hass=this.hass})()}async connectedCallback(){super.connectedCallback(),window.addEventListener("hass-more-info",this.popup),"hui-card-preview"===this.parentElement.localName?(this.editMode=!0,this.removeAttribute("hidden")):this.setAttribute("hidden","")}async disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("hass-more-info",this.popup)}popup(e){var t,i,s;if((null===(t=e.detail)||void 0===t?void 0:t.entityId)===this._config.entity&&!(null===(i=e.detail)||void 0===i?void 0:i.ignore_popup_card)){e.stopPropagation(),e.preventDefault();delete Object.assign({},this._config).card,null===(s=window.browser_mod)||void 0===s||s.service("popup",Object.assign({content:this._config.card},this._config)),setTimeout((()=>this.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:"."}}))),50)}}updated(e){super.updated(e),e.has("hass")&&this._element&&(this._element.hass=this.hass)}render(){return this.editMode?M` <ha-card> `}}t([et()],Pt.prototype,"_config",void 0),t([tt()],Pt.prototype,"lovelace",void 0),t([tt()],Pt.prototype,"hass",void 0),t([et()],Pt.prototype,"_selectedTab",void 0),t([et()],Pt.prototype,"_cardGUIMode",void 0),t([et()],Pt.prototype,"_cardGUIModeAvailable",void 0),t([it("hui-card-element-editor")],Pt.prototype,"_cardEditorEl",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((t=>setTimeout(t,1e3)));await window.browser_mod.connectionPromise,customElements.get("popup-card-editor")||(customElements.define("popup-card-editor",Pt),window.customCards=window.customCards||[],window.customCards.push({type:"popup-card",name:"Popup card",preview:!1,description:"Replace the more-info dialog for a given entity in the view that includes this card. (Browser Mod)"}))})();class kt extends Q{constructor(){super(),this.popup=this.popup.bind(this)}static getConfigElement(){return document.createElement("popup-card-editor")}static getStubConfig(t,e){return{entity:e[0],title:"Custom popup",dismissable:!0,card:{type:"markdown",content:"This replaces the more-info dialog"}}}setConfig(t){this._config=t,(async()=>{const e=await window.loadCardHelpers();this._element=await e.createCardElement(t.card),this._element.hass=this.hass})()}async connectedCallback(){super.connectedCallback(),window.addEventListener("hass-more-info",this.popup),"hui-card-preview"===this.parentElement.localName?(this.editMode=!0,this.removeAttribute("hidden")):this.setAttribute("hidden","")}async disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("hass-more-info",this.popup)}popup(t){var e,i,s;if((null===(e=t.detail)||void 0===e?void 0:e.entityId)===this._config.entity&&!(null===(i=t.detail)||void 0===i?void 0:i.ignore_popup_card)){t.stopPropagation(),t.preventDefault();delete Object.assign({},this._config).card,null===(s=window.browser_mod)||void 0===s||s.service("popup",Object.assign({content:this._config.card},this._config)),setTimeout((()=>this.dispatchEvent(new CustomEvent("hass-more-info",{bubbles:!0,composed:!0,cancelable:!1,detail:{entityId:"."}}))),50)}}updated(t){super.updated(t),t.has("hass")&&this._element&&(this._element.hass=this.hass)}render(){return this.editMode?O` <ha-card>
<div class="app-toolbar"> <div class="app-toolbar">
${this._config.dismissable?M` ${this._config.dismissable?O`
<ha-icon-button> <ha-icon-button>
<ha-icon .icon=${"mdi:close"}></ha-icon> <ha-icon .icon=${"mdi:close"}></ha-icon>
</ha-icon-button> </ha-icon-button>
@@ -287,17 +298,17 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
${this._config.style} ${this._config.style}
} }
</style> </style>
${void 0!==this._config.right_button||void 0!==this._config.left_button?M` ${void 0!==this._config.right_button||void 0!==this._config.left_button?O`
<footer class="mdc-dialog__actions"> <footer class="mdc-dialog__actions">
<span> <span>
${void 0!==this._config.left_button?M` ${void 0!==this._config.left_button?O`
<mwc-button <mwc-button
.label=${this._config.left_button} .label=${this._config.left_button}
></mwc-button> ></mwc-button>
`:""} `:""}
</span> </span>
<span> <span>
${void 0!==this._config.right_button?M` ${void 0!==this._config.right_button?O`
<mwc-button <mwc-button
.label=${this._config.right_button} .label=${this._config.right_button}
></mwc-button> ></mwc-button>
@@ -305,7 +316,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
</span> </span>
</footer> </footer>
`:""} `:""}
</ha-card>`:M``}static get styles(){return n` </ha-card>`:O``}static get styles(){return n`
:host { :host {
display: none !important; display: none !important;
} }
@@ -352,4 +363,4 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
padding: 8px; padding: 8px;
border-top: 1px solid transparent; border-top: 1px solid transparent;
} }
`}}e([ee()],Pe.prototype,"hass",void 0),e([te()],Pe.prototype,"_config",void 0),e([ee({attribute:"edit-mode",reflect:!0})],Pe.prototype,"editMode",void 0),e([te()],Pe.prototype,"_element",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((e=>setTimeout(e,1e3)));await window.browser_mod.connectionPromise,customElements.get("popup-card")||customElements.define("popup-card",Pe)})();const ke=e=>class extends e{constructor(){super(),this.__currentTitle=void 0,this._auto_settings_setup(),this.addEventListener("browser-mod-config-update",(()=>this._auto_settings_setup())),window.addEventListener("location-changed",(()=>{this._updateTitle(),setTimeout((()=>this._updateTitle()),500),setTimeout((()=>this._updateTitle()),1e3),setTimeout((()=>this._updateTitle()),5e3)}))}async _auto_settings_setup(){await this.connectionPromise;const e=this.settings;e.sidebarPanelOrder&&localStorage.setItem("sidebarPanelOrder",e.sidebarPanelOrder),e.sidebarHiddenPanels&&localStorage.setItem("sidebarHiddenPanels",e.sidebarHiddenPanels),e.defaultPanel&&localStorage.setItem("defaultPanel",e.defaultPanel),!0===e.hideSidebar&&(de(document.body,"home-assistant$home-assistant-main$app-drawer-layout").then((e=>{var t;return null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.setProperty("--app-drawer-width","0px")})),de(document.body,"home-assistant$home-assistant-main$app-drawer-layout app-drawer").then((e=>{var t;return null===(t=null==e?void 0:e.remove)||void 0===t?void 0:t.call(e)}))),!0===e.hideHeader&&customElements.whenDefined("app-header-layout").then((()=>{const e=customElements.get("app-header").prototype,t=e.attached;e.attached=function(){t.bind(this)(),this.style.setProperty("display","none")}})),void 0!==e.faviconTemplate&&(async()=>{this._faviconTemplateSubscription&&this._faviconTemplateSubscription(),this._faviconTemplateSubscription=void 0,this._faviconTemplateSubscription=await this.connection.subscribeMessage(this._updateFavicon,{type:"render_template",template:e.faviconTemplate,variables:{}})})(),void 0!==e.titleTemplate&&(async()=>{this._titleTemplateSubscription&&this._titleTemplateSubscription(),this._titleTemplateSubscription=void 0,this._titleTemplateSubscription=await this.connection.subscribeMessage(this._updateTitle.bind(this),{type:"render_template",template:e.titleTemplate,variables:{}})})()}get _currentFavicon(){const e=document.head.querySelector("link[rel~='icon']");return null==e?void 0:e.href}_updateFavicon({result:e}){document.head.querySelector("link[rel~='icon']").href=e,window.browser_mod.fireEvent("browser-mod-favicon-update")}get _currentTitle(){return this.__currentTitle}_updateTitle(e){e&&(this.__currentTitle=e.result),this.__currentTitle&&(document.title=this.__currentTitle),window.browser_mod.fireEvent("browser-mod-favicon-update")}},Ie="browser_mod-browser-id",Me=e=>class extends e{constructor(){if(super(),Storage&&!Storage.prototype.browser_mod_patched){const e=Storage.prototype.clear;Storage.prototype.clear=function(){const t=this.getItem(Ie),i=this.getItem("suspendWhenHidden");e.apply(this),this.setItem(Ie,t),this.setItem("suspendWhenHidden",i)},Storage.prototype.browser_mod_patched=!0}}async recall_id(){if(!this.connection)return;const e=await this.connection.sendMessagePromise({type:"browser_mod/recall_id"});e&&(localStorage[Ie]=e)}get browserID(){return document.querySelector("hc-main")?"CAST":localStorage[Ie]?localStorage[Ie]:(this.browserID="",this.recall_id(),this.browserID)}set browserID(e){""===e&&(e=function(){var e,t;const i=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);return null!==(t=null===(e=window.fully)||void 0===e?void 0:e.getDeviceId())&&void 0!==t?t:`${i()}${i()}-${i()}${i()}`}());const t=localStorage[Ie];localStorage[Ie]=e,this.browserIDChanged(t,e)}browserIDChanged(e,t){}};class Oe extends(be(xe(ye(we(me(ve(pe(ke(ge(_e(ue(Me(EventTarget))))))))))))){constructor(){super(),this.connect(),console.info(`%cBROWSER_MOD ${Se} IS INSTALLED\n %cBrowserID: ${this.browserID}`,"color: green; font-weight: bold","")}}window.browser_mod||(window.browser_mod=new Oe);export{Oe as BrowserMod}; `}}t([tt()],kt.prototype,"hass",void 0),t([et()],kt.prototype,"_config",void 0),t([tt({attribute:"edit-mode",reflect:!0})],kt.prototype,"editMode",void 0),t([et()],kt.prototype,"_element",void 0),(async()=>{for(;!window.browser_mod;)await new Promise((t=>setTimeout(t,1e3)));await window.browser_mod.connectionPromise,customElements.get("popup-card")||customElements.define("popup-card",kt)})();const It=t=>class extends t{constructor(){super(),this.__currentTitle=void 0,this._auto_settings_setup(),this.addEventListener("browser-mod-config-update",(()=>this._auto_settings_setup())),window.addEventListener("location-changed",(()=>{this._updateTitle(),setTimeout((()=>this._updateTitle()),500),setTimeout((()=>this._updateTitle()),1e3),setTimeout((()=>this._updateTitle()),5e3)}))}async _auto_settings_setup(){await this.connectionPromise;const t=this.settings;t.sidebarPanelOrder&&localStorage.setItem("sidebarPanelOrder",t.sidebarPanelOrder),t.sidebarHiddenPanels&&localStorage.setItem("sidebarHiddenPanels",t.sidebarHiddenPanels),t.defaultPanel&&localStorage.setItem("defaultPanel",t.defaultPanel),!0===t.hideSidebar&&(dt(document.body,"home-assistant$home-assistant-main$app-drawer-layout").then((t=>{var e;return null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.setProperty("--app-drawer-width","0px")})),dt(document.body,"home-assistant$home-assistant-main$app-drawer-layout app-drawer").then((t=>{var e;return null===(e=null==t?void 0:t.remove)||void 0===e?void 0:e.call(t)}))),!0===t.hideHeader&&customElements.whenDefined("app-header-layout").then((()=>{const t=customElements.get("app-header").prototype,e=t.attached;t.attached=function(){e.bind(this)(),this.style.setProperty("display","none")}})),void 0!==t.faviconTemplate&&(async()=>{this._faviconTemplateSubscription&&this._faviconTemplateSubscription(),this._faviconTemplateSubscription=void 0,this._faviconTemplateSubscription=await this.connection.subscribeMessage(this._updateFavicon,{type:"render_template",template:t.faviconTemplate,variables:{}})})(),void 0!==t.titleTemplate&&(async()=>{this._titleTemplateSubscription&&this._titleTemplateSubscription(),this._titleTemplateSubscription=void 0,this._titleTemplateSubscription=await this.connection.subscribeMessage(this._updateTitle.bind(this),{type:"render_template",template:t.titleTemplate,variables:{}})})()}get _currentFavicon(){const t=document.head.querySelector("link[rel~='icon']");return null==t?void 0:t.href}_updateFavicon({result:t}){document.head.querySelector("link[rel~='icon']").href=t,window.browser_mod.fireEvent("browser-mod-favicon-update")}get _currentTitle(){return this.__currentTitle}_updateTitle(t){t&&(this.__currentTitle=t.result),this.__currentTitle&&(document.title=this.__currentTitle),window.browser_mod.fireEvent("browser-mod-favicon-update")}},Ot="browser_mod-browser-id",Mt=t=>class extends t{constructor(){if(super(),Storage&&!Storage.prototype.browser_mod_patched){const t=Storage.prototype.clear;Storage.prototype.clear=function(){const e=this.getItem(Ot),i=this.getItem("suspendWhenHidden");t.apply(this),this.setItem(Ot,e),this.setItem("suspendWhenHidden",i)},Storage.prototype.browser_mod_patched=!0}}async recall_id(){if(!this.connection)return;const t=await this.connection.sendMessagePromise({type:"browser_mod/recall_id"});t&&(localStorage[Ot]=t)}get browserID(){return document.querySelector("hc-main")?"CAST":localStorage[Ot]?localStorage[Ot]:(this.browserID="",this.recall_id(),this.browserID)}set browserID(t){""===t&&(t=function(){var t,e;const i=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);return null!==(e=null===(t=window.fully)||void 0===t?void 0:t.getDeviceId())&&void 0!==e?e:`${i()}${i()}-${i()}${i()}`}());const e=localStorage[Ot];localStorage[Ot]=t,this.browserIDChanged(e,t)}browserIDChanged(t,e){}};class Lt extends(yt(St(ft(bt(_t(mt(vt(It(wt(gt(pt(Mt(EventTarget))))))))))))){constructor(){super(),this.connect(),console.info(`%cBROWSER_MOD ${Ct} IS INSTALLED\n %cBrowserID: ${this.browserID}`,"color: green; font-weight: bold","")}}window.browser_mod||(window.browser_mod=new Lt);export{Lt as BrowserMod};
@@ -1,4 +1,4 @@
function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(n=(r<3?o(n):r>3?o(t,s,n):o(t,s))||n);return r>3&&n&&Object.defineProperty(t,s,n),n}const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),i=new WeakMap;class o{constructor(e,t,i){if(this._$cssResult$=!0,i!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const s=this.t;if(t&&void 0===e){const t=void 0!==s&&1===s.length;t&&(e=i.get(s)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&i.set(s,e))}return e}toString(){return this.cssText}}const r=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,s,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[i+1]),e[0]);return new o(i,e,s)},n=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return(e=>new o("string"==typeof e?e:e+"",void 0,s))(t)})(e):e;var a;const l=window.trustedTypes,d=l?l.emptyScript:"",h=window.reactiveElementPolyfillSupport,c={toAttribute(e,t){switch(t){case Boolean:e=e?d:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let s=e;switch(t){case Boolean:s=null!==e;break;case Number:s=null===e?null:Number(e);break;case Object:case Array:try{s=JSON.parse(e)}catch(e){s=null}}return s}},u=(e,t)=>t!==e&&(t==t||e==e),p={attribute:!0,type:String,converter:c,reflect:!1,hasChanged:u};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;null!==(t=this.h)&&void 0!==t||(this.h=[]),this.h.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,s)=>{const i=this._$Ep(s,t);void 0!==i&&(this._$Ev.set(i,s),e.push(i))})),e}static createProperty(e,t=p){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const s="symbol"==typeof e?Symbol():"__"+e,i=this.getPropertyDescriptor(e,s,t);void 0!==i&&Object.defineProperty(this.prototype,e,i)}}static getPropertyDescriptor(e,t,s){return{get(){return this[t]},set(i){const o=this[e];this[t]=i,this.requestUpdate(e,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of t)this.createProperty(s,e[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const e of s)t.unshift(n(e))}else void 0!==e&&t.push(n(e));return t}static _$Ep(e,t){const s=t.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,s;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(s=e.hostConnected)||void 0===s||s.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const s=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,s)=>{t?e.adoptedStyleSheets=s.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):s.forEach((t=>{const s=document.createElement("style"),i=window.litNonce;void 0!==i&&s.setAttribute("nonce",i),s.textContent=t.cssText,e.appendChild(s)}))})(s,this.constructor.elementStyles),s}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,s){thisLine truncated function e(e,t,i,s){var o,r=arguments.length,n=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(n=(r<3?o(n):r>3?o(t,i,n):o(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n}const t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new WeakMap;class o{constructor(e,t,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const i=this.t;if(t&&void 0===e){const t=void 0!==i&&1===i.length;t&&(e=s.get(i)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&s.set(i,e))}return e}toString(){return this.cssText}}const r=(e,...t)=>{const s=1===e.length?e[0]:t.reduce(((t,i,s)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[s+1]),e[0]);return new o(s,e,i)},n=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new o("string"==typeof e?e:e+"",void 0,i))(t)})(e):e;var a;const l=window.trustedTypes,d=l?l.emptyScript:"",h=window.reactiveElementPolyfillSupport,c={toAttribute(e,t){switch(t){case Boolean:e=e?d:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},u=(e,t)=>t!==e&&(t==t||e==e),p={attribute:!0,type:String,converter:c,reflect:!1,hasChanged:u};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;null!==(t=this.h)&&void 0!==t||(this.h=[]),this.h.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,i)=>{const s=this._$Ep(i,t);void 0!==s&&(this._$Ev.set(s,i),e.push(s))})),e}static createProperty(e,t=p){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const i="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,i,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(s){const o=this[e];this[t]=s,this.requestUpdate(e,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of t)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(n(e))}else void 0!==e&&t.push(n(e));return t}static _$Ep(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,i;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(i=e.hostConnected)||void 0===i||i.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const i=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,i)=>{t?e.adoptedStyleSheets=i.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):i.forEach((t=>{const i=document.createElement("style"),s=window.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=t.cssText,e.appendChild(i)}))})(i,this.constructor.elementStyles),i}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,i){thisLine truncated
<ha-card outlined> <ha-card outlined>
<h1 class="card-header"> <h1 class="card-header">
<div class="name">This Browser</div> <div class="name">This Browser</div>
@@ -42,12 +42,12 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro
>A unique identifier for this browser-device combination.</span >A unique identifier for this browser-device combination.</span
> >
<ha-textfield <ha-textfield
.value=${null===(s=window.browser_mod)||void 0===s?void 0:s.browserID} .value=${null===(i=window.browser_mod)||void 0===i?void 0:i.browserID}
@change=${this.changeBrowserID} @change=${this.changeBrowserID}
></ha-textfield> ></ha-textfield>
</ha-settings-row> </ha-settings-row>
${(null===(i=window.browser_mod)||void 0===i?void 0:i.registered)?H` ${(null===(s=window.browser_mod)||void 0===s?void 0:s.registered)?H`
${this._renderSuspensionAlert()} ${this._renderSuspensionAlert()}
<ha-settings-row> <ha-settings-row>
<span slot="heading">Enable camera</span> <span slot="heading">Enable camera</span>
@@ -115,9 +115,9 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro
</ul>`),"true"!==window.fully.getBooleanSetting("preventSleepWhileScreenOff")&&e.push(H`<li>Power Settings</li> </ul>`),"true"!==window.fully.getBooleanSetting("preventSleepWhileScreenOff")&&e.push(H`<li>Power Settings</li>
<ul> <ul>
<li>Prevent from Sleep while Screen Off</li> <li>Prevent from Sleep while Screen Off</li>
</ul>`);const s=[];return"true"!==window.fully.getBooleanSetting("motionDetection")&&s.push(H`<li>Enable Visual Motion Detection</li>`),"true"!==window.fully.getBooleanSetting("screenOnOnMotion")&&s.push(H`<li>Turn Screen On on Motion</li>`),"true"!==window.fully.getBooleanSetting("stopScreensaverOnMotion")&&s.push(H`<li>Exit Screensaver on Motion</li>`),0!==s.length&&e.push(H`<li>Motion Detection (PLUS)</li> </ul>`);const i=[];return"true"!==window.fully.getBooleanSetting("motionDetection")&&i.push(H`<li>Enable Visual Motion Detection</li>`),"true"!==window.fully.getBooleanSetting("screenOnOnMotion")&&i.push(H`<li>Turn Screen On on Motion</li>`),"true"!==window.fully.getBooleanSetting("stopScreensaverOnMotion")&&i.push(H`<li>Exit Screensaver on Motion</li>`),0!==i.length&&e.push(H`<li>Motion Detection (PLUS)</li>
<ul> <ul>
${s} ${i}
</ul>`),"true"!==window.fully.getBooleanSetting("remoteAdmin")&&e.push(H`<li>Remote Administration (PLUS)</li> </ul>`),"true"!==window.fully.getBooleanSetting("remoteAdmin")&&e.push(H`<li>Remote Administration (PLUS)</li>
<ul> <ul>
<li>Enable Remote Administration</li> <li>Enable Remote Administration</li>
@@ -131,7 +131,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro
display: block; display: block;
margin-top: 8px; margin-top: 8px;
} }
`}}e([ee()],se.prototype,"hass",void 0),e([ee()],se.prototype,"dirty",void 0),customElements.define("browser-mod-browser-settings-card",se);class ie extends Z{firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}unregister_browser(e){const t=e.currentTarget.browserID;window.browser_mod.showPopup("Unregister browser",`Are you sure you want to unregister Browser ${t}?`,{right_button:"Yes",right_button_action:()=>{console.log(t,window.browser_mod.browserID),t===window.browser_mod.browserID?(console.log("Unregister self"),window.browser_mod.registered=!1):window.browser_mod.connection.sendMessage({type:"browser_mod/unregister",browserID:t})},left_button:"No"})}register_cast(){window.browser_mod.connection.sendMessage({type:"browser_mod/register",browserID:"CAST"})}render(){return H` `}}e([ee()],ie.prototype,"hass",void 0),e([ee()],ie.prototype,"dirty",void 0),customElements.define("browser-mod-browser-settings-card",ie);class se extends Z{firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}unregister_browser(e){const t=e.currentTarget.browserID;window.browser_mod.showPopup("Unregister browser",`Are you sure you want to unregister Browser ${t}?`,{right_button:"Yes",right_button_action:()=>{t===window.browser_mod.browserID?window.browser_mod.registered=!1:window.browser_mod.connection.sendMessage({type:"browser_mod/unregister",browserID:t})},left_button:"No"})}register_cast(){window.browser_mod.connection.sendMessage({type:"browser_mod/register",browserID:"CAST"})}render(){return H`
<ha-card header="Registered Browsers" outlined> <ha-card header="Registered Browsers" outlined>
<div class="card-content"> <div class="card-content">
${Object.keys(window.browser_mod.browsers).map((e=>H` <ha-settings-row> ${Object.keys(window.browser_mod.browsers).map((e=>H` <ha-settings-row>
@@ -160,7 +160,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro
ha-icon-button > * { ha-icon-button > * {
display: flex; display: flex;
} }
`}}e([ee()],ie.prototype,"hass",void 0),customElements.define("browser-mod-registered-browsers-card",ie),(async()=>{var e,t,s,i,o,r,n;await customElements.whenDefined("partial-panel-resolver"),await customElements.whenDefined("partial-panel-resolver");const a=document.createElement("partial-panel-resolver").getRoutes([{component_name:"developer-tools",url_path:"a"}]);await(null===(s=null===(t=null===(e=null==a?void 0:a.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===s?void 0:s.call(t));const l=document.createElement("developer-tools-router");await(null===(n=null===(r=null===(o=null===(i=null==l?void 0:l.routerOptions)||void 0===i?void 0:i.routes)||void 0===o?void 0:o.template)||void 0===r?void 0:r.load)||void 0===n?void 0:n.call(r)),await customElements.whenDefined("developer-tools-template")})();class oe extends Z{constructor(){super(...arguments),this._selectedTab=0}firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate())),window.browser_mod.addEventListener("browser-mod-favicon-update",(()=>this.requestUpdate()))}_handleSwitchTab(e){this._selectedTab=parseInt(e.detail.index,10)}render(){const e=["user","browser","global"][this._selectedTab];return H` `}}e([ee()],se.prototype,"hass",void 0),customElements.define("browser-mod-registered-browsers-card",se),(async()=>{var e,t,i,s,o,r,n;await customElements.whenDefined("partial-panel-resolver"),await customElements.whenDefined("partial-panel-resolver");const a=document.createElement("partial-panel-resolver").getRoutes([{component_name:"developer-tools",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==a?void 0:a.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t));const l=document.createElement("developer-tools-router");await(null===(n=null===(r=null===(o=null===(s=null==l?void 0:l.routerOptions)||void 0===s?void 0:s.routes)||void 0===o?void 0:o.template)||void 0===r?void 0:r.load)||void 0===n?void 0:n.call(r)),await customElements.whenDefined("developer-tools-template")})();class oe extends Z{constructor(){super(...arguments),this._selectedTab=0}firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate())),window.browser_mod.addEventListener("browser-mod-favicon-update",(()=>this.requestUpdate()))}_handleSwitchTab(e){this._selectedTab=parseInt(e.detail.index,10)}render(){const e=["user","browser","global"][this._selectedTab];return H`
<ha-card header="Frontend Settings" outlined> <ha-card header="Frontend Settings" outlined>
<div class="card-content"> <div class="card-content">
<ha-alert alert-type="warning"> <ha-alert alert-type="warning">
@@ -195,7 +195,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro
${this._render_settings(e)} ${this._render_settings(e)}
</div> </div>
</ha-card> </ha-card>
`}_render_settings(e){const t=window.browser_mod.global_settings,s=window.browser_mod.browser_settings,i=window.browser_mod.user_settings,o={global:t,browser:s,user:i}[e],r=e=>({true:"Enabled",false:"Disabled",undefined:"Unset"}[String(e)]),n=e=>void 0===e?"Unset":"Set",a=t=>"browser"!==e&&void 0!==s[t]?H`<br />Overridden by browser setting`:"global"===e&&void 0!==i[t]?H`<br />Overridden by user setting`:void 0;return H` `}_render_settings(e){const t=window.browser_mod.global_settings,i=window.browser_mod.browser_settings,s=window.browser_mod.user_settings,o={global:t,browser:i,user:s}[e],r=e=>({true:"Enabled",false:"Disabled",undefined:"Unset"}[String(e)]),n=e=>void 0===e?"Unset":"Set",a=t=>"browser"!==e&&void 0!==i[t]?H`<br />Overridden by browser setting`:"global"===e&&void 0!==s[t]?H`<br />Overridden by user setting`:void 0;return H`
<div class="box"> <div class="box">
<ha-settings-row> <ha-settings-row>
<span slot="heading">Favicon template</span> <span slot="heading">Favicon template</span>
@@ -205,7 +205,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro
<ha-code-editor <ha-code-editor
.hass=${this.hass} .hass=${this.hass}
.value=${o.faviconTemplate} .value=${o.faviconTemplate}
@value-changed=${t=>{const s=t.detail.value||void 0;window.browser_mod.set_setting("faviconTemplate",s,e)}} @value-changed=${t=>{const i=t.detail.value||void 0;window.browser_mod.set_setting("faviconTemplate",i,e)}}
></ha-code-editor> ></ha-code-editor>
<ha-settings-row> <ha-settings-row>
<mwc-button <mwc-button
@@ -224,7 +224,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro
<ha-code-editor <ha-code-editor
.hass=${this.hass} .hass=${this.hass}
.value=${o.titleTemplate} .value=${o.titleTemplate}
@value-changed=${t=>{const s=t.detail.value||void 0;window.browser_mod.set_setting("titleTemplate",s,e)}} @value-changed=${t=>{const i=t.detail.value||void 0;window.browser_mod.set_setting("titleTemplate",i,e)}}
></ha-code-editor> ></ha-code-editor>
<ha-settings-row> <ha-settings-row>
<mwc-button <mwc-button
@@ -356,7 +356,7 @@ function e(e,t,s,i){var o,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPro
display: flex; display: flex;
align-items: center; align-items: center;
} }
`}}e([ee()],oe.prototype,"hass",void 0),e([function(e){return ee({...e,state:!0})}()],oe.prototype,"_selectedTab",void 0),customElements.define("browser-mod-frontend-settings-card",oe),(async()=>{var e,t,s,i,o,r,n,a,l,d,h;await customElements.whenDefined("partial-panel-resolver");const c=document.createElement("partial-panel-resolver").getRoutes([{component_name:"config",url_path:"a"}]);await(null===(s=null===(t=null===(e=null==c?void 0:c.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===s?void 0:s.call(t)),await customElements.whenDefined("ha-panel-config");const u=document.createElement("ha-panel-config");await(null===(n=null===(r=null===(o=null===(i=null==u?void 0:u.routerOptions)||void 0===i?void 0:i.routes)||void 0===o?void 0:o.dashboard)||void 0===r?void 0:r.load)||void 0===n?void 0:n.call(r)),await(null===(h=null===(d=null===(l=null===(a=null==u?void 0:u.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.cloud)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends Z{firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){return H` `}}e([ee()],oe.prototype,"hass",void 0),e([function(e){return ee({...e,state:!0})}()],oe.prototype,"_selectedTab",void 0),customElements.define("browser-mod-frontend-settings-card",oe),(async()=>{var e,t,i,s,o,r,n,a,l,d,h;await customElements.whenDefined("partial-panel-resolver");const c=document.createElement("partial-panel-resolver").getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==c?void 0:c.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t)),await customElements.whenDefined("ha-panel-config");const u=document.createElement("ha-panel-config");await(null===(n=null===(r=null===(o=null===(s=null==u?void 0:u.routerOptions)||void 0===s?void 0:s.routes)||void 0===o?void 0:o.dashboard)||void 0===r?void 0:r.load)||void 0===n?void 0:n.call(r)),await(null===(h=null===(d=null===(l=null===(a=null==u?void 0:u.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.cloud)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends Z{firstUpdated(){window.browser_mod.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){return H`
<ha-app-layout> <ha-app-layout>
<app-header slot="header" fixed> <app-header slot="header" fixed>
<app-toolbar> <app-toolbar>
+1 -1
View File
@@ -5,7 +5,7 @@
"dependencies": ["panel_custom", "websocket_api", "http", "frontend", "lovelace"], "dependencies": ["panel_custom", "websocket_api", "http", "frontend", "lovelace"],
"codeowners": [], "codeowners": [],
"requirements": [], "requirements": [],
"version": "2.0.0b2", "version": "2.0.0b3",
"iot_class": "local_push", "iot_class": "local_push",
"config_flow": true "config_flow": true
} }
+103 -7
View File
@@ -10,16 +10,38 @@ data:
left_button: Left button left_button: Left button
``` ```
![Popup](https://user-images.githubusercontent.com/1299821/180668969-c647f301-3f3d-4f3b-a1f8-d95af8b48873.png) ![Dialog Anatomy](https://user-images.githubusercontent.com/1299821/182708739-f89e3b2b-199f-43e0-bf04-e1dfc7075b2a.png)
## Displaying a dashboard card in a popup ## Size
The `size` parameter can be set to `normal`, `wide` and `fullscreen` with results as below (background blur has been exagerated for clarity):
![Normal Size](https://user-images.githubusercontent.com/1299821/182709146-439814f1-d479-4fc7-aab1-e28f5c9a13c7.png)
![Wide Size](https://user-images.githubusercontent.com/1299821/182709172-c98a9c23-5e58-4564-bcb7-1d187842948f.png)
![Fullscreen Size](https://user-images.githubusercontent.com/1299821/182709224-fb2e7b92-8a23-4422-95a0-f0f2835909e0.png)
## HTML content
```yaml ```yaml
service: browser_mod.popup service: browser_mod.popup
data: data:
title: The title title: HTML content
right_button: Right button content: |
left_button: Left button An <b>HTML</b> string.
<p> Pretty much any HTML works: <ha-icon icon="mdi:lamp" style="color: red;"></ha-icon>
```
![HTML content](https://user-images.githubusercontent.com/1299821/182710044-6fea3ba3-5262-4361-a131-691770340518.png)
## Dashboard card content
```yaml
service: browser_mod.popup
data:
title: HTML content
content: content:
type: entities type: entities
entities: entities:
@@ -28,10 +50,53 @@ data:
- light.kitchen_lights - light.kitchen_lights
``` ```
![Popup with card](https://user-images.githubusercontent.com/1299821/180669077-bbc86831-3a8a-4e54-b098-d900d62d3508.png) ![Card content](https://user-images.githubusercontent.com/1299821/182710445-f09b74b8-dd53-4d65-8eba-0945fc1d418e.png)
## Form content
`content` can be a list of ha-form schemas and the popup will then contain a form for user input:
```
<ha-form schema>:
name: <string>
[label: <string>]
[default: <any>]
selector: <Home Assistant Selector>
```
| | |
|-|-|
| `name` | A unique parameter name |
| `label` | A description of the parameter |
| `default` | The default value for the parameter |
| `selector` | A [Home Assistant selector](https://www.home-assistant.io/docs/blueprint/selectors) |
The data from the form will be forwarded as data for any `right_button_action` or `left_button_action` of the popup.
```yaml
service: browser_mod.popup
data:
title: Form content
content:
- name: parameter_name
label: Descriptive name
selector:
text: null
- name: another_parameter
label: A number
default: 5
selector:
number:
min: 0
max: 10
slider: true
```
![Form content](https://user-images.githubusercontent.com/1299821/182712670-f3b4fdb7-84a9-49d1-a26f-2cdaa450fa0e.png)
## Actionable popups ## Actionable popups
Example of a popup with actions opening more popups or calling Home Assistant services:
```yaml ```yaml
service: browser_mod.popup service: browser_mod.popup
data: data:
@@ -62,4 +127,35 @@ data:
entity_id: light.bed_light entity_id: light.bed_light
``` ```
![Advanced popup](https://user-images.githubusercontent.com/1299821/180670190-18cf8eee-cf18-47b9-84d1-e62ef327c615.gif) ![Multi-level popup](https://user-images.githubusercontent.com/1299821/182713421-708d0026-bcfa-4ba6-bbcd-3b85b584162d.gif)
## Forward form data
The following popup would ask the user for a list of rooms to vacuum and then populate the `params` parameter of the `vacuum.send_command` service call from the result:
```yaml
service: browser_mod.popup
data:
title: Where to vacuum?
right_button: Go!
right_button_action:
service: vacuum.send_command
data:
entity_id: vacuum.xiaomi
command: app_segment_clean
content:
- name: params
label: Rooms to clean
selector:
select:
multiple: true
options:
- label: Kitchen
value: 11
- label: Living room
value: 13
- label: Bedroom
value: 12
```
![Vacuum popup](https://user-images.githubusercontent.com/1299821/182713714-ef4149b1-217a-4d41-9737-714f5320c25c.png)
+5 -3
View File
@@ -125,7 +125,7 @@ Display a popup dialog
service: browser_mod.popup service: browser_mod.popup
data: data:
[title: <string>] [title: <string>]
content: <string / Dashboard card configuration> content: <string / Dashboard card configuration / ha-form schema>
[size: <NORMAL/wide/fullscreen>] [size: <NORMAL/wide/fullscreen>]
[right_button: <string>] [right_button: <string>]
[right_button_action: <service call>] [right_button_action: <service call>]
@@ -143,7 +143,7 @@ data:
| | | | | |
|---|---| |---|---|
|`title` | The title of the popup window.| |`title` | The title of the popup window.|
|`content`| HTML or a dashboard card configuration to display.| |`content`| HTML, a dashboard card configuration or ha-form schema to display.|
| `size` | `wide` will make the popup window wider. `fullscreen` will make it cover the entire screen. | | `size` | `wide` will make the popup window wider. `fullscreen` will make it cover the entire screen. |
| `right_button`| The text of the right action button.| | `right_button`| The text of the right action button.|
| `right_button_action`| Action to perform when the right action button is pressed. | | `right_button_action`| Action to perform when the right action button is pressed. |
@@ -171,7 +171,9 @@ style:
Note that any Browser Mod services performed as `_action`s here will be performed only on the same Browser as initiated the action unless `browser_id` is given. Note that any Browser Mod services performed as `_action`s here will be performed only on the same Browser as initiated the action unless `browser_id` is given.
For usage examples, see [popups.md](popups.md). If a ha-form schema is used for `content` the resulting data will be inserted into the `data` for any `_action`.
See [popups.md](popups.md) for more information and usage examples.
## `browser_mod.close_popup` ## `browser_mod.close_popup`
@@ -14,9 +14,7 @@ class BrowserModRegisteredBrowsersCard extends LitElement {
const browserID = ev.currentTarget.browserID; const browserID = ev.currentTarget.browserID;
const unregisterCallback = () => { const unregisterCallback = () => {
console.log(browserID, window.browser_mod.browserID);
if (browserID === window.browser_mod.browserID) { if (browserID === window.browser_mod.browserID) {
console.log("Unregister self");
window.browser_mod.registered = false; window.browser_mod.registered = false;
} else { } else {
window.browser_mod.connection.sendMessage({ window.browser_mod.connection.sendMessage({
+14 -2
View File
@@ -81,9 +81,9 @@ export const loadHaForm = async () => {
await loadLoadCardHelpers(); await loadLoadCardHelpers();
const helpers = await window.loadCardHelpers(); const helpers = await window.loadCardHelpers();
if (!helpers) return; if (!helpers) return;
const card = await helpers.createCardElement({ type: "entity" }); const card = await helpers.createCardElement({ type: "button" });
if (!card) return; if (!card) return;
await card.getConfigElement(); await card.constructor.getConfigElement();
}; };
// Loads in ha-config-dashboard which is used to copy styling // Loads in ha-config-dashboard which is used to copy styling
@@ -120,3 +120,15 @@ export const loadDeveloperToolsTemplate = async () => {
await dtRouter?.routerOptions?.routes?.template?.load?.(); await dtRouter?.routerOptions?.routes?.template?.load?.();
await customElements.whenDefined("developer-tools-template"); await customElements.whenDefined("developer-tools-template");
}; };
export function throttle(timeout) {
return function (target, propertyKey, descriptor) {
const fn = descriptor.value;
let cooldown = undefined;
descriptor.value = function (...rest) {
if (cooldown) return;
cooldown = setTimeout(() => (cooldown = undefined), timeout);
return fn.bind(this)(...rest);
};
};
}
+15 -14
View File
@@ -1,6 +1,5 @@
import "./browser-player"; import "./browser-player";
// import { BrowserModConnection } from "./connection";
import { ConnectionMixin } from "./connection"; import { ConnectionMixin } from "./connection";
import { ScreenSaverMixin } from "./screensaver"; import { ScreenSaverMixin } from "./screensaver";
import { MediaPlayerMixin } from "./mediaPlayer"; import { MediaPlayerMixin } from "./mediaPlayer";
@@ -19,7 +18,8 @@ import { BrowserIDMixin } from "./browserID";
/* /*
TODO: TODO:
- Fix nomenclature - More pictures for documentation
x Fix nomenclature
x Command -> Service x Command -> Service
x Device -> Browser x Device -> Browser
- Popups - Popups
@@ -28,6 +28,8 @@ import { BrowserIDMixin } from "./browserID";
X Timeout X Timeout
X Fullscreen X Fullscreen
x Popup-card x Popup-card
x Auto-close
x Forms that are forwarded to service calls
x Motion/occupancy tracker x Motion/occupancy tracker
x Information about interaction requirement x Information about interaction requirement
x Information about fullykiosk x Information about fullykiosk
@@ -39,29 +41,28 @@ import { BrowserIDMixin } from "./browserID";
x ll-custom handling x ll-custom handling
- Commands - Commands
x popup x popup
x Auto-close
x close_popup x close_popup
x more-info x more-info
x navigate x navigate
- lovelace-reload? o lovelace-reload?
- Not needed o Not needed
x window-reload x window-reload
- screensaver ? o screensaver ?
- Refer to automations instead o Refer to automations instead
x sequence x sequence
x delay x delay
x javascript eval x javascript eval
- toast? o toast?
- Replaced with popups with timeout o Replaced with popups with timeout
x Redesign services to target devices x Redesign services to target devices
x frontend editor for popup cards x frontend editor for popup cards
- also screensavers o also screensavers
- Saved frontend settings x Saved frontend settings
X Framework X Framework
x Save sidebar x Save sidebar
x Kiosk mode x Kiosk mode
x Default dashboard x Default dashboard
- Screensaver? o Screensaver?
x Favicon templates x Favicon templates
x Title templates x Title templates
- Tweaks - Tweaks
@@ -69,9 +70,9 @@ import { BrowserIDMixin } from "./browserID";
x Card-mod preload x Card-mod preload
x Video player x Video player
x Media_seek x Media_seek
- Screensavers o Screensavers
x IMPORTANT: FIX DEFAULT HIDING OF ENTITIES x IMPORTANT: FIX DEFAULT HIDING OF ENTITIES
- NOFIX. Home Assistant bug o NOFIX. Home Assistant bug
X Check functionality with CAST - may need to add frontend part as a lovelace resource X Check functionality with CAST - may need to add frontend part as a lovelace resource
*/ */
export class BrowserMod extends ServicesMixin( export class BrowserMod extends ServicesMixin(
+9 -12
View File
@@ -1,12 +1,11 @@
import { selectTree } from "../helpers"; import { selectTree, throttle } from "../helpers";
export const MediaPlayerMixin = (SuperClass) => { export const MediaPlayerMixin = (SuperClass) => {
return class MediaPlayerMixinClass extends SuperClass { class MediaPlayerMixinClass extends SuperClass {
public player; public player;
private _audio_player; private _audio_player;
private _video_player; private _video_player;
private _player_enabled; private _player_enabled;
private _player_update_cooldown;
constructor() { constructor() {
super(); super();
@@ -24,10 +23,10 @@ export const MediaPlayerMixin = (SuperClass) => {
} }
for (const ev of ["timeupdate"]) { for (const ev of ["timeupdate"]) {
this._audio_player.addEventListener(ev, () => this._audio_player.addEventListener(ev, () =>
this._player_update_choked() this._player_update_throttled()
); );
this._video_player.addEventListener(ev, () => this._video_player.addEventListener(ev, () =>
this._player_update_choked() this._player_update_throttled()
); );
} }
@@ -99,12 +98,8 @@ export const MediaPlayerMixin = (SuperClass) => {
} }
} }
private _player_update_choked() { @throttle(3000)
if (this._player_update_cooldown) return; _player_update_throttled() {
this._player_update_cooldown = window.setTimeout(
() => (this._player_update_cooldown = undefined),
3000
);
this._player_update(); this._player_update();
} }
@@ -129,5 +124,7 @@ export const MediaPlayerMixin = (SuperClass) => {
}, },
}); });
} }
}; }
return MediaPlayerMixinClass;
}; };
+53 -21
View File
@@ -2,6 +2,7 @@ import { LitElement, html, css } from "lit";
import { property, query } from "lit/decorators.js"; import { property, query } from "lit/decorators.js";
import { unsafeHTML } from "lit/directives/unsafe-html.js"; import { unsafeHTML } from "lit/directives/unsafe-html.js";
import { provideHass, loadLoadCardHelpers, hass_base_el } from "../helpers"; import { provideHass, loadLoadCardHelpers, hass_base_el } from "../helpers";
import { loadHaForm } from "../helpers";
class BrowserModPopup extends LitElement { class BrowserModPopup extends LitElement {
@property() open; @property() open;
@@ -23,6 +24,7 @@ class BrowserModPopup extends LitElement {
_timeoutStart; _timeoutStart;
_timeoutTimer; _timeoutTimer;
_resolveClosed; _resolveClosed;
_formdata;
async closeDialog() { async closeDialog() {
this.open = false; this.open = false;
@@ -76,10 +78,30 @@ class BrowserModPopup extends LitElement {
autoclose = false, autoclose = false,
} = {} } = {}
) { ) {
this._formdata = undefined;
this.title = title; this.title = title;
if (content && content instanceof HTMLElement) {
this.card = undefined; this.card = undefined;
if (content && content instanceof HTMLElement) {
this.content = content; this.content = content;
} else if (content && Array.isArray(content)) {
loadHaForm();
const form: any = document.createElement("ha-form");
form.schema = content;
form.computeLabel = (s) => s.label ?? s.name;
form.hass = window.browser_mod.hass;
this._formdata = {};
for (const i of content) {
if (i.name && i.default !== undefined) {
this._formdata[i.name] = i.default;
}
}
form.data = this._formdata;
provideHass(form);
form.addEventListener("value-changed", (ev) => {
this._formdata = { ...ev.detail.value };
form.data = this._formdata;
});
this.content = form;
} else if (content && typeof content === "object") { } else if (content && typeof content === "object") {
// Create a card from config in content // Create a card from config in content
this.card = true; this.card = true;
@@ -90,7 +112,6 @@ class BrowserModPopup extends LitElement {
this.content = card; this.content = card;
} else { } else {
// Basic HTML content // Basic HTML content
this.card = undefined;
this.content = unsafeHTML(content); this.content = unsafeHTML(content);
} }
@@ -115,12 +136,12 @@ class BrowserModPopup extends LitElement {
async _primary() { async _primary() {
if (this._actions?.dismiss_action) this._actions.dismiss_action = undefined; if (this._actions?.dismiss_action) this._actions.dismiss_action = undefined;
this.dialog?.close(); this.dialog?.close();
this._actions?.right_button_action?.(); this._actions?.right_button_action?.(this._formdata);
} }
async _secondary() { async _secondary() {
if (this._actions?.dismiss_action) this._actions.dismiss_action = undefined; if (this._actions?.dismiss_action) this._actions.dismiss_action = undefined;
this.dialog?.close(); this.dialog?.close();
this._actions?.left_button_action?.(); this._actions?.left_button_action?.(this._formdata);
} }
async _dismiss(ev?) { async _dismiss(ev?) {
this.dialog?.close(); this.dialog?.close();
@@ -150,16 +171,21 @@ class BrowserModPopup extends LitElement {
: ""} : ""}
${this.title ${this.title
? html` ? html`
<app-toolbar slot="heading"> <div slot="heading">
<ha-header-bar>
${this.dismissable ${this.dismissable
? html` ? html`
<ha-icon-button dialogAction="cancel"> <ha-icon-button
dialogAction="cancel"
slot="navigationIcon"
>
<ha-icon .icon=${"mdi:close"}></ha-icon> <ha-icon .icon=${"mdi:close"}></ha-icon>
</ha-icon-button> </ha-icon-button>
` `
: ""} : ""}
<div class="main-title">${this.title}</div> <div slot="title" class="main-title">${this.title}</div>
</app-toolbar> </ha-header-bar>
</div>
` `
: html``} : html``}
@@ -171,6 +197,7 @@ class BrowserModPopup extends LitElement {
slot="primaryAction" slot="primaryAction"
.label=${this.right_button} .label=${this.right_button}
@click=${this._primary} @click=${this._primary}
class="action-button"
></mwc-button> ></mwc-button>
` `
: ""} : ""}
@@ -180,6 +207,7 @@ class BrowserModPopup extends LitElement {
slot="secondaryAction" slot="secondaryAction"
.label=${this.left_button} .label=${this.left_button}
@click=${this._secondary} @click=${this._secondary}
class="action-button"
></mwc-button> ></mwc-button>
` `
: ""} : ""}
@@ -195,6 +223,7 @@ class BrowserModPopup extends LitElement {
static get styles() { static get styles() {
return css` return css`
ha-dialog { ha-dialog {
--dialog-backdrop-filter: blur(5px);
z-index: 10; z-index: 10;
--mdc-dialog-min-width: var(--popup-min-width, 400px); --mdc-dialog-min-width: var(--popup-min-width, 400px);
--mdc-dialog-max-width: var(--popup-max-width, 600px); --mdc-dialog-max-width: var(--popup-max-width, 600px);
@@ -202,13 +231,12 @@ class BrowserModPopup extends LitElement {
--mdc-dialog-content-ink-color: var(--primary-text-color); --mdc-dialog-content-ink-color: var(--primary-text-color);
--justify-action-buttons: space-between; --justify-action-buttons: space-between;
--mdc-dialog-box-shadow: 0px 0px 0px --dialog-box-shadow: 0px 0px 0px
var(--popup-border-width, var(--ha-card-border-width, 2px)) var(--popup-border-width, var(--ha-card-border-width, 2px))
var( var(
--popup-border-color, --popup-border-color,
var(--ha-card-border-color, var(--divider-color, #e0e0e0)) var(--ha-card-border-color, var(--divider-color, #e0e0e0))
); );
--ha-dialog-border-radius: var(--popup-border-radius, 8px);
--mdc-theme-surface: var( --mdc-theme-surface: var(
--popup-background-color, --popup-background-color,
var(--ha-card-background, var(--card-background-color, white)) var(--ha-card-background, var(--card-background-color, white))
@@ -224,6 +252,7 @@ class BrowserModPopup extends LitElement {
--mdc-dialog-max-height: 100%; --mdc-dialog-max-height: 100%;
--mdc-shape-medium: 0px; --mdc-shape-medium: 0px;
--vertial-align-dialog: flex-end; --vertial-align-dialog: flex-end;
--ha-dialog-border-radius: 0px;
} }
.progress::before { .progress::before {
content: ""; content: "";
@@ -236,23 +265,20 @@ class BrowserModPopup extends LitElement {
z-index: 10; z-index: 10;
} }
app-toolbar { ha-header-bar {
--mdc-theme-on-primary: var(--primary-text-color);
--mdc-theme-primary: var(--mdc-theme-surface);
flex-shrink: 0; flex-shrink: 0;
color: var(--primary-text-color); display: block;
background-color: var(
--popup-header-background-color,
var(--popup-background-color, var(--sidebar-background-color))
);
} }
ha-icon-button > * { ha-icon-button > * {
display: flex; display: flex;
} }
.main-title { .main-title {
margin-left: 16px;
line-height: 1.3em;
max-height: 2.6em;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
cursor: default;
} }
.content { .content {
--padding-x: 24px; --padding-x: 24px;
@@ -269,9 +295,11 @@ class BrowserModPopup extends LitElement {
:host([card]) .content { :host([card]) .content {
--padding-x: 0px; --padding-x: 0px;
--padding-y: 0px; --padding-y: 0px;
--ha-card-box-shadow: none;
} }
:host([actions]) .content { :host([actions]) .content {
border-bottom: 1px solid var(--popup-border-color, var(--divider-color)); xborder-bottom: 2px solid
var(--popup-border-color, var(--divider-color));
--footer-height: 54px; --footer-height: 54px;
} }
:host([wide]) .content { :host([wide]) .content {
@@ -280,10 +308,14 @@ class BrowserModPopup extends LitElement {
:host([fullscreen]) .content { :host([fullscreen]) .content {
height: calc( height: calc(
100vh - var(--header-height) - var(--footer-height) - 2 * 100vh - var(--header-height) - var(--footer-height) - 2 *
var(--padding-y) var(--padding-y) - 16px
); );
} }
.action-button {
margin-bottom: -24px;
}
@media all and (max-width: 450px), all and (max-height: 500px) { @media all and (max-width: 450px), all and (max-height: 500px) {
ha-dialog { ha-dialog {
--mdc-dialog-min-width: 100vw; --mdc-dialog-min-width: 100vw;
+15 -6
View File
@@ -128,7 +128,13 @@ export const ServicesMixin = (SuperClass) => {
const { title, content, ...d } = data; const { title, content, ...d } = data;
for (const [k, v] of Object.entries(d)) { for (const [k, v] of Object.entries(d)) {
if (k.endsWith("_action")) { if (k.endsWith("_action")) {
d[k] = () => this._service_action(v as any); d[k] = (ext_data?) => {
const { service, data } = v as any;
this._service_action({
service,
data: { ...data, ...ext_data },
});
};
} }
} }
this.showPopup(title, content, d); this.showPopup(title, content, d);
@@ -147,18 +153,21 @@ export const ServicesMixin = (SuperClass) => {
break; break;
case "console": case "console":
console.log(data.message); if (
Object.keys(data).length > 1 ||
(data && data.message === undefined)
)
console.dir(data);
else console.log(data.message);
break; break;
case "javascript": case "javascript":
const code = ` const code = `
"use strict"; "use strict";
// Insert global definitions here
const hass = (document.querySelector("home-assistant") || document.querySelector("hc-main")).hass;
${data.code} ${data.code}
`; `;
const fn = new Function(code); const fn = new Function("hass", "data", code);
fn(); fn(this.hass, data);
break; break;
} }
} }
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "browser_mod", "name": "browser_mod",
"private": true, "private": true,
"version": "2.0.0b2", "version": "2.0.0b3",
"description": "", "description": "",
"scripts": { "scripts": {
"build": "rollup -c", "build": "rollup -c",