UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

5 lines 10.2 kB
export const __webpack_ids__=["37860"];export const __webpack_modules__={84200:function(e,t,i){i.d(t,{r:()=>a});i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814);const o=(e,t,i=true)=>{if(!e||e===document.body)return null;if((e=e.assignedSlot??e).parentElement)e=e.parentElement;else{const t=e.getRootNode();e=t instanceof ShadowRoot?t.host:null}return(i?Object.prototype.hasOwnProperty.call(e,t):e&&t in e)?e:o(e,t,i)},a=(e,t,i=true)=>{const a=new Set;for(;e;)a.add(e),e=o(e,t,i);return a}},81165:function(e,t,i){i.d(t,{j:()=>o});const o=(e=document)=>e.activeElement?.shadowRoot?.activeElement?o(e.activeElement.shadowRoot):e.activeElement},76320:function(e,t,i){i.d(t,{T:()=>o,y:()=>a});const o=e=>{requestAnimationFrame((()=>setTimeout(e,0)))},a=()=>new Promise((e=>{o(e)}))},73729:function(e,t,i){i.d(t,{i:()=>p});var o=i(44249),a=i(72621),n=i(74966),r=i(51408),s=i(57243),d=i(15093),l=i(76525);i(23334);const c=["button","ha-list-item"],p=(e,t)=>s.dy` <div class="header_title"> <ha-icon-button .label="${e?.localize("ui.common.close")??"Close"}" .path="${"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"}" dialogAction="close" class="header_button"></ha-icon-button> <span>${t}</span> </div> `;(0,o.Z)([(0,d.Mo)("ha-dialog")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",key:l.gA,value:void 0},{kind:"method",key:"scrollToPos",value:function(e,t){this.contentElement?.scrollTo(e,t)}},{kind:"method",key:"renderHeading",value:function(){return s.dy`<slot name="heading"> ${(0,a.Z)(i,"renderHeading",this,3)([])} </slot>`}},{kind:"method",key:"firstUpdated",value:function(){(0,a.Z)(i,"firstUpdated",this,3)([]),this.suppressDefaultPressSelector=[this.suppressDefaultPressSelector,c].join(", "),this._updateScrolledAttribute(),this.contentElement?.addEventListener("scroll",this._onScroll,{passive:!0})}},{kind:"method",key:"disconnectedCallback",value:function(){(0,a.Z)(i,"disconnectedCallback",this,3)([]),this.contentElement.removeEventListener("scroll",this._onScroll)}},{kind:"field",key:"_onScroll",value(){return()=>{this._updateScrolledAttribute()}}},{kind:"method",key:"_updateScrolledAttribute",value:function(){this.contentElement&&this.toggleAttribute("scrolled",0!==this.contentElement.scrollTop)}},{kind:"field",static:!0,key:"styles",value:()=>[r.W,s.iv`:host([scrolled]) ::slotted(ha-dialog-header){border-bottom:1px solid var(--mdc-dialog-scroll-divider-color,rgba(0,0,0,.12))}.mdc-dialog{--mdc-dialog-scroll-divider-color:var( --dialog-scroll-divider-color, var(--divider-color) );z-index:var(--dialog-z-index,8);-webkit-backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));--mdc-dialog-box-shadow:var(--dialog-box-shadow, none);--mdc-typography-headline6-font-weight:400;--mdc-typography-headline6-font-size:1.574rem}.mdc-dialog__actions{justify-content:var(--justify-action-buttons,flex-end);padding-bottom:max(env(safe-area-inset-bottom),24px)}.mdc-dialog__actions span:first-child{flex:var(--secondary-action-button-flex,unset)}.mdc-dialog__actions span:nth-child(2){flex:var(--primary-action-button-flex,unset)}.mdc-dialog__container{align-items:var(--vertical-align-dialog,center)}.mdc-dialog__title{padding:24px 24px 0 24px}.mdc-dialog__title:has(span){padding:12px 12px 0}.mdc-dialog__actions{padding:12px 24px 12px 24px}.mdc-dialog__title::before{content:unset}.mdc-dialog .mdc-dialog__content{position:var(--dialog-content-position,relative);padding:var(--dialog-content-padding,24px)}:host([hideactions]) .mdc-dialog .mdc-dialog__content{padding-bottom:max(var(--dialog-content-padding,24px),env(safe-area-inset-bottom))}.mdc-dialog .mdc-dialog__surface{position:var(--dialog-surface-position,relative);top:var(--dialog-surface-top);margin-top:var(--dialog-surface-margin-top);min-height:var(--mdc-dialog-min-height,auto);border-radius:var(--ha-dialog-border-radius,28px);-webkit-backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);background:var(--ha-dialog-surface-background,var(--mdc-theme-surface,#fff))}:host([flexContent]) .mdc-dialog .mdc-dialog__content{display:flex;flex-direction:column}.header_title{display:flex;align-items:center;direction:var(--direction)}.header_title span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;padding-left:4px}.header_button{text-decoration:none;color:inherit;inset-inline-start:initial;inset-inline-end:-12px;direction:var(--direction)}.dialog-actions{inset-inline-start:initial!important;inset-inline-end:0px!important;direction:var(--direction)}`]}]}}),n.M)},77333:function(e,t,i){i.r(t),i.d(t,{HaImagecropperDialog:()=>p});var o=i(44249),a=(i(75656),i(50100),i(18084),i(31622),i(65509)),n=i.n(a),r=i(93528),s=i(57243),d=i(15093),l=i(35359),c=(i(73729),i(28008));let p=(0,o.Z)([(0,d.Mo)("image-cropper-dialog")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,d.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,d.SB)()],key:"_params",value:void 0},{kind:"field",decorators:[(0,d.SB)()],key:"_open",value:()=>!1},{kind:"field",decorators:[(0,d.IO)("img",!0)],key:"_image",value:void 0},{kind:"field",key:"_cropper",value:void 0},{kind:"field",decorators:[(0,d.SB)()],key:"_isTargetAspectRatio",value:void 0},{kind:"method",key:"showDialog",value:function(e){this._params=e,this._open=!0}},{kind:"method",key:"closeDialog",value:function(){this._open=!1,this._params=void 0,this._cropper?.destroy(),this._cropper=void 0,this._isTargetAspectRatio=!1}},{kind:"method",key:"updated",value:function(e){e.has("_params")&&this._params&&(this._cropper?this._cropper.replace(URL.createObjectURL(this._params.file)):(this._image.src=URL.createObjectURL(this._params.file),this._cropper=new(n())(this._image,{aspectRatio:this._params.options.aspectRatio,viewMode:1,dragMode:"move",minCropBoxWidth:50,ready:()=>{this._isTargetAspectRatio=this._checkMatchAspectRatio(),URL.revokeObjectURL(this._image.src)}})))}},{kind:"method",key:"_checkMatchAspectRatio",value:function(){const e=this._params?.options.aspectRatio;if(!e)return!0;const t=this._cropper.getImageData();if(t.aspectRatio===e)return!0;if(t.naturalWidth>t.naturalHeight){const i=t.naturalWidth/e;return Math.abs(i-t.naturalHeight)<=1}const i=t.naturalHeight*e;return Math.abs(i-t.naturalWidth)<=1}},{kind:"method",key:"render",value:function(){return s.dy`<ha-dialog @closed="${this.closeDialog}" scrimClickAction escapeKeyAction .open="${this._open}"> <div class="container ${(0,l.$)({round:Boolean(this._params?.options.round)})}"> <img alt="${this.hass.localize("ui.dialogs.image_cropper.crop_image")}"> </div> <mwc-button slot="secondaryAction" @click="${this.closeDialog}"> ${this.hass.localize("ui.common.cancel")} </mwc-button> ${this._isTargetAspectRatio?s.dy`<mwc-button slot="primaryAction" @click="${this._useOriginal}"> ${this.hass.localize("ui.dialogs.image_cropper.use_original")} </mwc-button>`:s.Ld} <mwc-button slot="primaryAction" @click="${this._cropImage}"> ${this.hass.localize("ui.dialogs.image_cropper.crop")} </mwc-button> </ha-dialog>`}},{kind:"method",key:"_cropImage",value:function(){this._cropper.getCroppedCanvas().toBlob((e=>{if(!e)return;const t=new File([e],this._params.file.name,{type:this._params.options.type||this._params.file.type});this._params.croppedCallback(t),this.closeDialog()}),this._params.options.type||this._params.file.type,this._params.options.quality)}},{kind:"method",key:"_useOriginal",value:function(){this._params.croppedCallback(this._params.file),this.closeDialog()}},{kind:"get",static:!0,key:"styles",value:function(){return[c.yu,s.iv`${(0,s.$m)(r)} .container{max-width:640px}img{max-width:100%}.container.round .cropper-face,.container.round .cropper-view-box{border-radius:50%}.cropper-line,.cropper-point,.cropper-point.point-se::before{background-color:var(--primary-color)}`]}}]}}),s.oi)},76525:function(e,t,i){i.d(t,{L$:()=>g,gA:()=>l,lD:()=>m,ts:()=>h,vC:()=>c});i(92745);var o=i(5111),a=i(84200);if(66977!=i.j)var n=i(81165);if(66977!=i.j)var r=i(76320);const s={},d=[],l=Symbol.for("HA focus target"),c=async(e,t,i,r,p,g=!0)=>{if(!(i in s)){if(!p)return!1;s[i]={element:p().then((()=>{const t=document.createElement(i);return e.provideHass(t),t.addEventListener("dialog-closed",u),t.addEventListener("dialog-closed",f),t}))}}if(g){const{history:a}=o.E;if(a.state?.dialog&&!d.length)return await new Promise((e=>{setTimeout(e)})),c(e,t,i,r,p,g);const n=d.findIndex((e=>e.dialogTag===i));-1!==n&&d.splice(n,1),d.push({element:e,root:t,dialogTag:i,dialogParams:r,dialogImport:p,addHistory:g});const s={dialog:i};a.state?.dialog?a.replaceState(s,""):(a.replaceState({...a.state,opensDialog:!0},""),a.pushState(s,""))}s[i].closedFocusTargets=(0,a.r)((0,n.j)(),l);const h=await s[i].element;return t.appendChild(h),h.showDialog(r),!0},p=async e=>{if(!(e in s))return!0;const t=await s[e].element;return!t.closeDialog||!1!==t.closeDialog()},g=async()=>{if(d.length){const e=d.pop(),t=await p(e.dialogTag);return t||d.push(e),d.length&&o.E.history.state?.opensDialog&&o.E.history.pushState({dialog:d[d.length-1].dialogTag},""),t}return!0},h=async()=>{for(let e=d.length-1;e>=0;e--){if(!(!d[e]||await p(d[e].dialogTag)))return!1}return!0},u=e=>{const t=d.findIndex((t=>t.dialogTag===e.detail.dialog));-1!==t&&d.splice(t,1),o.E.history.state?.dialog===e.detail.dialog&&(d.length?o.E.history.replaceState({dialog:d[d.length-1].dialogTag},""):-1!==t&&o.E.history.back())},m=(e,t)=>{e.addEventListener("show-dialog",(i=>{const{dialogTag:o,dialogImport:a,dialogParams:n,addHistory:r}=i.detail;c(e,t,o,n,a,r)}))},f=async e=>{if(!s[e.detail.dialog])return;const t=s[e.detail.dialog].closedFocusTargets;if(delete s[e.detail.dialog].closedFocusTargets,!t)return;let i=(0,n.j)();i instanceof HTMLElement&&i.blur(),await(0,r.y)();for(const e of t)if(e instanceof HTMLElement&&(e.focus(),i=(0,n.j)(),i&&i!==document.body))return}}}; //# sourceMappingURL=37860.e3cc54a2877af2bb.js.map