iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
3 lines • 19.8 kB
JavaScript
/*! For license information please see chunk.5073a838b97405d7bb7a.js.LICENSE.txt */
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[3122],{90440:function(e,t,n){"use strict";function i(e){return void 0===e&&(e=window),!!function(e){void 0===e&&(e=window);var t=!1;try{var n={get passive(){return t=!0,!1}},i=function(){};e.document.addEventListener("test",i,n),e.document.removeEventListener("test",i,n)}catch(r){t=!1}return t}(e)&&{passive:!0}}n.d(t,{K:function(){return i}})},82653:function(e,t,n){"use strict";n.r(t),n.d(t,{HuiConditionalCardEditor:function(){return R}});n(87482),n(91441);var i=n(15652),r=n(4268),o=n(47181),a=(n(74535),n(32979),n(52231),n(45890));function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(){var e=y(["\n paper-tabs {\n --paper-tabs-selection-bar-color: var(--primary-color);\n --paper-tab-ink: var(--primary-color);\n border-bottom: 1px solid var(--divider-color);\n }\n .conditions {\n margin-top: 8px;\n }\n .condition {\n margin-top: 8px;\n border: 1px solid var(--divider-color);\n padding: 12px;\n }\n .condition .state {\n display: flex;\n align-items: flex-end;\n }\n .condition .state paper-dropdown-menu {\n margin-right: 16px;\n }\n .condition .state paper-input {\n flex-grow: 1;\n }\n\n .card {\n margin-top: 8px;\n border: 1px solid var(--divider-color);\n padding: 12px;\n }\n @media (max-width: 450px) {\n .card,\n .condition {\n margin: 8px -12px 0;\n }\n }\n .card .card-options {\n display: flex;\n justify-content: flex-end;\n width: 100%;\n }\n .gui-mode-button {\n margin-right: auto;\n }\n "]);return c=function(){return e},e}function d(e){return function(e){if(Array.isArray(e))return S(e)}(e)||D(e)||T(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(){var e=y(['\n <div class="condition">\n <div class="entity">\n <ha-entity-picker\n .hass=',"\n .value=","\n .index=","\n .configValue=","\n @change=",'\n allow-custom-entity\n ></ha-entity-picker>\n </div>\n <div class="state">\n <paper-dropdown-menu>\n <paper-listbox\n .selected=','\n slot="dropdown-content"\n .index=',"\n .configValue=","\n @selected-item-changed=","\n >\n <paper-item\n >","</paper-item\n >\n <paper-item\n >",'</paper-item\n >\n </paper-listbox>\n </paper-dropdown-menu>\n <paper-input\n .label="'," (",": '","')\"\n .value=","\n .index=","\n .configValue=","\n @value-changed=","\n ></paper-input>\n </div>\n </div>\n "]);return l=function(){return e},e}function u(){var e=y(['\n <div class="conditions">\n ',"\n ",'\n <div class="condition">\n <ha-entity-picker\n .hass=',"\n @change=","\n ></ha-entity-picker>\n </div>\n </div>\n "]);return u=function(){return e},e}function f(){var e=y(["\n <hui-card-picker\n .hass=","\n .lovelace=","\n @config-changed=","\n ></hui-card-picker>\n "]);return f=function(){return e},e}function p(){var e=y(['\n <div class="card-options">\n <mwc-button\n @click=',"\n .disabled=",'\n class="gui-mode-button"\n >\n ',"\n </mwc-button>\n <mwc-button @click=","\n >","</mwc-button\n >\n </div>\n <hui-element-editor\n .hass=","\n .value=","\n .lovelace=","\n @config-changed=","\n @GUImode-changed=","\n ></hui-element-editor>\n "]);return p=function(){return e},e}function h(){var e=y(['\n <div class="card">\n ',"\n </div>\n "]);return h=function(){return e},e}function v(){var e=y(["\n <paper-tabs\n .selected=","\n @iron-select=","\n >\n <paper-tab\n >","</paper-tab\n >\n <paper-tab\n >","</paper-tab\n >\n </paper-tabs>\n ","\n "]);return v=function(){return e},e}function m(){var e=y([""]);return m=function(){return e},e}function y(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=E(e);if(t){var r=E(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return k(this,n)}}function k(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?w(e):t}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(){x=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(n){t.forEach((function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var r=t.placement;if(t.kind===i&&("static"===r||"prototype"===r)){var o="static"===r?e:n;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var i=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],i=[],r={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,r)}),this),e.forEach((function(e){if(!j(e))return n.push(e);var t=this.decorateElement(e,r);n.push(t.element),n.push.apply(n,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:n,finishers:i};var o=this.decorateConstructor(n,t);return i.push.apply(i,o.finishers),o.finishers=i,o},addElementPlacement:function(e,t,n){var i=t[e.placement];if(!n&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var n=[],i=[],r=e.decorators,o=r.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,r[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&i.push(c.finisher);var d=c.extras;if(d){for(var l=0;l<d.length;l++)this.addElementPlacement(d[l],t);n.push.apply(n,d)}}return{element:e,finishers:i,extras:n}},decorateConstructor:function(e,t){for(var n=[],i=t.length-1;i>=0;i--){var r=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[i])(r)||r);if(void 0!==o.finisher&&n.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||D(t)||T(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=z(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+i+'"');var r=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:n,placement:i,descriptor:Object.assign({},r)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(r,"get","The property descriptor of a field descriptor"),this.disallowProperty(r,"set","The property descriptor of a field descriptor"),this.disallowProperty(r,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:O(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=O(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var i=(0,t[n])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function C(e){var t,n=z(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var i={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function P(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function j(e){return e.decorators&&e.decorators.length}function A(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function O(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function z(e){var t=function(e,t){if("object"!==s(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==s(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===s(t)?t:String(t)}function T(e,t){if(e){if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,t):void 0}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function D(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}var I=(0,r.Ry)({entity:(0,r.Z_)(),state:(0,r.jt)((0,r.Z_)()),state_not:(0,r.jt)((0,r.Z_)())}),M=(0,r.Ry)({type:(0,r.Z_)(),card:(0,r.Yj)(),conditions:(0,r.jt)((0,r.IX)(I))}),R=function(e,t,n,i){var r=x();if(i)for(var o=0;o<i.length;o++)r=i[o](r);var a=t((function(e){r.initializeInstanceElements(e,s.elements)}),n),s=r.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},i=0;i<e.length;i++){var r,o=e[i];if("method"===o.kind&&(r=t.find(n)))if(A(o.descriptor)||A(r.descriptor)){if(j(o)||j(r))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");r.descriptor=o.descriptor}else{if(j(o)){if(j(r))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");r.decorators=o.decorators}P(o,r)}else t.push(o)}return t}(a.d.map(C)),e);return r.initializeClassElements(a.F,s.elements),r.runClassFinishers(a.F,s.finishers)}([(0,i.Mo)("hui-conditional-card-editor")],(function(e,t){return{F:function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(i,t);var n=_(i);function i(){var t;g(this,i);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return t=n.call.apply(n,[this].concat(o)),e(w(t)),t}return i}(t),d:[{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"lovelace",value:void 0},{kind:"field",decorators:[(0,i.sz)()],key:"_config",value:void 0},{kind:"field",decorators:[(0,i.sz)()],key:"_GUImode",value:function(){return!0}},{kind:"field",decorators:[(0,i.sz)()],key:"_guiModeAvailable",value:function(){return!0}},{kind:"field",decorators:[(0,i.sz)()],key:"_cardTab",value:function(){return!1}},{kind:"field",decorators:[(0,i.IO)("hui-element-editor")],key:"_cardEditorEl",value:void 0},{kind:"method",key:"setConfig",value:function(e){(0,r.hu)(e,M),this._config=e}},{kind:"method",key:"refreshYamlEditor",value:function(e){var t;null===(t=this._cardEditorEl)||void 0===t||t.refreshYamlEditor(e)}},{kind:"method",key:"render",value:function(){var e=this;return this.hass&&this._config?(0,i.dy)(v(),this._cardTab?"1":"0",this._selectTab,this.hass.localize("ui.panel.lovelace.editor.card.conditional.conditions"),this.hass.localize("ui.panel.lovelace.editor.card.conditional.card"),this._cardTab?(0,i.dy)(h(),void 0!==this._config.card.type?(0,i.dy)(p(),this._toggleMode,!this._guiModeAvailable,this.hass.localize(!this._cardEditorEl||this._GUImode?"ui.panel.lovelace.editor.edit_card.show_code_editor":"ui.panel.lovelace.editor.edit_card.show_visual_editor"),this._handleReplaceCard,this.hass.localize("ui.panel.lovelace.editor.card.conditional.change_type"),this.hass,this._config.card,this.lovelace,this._handleCardChanged,this._handleGUIModeChanged):(0,i.dy)(f(),this.hass,this.lovelace,this._handleCardPicked)):(0,i.dy)(u(),this.hass.localize("ui.panel.lovelace.editor.card.conditional.condition_explanation"),this._config.conditions.map((function(t,n){var r;return(0,i.dy)(l(),e.hass,t.entity,n,"entity",e._changeCondition,void 0!==t.state_not?1:0,n,"invert",e._changeCondition,e.hass.localize("ui.panel.lovelace.editor.card.conditional.state_equal"),e.hass.localize("ui.panel.lovelace.editor.card.conditional.state_not_equal"),e.hass.localize("ui.panel.lovelace.editor.card.generic.state"),e.hass.localize("ui.panel.lovelace.editor.card.conditional.current_state"),null===(r=e.hass)||void 0===r?void 0:r.states[t.entity].state,void 0!==t.state_not?t.state_not:t.state,n,"state",e._changeCondition)})),this.hass,this._addCondition)):(0,i.dy)(m())}},{kind:"method",key:"_selectTab",value:function(e){this._cardTab=1===parseInt(e.target.selected,10)}},{kind:"method",key:"_toggleMode",value:function(){var e;null===(e=this._cardEditorEl)||void 0===e||e.toggleMode()}},{kind:"method",key:"_setMode",value:function(e){this._GUImode=e,this._cardEditorEl&&(this._cardEditorEl.GUImode=e)}},{kind:"method",key:"_handleGUIModeChanged",value:function(e){e.stopPropagation(),this._GUImode=e.detail.guiMode,this._guiModeAvailable=e.detail.guiModeAvailable}},{kind:"method",key:"_handleCardPicked",value:function(e){e.stopPropagation(),this._config&&(this._setMode(!0),this._guiModeAvailable=!0,this._config=Object.assign({},this._config,{card:e.detail.config}),(0,o.B)(this,"config-changed",{config:this._config}))}},{kind:"method",key:"_handleCardChanged",value:function(e){e.stopPropagation(),this._config&&(this._config=Object.assign({},this._config,{card:e.detail.config}),this._guiModeAvailable=e.detail.guiModeAvailable,(0,o.B)(this,"config-changed",{config:this._config}))}},{kind:"method",key:"_handleReplaceCard",value:function(){this._config&&(this._config=Object.assign({},this._config,{card:{}}),(0,o.B)(this,"config-changed",{config:this._config}))}},{kind:"method",key:"_addCondition",value:function(e){var t=e.target;if(""!==t.value&&this._config){var n=d(this._config.conditions);n.push({entity:t.value,state:""}),this._config=Object.assign({},this._config,{conditions:n}),t.value="",(0,o.B)(this,"config-changed",{config:this._config})}}},{kind:"method",key:"_changeCondition",value:function(e){var t=e.target;if(this._config&&t){var n=d(this._config.conditions);if("entity"===t.configValue&&""===t.value)n.splice(t.index,1);else{var i=Object.assign({},n[t.index]);"entity"===t.configValue?i.entity=t.value:"state"===t.configValue?void 0!==i.state_not?i.state_not=t.value:i.state=t.value:"invert"===t.configValue&&(1===t.selected?i.state&&(i.state_not=i.state,delete i.state):i.state_not&&(i.state=i.state_not,delete i.state_not)),n[t.index]=i}this._config=Object.assign({},this._config,{conditions:n}),(0,o.B)(this,"config-changed",{config:this._config})}}},{kind:"get",static:!0,key:"styles",value:function(){return[a.A,(0,i.iv)(c())]}}]}}),i.oi)}}]);
//# sourceMappingURL=chunk.5073a838b97405d7bb7a.js.map