- `:this._showError(eo("common.show_error"))}renderText(){return this.config.show_name||this.config.show_state?It`
+ `:this._showError(bo("common.show_error"))}renderText(){return this.config.show_name||this.config.show_state?It`
${this.config.show_name?It`
${this.ctrl.name}
@@ -584,7 +584,7 @@ class ae{constructor(t){this.classes=new Set,this.changed=!1,this.element=t;cons
.icon=${this.ctrl.icon}
/>
- `}renderAction(){var t,e,i,o,s;return!1===(null===(t=this.config.action_button)||void 0===t?void 0:t.show)?It``:(null===(e=this.config.action_button)||void 0===e?void 0:e.mode)===_e.TOGGLE?It`
+ `}renderAction(){var t,e,i,o,r;return!1===(null===(t=this.config.action_button)||void 0===t?void 0:t.show)?It``:(null===(e=this.config.action_button)||void 0===e?void 0:e.mode)===_e.TOGGLE?It`
- ${void 0===(null===(o=this.config.action_button)||void 0===o?void 0:o.show_spinner)||(null===(s=this.config.action_button)||void 0===s?void 0:s.show_spinner)?It`
+ ${void 0===(null===(o=this.config.action_button)||void 0===o?void 0:o.show_spinner)||(null===(r=this.config.action_button)||void 0===r?void 0:r.show_spinner)?It`
`:""}
- `}_handleAction(t,e){var i;this.hass&&this.config&&t.detail.action&&("toggle"!==(null===(i=e.tap_action)||void 0===i?void 0:i.action)||this.ctrl.isUnavailable||this.animateActionStart(),$(this,this.hass,Object.assign(Object.assign({},e),{entity:this.config.entity}),t.detail.action))}handleLockClick(t){t.preventDefault(),this.locked?this.unlockCard():this.lockCard()}lockCard(){clearTimeout(this.lockTimeout),this.locked=!0,this.card.classList.add("locked")}unlockCard(){var t,e;clearTimeout(this.lockTimeout),this.locked=!1,this.card.classList.remove("locked"),this.lockTimeout=setTimeout(()=>{this.lockCard()},1e3*((null===(e=null===(t=this.config.slider)||void 0===t?void 0:t.lock)||void 0===e?void 0:e.duration)||5))}async handleClick(t){this.ctrl.hasToggle&&!this.ctrl.isUnavailable&&(t.preventDefault(),this.animateActionStart(),this.ctrl.log("Toggle"),await P(this.hass,this.config.entity))}_toggle(){this.hass&&this.config&&$(this,this.hass,{tap_action:{action:"toggle"},entity:this.config.entity},"tap")}setStateValue(t){this.ctrl.log("setStateValue",t),this.updateValue(t,!1),this.ctrl.value=t,this.animateActionStart()}animateActionStart(){this.animateActionEnd(),this.action&&this.action.classList.add("loading")}animateActionEnd(){this.action&&(clearTimeout(this.actionTimeout),this.actionTimeout=setTimeout(()=>{this.action.classList.remove("loading")},750))}updateValue(t,e=!0){this.changing=e,this.changed=!e,this.ctrl.log("updateValue",t),this.ctrl.targetValue=t,this.button&&(this.button.classList.remove("off"),e?this.button.classList.add("changing"):(this.button.classList.remove("changing"),this.ctrl.isOff&&this.button.classList.add("off")),this.stateText&&(this.stateText.innerHTML=this.ctrl.isUnavailable?""+this.hass.localize("state.default.unavailable"):this.ctrl.label),this.button.style.setProperty("--slider-value",this.ctrl.percentage+"%"),this.button.style.setProperty("--slider-bg-filter",this.ctrl.style.slider.filter),this.button.style.setProperty("--slider-color",this.ctrl.style.slider.color),this.button.style.setProperty("--icon-filter",this.ctrl.style.icon.filter),this.button.style.setProperty("--icon-color",this.ctrl.style.icon.color),this.button.style.setProperty("--icon-rotate-speed",this.ctrl.style.icon.rotateSpeed||"0s"))}_showError(t){const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t,origConfig:this.config}),It`
+ `}_handleAction(t,e){var i;this.hass&&this.config&&t.detail.action&&("toggle"!==(null===(i=e.tap_action)||void 0===i?void 0:i.action)||this.ctrl.isUnavailable||this.animateActionStart(),A(this,this.hass,Object.assign(Object.assign({},e),{entity:this.config.entity}),t.detail.action))}handleLockClick(t){t.preventDefault(),this.locked?this.unlockCard():this.lockCard()}lockCard(){clearTimeout(this.lockTimeout),this.locked=!0,this.card.classList.add("locked")}unlockCard(){var t,e;clearTimeout(this.lockTimeout),this.locked=!1,this.card.classList.remove("locked"),this.lockTimeout=setTimeout(()=>{this.lockCard()},1e3*((null===(e=null===(t=this.config.slider)||void 0===t?void 0:t.lock)||void 0===e?void 0:e.duration)||5))}async handleClick(t){this.ctrl.hasToggle&&!this.ctrl.isUnavailable&&(t.preventDefault(),this.animateActionStart(),this.ctrl.log("Toggle"),await P(this.hass,this.config.entity))}_toggle(){this.hass&&this.config&&A(this,this.hass,{tap_action:{action:"toggle"},entity:this.config.entity},"tap")}setStateValue(t){this.ctrl.log("setStateValue",t),this.updateValue(t,!1),this.ctrl.value=t,this.animateActionStart()}animateActionStart(){this.animateActionEnd(),this.action&&this.action.classList.add("loading")}animateActionEnd(){this.action&&(clearTimeout(this.actionTimeout),this.actionTimeout=setTimeout(()=>{this.action.classList.remove("loading")},750))}updateValue(t,e=!0){this.changing=e,this.changed=!e,this.ctrl.log("updateValue",t),this.ctrl.targetValue=t,this.button&&(this.button.classList.remove("off"),e?this.button.classList.add("changing"):(this.button.classList.remove("changing"),this.ctrl.isOff&&this.button.classList.add("off")),this.stateText&&(this.stateText.innerHTML=this.ctrl.isUnavailable?""+this.hass.localize("state.default.unavailable"):this.ctrl.label),this.button.style.setProperty("--slider-value",this.ctrl.percentage+"%"),this.button.style.setProperty("--slider-bg-filter",this.ctrl.style.slider.filter),this.button.style.setProperty("--slider-color",this.ctrl.style.slider.color),this.button.style.setProperty("--icon-filter",this.ctrl.style.icon.filter),this.button.style.setProperty("--icon-color",this.ctrl.style.icon.color),this.button.style.setProperty("--icon-rotate-speed",this.ctrl.style.icon.rotateSpeed||"0s"))}_showError(t){const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t,origConfig:this.config}),It`
${e}
- `}getColorFromVariable(t){if(void 0!==t&&"var"===t.substring(0,3)){let e=window.getComputedStyle(this).getPropertyValue(t.substring(4).slice(0,-1)).trim();return e.length||(e=window.getComputedStyle(document.documentElement).getPropertyValue(t.substring(4).slice(0,-1)).trim()),e}return t}onPointerDown(t){t.preventDefault(),t.stopPropagation(),this.ctrl.isSliderDisabled||this.slider.setPointerCapture(t.pointerId)}onPointerUp(t){t.stopPropagation(),this.ctrl.isSliderDisabled||(this.setStateValue(this.ctrl.targetValue),this.slider.releasePointerCapture(t.pointerId))}onPointerMove(t){if(this.ctrl.isSliderDisabled)return;if(!this.slider.hasPointerCapture(t.pointerId))return;const{left:e,top:i,width:o,height:s}=this.slider.getBoundingClientRect(),r=this.ctrl.moveSlider(t,{left:e,top:i,width:o,height:s});this.ctrl.log("onPointerMove",r),this.updateValue(r)}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}static get styles(){return oe`
+ `}getColorFromVariable(t){if(void 0!==t&&"var"===t.substring(0,3)){let e=window.getComputedStyle(this).getPropertyValue(t.substring(4).slice(0,-1)).trim();return e.length||(e=window.getComputedStyle(document.documentElement).getPropertyValue(t.substring(4).slice(0,-1)).trim()),e}return t}onPointerDown(t){t.preventDefault(),t.stopPropagation(),this.ctrl.isSliderDisabled||this.slider.setPointerCapture(t.pointerId)}onPointerUp(t){t.stopPropagation(),this.ctrl.isSliderDisabled||(this.setStateValue(this.ctrl.targetValue),this.slider.releasePointerCapture(t.pointerId))}onPointerMove(t){if(this.ctrl.isSliderDisabled)return;if(!this.slider.hasPointerCapture(t.pointerId))return;const{left:e,top:i,width:o,height:r}=this.slider.getBoundingClientRect(),s=this.ctrl.moveSlider(t,{left:e,top:i,width:o,height:r});this.ctrl.log("onPointerMove",s),this.updateValue(s)}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}static get styles(){return oe`
ha-card {
box-sizing: border-box;
height: 100%;
@@ -1066,4 +1066,4 @@ class ae{constructor(t){this.classes=new Set,this.changed=!1,this.element=t;cons
stroke-dashoffset: -124;
}
}
- `}};t([Zt({attribute:!1})],oo.prototype,"hass",void 0),t([Jt()],oo.prototype,"config",void 0),t([Kt(".state")],oo.prototype,"stateText",void 0),t([Kt(".button")],oo.prototype,"button",void 0),t([Kt(".action")],oo.prototype,"action",void 0),t([Kt(".slider")],oo.prototype,"slider",void 0),t([Kt(".type-custom-slider-button-card")],oo.prototype,"card",void 0),oo=t([Yt("slider-button-card")],oo);export{oo as SliderButtonCard};
+ `}};t([Zt({attribute:!1})],_o.prototype,"hass",void 0),t([Kt()],_o.prototype,"config",void 0),t([Jt(".state")],_o.prototype,"stateText",void 0),t([Jt(".button")],_o.prototype,"button",void 0),t([Jt(".action")],_o.prototype,"action",void 0),t([Jt(".slider")],_o.prototype,"slider",void 0),t([Jt(".type-custom-slider-button-card")],_o.prototype,"card",void 0),_o=t([Yt("slider-button-card")],_o);export{_o as SliderButtonCard};
diff --git a/src/localize/languages/de.json b/src/localize/languages/de.json
index 8c74995..ba54bf5 100644
--- a/src/localize/languages/de.json
+++ b/src/localize/languages/de.json
@@ -28,7 +28,11 @@
"use_brightness": "Helligkeit benutzen?",
"show_track": "Spur anzeigen?",
"toggle_on_click": "Als Schalter benutzen (schieben deaktivieren)",
- "force_square": "Quadrat erzwingen?"
+ "force_square": "Quadrat erzwingen?",
+ "lock": {
+ "enabled": "Sperre aktiviert?",
+ "duration": "Sperrdauer in Sekunden"
+ }
},
"action_button": {
"title": "Action-Knopf",
diff --git a/src/localize/languages/he.json b/src/localize/languages/he.json
index 5ed3480..66915cc 100644
--- a/src/localize/languages/he.json
+++ b/src/localize/languages/he.json
@@ -28,7 +28,11 @@
"use_brightness": "להשתמש בבהירות?",
"show_track": "להציג מסלול?",
"toggle_on_click": "פעל כמתג (השבת החלקה)",
- "force_square": "כוח מרובע?"
+ "force_square": "כוח מרובע?",
+ "lock": {
+ "enabled": "נעילה מופעלת?",
+ "duration": "משך נעילה בשניות"
+ }
},
"action_button": {
"title": "כפתור פעולה",
diff --git a/src/localize/languages/ko.json b/src/localize/languages/ko.json
index 54fd4bc..11db1b8 100644
--- a/src/localize/languages/ko.json
+++ b/src/localize/languages/ko.json
@@ -28,7 +28,11 @@
"use_brightness": "밝기 사용",
"show_track": "범위 표시",
"toggle_on_click": "토글 버튼으로 동작(슬라이더 비활성화)",
- "force_square": "정사각형 모양으로 고정"
+ "force_square": "정사각형 모양으로 고정",
+ "lock": {
+ "enabled": "잠금을 사용 하시겠습니까?",
+ "duration": "잠금 기간 (초)"
+ }
},
"action_button": {
"title": "액션 버튼",
@@ -60,4 +64,3 @@
"custom": "커스텀 모드"
}
}
-
\ No newline at end of file
diff --git a/src/localize/languages/nl.json b/src/localize/languages/nl.json
index 84dd15f..cf058b6 100644
--- a/src/localize/languages/nl.json
+++ b/src/localize/languages/nl.json
@@ -28,7 +28,11 @@
"use_brightness": "Gebruik helderheid?",
"show_track": "Toon spoor?",
"toggle_on_click": "Fungeren als een schakelaar (schuiven uitschakelen)",
- "force_square": "Forceer vierkant?"
+ "force_square": "Forceer vierkant?",
+ "lock": {
+ "enabled": "Vergrendelen ingeschakeld?",
+ "duration": "Vergrendelingsduur in seconden"
+ }
},
"action_button": {
"title": "Actie button",
diff --git a/src/localize/languages/pl.json b/src/localize/languages/pl.json
index dee6a5c..0f2f562 100644
--- a/src/localize/languages/pl.json
+++ b/src/localize/languages/pl.json
@@ -28,7 +28,11 @@
"use_brightness": "Użyć jasności?",
"show_track": "Pokazać ślad?",
"toggle_on_click": "Działaj jako przełącznik (wyłącz przesuwanie)",
- "force_square": "Wymusić kwadrat?"
+ "force_square": "Wymusić kwadrat?",
+ "lock": {
+ "enabled": "Blokada włączona?",
+ "duration": "Czas blokady w sekundach"
+ }
},
"action_button": {
"title": "Przycisk akcji",
diff --git a/src/localize/languages/pt.json b/src/localize/languages/pt.json
index f0c3d15..1096a3a 100644
--- a/src/localize/languages/pt.json
+++ b/src/localize/languages/pt.json
@@ -28,7 +28,11 @@
"use_brightness": "Usar Brilho?",
"show_track": "Mostrar Acompanhamento?",
"toggle_on_click": "Atua como um alternador (desative o deslizamento)",
- "force_square": "Forçar Quadrado?"
+ "force_square": "Forçar Quadrado?",
+ "lock": {
+ "enabled": "Bloqueio ativado?",
+ "duration": "Duração do bloqueio em segundos"
+ }
},
"action_button": {
"title": "Botão de Ação",
diff --git a/src/localize/languages/ru.json b/src/localize/languages/ru.json
index 88b54f1..cd2eedb 100644
--- a/src/localize/languages/ru.json
+++ b/src/localize/languages/ru.json
@@ -28,7 +28,11 @@
"use_brightness": "Использовать яркость?",
"show_track": "Показать трек?",
"toggle_on_click": "Действовать как переключатель (отключить скольжение)",
- "force_square": "Отображать квадратным?"
+ "force_square": "Отображать квадратным?",
+ "lock": {
+ "enabled": "Блокировка включена?",
+ "duration": "Длительность блокировки в секундах"
+ }
},
"action_button": {
"title": "Кнопка действия",
diff --git a/src/types.ts b/src/types.ts
index df1645e..245e2f2 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -54,7 +54,7 @@ export interface SliderConfig {
}
export interface LockConfig {
- enabled?: boolean;
+ enabled: boolean;
layout?: LockLayout;
duration?: number;
}