diff --git a/README.md b/README.md index bb4b9bd..9c79ea7 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ [![License][license-shield]](LICENSE.md) [![hacs_badge](https://img.shields.io/badge/HACS-default-orange.svg?style=for-the-badge)](https://github.com/custom-components/hacs) -Display the options of an `input_select` entity as a clickable list card. +Display the options of an `input_select` or a `select` entity as a clickable list card. In other words: the content of the dropdown menu is displayed as a card. -The `input_select.select_option` service is called after the user clicks (selects) an option. +The `(input_)select.select_option` service is called after the user clicks (selects) an option. Some use cases: * Select with too many options to show in dropdown @@ -27,16 +27,16 @@ Select List Card supports Lovelace's Visual Editor. Click the + button to add a ### Options -| Name | Type | Default | Description | -| ------------------ | ------- | ------------ | --------------------------------------------------------------------------- | -| type | string | **required** | `custom:select-list-card` | -| entity | string | **required** | An entity_id within the `input_select` domain. | -| title | string | `` | Card header title | -| icon | string | `` | Card header icon | -| show_toggle | boolean | `false` | Card header toggle | -| truncate | boolean | `true` | Truncate option text to fit 1 line | -| scroll_to_selected | boolean | `true` | Scroll the list to the position of the selected option | -| max_options | number | `5` | Number of options before a scrollbar appears, 0 = no scrollbar | +| Name | Type | Default | Description | +| ------------------ | ------- | ------------ |----------------------------------------------------------------| +| type | string | **required** | `custom:select-list-card` | +| entity | string | **required** | An entity_id within the `input_select` or `select` domain. | +| title | string | `` | Card header title | +| icon | string | `` | Card header icon | +| show_toggle | boolean | `false` | Card header toggle | +| truncate | boolean | `true` | Truncate option text to fit 1 line | +| scroll_to_selected | boolean | `true` | Scroll the list to the position of the selected option | +| max_options | number | `5` | Number of options before a scrollbar appears, 0 = no scrollbar | diff --git a/dist/select-list-card.js b/dist/select-list-card.js index b10e5eb..ae74adc 100644 --- a/dist/select-list-card.js +++ b/dist/select-list-card.js @@ -183,7 +183,7 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.3.1");const se={};class ie extends W{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const e=this.getStyles();if(void 0===e)this._styles=[];else if(Array.isArray(e)){const t=(e,s)=>e.reduceRight((e,s)=>Array.isArray(s)?t(s,e):(e.add(s),e),s),s=t(e,new Set),i=[];s.forEach(e=>i.unshift(e)),this._styles=i}else this._styles=[e]}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?Q?this.renderRoot.adoptedStyleSheets=e.map(e=>e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){const t=this.render();super.update(e),t!==se&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){return se}}ie.finalized=!0,ie.render=(e,t,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,r=A.has(t),o=U&&11===t.nodeType&&!!t.host,a=o&&!H.has(n),l=a?document.createDocumentFragment():t;if(((e,t,i)=>{let n=A.get(t);void 0===n&&(s(t,t.firstChild),A.set(t,n=new P(Object.assign({templateFactory:O},i))),n.appendInto(t)),n.setValue(e),n.commit()})(e,l,Object.assign({templateFactory:Y(n)},i)),a){const e=A.get(l);A.delete(l);const i=e.value instanceof y?e.value.template:void 0;q(n,l,i),s(t,t.firstChild),t.appendChild(l),A.set(t,e)}!r&&o&&window.ShadyCSS.styleElement(t.host)};var ne=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,re="[^\\s]+",oe=/\[([^]*?)\]/gm;function ae(e,t){for(var s=[],i=0,n=e.length;i-1?i:null}};function ce(e){for(var t=[],s=1;s3?0:(e-e%10!=10?1:0)*e%10]}},ge=ce({},pe),me=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length0?"-":"+")+me(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+me(Math.floor(Math.abs(t)/60),2)+":"+me(Math.abs(t)%60,2)}},_e=function(e){return+e-1},ye=[null,"[1-9]\\d?"],ve=[null,re],be=["isPm",re,function(e,t){var s=e.toLowerCase();return s===t.amPm[0]?0:s===t.amPm[1]?1:null}],we=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var s=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?s:-s}return 0}],Se=(le("monthNamesShort"),le("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var xe=function(e,t,s){if(void 0===t&&(t=Se.default),void 0===s&&(s={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var i=[];t=(t=Se[t]||t).replace(oe,(function(e,t){return i.push(t),"@@@"}));var n=ce(ce({},ge),s);return(t=t.replace(ne,(function(t){return fe[t](e,n)}))).replace(/@@@/g,(function(){return i.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}})(),function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}}();var ke="hass:bookmark",Pe={alert:"hass:alert",automation:"hass:playlist-play",calendar:"hass:calendar",camera:"hass:video",climate:"hass:thermostat",configurator:"hass:settings",conversation:"hass:text-to-speech",device_tracker:"hass:account",fan:"hass:fan",group:"hass:google-circles-communities",history_graph:"hass:chart-line",homeassistant:"hass:home-assistant",homekit:"hass:home-automation",image_processing:"hass:image-filter-frames",input_boolean:"hass:drawing",input_datetime:"hass:calendar-clock",input_number:"hass:ray-vertex",input_select:"hass:format-list-bulleted",input_text:"hass:textbox",light:"hass:lightbulb",mailbox:"hass:mailbox",notify:"hass:comment-alert",person:"hass:account",plant:"hass:flower",proximity:"hass:apple-safari",remote:"hass:remote",scene:"hass:google-pages",script:"hass:file-document",sensor:"hass:eye",simple_alarm:"hass:bell",sun:"hass:white-balance-sunny",switch:"hass:flash",timer:"hass:timer",updater:"hass:cloud-upload",vacuum:"hass:robot-vacuum",water_heater:"hass:thermometer",weblink:"hass:open-in-new"};function Ce(e,t){if(e in Pe)return Pe[e];switch(e){case"alarm_control_panel":switch(t){case"armed_home":return"hass:bell-plus";case"armed_night":return"hass:bell-sleep";case"disarmed":return"hass:bell-outline";case"triggered":return"hass:bell-ring";default:return"hass:bell"}case"binary_sensor":return t&&"off"===t?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===t?"hass:window-closed":"hass:window-open";case"lock":return t&&"unlocked"===t?"hass:lock-open":"hass:lock";case"media_player":return t&&"off"!==t&&"idle"!==t?"hass:cast-connected":"hass:cast";case"zwave":switch(t){case"dead":return"hass:emoticon-dead";case"sleeping":return"hass:sleep";case"initializing":return"hass:timer-sand";default:return"hass:z-wave"}default:return console.warn("Unable to find icon for domain "+e+" ("+t+")"),ke}}var Ne={humidity:"hass:water-percent",illuminance:"hass:brightness-5",temperature:"hass:thermometer",pressure:"hass:gauge",power:"hass:flash",signal_strength:"hass:wifi"},Te={binary_sensor:function(e){var t=e.state&&"off"===e.state;switch(e.attributes.device_class){case"battery":return t?"hass:battery":"hass:battery-outline";case"cold":return t?"hass:thermometer":"hass:snowflake";case"connectivity":return t?"hass:server-network-off":"hass:server-network";case"door":return t?"hass:door-closed":"hass:door-open";case"garage_door":return t?"hass:garage":"hass:garage-open";case"gas":case"power":case"problem":case"safety":case"smoke":return t?"hass:shield-check":"hass:alert";case"heat":return t?"hass:thermometer":"hass:fire";case"light":return t?"hass:brightness-5":"hass:brightness-7";case"lock":return t?"hass:lock":"hass:lock-open";case"moisture":return t?"hass:water-off":"hass:water";case"motion":return t?"hass:walk":"hass:run";case"occupancy":return t?"hass:home-outline":"hass:home";case"opening":return t?"hass:square":"hass:square-outline";case"plug":return t?"hass:power-plug-off":"hass:power-plug";case"presence":return t?"hass:home-outline":"hass:home";case"sound":return t?"hass:music-note-off":"hass:music-note";case"vibration":return t?"hass:crop-portrait":"hass:vibrate";case"window":return t?"hass:window-closed":"hass:window-open";default:return t?"hass:radiobox-blank":"hass:checkbox-marked-circle"}},cover:function(e){var t="closed"!==e.state;switch(e.attributes.device_class){case"garage":return t?"hass:garage-open":"hass:garage";case"door":return t?"hass:door-open":"hass:door-closed";case"shutter":return t?"hass:window-shutter-open":"hass:window-shutter";case"blind":return t?"hass:blinds-open":"hass:blinds";case"window":return t?"hass:window-open":"hass:window-closed";default:return Ce("cover",e.state)}},sensor:function(e){var t=e.attributes.device_class;if(t&&t in Ne)return Ne[t];if("battery"===t){var s=Number(e.state);if(isNaN(s))return"hass:battery-unknown";var i=10*Math.round(s/10);return i>=100?"hass:battery":i<=0?"hass:battery-alert":"hass:battery-"+i}var n=e.attributes.unit_of_measurement;return"°C"===n||"°F"===n?"hass:thermometer":Ce("sensor")},input_datetime:function(e){return e.attributes.has_date?e.attributes.has_time?Ce("input_datetime"):"hass:calendar":"hass:clock"}},Me=function(e){if(!e)return ke;if(e.attributes.icon)return e.attributes.icon;var t=function(e){return e.substr(0,e.indexOf("."))}(e.entity_id);return t in Te?Te[t](e):Ce(t,e.state)},$e={version:"Version",name:"Select list card",description:"Display the options of an input_select entity as a clickable list card."},Ee={missing_entity:"Entity is required",invalid_configuration:"Invalid configuration",not_available:"Entity is not available"},Oe={entity:"Entity (required)",title:"Card title (optional)",icon:"Icon (optional)",max_options:"Number of options shown (0 = all)",truncate:"Truncate long option name",show_toggle:"Show toggle in header",scroll_to_selected:"Selected option always in view"},Ve={common:$e,error:Ee,editor:Oe},Ae={version:"Versión",name:"Seleccionar tarjeta de la lista",description:"Mostrar las opciones de una entidad input_select como una tarjeta de lista en la que se puede hacer clic."},De={missing_entity:"Se requiere entidad",invalid_configuration:"configuración no válida",not_available:"La entidad no está disponible."},je={entity:"Entidad (requerida)",title:"Título de la tarjeta (opcional)",icon:"Icono (opcional)",max_options:"Número de opciones mostradas (0 = todas)",truncate:"Truncar el nombre de la opción larga",show_toggle:"Mostrar boton deslizante en la cabecera",scroll_to_selected:"Opción seleccionada siempre a la vista"},ze={common:Ae,error:De,editor:je},Ue={version:"Verzió",name:"Select list card",description:"Az input_select megjelenítése mint egy gördíthető, kattintható lista."},Ye={missing_entity:"Entitás megadása kötelező",invalid_configuration:"Hibás konfiguráció",not_available:"Az entitás nem elérhető"},Re={entity:"Entitás (kötelező)",title:"Kártya címe (opcionális)",icon:"Ikon (opcionális)",max_options:"Megjelenített sorok száma (0 = összes)",truncate:"Sor hosszának levágása egységes szélesség érdekében",show_toggle:"Kapcsoló megjelenítése a fejlécben",scroll_to_selected:"Előreugrás a kijelölt sorra"},He={common:Ue,error:Ye,editor:Re},qe={version:"Versie",name:"Select lijst kaart",description:"Toon de opties van een input_select entiteit in een kaart"},Ie={missing_entity:"Het specificeren van een entiteit is verplicht!",invalid_configuration:"Geen geldige configuratie",not_available:"Entiteit is niet beschikbaar"},Fe={entity:"Entiteit (verplicht)",title:"Kaart titel (optioneel)",icon:"Icoon (optioneel)",max_options:"Aantal opties zichtbaar (0 = alles)",truncate:"Kap lange optie name af",show_toggle:"Toon toggle in titel",scroll_to_selected:"Geselecteerde optie altijd zichtbaar"},Le={common:qe,error:Ie,editor:Fe};const We={en:Object.freeze({__proto__:null,common:$e,error:Ee,editor:Oe,default:Ve}),es:Object.freeze({__proto__:null,common:Ae,error:De,editor:je,default:ze}),hu:Object.freeze({__proto__:null,common:Ue,error:Ye,editor:Re,default:He}),nl:Object.freeze({__proto__:null,common:qe,error:Ie,editor:Fe,default:Le})};function Be(e,t="",s=""){const i=e.split(".")[0],n=e.split(".")[1],r=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let o;try{o=We[r][i][n]}catch(e){o=We.en[i][n]}return void 0===o&&(o=We.en[i][n]),""!==t&&""!==s&&(o=o.replace(t,s)),o}let Je=class extends ie{setConfig(e){this._config=e}get _title(){return this._config&&this._config.title||""}get _icon(){return this._config&&this._config.icon||""}get _entity(){return this._config&&this._config.entity||""}get _truncate(){return this._config&&this._config.truncate||!0}get _scroll_to_selected(){return this._config&&this._config.scroll_to_selected||!0}get _show_toggle(){return this._config&&this._config.show_toggle||!1}get _max_options(){return this._config&&void 0!==this._config.max_options?this._config.max_options:5}render(){if(!this.hass)return j``;const e=Object.keys(this.hass.states).filter(e=>"input_select"===e.substr(0,e.indexOf(".")));return j` +(window.litElementVersions||(window.litElementVersions=[])).push("2.3.1");const se={};class ie extends W{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const e=this.getStyles();if(void 0===e)this._styles=[];else if(Array.isArray(e)){const t=(e,s)=>e.reduceRight((e,s)=>Array.isArray(s)?t(s,e):(e.add(s),e),s),s=t(e,new Set),i=[];s.forEach(e=>i.unshift(e)),this._styles=i}else this._styles=[e]}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?Q?this.renderRoot.adoptedStyleSheets=e.map(e=>e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){const t=this.render();super.update(e),t!==se&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){return se}}ie.finalized=!0,ie.render=(e,t,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,r=A.has(t),o=U&&11===t.nodeType&&!!t.host,a=o&&!H.has(n),l=a?document.createDocumentFragment():t;if(((e,t,i)=>{let n=A.get(t);void 0===n&&(s(t,t.firstChild),A.set(t,n=new P(Object.assign({templateFactory:O},i))),n.appendInto(t)),n.setValue(e),n.commit()})(e,l,Object.assign({templateFactory:Y(n)},i)),a){const e=A.get(l);A.delete(l);const i=e.value instanceof y?e.value.template:void 0;q(n,l,i),s(t,t.firstChild),t.appendChild(l),A.set(t,e)}!r&&o&&window.ShadyCSS.styleElement(t.host)};var ne=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,re="[^\\s]+",oe=/\[([^]*?)\]/gm;function ae(e,t){for(var s=[],i=0,n=e.length;i-1?i:null}};function ce(e){for(var t=[],s=1;s3?0:(e-e%10!=10?1:0)*e%10]}},ge=ce({},pe),me=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length0?"-":"+")+me(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+me(Math.floor(Math.abs(t)/60),2)+":"+me(Math.abs(t)%60,2)}},_e=function(e){return+e-1},ye=[null,"[1-9]\\d?"],ve=[null,re],be=["isPm",re,function(e,t){var s=e.toLowerCase();return s===t.amPm[0]?0:s===t.amPm[1]?1:null}],we=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var s=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?s:-s}return 0}],Se=(le("monthNamesShort"),le("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var xe=function(e,t,s){if(void 0===t&&(t=Se.default),void 0===s&&(s={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var i=[];t=(t=Se[t]||t).replace(oe,(function(e,t){return i.push(t),"@@@"}));var n=ce(ce({},ge),s);return(t=t.replace(ne,(function(t){return fe[t](e,n)}))).replace(/@@@/g,(function(){return i.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}})(),function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}}();var ke="hass:bookmark",Pe={alert:"hass:alert",automation:"hass:playlist-play",calendar:"hass:calendar",camera:"hass:video",climate:"hass:thermostat",configurator:"hass:settings",conversation:"hass:text-to-speech",device_tracker:"hass:account",fan:"hass:fan",group:"hass:google-circles-communities",history_graph:"hass:chart-line",homeassistant:"hass:home-assistant",homekit:"hass:home-automation",image_processing:"hass:image-filter-frames",input_boolean:"hass:drawing",input_datetime:"hass:calendar-clock",input_number:"hass:ray-vertex",input_select:"hass:format-list-bulleted",input_text:"hass:textbox",light:"hass:lightbulb",mailbox:"hass:mailbox",notify:"hass:comment-alert",person:"hass:account",plant:"hass:flower",proximity:"hass:apple-safari",remote:"hass:remote",scene:"hass:google-pages",script:"hass:file-document",sensor:"hass:eye",simple_alarm:"hass:bell",sun:"hass:white-balance-sunny",switch:"hass:flash",timer:"hass:timer",updater:"hass:cloud-upload",vacuum:"hass:robot-vacuum",water_heater:"hass:thermometer",weblink:"hass:open-in-new"};function Ce(e,t){if(e in Pe)return Pe[e];switch(e){case"alarm_control_panel":switch(t){case"armed_home":return"hass:bell-plus";case"armed_night":return"hass:bell-sleep";case"disarmed":return"hass:bell-outline";case"triggered":return"hass:bell-ring";default:return"hass:bell"}case"binary_sensor":return t&&"off"===t?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===t?"hass:window-closed":"hass:window-open";case"lock":return t&&"unlocked"===t?"hass:lock-open":"hass:lock";case"media_player":return t&&"off"!==t&&"idle"!==t?"hass:cast-connected":"hass:cast";case"zwave":switch(t){case"dead":return"hass:emoticon-dead";case"sleeping":return"hass:sleep";case"initializing":return"hass:timer-sand";default:return"hass:z-wave"}default:return console.warn("Unable to find icon for domain "+e+" ("+t+")"),ke}}var Ne={humidity:"hass:water-percent",illuminance:"hass:brightness-5",temperature:"hass:thermometer",pressure:"hass:gauge",power:"hass:flash",signal_strength:"hass:wifi"},Te={binary_sensor:function(e){var t=e.state&&"off"===e.state;switch(e.attributes.device_class){case"battery":return t?"hass:battery":"hass:battery-outline";case"cold":return t?"hass:thermometer":"hass:snowflake";case"connectivity":return t?"hass:server-network-off":"hass:server-network";case"door":return t?"hass:door-closed":"hass:door-open";case"garage_door":return t?"hass:garage":"hass:garage-open";case"gas":case"power":case"problem":case"safety":case"smoke":return t?"hass:shield-check":"hass:alert";case"heat":return t?"hass:thermometer":"hass:fire";case"light":return t?"hass:brightness-5":"hass:brightness-7";case"lock":return t?"hass:lock":"hass:lock-open";case"moisture":return t?"hass:water-off":"hass:water";case"motion":return t?"hass:walk":"hass:run";case"occupancy":return t?"hass:home-outline":"hass:home";case"opening":return t?"hass:square":"hass:square-outline";case"plug":return t?"hass:power-plug-off":"hass:power-plug";case"presence":return t?"hass:home-outline":"hass:home";case"sound":return t?"hass:music-note-off":"hass:music-note";case"vibration":return t?"hass:crop-portrait":"hass:vibrate";case"window":return t?"hass:window-closed":"hass:window-open";default:return t?"hass:radiobox-blank":"hass:checkbox-marked-circle"}},cover:function(e){var t="closed"!==e.state;switch(e.attributes.device_class){case"garage":return t?"hass:garage-open":"hass:garage";case"door":return t?"hass:door-open":"hass:door-closed";case"shutter":return t?"hass:window-shutter-open":"hass:window-shutter";case"blind":return t?"hass:blinds-open":"hass:blinds";case"window":return t?"hass:window-open":"hass:window-closed";default:return Ce("cover",e.state)}},sensor:function(e){var t=e.attributes.device_class;if(t&&t in Ne)return Ne[t];if("battery"===t){var s=Number(e.state);if(isNaN(s))return"hass:battery-unknown";var i=10*Math.round(s/10);return i>=100?"hass:battery":i<=0?"hass:battery-alert":"hass:battery-"+i}var n=e.attributes.unit_of_measurement;return"°C"===n||"°F"===n?"hass:thermometer":Ce("sensor")},input_datetime:function(e){return e.attributes.has_date?e.attributes.has_time?Ce("input_datetime"):"hass:calendar":"hass:clock"}},Me=function(e){if(!e)return ke;if(e.attributes.icon)return e.attributes.icon;var t=function(e){return e.substr(0,e.indexOf("."))}(e.entity_id);return t in Te?Te[t](e):Ce(t,e.state)},$e={version:"Version",name:"Select list card",description:"Display the options of an input_select or a select entity as a clickable list card."},Ee={missing_entity:"Entity is required",invalid_configuration:"Invalid configuration",not_available:"Entity is not available"},Oe={entity:"Entity (required)",title:"Card title (optional)",icon:"Icon (optional)",max_options:"Number of options shown (0 = all)",truncate:"Truncate long option name",show_toggle:"Show toggle in header",scroll_to_selected:"Selected option always in view"},Ve={common:$e,error:Ee,editor:Oe},Ae={version:"Versión",name:"Seleccionar tarjeta de la lista",description:"Mostrar las opciones de una entidad input_select o un select como una tarjeta de lista en la que se puede hacer clic."},De={missing_entity:"Se requiere entidad",invalid_configuration:"configuración no válida",not_available:"La entidad no está disponible."},je={entity:"Entidad (requerida)",title:"Título de la tarjeta (opcional)",icon:"Icono (opcional)",max_options:"Número de opciones mostradas (0 = todas)",truncate:"Truncar el nombre de la opción larga",show_toggle:"Mostrar boton deslizante en la cabecera",scroll_to_selected:"Opción seleccionada siempre a la vista"},ze={common:Ae,error:De,editor:je},Ue={version:"Verzió",name:"Select list card",description:"Az input_select vagy a select megjelenítése mint egy gördíthető, kattintható lista."},Ye={missing_entity:"Entitás megadása kötelező",invalid_configuration:"Hibás konfiguráció",not_available:"Az entitás nem elérhető"},Re={entity:"Entitás (kötelező)",title:"Kártya címe (opcionális)",icon:"Ikon (opcionális)",max_options:"Megjelenített sorok száma (0 = összes)",truncate:"Sor hosszának levágása egységes szélesség érdekében",show_toggle:"Kapcsoló megjelenítése a fejlécben",scroll_to_selected:"Előreugrás a kijelölt sorra"},He={common:Ue,error:Ye,editor:Re},qe={version:"Versie",name:"Select lijst kaart",description:"Toon de opties van een input_select of een select entiteit in een kaart"},Ie={missing_entity:"Het specificeren van een entiteit is verplicht!",invalid_configuration:"Geen geldige configuratie",not_available:"Entiteit is niet beschikbaar"},Fe={entity:"Entiteit (verplicht)",title:"Kaart titel (optioneel)",icon:"Icoon (optioneel)",max_options:"Aantal opties zichtbaar (0 = alles)",truncate:"Kap lange optie name af",show_toggle:"Toon toggle in titel",scroll_to_selected:"Geselecteerde optie altijd zichtbaar"},Le={common:qe,error:Ie,editor:Fe};const We={en:Object.freeze({__proto__:null,common:$e,error:Ee,editor:Oe,default:Ve}),es:Object.freeze({__proto__:null,common:Ae,error:De,editor:je,default:ze}),hu:Object.freeze({__proto__:null,common:Ue,error:Ye,editor:Re,default:He}),nl:Object.freeze({__proto__:null,common:qe,error:Ie,editor:Fe,default:Le})};function Be(e,t="",s=""){const i=e.split(".")[0],n=e.split(".")[1],r=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let o;try{o=We[r][i][n]}catch(e){o=We.en[i][n]}return void 0===o&&(o=We.en[i][n]),""!==t&&""!==s&&(o=o.replace(t,s)),o}let Je=class extends ie{setConfig(e){this._config=e}get _title(){return this._config&&this._config.title||""}get _icon(){return this._config&&this._config.icon||""}get _entity(){return this._config&&this._config.entity||""}get _truncate(){return this._config&&this._config.truncate||!0}get _scroll_to_selected(){return this._config&&this._config.scroll_to_selected||!0}get _show_toggle(){return this._config&&this._config.show_toggle||!1}get _max_options(){return this._config&&void 0!==this._config.max_options?this._config.max_options:5}render(){if(!this.hass)return j``;const e=Object.keys(this.hass.states).filter(e=>"input_select"===e.substr(0,e.indexOf(".")));return j`
@@ -239,7 +239,7 @@ found at http://polymer.github.io/PATENTS.txt @change=${this._valueChanged} > - ${Be("editor.show_toggle")} + ${Be("editor.truncate")}
e.startsWith("input_select"))||"",icon:"",truncate:!0,show_toggle:!1,scroll_to_selected:!0,max_options:5}}setConfig(e){if(!e||!e.entity||!e.entity.startsWith("input_select"))throw new Error(Be("error.invalid_configuration"));e.test_gui&&function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null}().setEditMode(!0),this.config=Object.assign({title:"",icon:"",show_toggle:!1,truncate:!0,scroll_to_selected:!0,max_options:5},e),this.open=this.open||this.config.open}async getCardSize(){let e=0;return this.config?(e+=this.config.title?1:0,e+=this.config.max_options?this.config.max_options:this.options.length,e):e}shouldUpdate(e){return function(e,t,s){if(t.has("config")||s)return!0;if(e.config.entity){var i=t.get("hass");return!i||i.states[e.config.entity]!==e.hass.states[e.config.entity]}return!1}(this,e,!1)}render(){if(!this.config.entity)return this.showError();const e=this.stateObj,t=e.state;this.options=e.attributes.options;const s=0===this.config.max_options?"":`max-height: ${48*(this.config.max_options||5)+16}px`;return j` + `}};e([Z()],Je.prototype,"hass",void 0),e([Z()],Je.prototype,"_config",void 0),Je=e([B("select-list-card-editor")],Je);var Ze;console.info(`%c select-list-card \n%c ${Be("common.version")} 1.2.0 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"select-list-card",name:""+Be("common.name"),description:""+Be("common.description"),preview:!0});let Ke=Ze=class extends ie{constructor(){super(...arguments),this.open=!0,this.options=[]}static async getConfigElement(){return document.createElement("select-list-card-editor")}static getStubConfig(e,t){return{entity:t.find(e=>e.startsWith("input_select")||e.startsWith("select"))||"",icon:"",truncate:!0,show_toggle:!1,scroll_to_selected:!0,max_options:5}}setConfig(e){if(!(e&&e.entity&&e.entity.startsWith("input_select")&&e.entity.startsWith("select")))throw new Error(Be("error.invalid_configuration"));e.test_gui&&function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null}().setEditMode(!0),this.config=Object.assign({title:"",icon:"",show_toggle:!1,truncate:!0,scroll_to_selected:!0,max_options:5},e),this.open=this.open||this.config.open}async getCardSize(){let e=0;return this.config?(e+=this.config.title?1:0,e+=this.config.max_options?this.config.max_options:this.options.length,e):e}shouldUpdate(e){return function(e,t,s){if(t.has("config")||s)return!0;if(e.config.entity){var i=t.get("hass");return!i||i.states[e.config.entity]!==e.hass.states[e.config.entity]}return!1}(this,e,!1)}render(){if(!this.config.entity)return this.showError();const e=this.stateObj,t=e.state;this.options=e.attributes.options;const s=0===this.config.max_options?"":`max-height: ${48*(this.config.max_options||5)+16}px`;return j` ${this.config.title&&this.config.title.length?j`
- `}get stateObj(){return this.hass.states[this.config.entity]}toggle(){if(this.config.show_toggle&&(this.open=!this.open,this.open)){const e=this.listEl.querySelector(".iron-selected");e&&setTimeout(()=>{this.setScrollTop(e.offsetTop)},100)}}setScrollTop(e){this.config.scroll_to_selected&&(this.listEl.scrollTop=e-(this.listEl.offsetTop+8))}async selectedOptionChanged(e){const t=e.detail.item.innerText.trim(),s=this.stateObj.state;e.detail&&e.detail.item&&this.setScrollTop(e.detail.item.offsetTop),t!==s&&await Ze.setInputSelectOption(this.hass,this.config.entity,t)}static setInputSelectOption(e,t,s){return e.callService("input_select","select_option",{option:s,entity_id:t})}showError(){return j` + `}get stateObj(){return this.hass.states[this.config.entity]}toggle(){if(this.config.show_toggle&&(this.open=!this.open,this.open)){const e=this.listEl.querySelector(".iron-selected");e&&setTimeout(()=>{this.setScrollTop(e.offsetTop)},100)}}setScrollTop(e){this.config.scroll_to_selected&&(this.listEl.scrollTop=e-(this.listEl.offsetTop+8))}async selectedOptionChanged(e){const t=e.detail.item.innerText.trim(),s=this.stateObj.state;e.detail&&e.detail.item&&this.setScrollTop(e.detail.item.offsetTop),t!==s&&await Ze.setInputSelectOption(this.hass,this.config.entity,t)}static setInputSelectOption(e,t,s){const i=t.startsWith("input_select.")?"input_select":"select";return e.callService(i,"select_option",{option:s,entity_id:t})}showError(){return j`