homeassistant/www/community/lovelace-layout-card/layout-card.js

92 lines
14 KiB
JavaScript
Raw Normal View History

!function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.ContentRect=function(t){if("getBBox"in t){var e=t.getBBox();return Object.freeze({height:e.height,left:0,top:0,width:e.width})}var i=window.getComputedStyle(t);return Object.freeze({height:parseFloat(i.height||"0"),left:parseFloat(i.paddingLeft||"0"),top:parseFloat(i.paddingTop||"0"),width:parseFloat(i.width||"0")})}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(2),o=i(3),r=[],s=function(){function t(t){this.$$observationTargets=[],this.$$activeTargets=[],this.$$skippedTargets=[];var e=function(t){if(void 0===t)return"Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.";if("function"!=typeof t)return"Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function."}(t);if(e)throw TypeError(e);this.$$callback=t,r.push(this)}return t.prototype.observe=function(t){var e=a("observe",t);if(e)throw TypeError(e);c(this.$$observationTargets,t)>0||(this.$$observationTargets.push(new n.ResizeObservation(t)),f())},t.prototype.unobserve=function(t){var e=a("unobserve",t);if(e)throw TypeError(e);var i=c(this.$$observationTargets,t);i<0||(this.$$observationTargets.splice(i,1),m())},t.prototype.disconnect=function(){this.$$observationTargets=[],this.$$activeTargets=[]},t}();function a(t,e){return void 0===e?"Failed to execute '"+t+"' on 'ResizeObserver': 1 argument required, but only 0 present.":e instanceof window.Element?void 0:"Failed to execute '"+t+"' on 'ResizeObserver': parameter 1 is not of type 'Element'."}function c(t,e){for(var i=0;i<t.length;i+=1)if(t[i].target===e)return i;return-1}e.ResizeObserver=s;var l,d=function(t){r.forEach((function(e){e.$$activeTargets=[],e.$$skippedTargets=[],e.$$observationTargets.forEach((function(i){i.isActive()&&(h(i.target)>t?e.$$activeTargets.push(i):e.$$skippedTargets.push(i))}))}))},u=function(){var t=1/0;return r.forEach((function(e){if(e.$$activeTargets.length){var i=[];e.$$activeTargets.forEach((function(e){var n=new o.ResizeObserverEntry(e.target);i.push(n),e.$$broadcastWidth=n.contentRect.width,e.$$broadcastHeight=n.contentRect.height;var r=h(e.target);r<t&&(t=r)})),e.$$callback(i,e),e.$$activeTargets=[]}})),t},h=function(t){for(var e=0;t.parentNode;)t=t.parentNode,e+=1;return e},p=function(){var t,e=0;for(d(e);r.some((function(t){return!!t.$$activeTargets.length}));)e=u(),d(e);r.some((function(t){return!!t.$$skippedTargets.length}))&&(t=new window.ErrorEvent("ResizeLoopError",{message:"ResizeObserver loop completed with undelivered notifications."}),window.dispatchEvent(t))},f=function(){l||g()},g=function(){l=window.requestAnimationFrame((function(){p(),g()}))},m=function(){l&&!r.some((function(t){return!!t.$$observationTargets.length}))&&(window.cancelAnimationFrame(l),l=void 0)};e.install=function(){return window.ResizeObserver=s}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),o=function(){function t(t){this.target=t,this.$$broadcastWidth=this.$$broadcastHeight=0}return Object.defineProperty(t.prototype,"broadcastWidth",{get:function(){return this.$$broadcastWidth},enum
<div id="staging" class="grid"
style="
display: grid;
grid-template-rows: ${this._config.gridrows||"auto"};
grid-template-columns: ${this._config.gridcols||"auto"};
grid-gap: ${this._config.gridgap||"auto"};
place-items: ${this._config.gridplace||"auto"};
"></div>
`:o`
<div id="columns"
style="
${this._config.justify_content?`justify-content: ${this._config.justify_content};`:""}
">
${this.columns.map(t=>o`
${t}
`)}
</div>
<div id="staging"></div>
`}static get styles(){return r`
:host {
padding: 0;
display: block;
margin-bottom: 0!important;
}
:host(.panel) {
padding: 0 4px;
margin-top: 8px;
}
:host(.panel.stacked:first-child) {
margin-top: 8px !important;
}
@media(max-width: 500px) {
:host(.panel) {
padding-left: 0px;
padding-right: 0px;
}
}
#columns {
display: flex;
flex-direction: row;
justify-content: center;
margin-top: -8px;
}
.column {
flex-basis: 0;
flex-grow: 1;
overflow-x: hidden;
}
.column:first-child {
margin-left: -4px;
}
.column:last-child {
margin-right: -4px;
}
:host(.panel) .column {
margin: 0;
}
.cards>*,
.grid>* {
display: block;
margin: 4px 4px 8px;
}
.cards>*:first-child {
margin-top: 8px;
}
.cards>*:last-child {
margin-bottom: 4px;
}
@media(max-width: 500px) {
.cards:first-child>*,
.grid>* {
margin-left: 0px;
}
.cards:last-child>*,
.grid>* {
margin-right: 0px;
}
}
#staging:not(.grid) {
visibility: hidden;
height: 0;
}
#staging.grid {
margin: 0 -4px;
}
`}get _cardModder(){return{target:this}}}if(!customElements.get("layout-card")){customElements.define("layout-card",g);const t=i(4);console.info(`%cLAYOUT-CARD ${t.version} IS INSTALLED`,"color: green; font-weight: bold","")}}]);