UNPKG

iobroker.lovelace

Version:

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

11 lines 15.5 kB
/*! For license information please see 80764.c77f223a77948b20.js.LICENSE.txt */ export const __rspack_esm_id=80764;export const __rspack_esm_ids=[80764];export const __webpack_modules__={67258(e,t,a){a.d(t,{d:()=>i});const i=e=>{switch(e.language){case"cs":case"de":case"fi":case"fr":case"sk":case"sv":return" ";default:return""}}},41060(e,t,a){a.a(e,async function(e,t){try{a(18111),a(61701);var i=a(62826),r=a(5124),o=a(22441),s=a(6412),l=a(44537),n=a(1087),d=a(67258),c=a(46187),p=a(18350),h=a(26300),u=a(94355),g=e([p,h,u]);[p,h,u]=g.then?(await g)():g;const v="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",b="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M13.5,16V19H10.5V16H8L12,12L16,16H13.5M13,9V3.5L18.5,9H13Z";class f extends r.WF{firstUpdated(e){super.firstUpdated(e),this.autoOpenFileDialog&&this._openFilePicker()}get _name(){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return(this.value instanceof FileList?Array.from(this.value):(0,l.e)(this.value)).map(e=>e.name).join(", ")}render(){const e=this.localize||this.hass.localize;return r.qy` ${this.uploading?r.qy`<div class="container"> <div class="uploading"> <span class="header">${this.uploadingLabel||(this.value?e("ui.components.file-upload.uploading_name",{name:this._name}):e("ui.components.file-upload.uploading"))}</span> ${this.progress?r.qy`<div class="progress"> ${this.progress}${this.hass&&(0,d.d)(this.hass.locale)}% </div>`:r.s6} </div> <ha-progress-bar .indeterminate="${!this.progress}" .value="${this.progress}" loading></ha-progress-bar> </div>`:r.qy`<label for="${this.value?"":"input"}" class="container ${(0,s.H)({dragged:this._drag,multiple:this.multiple,value:Boolean(this.value)})}" @drop="${this._handleDrop}" @dragenter="${this._handleDragStart}" @dragover="${this._handleDragStart}" @dragleave="${this._handleDragEnd}" @dragend="${this._handleDragEnd}">${this.value?"string"==typeof this.value?r.qy`<div class="row"> <div class="value" @click="${this._openFilePicker}"> <ha-svg-icon .path="${this.icon||b}"></ha-svg-icon> ${this.value} </div> <ha-icon-button @click="${this._clearValue}" .label="${this.deleteLabel||e("ui.common.delete")}" .path="${v}"></ha-icon-button> </div>`:(this.value instanceof FileList?Array.from(this.value):(0,l.e)(this.value)).map(t=>r.qy`<div class="row"> <div class="value" @click="${this._openFilePicker}"> <ha-svg-icon .path="${this.icon||b}"></ha-svg-icon> ${t.name} - ${(0,c.A)(t.size)} </div> <ha-icon-button @click="${this._clearValue}" .label="${this.deleteLabel||e("ui.common.delete")}" .path="${v}"></ha-icon-button> </div>`):r.qy`<ha-button size="small" appearance="filled" @click="${this._openFilePicker}"> <ha-svg-icon slot="start" .path="${this.icon||b}"></ha-svg-icon> ${this.label||e("ui.components.file-upload.label")} </ha-button> <span class="secondary">${this.secondary||e("ui.components.file-upload.secondary")}</span> <span class="supports">${this.supports}</span>`} <input id="input" type="file" class="file" .accept="${this.accept}" .multiple="${this.multiple}" @change="${this._handleFilePicked}"></label>`} `}_openFilePicker(){this._input?.click()}_handleDrop(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer?.files&&(0,n.r)(this,"file-picked",{files:this.multiple||1===e.dataTransfer.files.length?Array.from(e.dataTransfer.files):[e.dataTransfer.files[0]]}),this._drag=!1}_handleDragStart(e){e.preventDefault(),e.stopPropagation(),this._drag=!0}_handleDragEnd(e){e.preventDefault(),e.stopPropagation(),this._drag=!1}_handleFilePicked(e){0!==e.target.files.length&&(this.value=e.target.files,(0,n.r)(this,"file-picked",{files:e.target.files}))}_clearValue(e){e.preventDefault(),this._input.value="",this.value=void 0,(0,n.r)(this,"change"),(0,n.r)(this,"files-cleared")}constructor(...e){super(...e),this.multiple=!1,this.disabled=!1,this.uploading=!1,this.autoOpenFileDialog=!1,this._drag=!1}}f.styles=r.AH`:host{display:block;height:240px}:host([disabled]){pointer-events:none;color:var(--disabled-text-color)}.container{position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;border:solid 1px var(--mdc-text-field-idle-line-color,rgba(0,0,0,.42));border-radius:var(--mdc-shape-small,var(--ha-border-radius-sm));height:100%}.row{display:flex;align-items:center}label.container{border:dashed 1px var(--mdc-text-field-idle-line-color,rgba(0,0,0,.42));cursor:pointer}.container .uploading{display:flex;flex-direction:column;width:100%;align-items:flex-start;padding:0 32px;box-sizing:border-box}:host([disabled]) .container{border-color:var(--disabled-color)}label.dragged,label:hover{border-style:solid}label.dragged{border-color:var(--primary-color)}.dragged:before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:var(--primary-color);content:"";opacity:var(--dark-divider-opacity);pointer-events:none;border-radius:var(--mdc-shape-small,4px)}label.value{cursor:default}label.value.multiple{justify-content:unset;overflow:auto}.highlight{color:var(--primary-color)}ha-button{margin-bottom:8px}.supports{color:var(--secondary-text-color);font-size:var(--ha-font-size-s)}:host([disabled]) .secondary{color:var(--disabled-text-color)}input.file{display:none}.value{cursor:pointer}.value ha-svg-icon{margin-right:8px;margin-inline-end:8px;margin-inline-start:initial}ha-button{--mdc-button-outline-color:var(--primary-color);--ha-icon-button-size:24px}ha-progress-bar{width:100%;padding:8px 32px;box-sizing:border-box}.header{font-weight:var(--ha-font-weight-medium)}.progress{color:var(--secondary-text-color)}button.link{background:0 0;border:none;padding:0;font-size:var(--ha-font-size-m);color:var(--primary-color);text-decoration:underline;cursor:pointer}`,(0,i.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"hass",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"localize",void 0),(0,i.Cg)([(0,o.MZ)()],f.prototype,"accept",void 0),(0,i.Cg)([(0,o.MZ)()],f.prototype,"icon",void 0),(0,i.Cg)([(0,o.MZ)()],f.prototype,"label",void 0),(0,i.Cg)([(0,o.MZ)()],f.prototype,"secondary",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"uploading-label"})],f.prototype,"uploadingLabel",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"delete-label"})],f.prototype,"deleteLabel",void 0),(0,i.Cg)([(0,o.MZ)()],f.prototype,"supports",void 0),(0,i.Cg)([(0,o.MZ)({type:Object})],f.prototype,"value",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],f.prototype,"multiple",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,reflect:!0})],f.prototype,"disabled",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],f.prototype,"uploading",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],f.prototype,"progress",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,attribute:"auto-open-file-dialog"})],f.prototype,"autoOpenFileDialog",void 0),(0,i.Cg)([(0,o.wk)()],f.prototype,"_drag",void 0),(0,i.Cg)([(0,o.P)("#input")],f.prototype,"_input",void 0),f=(0,i.Cg)([(0,o.EM)("ha-file-upload")],f),t()}catch(e){t(e)}})},25078(e,t,a){a.a(e,async function(e,i){try{a.r(t),a.d(t,{HaFileSelector:()=>u});var r=a(62826),o=a(5124),s=a(22441),l=a(1087),n=a(62854),d=a(65063),c=a(41060),p=e([c]);c=(p.then?(await p)():p)[0];const h="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z";class u extends o.WF{render(){return o.qy` <ha-file-upload .hass="${this.hass}" .accept="${this.selector.file?.accept}" .icon="${h}" .label="${this.label}" .required="${this.required}" .disabled="${this.disabled}" .supports="${this.helper}" .uploading="${this._busy}" .value="${this.value?this._filename?.name||this.hass.localize("ui.components.selectors.file.unknown_file"):void 0}" @file-picked="${this._uploadFile}" @change="${this._removeFile}"></ha-file-upload> `}willUpdate(e){super.willUpdate(e),e.has("value")&&this._filename&&this.value!==this._filename.fileId&&(this._filename=void 0)}async _uploadFile(e){this._busy=!0;const t=e.detail.files[0];try{const e=await(0,n.Q)(this.hass,t);this._filename={fileId:e,name:t.name},(0,l.r)(this,"value-changed",{value:e})}catch(e){(0,d.showAlertDialog)(this,{text:this.hass.localize("ui.components.selectors.file.upload_failed",{reason:e.message||e})})}finally{this._busy=!1}}constructor(...e){super(...e),this.disabled=!1,this.required=!0,this._busy=!1,this._removeFile=async()=>{this._busy=!0;try{await(0,n.n)(this.hass,this.value)}catch(e){}finally{this._busy=!1}this._filename=void 0,(0,l.r)(this,"value-changed",{value:""})}}}(0,r.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"selector",void 0),(0,r.Cg)([(0,s.MZ)()],u.prototype,"value",void 0),(0,r.Cg)([(0,s.MZ)()],u.prototype,"label",void 0),(0,r.Cg)([(0,s.MZ)()],u.prototype,"helper",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean})],u.prototype,"disabled",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean})],u.prototype,"required",void 0),(0,r.Cg)([(0,s.wk)()],u.prototype,"_filename",void 0),(0,r.Cg)([(0,s.wk)()],u.prototype,"_busy",void 0),u=(0,r.Cg)([(0,s.EM)("ha-selector-file")],u),i()}catch(e){i(e)}})},94355(e,t,a){a.a(e,async function(e,t){try{var i=a(62826),r=a(88590),o=a(5124),s=a(22441),l=e([r]);r=(l.then?(await l)():l)[0];class n extends r.A{static get styles(){return[r.A.styles,o.AH`:host{--indicator-color:var( --ha-progress-bar-indicator-color, var(--ha-color-on-primary-normal) );--track-color:var( --ha-progress-bar-track-color, var(--ha-color-fill-neutral-normal-hover) );--track-height:var(--ha-progress-bar-track-height, 12px);--wa-transition-slow:var(--ha-animation-duration-slow);position:relative}.progress-bar{border-radius:var(--ha-progress-bar-border-radius,var(--ha-border-radius-pill))}.indicator{background:var(--ha-progress-bar-indicator-background,var(--indicator-color))}:host([indeterminate]) .indicator{animation:wa-progress-indeterminate var(--ha-progress-bar-animation-duration,2.5s) infinite cubic-bezier(.37,0,.63,1)}@keyframes slide-highlight{0%{transform:translateX(-200%)}100%{transform:translateX(200%)}}:host([loading]:not([indeterminate])) .progress-bar::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,transparent 0%,oklch(from var(--indicator-color) 85% c h) 50%,transparent 100%);opacity:.5;animation:slide-highlight var(--ha-progress-bar-animation-duration,2.5s) infinite cubic-bezier(.37,0,.63,1);width:50%}:host::after{--width:var( --ha-progress-bar-indicator-highlight-width, calc(var(--track-height) * 2) );width:var(--width);height:var(--ha-progress-bar-indicator-highlight-height,calc(var(--track-height) * 2));content:"";position:absolute;inset-inline-start:clamp(var(--width)/ 2,var(--percentage,0%),calc(100% - var(--width)/ 2));top:50%;transform:translate(-50%,-50%);background-image:var(--ha-progress-bar-indicator-highlight-image);background-size:contain;background-repeat:no-repeat;background-position:center;pointer-events:none;transition:inset-inline-start var(--wa-transition-slow, 200ms) var(--wa-transition-easing, ease)}:host([indeterminate])::after{display:none}`]}constructor(...e){super(...e),this.loading=!1}}(0,i.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],n.prototype,"loading",void 0),n=(0,i.Cg)([(0,s.EM)("ha-progress-bar")],n),t()}catch(e){t(e)}})},62854(e,t,a){a.d(t,{Q:()=>i,n:()=>r});const i=async(e,t)=>{const a=new FormData;a.append("file",t);const i=await e.fetchWithAuth("/api/file_upload",{method:"POST",body:a});if(413===i.status)throw new Error(`Uploaded file is too large (${t.name})`);if(200!==i.status)throw new Error("Unknown error");return(await i.json()).file_id},r=async(e,t)=>e.callApi("DELETE","file_upload",{file_id:t})},65063(e,t,a){a.d(t,{an:()=>n,dk:()=>l,showAlertDialog:()=>s});var i=a(1087);const r=()=>Promise.all([a.e(4801),a.e(39763),a.e(32450),a.e(29962),a.e(32188)]).then(a.bind(a,26683)),o=(e,t,a)=>new Promise(o=>{const s=t.cancel,l=t.confirm;(0,i.r)(e,"show-dialog",{dialogTag:"dialog-box",dialogImport:r,dialogParams:{...t,...a,cancel:()=>{o(!!a?.prompt&&null),s&&s()},confirm:e=>{o(!a?.prompt||e),l&&l(e)}}})}),s=(e,t)=>o(e,t),l=(e,t)=>o(e,t,{confirmation:!0}),n=(e,t)=>o(e,t,{prompt:!0})},46187(e,t,a){a.d(t,{A:()=>i});const i=(e=0,t=2)=>{if(0===e)return"0 Bytes";t=t<0?0:t;const a=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/1024**a).toFixed(t))} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][a]}`}},35370(e,t,a){var i=a(26198);e.exports=function(e,t,a){for(var r=0,o=arguments.length>2?a:i(t),s=new e(o);o>r;)s[r]=t[r++];return s}},89429(e){e.exports=function(){}},88590(e,t,a){a.a(e,async function(e,i){try{a.d(t,{A:()=>v});var r=a(5124),o=a(22441),s=a(63672),l=a(95010),n=a(717),d=a(17060),c=a(4168),p=e([d]);d=(p.then?(await p)():p)[0];var h=Object.defineProperty,u=Object.getOwnPropertyDescriptor,g=(e,t,a,i)=>{for(var r,o=i>1?void 0:i?u(t,a):t,s=e.length-1;s>=0;s--)(r=e[s])&&(o=(i?r(t,a,o):r(o))||o);return i&&o&&h(t,a,o),o};let v=class extends n.A{updated(e){e.has("value")&&requestAnimationFrame(()=>{this.style.setProperty("--percentage",`${(0,l.q)(this.value,0,100)}%`)})}render(){return r.qy` <div part="base" class="progress-bar" role="progressbar" title="${(0,s.J)(this.title)}" aria-label="${this.label.length>0?this.label:this.localize.term("progress")}" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${this.indeterminate?"0":this.value}"> <div part="indicator" class="indicator"> ${this.indeterminate?"":r.qy` <slot part="label" class="label"></slot> `} </div> </div> `}constructor(){super(...arguments),this.localize=new d.c(this),this.value=0,this.indeterminate=!1,this.label=""}};v.css=c.A,g([(0,o.MZ)({type:Number,reflect:!0})],v.prototype,"value",2),g([(0,o.MZ)({type:Boolean,reflect:!0})],v.prototype,"indeterminate",2),g([(0,o.MZ)()],v.prototype,"label",2),v=g([(0,o.EM)("wa-progress-bar")],v),i()}catch(e){i(e)}})},4168(e,t,a){a.d(t,{A:()=>i});var i=a(5124).AH`:host{--track-height:1rem;--track-color:var(--wa-color-neutral-fill-normal);--indicator-color:var(--wa-color-brand-fill-loud);display:flex}.progress-bar{flex:1 1 auto;display:flex;position:relative;overflow:hidden;height:var(--track-height);border-radius:var(--wa-border-radius-pill);background-color:var(--track-color);color:var(--wa-color-brand-on-loud);font-size:var(--wa-font-size-s)}.indicator{width:var(--percentage);display:flex;align-items:center;justify-content:center;background-color:var(--indicator-color);text-align:center;white-space:nowrap;overflow:hidden;line-height:1;font-weight:var(--wa-font-weight-semibold);transition:all var(--wa-transition-slow, 200ms) var(--wa-transition-easing, ease);user-select:none;-webkit-user-select:none}:host([indeterminate]) .indicator{position:absolute;inset-block:0;inline-size:50%;animation:wa-progress-indeterminate 2.5s infinite cubic-bezier(.37,0,.63,1)}@media (forced-colors:active){.progress-bar{outline:solid 1px SelectedItem;background-color:var(--wa-color-surface-default)}.indicator{outline:solid 1px SelectedItem;background-color:SelectedItem}}@keyframes wa-progress-indeterminate{0%{inset-inline-start:-50%}100%,75%{inset-inline-start:100%}}`},95010(e,t,a){a.d(t,{q:()=>i,N:()=>r});a(16573),a(78100),a(77936),a(37467),a(44732),a(79577),a(16632),a(34226),a(9486),a(20456);function i(e,t,a){const i=e=>Object.is(e,-0)?0:e;return i(e<t?t:e>a?a:e)}function r(e=""){return`${e}${((e=21)=>{let t="",a=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&a[e]];return t})()}`}}};