${localize('editor.compact_view')}
${localize('editor.show_name')}
${localize('editor.show_status')}
${localize('editor.show_toolbar')}
${localize('editor.show_shortcuts')}
${localize('editor.animated')}
${localize('editor.code_only_note')}
`;
}
private valueChanged(event: Event): void {
if (!this.config || !this.hass || !event.target) {
return;
}
const target = event.target as HTMLElement & {
configValue?: string;
dataset?: { configValue?: string };
checked?: boolean;
value?: string;
};
const configValue = target.configValue || target.dataset?.configValue;
// For ha-selector with @value-changed event, get value from detail.value
let value: string | boolean | undefined;
if (
event.type === 'value-changed' &&
(event as CustomEvent<{ value?: string }>)?.detail?.value !== undefined
) {
value = (event as CustomEvent<{ value?: string }>).detail.value;
} else if (
event.type === 'selected' &&
(event as CustomEvent<{ index: number }>)?.detail?.index !== undefined
) {
// ha-select @selected event - get value from the selected item
const selectedIndex = (event as CustomEvent<{ index: number }>).detail
.index;
const items = target.querySelectorAll('mwc-list-item');
if (items[selectedIndex]) {
value =
(items[selectedIndex] as HTMLElement).getAttribute('value') || '';
}
} else {
value = target.checked !== undefined ? target.checked : target.value;
}
if (
!configValue ||
(this.config[configValue as keyof LawnMowerCardConfig] &&
this.config[configValue as keyof LawnMowerCardConfig] === value)
) {
return;
}
// Deep copy to avoid read-only property issues
const newConfig = JSON.parse(JSON.stringify(this.config));
newConfig[configValue as keyof LawnMowerCardConfig] = value;
this.config = newConfig;
fireEvent(this, 'config-changed', { config: this.config });
}
static get styles() {
return styles;
}
}