UNPKG

iobroker.lovelace

Version:

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

1 lines 13 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[64442],{85938:function(e,t,a){a(18111),a(22489),a(3362),a(46058),a(62953);var o=a(40445),i=a(5124),r=a(67576),s=a(1087);let n,l=e=>e;class d extends i.WF{updated(e){e.has("disabled")&&(this.disabled?this._destroySortable():this._createSortable())}disconnectedCallback(){super.disconnectedCallback(),this._shouldBeDestroy=!0,setTimeout(()=>{this._shouldBeDestroy&&(this._destroySortable(),this._shouldBeDestroy=!1)},1)}connectedCallback(){super.connectedCallback(),this._shouldBeDestroy=!1,this.hasUpdated&&!this.disabled&&this._createSortable()}createRenderRoot(){return this}render(){return this.noStyle?i.s6:(0,i.qy)(n||(n=l` <style>.sortable-fallback{display:none!important}.sortable-ghost{box-shadow:0 0 0 2px var(--primary-color);background:rgba(var(--rgb-primary-color),.25);border-radius:var(--ha-border-radius-sm);opacity:.4}.sortable-drag{border-radius:var(--ha-border-radius-sm);opacity:1;background:var(--card-background-color);box-shadow:0px 4px 8px 3px #00000026;cursor:grabbing}</style> `))}async _createSortable(){if(this._sortable)return;const e=this.children[0];if(!e)return;const t=(await Promise.all([a.e(85283),a.e(70322)]).then(a.bind(a,80745))).default,o=Object.assign(Object.assign({scroll:!0,forceAutoScrollFallback:!0,scrollSpeed:20,animation:150},this.options),{},{onChoose:this._handleChoose,onStart:this._handleStart,onEnd:this._handleEnd,onUpdate:this._handleUpdate,onAdd:this._handleAdd,onRemove:this._handleRemove});this.draggableSelector&&(o.draggable=this.draggableSelector),this.handleSelector&&(o.handle=this.handleSelector),void 0!==this.invertSwap&&(o.invertSwap=this.invertSwap),this.group&&(o.group=this.group),this.filter&&(o.filter=this.filter),this._sortable=new t(e,o)}_destroySortable(){this._sortable&&(this._sortable.destroy(),this._sortable=void 0)}constructor(...e){super(...e),this.disabled=!1,this.noStyle=!1,this.invertSwap=!1,this.rollback=!0,this._shouldBeDestroy=!1,this._handleUpdate=e=>{(0,s.r)(this,"item-moved",{newIndex:e.newIndex,oldIndex:e.oldIndex})},this._handleAdd=e=>{(0,s.r)(this,"item-added",{index:e.newIndex,data:e.item.sortableData,item:e.item})},this._handleRemove=e=>{(0,s.r)(this,"item-removed",{index:e.oldIndex})},this._handleEnd=async e=>{(0,s.r)(this,"drag-end"),this.rollback&&e.item.placeholder&&(e.item.placeholder.replaceWith(e.item),delete e.item.placeholder)},this._handleStart=()=>{(0,s.r)(this,"drag-start")},this._handleChoose=e=>{this.rollback&&(e.item.placeholder=document.createComment("sort-placeholder"),e.item.after(e.item.placeholder))}}}(0,o.Cg)([(0,r.MZ)({type:Boolean})],d.prototype,"disabled",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean,attribute:"no-style"})],d.prototype,"noStyle",void 0),(0,o.Cg)([(0,r.MZ)({type:String,attribute:"draggable-selector"})],d.prototype,"draggableSelector",void 0),(0,o.Cg)([(0,r.MZ)({type:String,attribute:"handle-selector"})],d.prototype,"handleSelector",void 0),(0,o.Cg)([(0,r.MZ)({type:String,attribute:"filter"})],d.prototype,"filter",void 0),(0,o.Cg)([(0,r.MZ)({type:String})],d.prototype,"group",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean,attribute:"invert-swap"})],d.prototype,"invertSwap",void 0),(0,o.Cg)([(0,r.MZ)({attribute:!1})],d.prototype,"options",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean})],d.prototype,"rollback",void 0),d=(0,o.Cg)([(0,r.EM)("ha-sortable")],d)},16161:function(e,t,a){a.a(e,async function(e,o){try{a.d(t,{uu:function(){return He}});a(74423),a(18111),a(22489),a(7588),a(61701),a(3362),a(17642),a(58004),a(33853),a(45876),a(32475),a(15024),a(31698),a(88454),a(29452),a(62953);var i=a(40445),r=(a(68825),a(5124)),s=a(67576),n=a(75751),l=a(1087),d=a(18350),c=a(29823),h=(a(70947),a(26300)),p=(a(85938),a(67094),a(45291)),u=a(50179),m=a(7349),v=a(38098),g=a(89807),f=a(11865),y=a(85032),b=a(47547),_=a(66102),w=a(89156),x=a(3453),S=a(81210),C=a(31095),$=a(1248),k=a(19300),M=a(57251),F=a(35598),H=a(58500),Z=a(44772),z=a(14501),T=a(58467),V=a(44577),E=a(5817),L=a(67034),I=a(13028),q=a(30277),B=a(38409),A=a(339),D=a(67142),K=a(5375),R=a(14312),U=a(29175),W=a(26671),j=a(61691),N=a(71982),O=a(91282),P=a(73269),J=a(29106),Q=a(57484),G=a(95605),X=a(77799),Y=a(45429),ee=a(52494),te=a(65115),ae=a(31235),oe=a(25232),ie=a(34609),re=a(75781),se=a(13174),ne=a(74049),le=e([d,c,h,u,m,v,f,w,_,y,b,$,F,H,Z,E,L,I,A,D,ne,W,j,N,O,P,z,J,Y,Q,G,T,ee,ie,re,se]);[d,c,h,u,m,v,f,w,_,y,b,$,F,H,Z,E,L,I,A,D,ne,W,j,N,O,P,z,J,Y,Q,G,T,ee,ie,re,se]=le.then?(await le)():le;let de,ce,he,pe,ue,me,ve,ge,fe,ye,be=e=>e;const _e="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",we="M21 11H3V9H21V11M21 13H3V15H21V13Z",xe="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",Se="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",Ce=["alarm-modes","area-controls","bar-gauge","button","climate-fan-modes","climate-hvac-modes","climate-preset-modes","climate-swing-modes","climate-swing-horizontal-modes","counter-actions","cover-open-close","cover-position-favorite","cover-position","cover-tilt-favorite","cover-tilt-position","cover-tilt","date-set","fan-direction","fan-oscillate","fan-preset-modes","fan-speed","humidifier-modes","humidifier-toggle","lawn-mower-commands","light-brightness","light-color-temp","light-color-favorites","lock-commands","lock-open-door","media-player-playback","media-player-sound-mode","media-player-source","media-player-volume-buttons","media-player-volume-slider","numeric-input","precipitation-forecast","select-options","trend-graph","target-humidity","target-temperature","temperature-forecast","toggle","update-actions","vacuum-commands","valve-open-close","valve-position-favorite","valve-position","water-heater-operation-modes"],$e=new Set(["alarm-modes","area-controls","bar-gauge","button","climate-fan-modes","climate-hvac-modes","climate-preset-modes","climate-swing-modes","climate-swing-horizontal-modes","counter-actions","cover-position-favorite","cover-tilt-favorite","fan-preset-modes","humidifier-modes","precipitation-forecast","temperature-forecast","lawn-mower-commands","media-player-playback","light-color-favorites","media-player-sound-mode","media-player-source","media-player-volume-buttons","media-player-volume-slider","numeric-input","select-options","trend-graph","update-actions","vacuum-commands","valve-position-favorite","water-heater-operation-modes"]),ke={"alarm-modes":u.S,"area-controls":m.s,"bar-gauge":v.N,button:g.l,"climate-fan-modes":f.f,"climate-swing-modes":w.W,"climate-swing-horizontal-modes":_.S,"climate-hvac-modes":y.E,"climate-preset-modes":b.p,"counter-actions":x.Q,"cover-open-close":S.O,"cover-position-favorite":C.B,"cover-position":$.H,"cover-tilt-favorite":M.x,"cover-tilt-position":F.C,"cover-tilt":k.l,"date-set":H.Z,"fan-direction":Z.n,"fan-oscillate":V.G,"fan-preset-modes":E.r,"fan-speed":L.Z,"humidifier-modes":I.J,"humidifier-toggle":q.R,"lawn-mower-commands":B.ED,"light-brightness":A._,"light-color-temp":D.a,"light-color-favorites":ne.F,"lock-commands":K.k,"lock-open-door":R.o,"media-player-playback":U.L,"media-player-sound-mode":W.u,"media-player-source":j.d,"media-player-volume-buttons":N.X,"media-player-volume-slider":O.R,"numeric-input":P.Q,"precipitation-forecast":z.t,"select-options":J.N,"trend-graph":Y.E,"target-humidity":Q.V,"target-temperature":G.E,"temperature-forecast":T.q,toggle:X.N,"update-actions":ee.J,"vacuum-commands":te.Ky,"valve-open-close":ae.B,"valve-position-favorite":oe.c,"valve-position":ie.U,"water-heater-operation-modes":re.Y},Me=(0,p.bH)(),Fe={};Me.forEach(e=>{Fe[e.type]=e});const He=(e,t,a)=>{const o=Ce.filter(e=>!a||a.includes(e)),i=Me.map(e=>`${p.IP}${e.type}`);return o.concat(i).filter(a=>Ze(e,t,a))},Ze=(e,t,a)=>{if((0,p.c8)(a)){const o=(0,p.Iu)(a),r=Fe[o];if(!r)return!1;try{if(r.isSupported)return r.isSupported(e,t);if(r.supported){const a=t.entity_id?e.states[t.entity_id]:void 0;return!!a&&r.supported(a)}return!0}catch(i){return!1}}const o=ke[a];return!o||o(e,t)};class ze extends r.WF{_supportsFeatureType(e){return!(!this.hass||!this.context)&&Ze(this.hass,this.context,e)}_getSupportedFeaturesType(){return this.hass&&this.context?He(this.hass,this.context,this.featuresTypes):[]}_isFeatureTypeEditable(e){if((0,p.c8)(e)){const t=(0,p.Iu)(e),a=Fe[t];return null==a?void 0:a.configurable}return $e.has(e)}_getFeatureTypeLabel(e){if((0,p.c8)(e)){const t=(0,p.Iu)(e),a=Fe[t];return(null==a?void 0:a.name)||e}return this.hass.localize(`ui.panel.lovelace.editor.features.types.${e}.label`)||e}_getKey(e){return this._featuresKeys.has(e)||this._featuresKeys.set(e,Math.random().toString()),this._featuresKeys.get(e)}render(){if(!this.features||!this.hass)return r.s6;const e=this._getSupportedFeaturesType(),t=e.filter(e=>!(0,p.c8)(e)),a=e.filter(e=>(0,p.c8)(e));return(0,r.qy)(de||(de=be` ${0} <ha-sortable handle-selector=".handle" @item-moved="${0}"> <div class="features"> ${0} </div> </ha-sortable> ${0} `),0===e.length&&0===this.features.length?(0,r.qy)(ce||(ce=be` <ha-alert type="info"> ${0} </ha-alert> `),this.hass.localize("ui.panel.lovelace.editor.features.no_compatible_available")):r.s6,this._featureMoved,(0,n.u)(this.features,e=>this._getKey(e),(e,t)=>{const a=e.type,o=this._supportsFeatureType(a),i=this._isFeatureTypeEditable(a);return(0,r.qy)(he||(he=be` <div class="feature"> <div class="handle"> <ha-svg-icon .path="${0}"></ha-svg-icon> </div> <div class="feature-content"> <div> <span> ${0} </span> ${0} </div> </div> ${0} <ha-icon-button .label="${0}" .path="${0}" class="remove-icon" .index="${0}" @click="${0}"></ha-icon-button> </div> `),we,this._getFeatureTypeLabel(a),this.context&&!o?(0,r.qy)(pe||(pe=be` <span class="secondary"> ${0} </span> `),this.hass.localize("ui.panel.lovelace.editor.features.not_compatible")):r.s6,i?(0,r.qy)(ue||(ue=be` <ha-icon-button .label="${0}" .path="${0}" class="edit-icon" .index="${0}" @click="${0}" .disabled="${0}"></ha-icon-button> `),this.hass.localize("ui.panel.lovelace.editor.features.edit"),xe,t,this._editFeature,!o):r.s6,this.hass.localize("ui.panel.lovelace.editor.features.remove"),_e,t,this._removeFeature)}),e.length>0?(0,r.qy)(me||(me=be` <ha-dropdown @wa-select="${0}"> <ha-button slot="trigger" appearance="filled" size="small"> <ha-svg-icon .path="${0}" slot="start"></ha-svg-icon> ${0} </ha-button> ${0} ${0} ${0} </ha-dropdown> `),this._addFeature,Se,this.hass.localize("ui.panel.lovelace.editor.features.add"),t.map(e=>(0,r.qy)(ve||(ve=be` <ha-dropdown-item .value="${0}"> ${0} </ha-dropdown-item> `),e,this._getFeatureTypeLabel(e))),t.length>0&&a.length>0?(0,r.qy)(ge||(ge=be`<wa-divider></wa-divider>`)):r.s6,a.map(e=>(0,r.qy)(fe||(fe=be` <ha-dropdown-item .value="${0}"> ${0} </ha-dropdown-item> `),e,this._getFeatureTypeLabel(e)))):r.s6)}async _addFeature(e){const t=e.detail.item.value;if(!t)return;const a=await(0,se.h)(t);let o;if(a&&a.getStubConfig)try{o=await a.getStubConfig(this.hass,this.context)}catch(r){const e=this.context.entity_id?this.hass.states[this.context.entity_id]:void 0;o=await a.getStubConfig(this.hass,e)}else o={type:t};const i=this.features.concat(o);(0,l.r)(this,"features-changed",{features:i})}_featureMoved(e){e.stopPropagation();const{oldIndex:t,newIndex:a}=e.detail,o=this.features.concat();o.splice(a,0,o.splice(t,1)[0]),(0,l.r)(this,"features-changed",{features:o})}_removeFeature(e){const t=e.currentTarget.index,a=this.features.concat();a.splice(t,1),(0,l.r)(this,"features-changed",{features:a})}_editFeature(e){const t=e.currentTarget.index;(0,l.r)(this,"edit-detail-element",{subElementConfig:{index:t,type:"feature",elementConfig:this.features[t]}})}constructor(...e){super(...e),this._featuresKeys=new WeakMap}}ze.styles=(0,r.AH)(ye||(ye=be`:host{display:flex!important;flex-direction:column}ha-dropdown{display:inline-block;align-self:flex-start;margin-top:var(--ha-space-2)}.feature{display:flex;align-items:center}.feature .handle{cursor:move;cursor:grab;padding-right:var(--ha-space-2);padding-inline-end:var(--ha-space-2);padding-inline-start:initial;direction:var(--direction)}.feature .handle>*{pointer-events:none}.feature-content{height:var(--ha-space-15);font-size:var(--ha-font-size-l);display:flex;align-items:center;justify-content:space-between;flex-grow:1}.feature-content div{display:flex;flex-direction:column}.edit-icon,.remove-icon{--ha-icon-button-size:var(--ha-space-9);color:var(--secondary-text-color)}.secondary{font-size:var(--ha-font-size-s);color:var(--secondary-text-color)}li[divider]{border-bottom-color:var(--divider-color)}`)),(0,i.Cg)([(0,s.MZ)({attribute:!1})],ze.prototype,"hass",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],ze.prototype,"context",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],ze.prototype,"features",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],ze.prototype,"featuresTypes",void 0),(0,i.Cg)([(0,s.MZ)()],ze.prototype,"label",void 0),ze=(0,i.Cg)([(0,s.EM)("hui-card-features-editor")],ze),o()}catch(de){o(de)}})}}]);