hassio-conf/www/plugins/fold-entity-row.js

87 lines
24 KiB
JavaScript
Raw Normal View History

2024-10-17 19:45:45 +00:00
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 l=t.length-1;l>=0;l--)(o=t[l])&&(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 Map;class o{constructor(t,e){if(this._$cssResult$=!0,e!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=s.get(this.cssText);return e&&void 0===t&&(s.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),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,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+"",i))(e)})(t):t;var l;const h=window.reactiveElementPolyfillSupport,a={toAttribute(t,e){switch(e){case Boolean:t=t?"":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}},d=(t,e)=>e!==t&&(e==e||t==t),c={attribute:!0,type:String,converter:a,reflect:!1,hasChanged:d};class u extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Eh(i,e);void 0!==s&&(this._$Eu.set(s,i),t.push(s))})),t}static createProperty(t,e=c){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)||c}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._$Eu=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 _$Eh(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ev=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Ep(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$Em)&&void 0!==e?e:this._$Em=[]).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._$Em)||void 0===e||e.splice(this._$Em.indexOf(t)>>>0,1)}_$Ep(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const i=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShad
<div id="head" @ll-custom=${this._customEvent} ?open=${this.open}>
${this.head}
<ha-icon
icon=${this.open?"mdi:chevron-up":"mdi:chevron-down"}
@action=${this.toggle}
.actionHandler=${ot({})}
role="${this._config.clickable?"":"switch"}"
tabindex="${this._config.clickable?"-1":"0"}"
aria-checked=${this.open?"true":"false"}
aria-label="${this._config.clickable?"":this.open?"Toggle fold closed":"Toggle fold open"}"
></ha-icon>
</div>
<div
id="items"
?open=${this.open}
aria-hidden="${String(!this.open)}"
aria-expanded="${String(this.open)}"
style=${`padding-left: ${this._config.padding}px; max-height: ${this.height}px;`}
>
<div id="measure">
${this.renderRows?null===(t=this.rows)||void 0===t?void 0:t.map((t=>U`<div>${t}</div>`)):""}
</div>
</div>
`}static get styles(){return n`
#head {
display: flex;
align-items: center;
--toggle-icon-width: 24px;
}
#head :not(ha-icon) {
flex-grow: 1;
max-width: calc(100% - var(--toggle-icon-width));
}
ha-icon {
width: var(--toggle-icon-width);
cursor: pointer;
border-radius: 50%;
background-size: cover;
}
ha-icon:focus {
outline: none;
background: var(--divider-color);
}
:host(.section-head) ha-icon {
margin-top: 16px;
}
#head :not(ha-icon):focus-visible {
outline: none;
background: var(--divider-color);
border-radius: 24px;
background-size: cover;
}
#head :not(ha-icon):focus {
outline: none;
}
#items {
padding: 0;
margin: 0;
overflow: hidden;
transition: max-height 0.2s ease-in-out;
height: 100%;
overflow: clip visible;
}
#measure {
overflow: clip visible;
}
#measure > * {
margin: 8px 0;
overflow: clip visible;
}
#measure > *:last-child {
margin-bottom: 0;
}
#measure > div * {
overflow: clip visible;
}
#head > *:first-child {
overflow: clip visible;
}
`}}t([G()],nt.prototype,"open",void 0),t([G()],nt.prototype,"renderRows",void 0),t([G()],nt.prototype,"head",void 0),t([G()],nt.prototype,"rows",void 0),t([G()],nt.prototype,"height",void 0),t([G()],nt.prototype,"maxheight",void 0),customElements.get("fold-entity-row")||(customElements.define("fold-entity-row",nt),console.info(`%cFOLD-ENTITY-ROW ${Q} IS INSTALLED`,"color: green; font-weight: bold",""));export{it as findParentCard};