Remove Lit localize mixin (#2597)

* Remove some localize mixins form Lit Elements

* Remove litLocalizeMixin

* Revert unwanted changes
This commit is contained in:
Paulus Schoutsen 2019-01-27 16:52:15 -08:00 committed by GitHub
parent 0a09eabce3
commit c3f473c3e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 142 additions and 204 deletions

View File

@ -61,7 +61,7 @@ class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
// So we sanitize the translation with innerText and then inject // So we sanitize the translation with innerText and then inject
// the name with a bold tag. // the name with a bold tag.
const loggingInWith = document.createElement("div"); const loggingInWith = document.createElement("div");
loggingInWith.innerText = this.localize( loggingInWith.innerText = this.hass!.localize(
"ui.panel.page-authorize.logging_in_with", "ui.panel.page-authorize.logging_in_with",
"authProviderName", "authProviderName",
"NAME" "NAME"
@ -78,7 +78,7 @@ class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
return html` return html`
${this.renderStyle()} ${this.renderStyle()}
<p> <p>
${this.localize( ${this.hass!.localize(
"ui.panel.page-authorize.authorizing_client", "ui.panel.page-authorize.authorizing_client",
"clientId", "clientId",
this.clientId this.clientId

View File

@ -1,10 +1,9 @@
import { Constructor, LitElement } from "lit-element"; import { Constructor, LitElement } from "lit-element";
import { HassBaseEl } from "./hass-base-mixin"; import { HassBaseEl } from "./hass-base-mixin";
import { hassLocalizeLitMixin } from "../../mixins/lit-localize-mixin";
import { HaToast } from "../../components/ha-toast"; import { HaToast } from "../../components/ha-toast";
export default (superClass: Constructor<LitElement & HassBaseEl>) => export default (superClass: Constructor<LitElement & HassBaseEl>) =>
class extends hassLocalizeLitMixin(superClass) { class extends superClass {
private _discToast?: HaToast; private _discToast?: HaToast;
protected hassConnected() { protected hassConnected() {

View File

@ -1,16 +0,0 @@
import { Constructor, LitElement } from "lit-element";
import { HomeAssistant, LocalizeMixin } from "../types";
const empty = () => "";
export const hassLocalizeLitMixin = <T extends LitElement>(
superClass: Constructor<T>
): Constructor<T & LocalizeMixin> =>
// @ts-ignore
class extends superClass {
public hass?: HomeAssistant;
get localize() {
return this.hass ? this.hass.localize : empty;
}
};

View File

@ -14,7 +14,6 @@ import {
callAlarmAction, callAlarmAction,
FORMAT_NUMBER, FORMAT_NUMBER,
} from "../../../data/alarm_control_panel"; } from "../../../data/alarm_control_panel";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import "../../../components/ha-card"; import "../../../components/ha-card";
import "../../../components/ha-label-badge"; import "../../../components/ha-label-badge";
@ -41,8 +40,7 @@ export interface Config extends LovelaceCardConfig {
states?: string[]; states?: string[];
} }
class HuiAlarmPanelCard extends hassLocalizeLitMixin(LitElement) class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
implements LovelaceCard {
public static async getConfigElement() { public static async getConfigElement() {
await import(/* webpackChunkName: "hui-alarm-panel-card-editor" */ "../editor/config-elements/hui-alarm-panel-card-editor"); await import(/* webpackChunkName: "hui-alarm-panel-card-editor" */ "../editor/config-elements/hui-alarm-panel-card-editor");
return document.createElement("hui-alarm-panel-card-editor"); return document.createElement("hui-alarm-panel-card-editor");
@ -186,8 +184,8 @@ class HuiAlarmPanelCard extends hassLocalizeLitMixin(LitElement)
private _label(state: string): string { private _label(state: string): string {
return ( return (
this.localize(`state.alarm_control_panel.${state}`) || this.hass!.localize(`state.alarm_control_panel.${state}`) ||
this.localize(`ui.card.alarm_control_panel.${state}`) this.hass!.localize(`ui.card.alarm_control_panel.${state}`)
); );
} }

View File

@ -11,7 +11,6 @@ import "../components/hui-entities-toggle";
import { fireEvent } from "../../../common/dom/fire_event"; import { fireEvent } from "../../../common/dom/fire_event";
import { DOMAINS_HIDE_MORE_INFO } from "../../../common/const"; import { DOMAINS_HIDE_MORE_INFO } from "../../../common/const";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { EntityConfig, EntityRow } from "../entity-rows/types"; import { EntityConfig, EntityRow } from "../entity-rows/types";
import { LovelaceCard, LovelaceCardEditor } from "../types"; import { LovelaceCard, LovelaceCardEditor } from "../types";
@ -37,8 +36,7 @@ export interface EntitiesCardConfig extends LovelaceCardConfig {
theme?: string; theme?: string;
} }
class HuiEntitiesCard extends hassLocalizeLitMixin(LitElement) class HuiEntitiesCard extends LitElement implements LovelaceCard {
implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-entities-card-editor" */ "../editor/config-elements/hui-entities-card-editor"); await import(/* webpackChunkName: "hui-entities-card-editor" */ "../editor/config-elements/hui-entities-card-editor");
return document.createElement("hui-entities-card-editor"); return document.createElement("hui-entities-card-editor");

View File

@ -16,7 +16,6 @@ import computeStateDomain from "../../../common/entity/compute_state_domain";
import computeStateName from "../../../common/entity/compute_state_name"; import computeStateName from "../../../common/entity/compute_state_name";
import applyThemesOnElement from "../../../common/dom/apply_themes_on_element"; import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
import { HomeAssistant, LightEntity } from "../../../types"; import { HomeAssistant, LightEntity } from "../../../types";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { LovelaceCard, LovelaceCardEditor } from "../types"; import { LovelaceCard, LovelaceCardEditor } from "../types";
import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace"; import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace";
import { longPress } from "../common/directives/long-press-directive"; import { longPress } from "../common/directives/long-press-directive";
@ -31,8 +30,7 @@ export interface Config extends LovelaceCardConfig {
hold_action?: ActionConfig; hold_action?: ActionConfig;
} }
class HuiEntityButtonCard extends hassLocalizeLitMixin(LitElement) class HuiEntityButtonCard extends LitElement implements LovelaceCard {
implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-entity-button-card-editor" */ "../editor/config-elements/hui-entity-button-card-editor"); await import(/* webpackChunkName: "hui-entity-button-card-editor" */ "../editor/config-elements/hui-entity-button-card-editor");
return document.createElement("hui-entity-button-card-editor"); return document.createElement("hui-entity-button-card-editor");

View File

@ -7,7 +7,6 @@ import {
} from "lit-element"; } from "lit-element";
import { classMap } from "lit-html/directives/class-map"; import { classMap } from "lit-html/directives/class-map";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { LovelaceCard, LovelaceCardEditor } from "../types"; import { LovelaceCard, LovelaceCardEditor } from "../types";
import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace"; import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace";
@ -38,8 +37,7 @@ export interface Config extends LovelaceCardConfig {
columns?: number; columns?: number;
} }
export class HuiGlanceCard extends hassLocalizeLitMixin(LitElement) export class HuiGlanceCard extends LitElement implements LovelaceCard {
implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-glance-card-editor" */ "../editor/config-elements/hui-glance-card-editor"); await import(/* webpackChunkName: "hui-glance-card-editor" */ "../editor/config-elements/hui-glance-card-editor");
return document.createElement("hui-glance-card-editor"); return document.createElement("hui-glance-card-editor");
@ -223,7 +221,7 @@ export class HuiGlanceCard extends hassLocalizeLitMixin(LitElement)
? html` ? html`
<div> <div>
${computeStateDisplay( ${computeStateDisplay(
this.localize, this.hass!.localize,
stateObj, stateObj,
this.hass!.language this.hass!.language
)} )}

View File

@ -9,7 +9,6 @@ import {
import { fireEvent } from "../../../common/dom/fire_event"; import { fireEvent } from "../../../common/dom/fire_event";
import { styleMap } from "lit-html/directives/style-map"; import { styleMap } from "lit-html/directives/style-map";
import { HomeAssistant, LightEntity } from "../../../types"; import { HomeAssistant, LightEntity } from "../../../types";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { LovelaceCard, LovelaceCardEditor } from "../types"; import { LovelaceCard, LovelaceCardEditor } from "../types";
import { LovelaceCardConfig } from "../../../data/lovelace"; import { LovelaceCardConfig } from "../../../data/lovelace";
import { longPress } from "../common/directives/long-press-directive"; import { longPress } from "../common/directives/long-press-directive";
@ -45,8 +44,7 @@ export interface Config extends LovelaceCardConfig {
theme?: string; theme?: string;
} }
export class HuiLightCard extends hassLocalizeLitMixin(LitElement) export class HuiLightCard extends LitElement implements LovelaceCard {
implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-light-card-editor" */ "../editor/config-elements/hui-light-card-editor"); await import(/* webpackChunkName: "hui-light-card-editor" */ "../editor/config-elements/hui-light-card-editor");
return document.createElement("hui-light-card-editor"); return document.createElement("hui-light-card-editor");

View File

@ -14,7 +14,6 @@ import computeStateDisplay from "../../../common/entity/compute_state_display";
import computeStateName from "../../../common/entity/compute_state_name"; import computeStateName from "../../../common/entity/compute_state_name";
import { longPress } from "../common/directives/long-press-directive"; import { longPress } from "../common/directives/long-press-directive";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace"; import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace";
import { LovelaceCard } from "../types"; import { LovelaceCard } from "../types";
@ -38,8 +37,7 @@ interface Config extends LovelaceCardConfig {
show_state?: boolean; show_state?: boolean;
} }
class HuiPictureEntityCard extends hassLocalizeLitMixin(LitElement) class HuiPictureEntityCard extends LitElement implements LovelaceCard {
implements LovelaceCard {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;
@ -89,7 +87,7 @@ class HuiPictureEntityCard extends hassLocalizeLitMixin(LitElement)
const name = this._config.name || computeStateName(stateObj); const name = this._config.name || computeStateName(stateObj);
const state = computeStateDisplay( const state = computeStateDisplay(
this.localize, this.hass!.localize,
stateObj, stateObj,
this.hass.language this.hass.language
); );

View File

@ -6,7 +6,6 @@ import {
} from "lit-element"; } from "lit-element";
import { classMap } from "lit-html/directives/class-map"; import { classMap } from "lit-html/directives/class-map";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { DOMAINS_TOGGLE } from "../../../common/const"; import { DOMAINS_TOGGLE } from "../../../common/const";
import { LovelaceCard } from "../types"; import { LovelaceCard } from "../types";
import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace"; import { LovelaceCardConfig, ActionConfig } from "../../../data/lovelace";
@ -40,8 +39,7 @@ interface Config extends LovelaceCardConfig {
hold_action?: ActionConfig; hold_action?: ActionConfig;
} }
class HuiPictureGlanceCard extends hassLocalizeLitMixin(LitElement) class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
implements LovelaceCard {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;
private _entitiesDialog?: EntityConfig[]; private _entitiesDialog?: EntityConfig[];
@ -154,7 +152,7 @@ class HuiPictureGlanceCard extends hassLocalizeLitMixin(LitElement)
.icon="${entityConf.icon || stateIcon(stateObj)}" .icon="${entityConf.icon || stateIcon(stateObj)}"
title="${` title="${`
${computeStateName(stateObj)} : ${computeStateDisplay( ${computeStateName(stateObj)} : ${computeStateDisplay(
this.localize, this.hass!.localize,
stateObj, stateObj,
this.hass!.language this.hass!.language
)} )}

View File

@ -6,7 +6,6 @@ import "@polymer/paper-checkbox/paper-checkbox";
import "../../../components/ha-card"; import "../../../components/ha-card";
import "../../../components/ha-icon"; import "../../../components/ha-icon";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { LovelaceCard, LovelaceCardEditor } from "../types"; import { LovelaceCard, LovelaceCardEditor } from "../types";
import { LovelaceCardConfig } from "../../../data/lovelace"; import { LovelaceCardConfig } from "../../../data/lovelace";
@ -22,8 +21,7 @@ export interface Config extends LovelaceCardConfig {
title?: string; title?: string;
} }
class HuiShoppingListCard extends hassLocalizeLitMixin(LitElement) class HuiShoppingListCard extends LitElement implements LovelaceCard {
implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-shopping-list-editor" */ "../editor/config-elements/hui-shopping-list-editor"); await import(/* webpackChunkName: "hui-shopping-list-editor" */ "../editor/config-elements/hui-shopping-list-editor");
return document.createElement("hui-shopping-list-card-editor"); return document.createElement("hui-shopping-list-card-editor");
@ -91,7 +89,7 @@ class HuiShoppingListCard extends hassLocalizeLitMixin(LitElement)
class="addButton" class="addButton"
@click="${this._addItem}" @click="${this._addItem}"
icon="hass:plus" icon="hass:plus"
.title="${this.localize( .title="${this.hass!.localize(
"ui.panel.lovelace.cards.shopping-list.add_item" "ui.panel.lovelace.cards.shopping-list.add_item"
)}" )}"
> >
@ -100,7 +98,7 @@ class HuiShoppingListCard extends hassLocalizeLitMixin(LitElement)
<paper-input <paper-input
no-label-float no-label-float
class="addBox" class="addBox"
placeholder="${this.localize( placeholder="${this.hass!.localize(
"ui.panel.lovelace.cards.shopping-list.add_item" "ui.panel.lovelace.cards.shopping-list.add_item"
)}" )}"
@keydown="${this._addKeyPress}" @keydown="${this._addKeyPress}"
@ -137,7 +135,7 @@ class HuiShoppingListCard extends hassLocalizeLitMixin(LitElement)
<div class="divider"></div> <div class="divider"></div>
<div class="checked"> <div class="checked">
<span class="label"> <span class="label">
${this.localize( ${this.hass!.localize(
"ui.panel.lovelace.cards.shopping-list.checked_items" "ui.panel.lovelace.cards.shopping-list.checked_items"
)} )}
</span> </span>
@ -145,7 +143,7 @@ class HuiShoppingListCard extends hassLocalizeLitMixin(LitElement)
class="clearall" class="clearall"
@click="${this._clearItems}" @click="${this._clearItems}"
icon="hass:notification-clear-all" icon="hass:notification-clear-all"
.title="${this.localize( .title="${this.hass!.localize(
"ui.panel.lovelace.cards.shopping-list.clear_items" "ui.panel.lovelace.cards.shopping-list.clear_items"
)}" )}"
> >

View File

@ -15,7 +15,6 @@ import computeStateName from "../../../common/entity/compute_state_name";
import { hasConfigOrEntityChanged } from "../common/has-changed"; import { hasConfigOrEntityChanged } from "../common/has-changed";
import { HomeAssistant, ClimateEntity } from "../../../types"; import { HomeAssistant, ClimateEntity } from "../../../types";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { LovelaceCard, LovelaceCardEditor } from "../types"; import { LovelaceCard, LovelaceCardEditor } from "../types";
import { LovelaceCardConfig } from "../../../data/lovelace"; import { LovelaceCardConfig } from "../../../data/lovelace";
import { loadRoundslider } from "../../../resources/jquery.roundslider.ondemand"; import { loadRoundslider } from "../../../resources/jquery.roundslider.ondemand";
@ -51,8 +50,7 @@ export interface Config extends LovelaceCardConfig {
name?: string; name?: string;
} }
export class HuiThermostatCard extends hassLocalizeLitMixin(LitElement) export class HuiThermostatCard extends LitElement implements LovelaceCard {
implements LovelaceCard {
public static async getConfigElement(): Promise<LovelaceCardEditor> { public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import(/* webpackChunkName: "hui-thermostat-card-editor" */ "../editor/config-elements/hui-thermostat-card-editor"); await import(/* webpackChunkName: "hui-thermostat-card-editor" */ "../editor/config-elements/hui-thermostat-card-editor");
return document.createElement("hui-thermostat-card-editor"); return document.createElement("hui-thermostat-card-editor");
@ -145,7 +143,7 @@ export class HuiThermostatCard extends hassLocalizeLitMixin(LitElement)
</div> </div>
<div class="climate-info"> <div class="climate-info">
<div id="set-temperature"></div> <div id="set-temperature"></div>
<div class="current-mode">${this.localize( <div class="current-mode">${this.hass!.localize(
`state.climate.${stateObj.state}` `state.climate.${stateObj.state}`
)}</div> )}</div>
<div class="modes"> <div class="modes">

View File

@ -5,7 +5,6 @@ import "@polymer/paper-icon-button/paper-icon-button";
import "@polymer/paper-listbox/paper-listbox"; import "@polymer/paper-listbox/paper-listbox";
import { showEditCardDialog } from "../editor/card-editor/show-edit-card-dialog"; import { showEditCardDialog } from "../editor/card-editor/show-edit-card-dialog";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { confDeleteCard } from "../editor/delete-card"; import { confDeleteCard } from "../editor/delete-card";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { LovelaceCardConfig } from "../../../data/lovelace"; import { LovelaceCardConfig } from "../../../data/lovelace";
@ -13,7 +12,7 @@ import { Lovelace } from "../types";
import { swapCard } from "../editor/config-util"; import { swapCard } from "../editor/config-util";
import { showMoveCardViewDialog } from "../editor/card-editor/show-move-card-view-dialog"; import { showMoveCardViewDialog } from "../editor/card-editor/show-move-card-view-dialog";
export class HuiCardOptions extends hassLocalizeLitMixin(LitElement) { export class HuiCardOptions extends LitElement {
public cardConfig?: LovelaceCardConfig; public cardConfig?: LovelaceCardConfig;
public hass?: HomeAssistant; public hass?: HomeAssistant;
public lovelace?: Lovelace; public lovelace?: Lovelace;
@ -71,7 +70,7 @@ export class HuiCardOptions extends hassLocalizeLitMixin(LitElement) {
<div class="options"> <div class="options">
<div class="primary-actions"> <div class="primary-actions">
<paper-button @click="${this._editCard}" <paper-button @click="${this._editCard}"
>${this.localize( >${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.edit" "ui.panel.lovelace.editor.edit_card.edit"
)}</paper-button )}</paper-button
> >
@ -101,7 +100,7 @@ export class HuiCardOptions extends hassLocalizeLitMixin(LitElement) {
<paper-listbox slot="dropdown-content"> <paper-listbox slot="dropdown-content">
<paper-item @click="${this._moveCard}">Move Card</paper-item> <paper-item @click="${this._moveCard}">Move Card</paper-item>
<paper-item @click="${this._deleteCard}" <paper-item @click="${this._deleteCard}"
>${this.localize( >${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.delete" "ui.panel.lovelace.editor.edit_card.delete"
)}</paper-item )}</paper-item
> >

View File

@ -8,7 +8,6 @@ import "@polymer/paper-button/paper-button";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { fireEvent, HASSDomEvent } from "../../../common/dom/fire_event"; import { fireEvent, HASSDomEvent } from "../../../common/dom/fire_event";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
declare global { declare global {
// for fire event // for fire event
@ -21,7 +20,7 @@ declare global {
} }
} }
export class HuiThemeSelectionEditor extends hassLocalizeLitMixin(LitElement) { export class HuiThemeSelectionEditor extends LitElement {
public value?: string; public value?: string;
public hass?: HomeAssistant; public hass?: HomeAssistant;

View File

@ -11,7 +11,6 @@ import format_date from "../../../common/datetime/format_date";
import format_date_time from "../../../common/datetime/format_date_time"; import format_date_time from "../../../common/datetime/format_date_time";
import format_time from "../../../common/datetime/format_time"; import format_time from "../../../common/datetime/format_time";
import relativeTime from "../../../common/datetime/relative_time"; import relativeTime from "../../../common/datetime/relative_time";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
const FORMATS: { [key: string]: (ts: Date, lang: string) => string } = { const FORMATS: { [key: string]: (ts: Date, lang: string) => string } = {
date: format_date, date: format_date,
@ -20,7 +19,7 @@ const FORMATS: { [key: string]: (ts: Date, lang: string) => string } = {
}; };
const INTERVAL_FORMAT = ["relative", "total"]; const INTERVAL_FORMAT = ["relative", "total"];
class HuiTimestampDisplay extends hassLocalizeLitMixin(LitElement) { class HuiTimestampDisplay extends LitElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
public ts?: Date; public ts?: Date;
public format?: "relative" | "total" | "date" | "datetime" | "time"; public format?: "relative" | "total" | "date" | "datetime" | "time";
@ -110,11 +109,11 @@ class HuiTimestampDisplay extends hassLocalizeLitMixin(LitElement) {
} }
private _updateRelative() { private _updateRelative() {
if (this.ts && this.localize) { if (this.ts && this.hass!.localize) {
this._relative = this._relative =
this._format === "relative" this._format === "relative"
? relativeTime(this.ts, this.localize) ? relativeTime(this.ts, this.hass!.localize)
: (this._relative = relativeTime(new Date(), this.localize, { : (this._relative = relativeTime(new Date(), this.hass!.localize, {
compareTime: this.ts, compareTime: this.ts,
includeTense: false, includeTense: false,
})); }));

View File

@ -5,7 +5,6 @@ import { HomeAssistant } from "../../../../types";
import { LovelaceCardConfig } from "../../../../data/lovelace"; import { LovelaceCardConfig } from "../../../../data/lovelace";
import { getCardElementTag } from "../../common/get-card-element-tag"; import { getCardElementTag } from "../../common/get-card-element-tag";
import { CardPickTarget } from "../types"; import { CardPickTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
const cards = [ const cards = [
{ name: "Alarm panel", type: "alarm-panel" }, { name: "Alarm panel", type: "alarm-panel" },
@ -34,13 +33,15 @@ const cards = [
{ name: "Weather Forecast", type: "weather-forecast" }, { name: "Weather Forecast", type: "weather-forecast" },
]; ];
export class HuiCardPicker extends hassLocalizeLitMixin(LitElement) { export class HuiCardPicker extends LitElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
public cardPicked?: (cardConf: LovelaceCardConfig) => void; public cardPicked?: (cardConf: LovelaceCardConfig) => void;
protected render(): TemplateResult | void { protected render(): TemplateResult | void {
return html` return html`
<h3>${this.localize("ui.panel.lovelace.editor.edit_card.pick_card")}</h3> <h3>
${this.hass!.localize("ui.panel.lovelace.editor.edit_card.pick_card")}
</h3>
<div class="cards-container"> <div class="cards-container">
${cards.map((card) => { ${cards.map((card) => {
return html` return html`

View File

@ -9,11 +9,10 @@ import "@polymer/paper-item/paper-item";
// tslint:disable-next-line:no-duplicate-imports // tslint:disable-next-line:no-duplicate-imports
import { PaperDialogElement } from "@polymer/paper-dialog/paper-dialog"; import { PaperDialogElement } from "@polymer/paper-dialog/paper-dialog";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { moveCard } from "../config-util"; import { moveCard } from "../config-util";
import { MoveCardViewDialogParams } from "./show-move-card-view-dialog"; import { MoveCardViewDialogParams } from "./show-move-card-view-dialog";
export class HuiDialogMoveCardView extends hassLocalizeLitMixin(LitElement) { export class HuiDialogMoveCardView extends LitElement {
private _params?: MoveCardViewDialogParams; private _params?: MoveCardViewDialogParams;
static get properties(): PropertyDeclarations { static get properties(): PropertyDeclarations {

View File

@ -13,10 +13,9 @@ import { haStyleDialog } from "../../../../resources/ha-style";
import "./hui-card-picker"; import "./hui-card-picker";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { LovelaceCardConfig } from "../../../../data/lovelace"; import { LovelaceCardConfig } from "../../../../data/lovelace";
export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) { export class HuiDialogPickCard extends LitElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
public cardPicked?: (cardConf: LovelaceCardConfig) => void; public cardPicked?: (cardConf: LovelaceCardConfig) => void;
public closeDialog?: () => void; public closeDialog?: () => void;
@ -32,7 +31,9 @@ export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
opened opened
@opened-changed="${this._openedChanged}" @opened-changed="${this._openedChanged}"
> >
<h2>${this.localize("ui.panel.lovelace.editor.edit_card.header")}</h2> <h2>
${this.hass!.localize("ui.panel.lovelace.editor.edit_card.header")}
</h2>
<paper-dialog-scrollable> <paper-dialog-scrollable>
<hui-card-picker <hui-card-picker
.hass="${this.hass}" .hass="${this.hass}"

View File

@ -22,7 +22,6 @@ import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardConfig } from "../../../../data/lovelace"; import { LovelaceCardConfig } from "../../../../data/lovelace";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import "./hui-yaml-editor"; import "./hui-yaml-editor";
import "./hui-card-preview"; import "./hui-card-preview";
@ -50,7 +49,7 @@ declare global {
} }
} }
export class HuiEditCard extends hassLocalizeLitMixin(LitElement) { export class HuiEditCard extends LitElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
public lovelace?: Lovelace; public lovelace?: Lovelace;
public path?: [number] | [number, number]; public path?: [number] | [number, number];
@ -140,7 +139,9 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
opened opened
@opened-changed="${this._openedChanged}" @opened-changed="${this._openedChanged}"
> >
<h2>${this.localize("ui.panel.lovelace.editor.edit_card.header")}</h2> <h2>
${this.hass!.localize("ui.panel.lovelace.editor.edit_card.header")}
</h2>
<paper-spinner <paper-spinner
?active="${this._loading}" ?active="${this._loading}"
alt="Loading" alt="Loading"
@ -165,12 +166,12 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
?disabled="${this._configElement === null || ?disabled="${this._configElement === null ||
this._configState !== "OK"}" this._configState !== "OK"}"
@click="${this._toggleEditor}" @click="${this._toggleEditor}"
>${this.localize( >${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.toggle_editor" "ui.panel.lovelace.editor.edit_card.toggle_editor"
)}</paper-button )}</paper-button
> >
<paper-button @click="${this.closeDialog}" <paper-button @click="${this.closeDialog}"
>${this.localize("ui.common.cancel")}</paper-button >${this.hass!.localize("ui.common.cancel")}</paper-button
> >
<paper-button <paper-button
?hidden="${!this._configValue || !this._configValue.value}" ?hidden="${!this._configValue || !this._configValue.value}"
@ -181,7 +182,7 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
?active="${this._saving}" ?active="${this._saving}"
alt="Saving" alt="Saving"
></paper-spinner> ></paper-spinner>
${this.localize("ui.common.save")}</paper-button ${this.hass!.localize("ui.common.save")}</paper-button
> >
</div> </div>
` `

View File

@ -10,7 +10,6 @@ import "@polymer/paper-listbox/paper-listbox";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -27,7 +26,7 @@ const cardConfigStruct = struct({
states: "array?", states: "array?",
}); });
export class HuiAlarmPanelCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiAlarmPanelCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -12,7 +12,6 @@ import "@polymer/paper-toggle-button/paper-toggle-button";
import { processEditorEntities } from "../process-editor-entities"; import { processEditorEntities } from "../process-editor-entities";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -45,7 +44,7 @@ const cardConfigStruct = struct({
entities: [entitiesConfigStruct], entities: [entitiesConfigStruct],
}); });
export class HuiEntitiesCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiEntitiesCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
static get properties(): PropertyDeclarations { static get properties(): PropertyDeclarations {
return { hass: {}, _config: {}, _configEntities: {} }; return { hass: {}, _config: {}, _configEntities: {} };

View File

@ -12,7 +12,6 @@ import {
EditorTarget, EditorTarget,
actionConfigStruct, actionConfigStruct,
} from "../types"; } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -34,7 +33,7 @@ const cardConfigStruct = struct({
theme: "string?", theme: "string?",
}); });
export class HuiEntityButtonCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiEntityButtonCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -9,7 +9,6 @@ import "@polymer/paper-toggle-button/paper-toggle-button";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -30,7 +29,7 @@ const cardConfigStruct = struct({
theme: "string?", theme: "string?",
}); });
export class HuiGaugeCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiGaugeCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -12,7 +12,6 @@ import "@polymer/paper-toggle-button/paper-toggle-button";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { processEditorEntities } from "../process-editor-entities"; import { processEditorEntities } from "../process-editor-entities";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -44,7 +43,7 @@ const cardConfigStruct = struct({
entities: [entitiesConfigStruct], entities: [entitiesConfigStruct],
}); });
export class HuiGlanceCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiGlanceCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -8,7 +8,6 @@ import "@polymer/paper-input/paper-input";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -22,7 +21,7 @@ const cardConfigStruct = struct({
aspect_ratio: "string?", aspect_ratio: "string?",
}); });
export class HuiIframeCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiIframeCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -8,7 +8,6 @@ import "@polymer/paper-input/paper-input";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -25,7 +24,7 @@ const cardConfigStruct = struct({
theme: "string?", theme: "string?",
}); });
export class HuiLightCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiLightCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -8,7 +8,6 @@ import "@polymer/paper-input/paper-input";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -36,8 +35,7 @@ const cardConfigStruct = struct({
entities: [entitiesConfigStruct], entities: [entitiesConfigStruct],
}); });
export class HuiMapCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;
private _configEntities?: EntityConfig[]; private _configEntities?: EntityConfig[];

View File

@ -9,7 +9,6 @@ import "@polymer/paper-input/paper-textarea";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -22,7 +21,7 @@ const cardConfigStruct = struct({
content: "string", content: "string",
}); });
export class HuiMarkdownCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiMarkdownCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -7,7 +7,6 @@ import {
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -20,7 +19,7 @@ const cardConfigStruct = struct({
entity: "string?", entity: "string?",
}); });
export class HuiMediaControlCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiMediaControlCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -12,7 +12,6 @@ import {
EditorTarget, EditorTarget,
actionConfigStruct, actionConfigStruct,
} from "../types"; } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -29,7 +28,7 @@ const cardConfigStruct = struct({
hold_action: struct.optional(actionConfigStruct), hold_action: struct.optional(actionConfigStruct),
}); });
export class HuiPictureCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiPictureCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -8,7 +8,6 @@ import "@polymer/paper-input/paper-input";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -24,7 +23,7 @@ const cardConfigStruct = struct({
name: "string?", name: "string?",
}); });
export class HuiPlantStatusCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiPlantStatusCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -11,7 +11,6 @@ import "@polymer/paper-listbox/paper-listbox";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -33,7 +32,7 @@ const cardConfigStruct = struct({
hours_to_show: "number?", hours_to_show: "number?",
}); });
export class HuiSensorCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiSensorCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -8,7 +8,6 @@ import "@polymer/paper-input/paper-input";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -19,7 +18,7 @@ const cardConfigStruct = struct({
title: "string?", title: "string?",
}); });
export class HuiShoppingListEditor extends hassLocalizeLitMixin(LitElement) export class HuiShoppingListEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -8,7 +8,6 @@ import "@polymer/paper-input/paper-input";
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -25,7 +24,7 @@ const cardConfigStruct = struct({
theme: "string?", theme: "string?",
}); });
export class HuiThermostatCardEditor extends hassLocalizeLitMixin(LitElement) export class HuiThermostatCardEditor extends LitElement
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -7,7 +7,6 @@ import {
import { struct } from "../../common/structs/struct"; import { struct } from "../../common/structs/struct";
import { EntitiesEditorEvent, EditorTarget } from "../types"; import { EntitiesEditorEvent, EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
@ -22,8 +21,7 @@ const cardConfigStruct = struct({
name: "string?", name: "string?",
}); });
export class HuiWeatherForecastCardEditor export class HuiWeatherForecastCardEditor extends LitElement
extends hassLocalizeLitMixin(LitElement)
implements LovelaceCardEditor { implements LovelaceCardEditor {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -18,10 +18,9 @@ import { haStyleDialog } from "../../../resources/ha-style";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { SaveDialogParams } from "./show-save-config-dialog"; import { SaveDialogParams } from "./show-save-config-dialog";
export class HuiSaveConfig extends hassLocalizeLitMixin(LitElement) { export class HuiSaveConfig extends LitElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _params?: SaveDialogParams; private _params?: SaveDialogParams;
private _saving: boolean; private _saving: boolean;
@ -52,16 +51,22 @@ export class HuiSaveConfig extends hassLocalizeLitMixin(LitElement) {
protected render(): TemplateResult | void { protected render(): TemplateResult | void {
return html` return html`
<paper-dialog with-backdrop> <paper-dialog with-backdrop>
<h2>${this.localize("ui.panel.lovelace.editor.save_config.header")}</h2> <h2>
${this.hass!.localize("ui.panel.lovelace.editor.save_config.header")}
</h2>
<paper-dialog-scrollable> <paper-dialog-scrollable>
<p>${this.localize("ui.panel.lovelace.editor.save_config.para")}</p>
<p> <p>
${this.localize("ui.panel.lovelace.editor.save_config.para_sure")} ${this.hass!.localize("ui.panel.lovelace.editor.save_config.para")}
</p>
<p>
${this.hass!.localize(
"ui.panel.lovelace.editor.save_config.para_sure"
)}
</p> </p>
</paper-dialog-scrollable> </paper-dialog-scrollable>
<div class="paper-dialog-buttons"> <div class="paper-dialog-buttons">
<paper-button @click="${this._closeDialog}" <paper-button @click="${this._closeDialog}"
>${this.localize( >${this.hass!.localize(
"ui.panel.lovelace.editor.save_config.cancel" "ui.panel.lovelace.editor.save_config.cancel"
)}</paper-button )}</paper-button
> >
@ -73,7 +78,7 @@ export class HuiSaveConfig extends hassLocalizeLitMixin(LitElement) {
?active="${this._saving}" ?active="${this._saving}"
alt="Saving" alt="Saving"
></paper-spinner> ></paper-spinner>
${this.localize( ${this.hass!.localize(
"ui.panel.lovelace.editor.save_config.save" "ui.panel.lovelace.editor.save_config.save"
)}</paper-button )}</paper-button
> >

View File

@ -19,10 +19,9 @@ import { haStyleDialog } from "../../../../resources/ha-style";
import "./hui-lovelace-editor"; import "./hui-lovelace-editor";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { LovelaceConfig } from "../../../../data/lovelace"; import { LovelaceConfig } from "../../../../data/lovelace";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { Lovelace } from "../../types"; import { Lovelace } from "../../types";
export class HuiDialogEditLovelace extends hassLocalizeLitMixin(LitElement) { export class HuiDialogEditLovelace extends LitElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _lovelace?: Lovelace; private _lovelace?: Lovelace;
private _config?: LovelaceConfig; private _config?: LovelaceConfig;
@ -69,7 +68,7 @@ export class HuiDialogEditLovelace extends hassLocalizeLitMixin(LitElement) {
></paper-dialog-scrollable> ></paper-dialog-scrollable>
<div class="paper-dialog-buttons"> <div class="paper-dialog-buttons">
<paper-button @click="${this._closeDialog}" <paper-button @click="${this._closeDialog}"
>${this.localize("ui.common.cancel")}</paper-button >${this.hass!.localize("ui.common.cancel")}</paper-button
> >
<paper-button <paper-button
?disabled="${!this._config || this._saving}" ?disabled="${!this._config || this._saving}"
@ -79,7 +78,7 @@ export class HuiDialogEditLovelace extends hassLocalizeLitMixin(LitElement) {
?active="${this._saving}" ?active="${this._saving}"
alt="Saving" alt="Saving"
></paper-spinner> ></paper-spinner>
${this.localize("ui.common.save")}</paper-button ${this.hass!.localize("ui.common.save")}</paper-button
> >
</div> </div>
</paper-dialog> </paper-dialog>

View File

@ -7,7 +7,6 @@ import {
import "@polymer/paper-input/paper-input"; import "@polymer/paper-input/paper-input";
import { EditorTarget } from "../types"; import { EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { configElementStyle } from "../config-elements/config-elements-style"; import { configElementStyle } from "../config-elements/config-elements-style";
@ -22,7 +21,7 @@ declare global {
} }
} }
export class HuiLovelaceEditor extends hassLocalizeLitMixin(LitElement) { export class HuiLovelaceEditor extends LitElement {
static get properties(): PropertyDeclarations { static get properties(): PropertyDeclarations {
return { hass: {}, config: {} }; return { hass: {}, config: {} };
} }

View File

@ -28,7 +28,6 @@ import {
LovelaceCardConfig, LovelaceCardConfig,
} from "../../../../data/lovelace"; } from "../../../../data/lovelace";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { EntitiesEditorEvent, ViewEditEvent } from "../types"; import { EntitiesEditorEvent, ViewEditEvent } from "../types";
import { processEditorEntities } from "../process-editor-entities"; import { processEditorEntities } from "../process-editor-entities";
import { EntityConfig } from "../../entity-rows/types"; import { EntityConfig } from "../../entity-rows/types";
@ -36,7 +35,7 @@ import { navigate } from "../../../../common/navigate";
import { Lovelace } from "../../types"; import { Lovelace } from "../../types";
import { deleteView, addView, replaceView } from "../config-util"; import { deleteView, addView, replaceView } from "../config-util";
export class HuiEditView extends hassLocalizeLitMixin(LitElement) { export class HuiEditView extends LitElement {
public lovelace?: Lovelace; public lovelace?: Lovelace;
public viewIndex?: number; public viewIndex?: number;
public hass?: HomeAssistant; public hass?: HomeAssistant;
@ -121,7 +120,9 @@ export class HuiEditView extends hassLocalizeLitMixin(LitElement) {
} }
return html` return html`
<paper-dialog with-backdrop> <paper-dialog with-backdrop>
<h2>${this.localize("ui.panel.lovelace.editor.edit_view.header")}</h2> <h2>
${this.hass!.localize("ui.panel.lovelace.editor.edit_view.header")}
</h2>
<paper-tabs <paper-tabs
scrollable scrollable
hide-scroll-buttons hide-scroll-buttons
@ -144,7 +145,7 @@ export class HuiEditView extends hassLocalizeLitMixin(LitElement) {
` `
: ""} : ""}
<paper-button @click="${this._closeDialog}" <paper-button @click="${this._closeDialog}"
>${this.localize("ui.common.cancel")}</paper-button >${this.hass!.localize("ui.common.cancel")}</paper-button
> >
<paper-button <paper-button
?disabled="${!this._config || this._saving}" ?disabled="${!this._config || this._saving}"
@ -154,7 +155,7 @@ export class HuiEditView extends hassLocalizeLitMixin(LitElement) {
?active="${this._saving}" ?active="${this._saving}"
alt="Saving" alt="Saving"
></paper-spinner> ></paper-spinner>
${this.localize("ui.common.save")}</paper-button ${this.hass!.localize("ui.common.save")}</paper-button
> >
</div> </div>
</paper-dialog> </paper-dialog>

View File

@ -7,7 +7,6 @@ import {
import "@polymer/paper-input/paper-input"; import "@polymer/paper-input/paper-input";
import { EditorTarget } from "../types"; import { EditorTarget } from "../types";
import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { configElementStyle } from "../config-elements/config-elements-style"; import { configElementStyle } from "../config-elements/config-elements-style";
@ -23,7 +22,7 @@ declare global {
} }
} }
export class HuiViewEditor extends hassLocalizeLitMixin(LitElement) { export class HuiViewEditor extends LitElement {
static get properties(): PropertyDeclarations { static get properties(): PropertyDeclarations {
return { hass: {}, _config: {} }; return { hass: {}, _config: {} };
} }

View File

@ -5,7 +5,6 @@ import "../../../components/ha-icon";
import { computeTooltip } from "../common/compute-tooltip"; import { computeTooltip } from "../common/compute-tooltip";
import { handleClick } from "../common/handle-click"; import { handleClick } from "../common/handle-click";
import { longPress } from "../common/directives/long-press-directive"; import { longPress } from "../common/directives/long-press-directive";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { LovelaceElement, LovelaceElementConfig } from "./types"; import { LovelaceElement, LovelaceElementConfig } from "./types";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
@ -13,8 +12,7 @@ interface Config extends LovelaceElementConfig {
icon: string; icon: string;
} }
export class HuiIconElement extends hassLocalizeLitMixin(LitElement) export class HuiIconElement extends LitElement implements LovelaceElement {
implements LovelaceElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -5,7 +5,6 @@ import "../components/hui-image";
import { computeTooltip } from "../common/compute-tooltip"; import { computeTooltip } from "../common/compute-tooltip";
import { handleClick } from "../common/handle-click"; import { handleClick } from "../common/handle-click";
import { longPress } from "../common/directives/long-press-directive"; import { longPress } from "../common/directives/long-press-directive";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { LovelaceElement, LovelaceElementConfig } from "./types"; import { LovelaceElement, LovelaceElementConfig } from "./types";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
@ -18,8 +17,7 @@ interface Config extends LovelaceElementConfig {
aspect_ratio?: string; aspect_ratio?: string;
} }
export class HuiImageElement extends hassLocalizeLitMixin(LitElement) export class HuiImageElement extends LitElement implements LovelaceElement {
implements LovelaceElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;

View File

@ -5,12 +5,10 @@ import "../../../components/entity/state-badge";
import { computeTooltip } from "../common/compute-tooltip"; import { computeTooltip } from "../common/compute-tooltip";
import { handleClick } from "../common/handle-click"; import { handleClick } from "../common/handle-click";
import { longPress } from "../common/directives/long-press-directive"; import { longPress } from "../common/directives/long-press-directive";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { LovelaceElement, LovelaceElementConfig } from "./types"; import { LovelaceElement, LovelaceElementConfig } from "./types";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
export class HuiStateIconElement extends hassLocalizeLitMixin(LitElement) export class HuiStateIconElement extends LitElement implements LovelaceElement {
implements LovelaceElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: LovelaceElementConfig; private _config?: LovelaceElementConfig;

View File

@ -6,7 +6,6 @@ import computeStateDisplay from "../../../common/entity/compute_state_display";
import { computeTooltip } from "../common/compute-tooltip"; import { computeTooltip } from "../common/compute-tooltip";
import { handleClick } from "../common/handle-click"; import { handleClick } from "../common/handle-click";
import { longPress } from "../common/directives/long-press-directive"; import { longPress } from "../common/directives/long-press-directive";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { LovelaceElement, LovelaceElementConfig } from "./types"; import { LovelaceElement, LovelaceElementConfig } from "./types";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
@ -15,8 +14,7 @@ interface Config extends LovelaceElementConfig {
suffix?: string; suffix?: string;
} }
class HuiStateLabelElement extends hassLocalizeLitMixin(LitElement) class HuiStateLabelElement extends LitElement implements LovelaceElement {
implements LovelaceElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: Config; private _config?: Config;
@ -47,7 +45,7 @@ class HuiStateLabelElement extends hassLocalizeLitMixin(LitElement)
.longPress="${longPress()}" .longPress="${longPress()}"
> >
${this._config.prefix}${state ${this._config.prefix}${state
? computeStateDisplay(this.localize, state, this.hass!.language) ? computeStateDisplay(this.hass!.localize, state, this.hass!.language)
: "-"}${this._config.suffix} : "-"}${this._config.suffix}
</div> </div>
`; `;

View File

@ -11,12 +11,10 @@ import "./hui-error-entity-row";
import computeStateDisplay from "../../../common/entity/compute_state_display"; import computeStateDisplay from "../../../common/entity/compute_state_display";
import { DOMAINS_TOGGLE } from "../../../common/const"; import { DOMAINS_TOGGLE } from "../../../common/const";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types"; import { EntityRow, EntityConfig } from "./types";
class HuiGroupEntityRow extends hassLocalizeLitMixin(LitElement) class HuiGroupEntityRow extends LitElement implements EntityRow {
implements EntityRow {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: EntityConfig; private _config?: EntityConfig;
@ -61,7 +59,7 @@ class HuiGroupEntityRow extends hassLocalizeLitMixin(LitElement)
: html` : html`
<div> <div>
${computeStateDisplay( ${computeStateDisplay(
this.localize, this.hass!.localize,
stateObj, stateObj,
this.hass.language this.hass.language
)} )}

View File

@ -8,12 +8,10 @@ import {
import "../components/hui-generic-entity-row"; import "../components/hui-generic-entity-row";
import "./hui-error-entity-row"; import "./hui-error-entity-row";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types"; import { EntityRow, EntityConfig } from "./types";
class HuiLockEntityRow extends hassLocalizeLitMixin(LitElement) class HuiLockEntityRow extends LitElement implements EntityRow {
implements EntityRow {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: EntityConfig; private _config?: EntityConfig;
@ -51,8 +49,8 @@ class HuiLockEntityRow extends hassLocalizeLitMixin(LitElement)
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}"> <hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<paper-button @click="${this._callService}"> <paper-button @click="${this._callService}">
${stateObj.state === "locked" ${stateObj.state === "locked"
? this.localize("ui.card.lock.unlock") ? this.hass!.localize("ui.card.lock.unlock")
: this.localize("ui.card.lock.lock")} : this.hass!.localize("ui.card.lock.lock")}
</paper-button> </paper-button>
</hui-generic-entity-row> </hui-generic-entity-row>
`; `;

View File

@ -3,7 +3,6 @@ import "@polymer/paper-icon-button/paper-icon-button";
import "../components/hui-generic-entity-row"; import "../components/hui-generic-entity-row";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { EntityRow, EntityConfig } from "./types"; import { EntityRow, EntityConfig } from "./types";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { HassEntity } from "home-assistant-js-websocket"; import { HassEntity } from "home-assistant-js-websocket";
@ -15,8 +14,7 @@ import {
SUPPORT_PAUSE, SUPPORT_PAUSE,
} from "../../../data/media-player"; } from "../../../data/media-player";
class HuiMediaPlayerEntityRow extends hassLocalizeLitMixin(LitElement) class HuiMediaPlayerEntityRow extends LitElement implements EntityRow {
implements EntityRow {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: EntityConfig; private _config?: EntityConfig;
@ -60,8 +58,8 @@ class HuiMediaPlayerEntityRow extends hassLocalizeLitMixin(LitElement)
${OFF_STATES.includes(stateObj.state) ${OFF_STATES.includes(stateObj.state)
? html` ? html`
<div> <div>
${this.localize(`state.media_player.${stateObj.state}`) || ${this.hass!.localize(`state.media_player.${stateObj.state}`) ||
this.localize(`state.default.${stateObj.state}`) || this.hass!.localize(`state.default.${stateObj.state}`) ||
stateObj.state} stateObj.state}
</div> </div>
` `

View File

@ -9,12 +9,10 @@ import "../components/hui-generic-entity-row";
import "../../../components/entity/ha-entity-toggle"; import "../../../components/entity/ha-entity-toggle";
import "./hui-error-entity-row"; import "./hui-error-entity-row";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types"; import { EntityRow, EntityConfig } from "./types";
class HuiSceneEntityRow extends hassLocalizeLitMixin(LitElement) class HuiSceneEntityRow extends LitElement implements EntityRow {
implements EntityRow {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: EntityConfig; private _config?: EntityConfig;
@ -59,7 +57,7 @@ class HuiSceneEntityRow extends hassLocalizeLitMixin(LitElement)
` `
: html` : html`
<paper-button @click="${this._callService}"> <paper-button @click="${this._callService}">
${this.localize("ui.card.scene.activate")} ${this.hass!.localize("ui.card.scene.activate")}
</paper-button> </paper-button>
`} `}
</hui-generic-entity-row> </hui-generic-entity-row>

View File

@ -9,12 +9,10 @@ import "../components/hui-generic-entity-row";
import "../../../components/entity/ha-entity-toggle"; import "../../../components/entity/ha-entity-toggle";
import "./hui-error-entity-row"; import "./hui-error-entity-row";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types"; import { EntityRow, EntityConfig } from "./types";
class HuiScriptEntityRow extends hassLocalizeLitMixin(LitElement) class HuiScriptEntityRow extends LitElement implements EntityRow {
implements EntityRow {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: EntityConfig; private _config?: EntityConfig;
@ -59,7 +57,7 @@ class HuiScriptEntityRow extends hassLocalizeLitMixin(LitElement)
` `
: html` : html`
<paper-button @click="${this._callService}"> <paper-button @click="${this._callService}">
${this.localize("ui.card.script.execute")} ${this.hass!.localize("ui.card.script.execute")}
</paper-button> </paper-button>
`} `}
</hui-generic-entity-row> </hui-generic-entity-row>

View File

@ -13,14 +13,12 @@ import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types"; import { EntityRow, EntityConfig } from "./types";
import computeStateDisplay from "../../../common/entity/compute_state_display"; import computeStateDisplay from "../../../common/entity/compute_state_display";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
interface SensorEntityConfig extends EntityConfig { interface SensorEntityConfig extends EntityConfig {
format?: "relative" | "date" | "time" | "datetime"; format?: "relative" | "date" | "time" | "datetime";
} }
class HuiSensorEntityRow extends hassLocalizeLitMixin(LitElement) class HuiSensorEntityRow extends LitElement implements EntityRow {
implements EntityRow {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: SensorEntityConfig; private _config?: SensorEntityConfig;
@ -65,7 +63,11 @@ class HuiSensorEntityRow extends hassLocalizeLitMixin(LitElement)
.format="${this._config.format}" .format="${this._config.format}"
></hui-timestamp-display> ></hui-timestamp-display>
` `
: computeStateDisplay(this.localize, stateObj, this.hass.language)} : computeStateDisplay(
this.hass!.localize,
stateObj,
this.hass.language
)}
</div> </div>
</hui-generic-entity-row> </hui-generic-entity-row>
`; `;

View File

@ -9,12 +9,10 @@ import "../components/hui-generic-entity-row";
import "./hui-error-entity-row"; import "./hui-error-entity-row";
import computeStateDisplay from "../../../common/entity/compute_state_display"; import computeStateDisplay from "../../../common/entity/compute_state_display";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types"; import { EntityRow, EntityConfig } from "./types";
class HuiTextEntityRow extends hassLocalizeLitMixin(LitElement) class HuiTextEntityRow extends LitElement implements EntityRow {
implements EntityRow {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: EntityConfig; private _config?: EntityConfig;
@ -51,7 +49,11 @@ class HuiTextEntityRow extends hassLocalizeLitMixin(LitElement)
${this.renderStyle()} ${this.renderStyle()}
<hui-generic-entity-row .hass="${this.hass}" .config="${this._config}"> <hui-generic-entity-row .hass="${this.hass}" .config="${this._config}">
<div> <div>
${computeStateDisplay(this.localize, stateObj, this.hass.language)} ${computeStateDisplay(
this.hass!.localize,
stateObj,
this.hass.language
)}
</div> </div>
</hui-generic-entity-row> </hui-generic-entity-row>
`; `;

View File

@ -10,12 +10,10 @@ import "../../../components/entity/ha-entity-toggle";
import "./hui-error-entity-row"; import "./hui-error-entity-row";
import computeStateDisplay from "../../../common/entity/compute_state_display"; import computeStateDisplay from "../../../common/entity/compute_state_display";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types"; import { EntityRow, EntityConfig } from "./types";
class HuiToggleEntityRow extends hassLocalizeLitMixin(LitElement) class HuiToggleEntityRow extends LitElement implements EntityRow {
implements EntityRow {
public hass?: HomeAssistant; public hass?: HomeAssistant;
private _config?: EntityConfig; private _config?: EntityConfig;
@ -60,7 +58,7 @@ class HuiToggleEntityRow extends hassLocalizeLitMixin(LitElement)
: html` : html`
<div> <div>
${computeStateDisplay( ${computeStateDisplay(
this.localize, this.hass!.localize,
stateObj, stateObj,
this.hass!.language this.hass!.language
)} )}

View File

@ -6,8 +6,13 @@ import "../../layouts/hass-error-screen";
import "./hui-root"; import "./hui-root";
import { HomeAssistant, PanelInfo, Route } from "../../types"; import { HomeAssistant, PanelInfo, Route } from "../../types";
import { Lovelace } from "./types"; import { Lovelace } from "./types";
import { LitElement, html, PropertyValues, TemplateResult } from "lit-element"; import {
import { hassLocalizeLitMixin } from "../../mixins/lit-localize-mixin"; LitElement,
html,
PropertyValues,
TemplateResult,
PropertyDeclarations,
} from "lit-element";
import { showSaveDialog } from "./editor/show-save-config-dialog"; import { showSaveDialog } from "./editor/show-save-config-dialog";
import { generateLovelaceConfig } from "./common/generate-lovelace-config"; import { generateLovelaceConfig } from "./common/generate-lovelace-config";
@ -17,7 +22,7 @@ interface LovelacePanelConfig {
let editorLoaded = false; let editorLoaded = false;
class LovelacePanel extends hassLocalizeLitMixin(LitElement) { class LovelacePanel extends LitElement {
public panel?: PanelInfo<LovelacePanelConfig>; public panel?: PanelInfo<LovelacePanelConfig>;
public hass?: HomeAssistant; public hass?: HomeAssistant;
public narrow?: boolean; public narrow?: boolean;
@ -29,22 +34,23 @@ class LovelacePanel extends hassLocalizeLitMixin(LitElement) {
private lovelace?: Lovelace; private lovelace?: Lovelace;
private mqls?: MediaQueryList[]; private mqls?: MediaQueryList[];
static get properties() { static get properties(): PropertyDeclarations {
return { return {
hass: {}, hass: {},
lovelace: {}, lovelace: {},
narrow: { type: Boolean, value: false }, narrow: {},
showMenu: { type: Boolean, value: false }, showMenu: {},
route: {}, route: {},
_columns: { type: Number, value: 1 }, _columns: {},
_state: { type: String, value: "loading" }, _state: {},
_errorMsg: String, _errorMsg: {},
_config: { type: {}, value: null }, _config: {},
}; };
} }
constructor() { constructor() {
super(); super();
this._state = "loading";
this._closeEditor = this._closeEditor.bind(this); this._closeEditor = this._closeEditor.bind(this);
} }
@ -155,7 +161,7 @@ class LovelacePanel extends hassLocalizeLitMixin(LitElement) {
this._errorMsg = err.message; this._errorMsg = err.message;
return; return;
} }
conf = generateLovelaceConfig(this.hass!, this.localize); conf = generateLovelaceConfig(this.hass!, this.hass!.localize);
confMode = "generated"; confMode = "generated";
} }

View File

@ -11,7 +11,6 @@ import "@polymer/paper-spinner/paper-spinner";
import { struct } from "./common/structs/struct"; import { struct } from "./common/structs/struct";
import { Lovelace } from "./types"; import { Lovelace } from "./types";
import { hassLocalizeLitMixin } from "../../mixins/lit-localize-mixin";
import "../../components/ha-icon"; import "../../components/ha-icon";
import { haStyle } from "../../resources/ha-style"; import { haStyle } from "../../resources/ha-style";
@ -24,7 +23,7 @@ const lovelaceStruct = struct.interface({
resources: struct.optional(["object"]), resources: struct.optional(["object"]),
}); });
class LovelaceFullConfigEditor extends hassLocalizeLitMixin(LitElement) { class LovelaceFullConfigEditor extends LitElement {
public lovelace?: Lovelace; public lovelace?: Lovelace;
public closeEditor?: () => void; public closeEditor?: () => void;
private _saving?: boolean; private _saving?: boolean;

View File

@ -30,7 +30,6 @@ import "../../components/ha-icon";
import { loadModule, loadCSS, loadJS } from "../../common/dom/load_resource"; import { loadModule, loadCSS, loadJS } from "../../common/dom/load_resource";
import { subscribeNotifications } from "../../data/ws-notifications"; import { subscribeNotifications } from "../../data/ws-notifications";
import debounce from "../../common/util/debounce"; import debounce from "../../common/util/debounce";
import { hassLocalizeLitMixin } from "../../mixins/lit-localize-mixin";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
import { LovelaceConfig } from "../../data/lovelace"; import { LovelaceConfig } from "../../data/lovelace";
import { navigate } from "../../common/navigate"; import { navigate } from "../../common/navigate";
@ -55,7 +54,7 @@ const JS_CACHE = {};
let loadedUnusedEntities = false; let loadedUnusedEntities = false;
class HUIRoot extends hassLocalizeLitMixin(LitElement) { class HUIRoot extends LitElement {
public narrow?: boolean; public narrow?: boolean;
public showMenu?: boolean; public showMenu?: boolean;
public hass?: HomeAssistant; public hass?: HomeAssistant;
@ -141,7 +140,7 @@ class HUIRoot extends hassLocalizeLitMixin(LitElement) {
></paper-icon-button> ></paper-icon-button>
<div main-title> <div main-title>
${this.config.title || ${this.config.title ||
this.localize("ui.panel.lovelace.editor.header")} this.hass!.localize("ui.panel.lovelace.editor.header")}
<paper-icon-button <paper-icon-button
icon="hass:pencil" icon="hass:pencil"
class="edit-icon" class="edit-icon"
@ -213,7 +212,7 @@ class HUIRoot extends hassLocalizeLitMixin(LitElement) {
>Unused entities</paper-item >Unused entities</paper-item
> >
<paper-item @click="${this._editModeEnable}" <paper-item @click="${this._editModeEnable}"
>${this.localize( >${this.hass!.localize(
"ui.panel.lovelace.editor.configure_ui" "ui.panel.lovelace.editor.configure_ui"
)}</paper-item )}</paper-item
> >
@ -260,7 +259,7 @@ class HUIRoot extends hassLocalizeLitMixin(LitElement) {
? html` ? html`
<paper-button id="add-view" @click="${this._addView}"> <paper-button id="add-view" @click="${this._addView}">
<ha-icon <ha-icon
title="${this.localize( title="${this.hass!.localize(
"ui.panel.lovelace.editor.edit_view.add" "ui.panel.lovelace.editor.edit_view.add"
)}" )}"
icon="hass:plus" icon="hass:plus"

View File

@ -13,7 +13,6 @@ import { HaStateLabelBadge } from "../../components/entity/ha-state-label-badge"
import applyThemesOnElement from "../../common/dom/apply_themes_on_element"; import applyThemesOnElement from "../../common/dom/apply_themes_on_element";
import { hassLocalizeLitMixin } from "../../mixins/lit-localize-mixin";
import { LovelaceViewConfig, LovelaceCardConfig } from "../../data/lovelace"; import { LovelaceViewConfig, LovelaceCardConfig } from "../../data/lovelace";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
@ -43,7 +42,7 @@ const getColumnIndex = (columnEntityCount: number[], size: number) => {
return minIndex; return minIndex;
}; };
export class HUIView extends hassLocalizeLitMixin(LitElement) { export class HUIView extends LitElement {
public hass?: HomeAssistant; public hass?: HomeAssistant;
public lovelace?: Lovelace; public lovelace?: Lovelace;
public columns?: number; public columns?: number;
@ -96,7 +95,9 @@ export class HUIView extends hassLocalizeLitMixin(LitElement) {
<paper-fab <paper-fab
elevated="2" elevated="2"
icon="hass:plus" icon="hass:plus"
title="${this.localize("ui.panel.lovelace.editor.edit_card.add")}" title="${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.add"
)}"
@click="${this._addCard}" @click="${this._addCard}"
></paper-fab> ></paper-fab>
` `