iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 12 kB
JavaScript
export const __webpack_ids__=["40955"];export const __webpack_modules__={62801:function(e,t,a){var i=a(44249),o=a(72621),r=(a(9359),a(56475),a(22139),a(57243)),n=a(15093),s=a(36522);(0,i.Z)([(0,n.Mo)("ha-sortable")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",key:"_sortable",value:void 0},{kind:"field",decorators:[(0,n.Cb)({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[(0,n.Cb)({type:Boolean,attribute:"no-style"})],key:"noStyle",value:()=>!1},{kind:"field",decorators:[(0,n.Cb)({type:String,attribute:"draggable-selector"})],key:"draggableSelector",value:void 0},{kind:"field",decorators:[(0,n.Cb)({type:String,attribute:"handle-selector"})],key:"handleSelector",value:void 0},{kind:"field",decorators:[(0,n.Cb)({type:String,attribute:"filter"})],key:"filter",value:void 0},{kind:"field",decorators:[(0,n.Cb)({type:String})],key:"group",value:void 0},{kind:"field",decorators:[(0,n.Cb)({type:Boolean,attribute:"invert-swap"})],key:"invertSwap",value:()=>!1},{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"options",value:void 0},{kind:"field",decorators:[(0,n.Cb)({type:Boolean})],key:"rollback",value:()=>!0},{kind:"method",key:"updated",value:function(e){e.has("disabled")&&(this.disabled?this._destroySortable():this._createSortable())}},{kind:"field",key:"_shouldBeDestroy",value:()=>!1},{kind:"method",key:"disconnectedCallback",value:function(){(0,o.Z)(i,"disconnectedCallback",this,3)([]),this._shouldBeDestroy=!0,setTimeout((()=>{this._shouldBeDestroy&&(this._destroySortable(),this._shouldBeDestroy=!1)}),1)}},{kind:"method",key:"connectedCallback",value:function(){(0,o.Z)(i,"connectedCallback",this,3)([]),this._shouldBeDestroy=!1,this.hasUpdated&&!this.disabled&&this._createSortable()}},{kind:"method",key:"createRenderRoot",value:function(){return this}},{kind:"method",key:"render",value:function(){return this.noStyle?r.Ld:r.dy` <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:4px;opacity:.4}.sortable-drag{border-radius:4px;opacity:1;background:var(--card-background-color);box-shadow:0px 4px 8px 3px #00000026;cursor:grabbing}</style> `}},{kind:"method",key:"_createSortable",value:async function(){if(this._sortable)return;const e=this.children[0];if(!e)return;const t=(await Promise.all([a.e("34153"),a.e("467")]).then(a.bind(a,59807))).default,i={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&&(i.draggable=this.draggableSelector),this.handleSelector&&(i.handle=this.handleSelector),void 0!==this.invertSwap&&(i.invertSwap=this.invertSwap),this.group&&(i.group=this.group),this.filter&&(i.filter=this.filter),this._sortable=new t(e,i)}},{kind:"field",key:"_handleUpdate",value(){return e=>{(0,s.B)(this,"item-moved",{newIndex:e.newIndex,oldIndex:e.oldIndex})}}},{kind:"field",key:"_handleAdd",value(){return e=>{(0,s.B)(this,"item-added",{index:e.newIndex,data:e.item.sortableData})}}},{kind:"field",key:"_handleRemove",value(){return e=>{(0,s.B)(this,"item-removed",{index:e.oldIndex})}}},{kind:"field",key:"_handleEnd",value(){return async e=>{(0,s.B)(this,"drag-end"),this.rollback&&e.item.placeholder&&(e.item.placeholder.replaceWith(e.item),delete e.item.placeholder)}}},{kind:"field",key:"_handleStart",value(){return()=>{(0,s.B)(this,"drag-start")}}},{kind:"field",key:"_handleChoose",value(){return e=>{this.rollback&&(e.item.placeholder=document.createComment("sort-placeholder"),e.item.after(e.item.placeholder))}}},{kind:"method",key:"_destroySortable",value:function(){this._sortable&&(this._sortable.destroy(),this._sortable=void 0)}}]}}),r.oi)},71295:function(e,t,a){a.a(e,(async function(e,i){try{a.d(t,{Bc:()=>G});var o=a(44249),r=(a(9359),a(56475),a(31526),a(70104),a(92519),a(42179),a(89256),a(24931),a(88463),a(57449),a(19814),a(57243)),n=a(15093),s=a(91583),d=a(36522),l=a(49976),c=(a(59826),a(23334),a(7285),a(62801),a(37583),a(17951)),u=a(81440),h=a(80323),p=a(91455),m=a(99192),f=a(21271),v=a(19638),y=a(40699),b=a(2712),k=a(81644),g=a(63525),_=a(50662),x=a(66967),w=a(64796),H=a(42359),S=a(43458),V=a(84988),$=a(33777),C=a(34318),M=a(57220),T=a(37841),F=a(2855),L=a(20427),B=a(97908),z=a(38273),I=a(56107),A=a(63025),Z=a(93738),j=a(12139),E=a(28973),K=a(86609),O=e([u,h,f,v,m,k,_,x,w,H,$,C,F,L,z,I,Z,E,K]);[u,h,f,v,m,k,_,x,w,H,$,C,F,L,z,I,Z,E,K]=O.then?(await O)():O;const D="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",R="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",U="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",N="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",P=["alarm-modes","climate-fan-modes","climate-hvac-modes","climate-preset-modes","climate-swing-modes","climate-swing-horizontal-modes","counter-actions","cover-open-close","cover-position","cover-tilt-position","cover-tilt","fan-preset-modes","fan-speed","humidifier-modes","humidifier-toggle","lawn-mower-commands","light-brightness","light-color-temp","lock-commands","lock-open-door","media-player-volume-slider","numeric-input","select-options","target-humidity","target-temperature","toggle","update-actions","vacuum-commands","water-heater-operation-modes"],W=new Set(["alarm-modes","climate-fan-modes","climate-hvac-modes","climate-preset-modes","climate-swing-modes","climate-swing-horizontal-modes","counter-actions","fan-preset-modes","humidifier-modes","lawn-mower-commands","numeric-input","select-options","update-actions","vacuum-commands","water-heater-operation-modes"]),J={"alarm-modes":u.p,"climate-fan-modes":h.o,"climate-swing-modes":f.z,"climate-swing-horizontal-modes":v.Z,"climate-hvac-modes":p.C,"climate-preset-modes":m.v,"counter-actions":y.g,"cover-open-close":b.C,"cover-position":k.K,"cover-tilt-position":_.z,"cover-tilt":g.g,"fan-preset-modes":x.N,"fan-speed":w.U,"humidifier-modes":H.v,"humidifier-toggle":S.S,"lawn-mower-commands":V.or,"light-brightness":$.T,"light-color-temp":C.A,"lock-commands":M.R,"lock-open-door":T.z,"media-player-volume-slider":F.m,"numeric-input":L.L,"select-options":B.g,"target-humidity":z.J,"target-temperature":I.z,toggle:A.S,"update-actions":Z.s,"vacuum-commands":j.NA,"water-heater-operation-modes":E.F},Q=(0,c.tS)(),q={};Q.forEach((e=>{q[e.type]=e}));const G=(e,t)=>{const a=P.filter((e=>!t||t.includes(e))),i=Q.map((e=>`${c.Qo}${e.type}`));return a.concat(i).filter((t=>X(e,t)))},X=(e,t)=>{if((0,c.IT)(t)){const a=(0,c.V0)(t),i=q[a];if(!i?.supported)return!0;try{return i.supported(e)}catch{return!1}}const a=J[t];return!a||a(e)};(0,o.Z)([(0,n.Mo)("hui-card-features-editor")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"stateObj",value:void 0},{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"features",value:void 0},{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"featuresTypes",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"label",value:void 0},{kind:"field",key:"_featuresKeys",value:()=>new WeakMap},{kind:"method",key:"_supportsFeatureType",value:function(e){return!!this.stateObj&&X(this.stateObj,e)}},{kind:"method",key:"_getSupportedFeaturesType",value:function(){return this.stateObj?G(this.stateObj,this.featuresTypes):[]}},{kind:"method",key:"_isFeatureTypeEditable",value:function(e){if((0,c.IT)(e)){const t=(0,c.V0)(e),a=q[t];return a?.configurable}return W.has(e)}},{kind:"method",key:"_getFeatureTypeLabel",value:function(e){if((0,c.IT)(e)){const t=(0,c.V0)(e),a=q[t];return a?.name||e}return this.hass.localize(`ui.panel.lovelace.editor.features.types.${e}.label`)||e}},{kind:"method",key:"_getKey",value:function(e){return this._featuresKeys.has(e)||this._featuresKeys.set(e,Math.random().toString()),this._featuresKeys.get(e)}},{kind:"method",key:"render",value:function(){if(!this.features||!this.hass)return r.Ld;const e=this._getSupportedFeaturesType(),t=e.filter((e=>!(0,c.IT)(e))),a=e.filter((e=>(0,c.IT)(e)));return r.dy` ${0===e.length&&0===this.features.length?r.dy` <ha-alert type="info"> ${this.hass.localize("ui.panel.lovelace.editor.features.no_compatible_available")} </ha-alert> `:r.Ld} <ha-sortable handle-selector=".handle" -moved="${this._featureMoved}"> <div class="features"> ${(0,s.r)(this.features,(e=>this._getKey(e)),((e,t)=>{const a=e.type,i=this._supportsFeatureType(a),o=this._isFeatureTypeEditable(a);return r.dy` <div class="feature"> <div class="handle"> <ha-svg-icon .path="${R}"></ha-svg-icon> </div> <div class="feature-content"> <div> <span> ${this._getFeatureTypeLabel(a)} </span> ${this.stateObj&&!i?r.dy` <span class="secondary"> ${this.hass.localize("ui.panel.lovelace.editor.features.not_compatible")} </span> `:r.Ld} </div> </div> ${o?r.dy` <ha-icon-button .label="${this.hass.localize("ui.panel.lovelace.editor.features.edit")}" .path="${U}" class="edit-icon" .index="${t}" ="${this._editFeature}" .disabled="${!i}"></ha-icon-button> `:r.Ld} <ha-icon-button .label="${this.hass.localize("ui.panel.lovelace.editor.features.remove")}" .path="${D}" class="remove-icon" .index="${t}" ="${this._removeFeature}"></ha-icon-button> </div> `}))} </div> </ha-sortable> ${e.length>0?r.dy` <ha-button-menu fixed ="${this._addFeature}" ="${l.U}"> <ha-button slot="trigger" outlined .label="${this.hass.localize("ui.panel.lovelace.editor.features.add")}"> <ha-svg-icon .path="${N}" slot="icon"></ha-svg-icon> </ha-button> ${t.map((e=>r.dy` <ha-list-item .value="${e}"> ${this._getFeatureTypeLabel(e)} </ha-list-item> `))} ${t.length>0&&a.length>0?r.dy`<li divider role="separator"></li>`:r.Ld} ${a.map((e=>r.dy` <ha-list-item .value="${e}"> ${this._getFeatureTypeLabel(e)} </ha-list-item> `))} </ha-button-menu> `:r.Ld} `}},{kind:"method",key:"_addFeature",value:async function(e){const t=e.detail.index;if(null==t)return;const a=this._getSupportedFeaturesType()[t];if(!a)return;const i=await(0,K.A)(a);let o;o=i&&i.getStubConfig?await i.getStubConfig(this.hass,this.stateObj):{type:a};const r=this.features.concat(o);(0,d.B)(this,"features-changed",{features:r})}},{kind:"method",key:"_featureMoved",value:function(e){e.stopPropagation();const{oldIndex:t,newIndex:a}=e.detail,i=this.features.concat();i.splice(a,0,i.splice(t,1)[0]),(0,d.B)(this,"features-changed",{features:i})}},{kind:"method",key:"_removeFeature",value:function(e){const t=e.currentTarget.index,a=this.features.concat();a.splice(t,1),(0,d.B)(this,"features-changed",{features:a})}},{kind:"method",key:"_editFeature",value:function(e){const t=e.currentTarget.index;(0,d.B)(this,"edit-detail-element",{subElementConfig:{index:t,type:"feature",elementConfig:this.features[t]}})}},{kind:"field",static:!0,key:"styles",value:()=>r.iv`:host{display:flex!important;flex-direction:column}ha-button-menu{margin-top:8px}.feature{display:flex;align-items:center}.feature .handle{cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction)}.feature .handle>*{pointer-events:none}.feature-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:space-between;flex-grow:1}.feature-content div{display:flex;flex-direction:column}.edit-icon,.remove-icon{--mdc-icon-button-size:36px;color:var(--secondary-text-color)}.secondary{font-size:12px;color:var(--secondary-text-color)}li[divider]{border-bottom-color:var(--divider-color)}`}]}}),r.oi);i()}catch(e){i(e)}}))}};
//# sourceMappingURL=40955.8ba89ec1c2ea01d3.js.map