Compare commits
5 Commits
87664b60ee
...
1568244c6a
Author | SHA1 | Date |
---|---|---|
Christoph Wiechert | 1568244c6a | |
semantic-release-bot | 605b096509 | |
Jérôme Wiedemann | ab2b3939bc | |
semantic-release-bot | 27877b9f68 | |
Jérôme Wiedemann | 56c3f44066 |
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,3 +1,17 @@
|
||||||
|
### [4.1.2-dev.2](https://github.com/custom-cards/button-card/compare/v4.1.2-dev.1...v4.1.2-dev.2) (2024-02-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* support for new ha-state-icon in 2024.02 ([ab2b393](https://github.com/custom-cards/button-card/commit/ab2b3939bcce504125853d2ca9312d32f9a3f6d6))
|
||||||
|
|
||||||
|
### [4.1.2-dev.1](https://github.com/custom-cards/button-card/compare/v4.1.1...v4.1.2-dev.1) (2023-08-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* card would sometimes not be clickable ([56c3f44](https://github.com/custom-cards/button-card/commit/56c3f44066c6bd08fb8a7d8bb8fa679920dc5992)), closes [#738](https://github.com/custom-cards/button-card/issues/738) [#759](https://github.com/custom-cards/button-card/issues/759)
|
||||||
|
|
||||||
### [4.1.1](https://github.com/custom-cards/button-card/compare/v4.1.0...v4.1.1) (2023-08-03)
|
### [4.1.1](https://github.com/custom-cards/button-card/compare/v4.1.0...v4.1.1) (2023-08-03)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "button-card",
|
"name": "button-card",
|
||||||
"version": "4.1.1",
|
"version": "4.1.2-dev.2",
|
||||||
"description": "Button card for lovelace",
|
"description": "Button card for lovelace",
|
||||||
"main": "dist/button-card.js",
|
"main": "dist/button-card.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {
|
||||||
ButtonCardEmbeddedCards,
|
ButtonCardEmbeddedCards,
|
||||||
ButtonCardEmbeddedCardsConfig,
|
ButtonCardEmbeddedCardsConfig,
|
||||||
ColorType,
|
ColorType,
|
||||||
|
CustomFields,
|
||||||
} from './types/types';
|
} from './types/types';
|
||||||
import { actionHandler } from './action-handler';
|
import { actionHandler } from './action-handler';
|
||||||
import {
|
import {
|
||||||
|
@ -872,38 +873,26 @@ class ButtonCard extends LitElement {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _hasChildCards(customFields: CustomFields | undefined): boolean {
|
||||||
|
if (!customFields) return false;
|
||||||
|
return Object.keys(customFields).some((key) => {
|
||||||
|
const value = customFields![key];
|
||||||
|
if ((value as CustomFieldCard)!.card) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private _isClickable(state: HassEntity | undefined, configState: StateConfig | undefined): boolean {
|
private _isClickable(state: HassEntity | undefined, configState: StateConfig | undefined): boolean {
|
||||||
let clickable = true;
|
|
||||||
const tap_action = this._getTemplateOrValue(state, this._config!.tap_action!.action);
|
const tap_action = this._getTemplateOrValue(state, this._config!.tap_action!.action);
|
||||||
const hold_action = this._getTemplateOrValue(state, this._config!.hold_action!.action);
|
const hold_action = this._getTemplateOrValue(state, this._config!.hold_action!.action);
|
||||||
const double_tap_action = this._getTemplateOrValue(state, this._config!.double_tap_action!.action);
|
const double_tap_action = this._getTemplateOrValue(state, this._config!.double_tap_action!.action);
|
||||||
let hasChildCards = false;
|
const hasChildCards =
|
||||||
if (this._config!.custom_fields) {
|
this._hasChildCards(this._config!.custom_fields) ||
|
||||||
hasChildCards = Object.keys(this._config!.custom_fields).some((key) => {
|
!!(configState && this._hasChildCards(configState.custom_fields));
|
||||||
const value = this._config!.custom_fields![key];
|
|
||||||
if ((value as CustomFieldCard)!.card) {
|
return tap_action != 'none' || hold_action != 'none' || double_tap_action != 'none' || hasChildCards;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!hasChildCards && configState) {
|
|
||||||
if (configState.custom_fields) {
|
|
||||||
return (hasChildCards = Object.keys(configState.custom_fields).some((key) => {
|
|
||||||
const value = configState.custom_fields![key];
|
|
||||||
if ((value as CustomFieldCard)!.card) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tap_action != 'none' || hold_action != 'none' || double_tap_action != 'none' || hasChildCards) {
|
|
||||||
clickable = true;
|
|
||||||
} else {
|
|
||||||
clickable = false;
|
|
||||||
}
|
|
||||||
return clickable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _rotate(configState: StateConfig | undefined): boolean {
|
private _rotate(configState: StateConfig | undefined): boolean {
|
||||||
|
@ -1169,6 +1158,8 @@ class ButtonCard extends LitElement {
|
||||||
? html`
|
? html`
|
||||||
<ha-state-icon
|
<ha-state-icon
|
||||||
.state=${state}
|
.state=${state}
|
||||||
|
.stateObj=${state}
|
||||||
|
.hass=${this._hass}
|
||||||
?data-domain=${domain}
|
?data-domain=${domain}
|
||||||
data-state=${ifDefined(state?.state)}
|
data-state=${ifDefined(state?.state)}
|
||||||
style=${styleMap(haIconStyle)}
|
style=${styleMap(haIconStyle)}
|
||||||
|
|
Loading…
Reference in New Issue