Maintenance
This commit is contained in:
@@ -22,6 +22,7 @@ declare global {
|
||||
class ActionHandler extends HTMLElement implements ActionHandler {
|
||||
public holdTime = 500;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
public ripple: any;
|
||||
|
||||
protected timer?: number;
|
||||
|
||||
+14
-3
@@ -1,4 +1,15 @@
|
||||
import { LitElement, html, customElement, property, CSSResult, TemplateResult, css, PropertyValues } from 'lit-element';
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {
|
||||
LitElement,
|
||||
html,
|
||||
customElement,
|
||||
property,
|
||||
CSSResult,
|
||||
TemplateResult,
|
||||
css,
|
||||
PropertyValues,
|
||||
internalProperty,
|
||||
} from 'lit-element';
|
||||
import {
|
||||
HomeAssistant,
|
||||
hasConfigOrEntityChanged,
|
||||
@@ -43,8 +54,8 @@ export class BoilerplateCard extends LitElement {
|
||||
}
|
||||
|
||||
// TODO Add any properities that should cause your element to re-render here
|
||||
@property() public hass!: HomeAssistant;
|
||||
@property() private config!: BoilerplateCardConfig;
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
@internalProperty() private config!: BoilerplateCardConfig;
|
||||
|
||||
public setConfig(config: BoilerplateCardConfig): void {
|
||||
// TODO Check for required fields and that they are of the proper format
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
export const CARD_VERSION = '1.2.0';
|
||||
export const CARD_VERSION = '1.3.0';
|
||||
|
||||
+23
-40
@@ -1,4 +1,15 @@
|
||||
import { LitElement, html, customElement, property, TemplateResult, CSSResult, css } from 'lit-element';
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
import {
|
||||
LitElement,
|
||||
html,
|
||||
customElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
CSSResult,
|
||||
css,
|
||||
internalProperty,
|
||||
} from 'lit-element';
|
||||
import { HomeAssistant, fireEvent, LovelaceCardEditor, ActionConfig } from 'custom-card-helpers';
|
||||
|
||||
import { BoilerplateCardConfig } from './types';
|
||||
@@ -46,10 +57,10 @@ const options = {
|
||||
|
||||
@customElement('boilerplate-card-editor')
|
||||
export class BoilerplateCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
@property() public hass?: HomeAssistant;
|
||||
@property() private _config?: BoilerplateCardConfig;
|
||||
@property() private _toggle?: boolean;
|
||||
@property() private _helpers?: any;
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
@internalProperty() private _config?: BoilerplateCardConfig;
|
||||
@internalProperty() private _toggle?: boolean;
|
||||
@internalProperty() private _helpers?: any;
|
||||
private _initialized = false;
|
||||
|
||||
public setConfig(config: BoilerplateCardConfig): void {
|
||||
@@ -67,59 +78,31 @@ export class BoilerplateCardEditor extends LitElement implements LovelaceCardEdi
|
||||
}
|
||||
|
||||
get _name(): string {
|
||||
if (this._config) {
|
||||
return this._config.name || '';
|
||||
}
|
||||
|
||||
return '';
|
||||
return this._config?.name || '';
|
||||
}
|
||||
|
||||
get _entity(): string {
|
||||
if (this._config) {
|
||||
return this._config.entity || '';
|
||||
}
|
||||
|
||||
return '';
|
||||
return this._config?.entity || '';
|
||||
}
|
||||
|
||||
get _show_warning(): boolean {
|
||||
if (this._config) {
|
||||
return this._config.show_warning || false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return this._config?.show_warning || false;
|
||||
}
|
||||
|
||||
get _show_error(): boolean {
|
||||
if (this._config) {
|
||||
return this._config.show_error || false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return this._config?.show_error || false;
|
||||
}
|
||||
|
||||
get _tap_action(): ActionConfig {
|
||||
if (this._config) {
|
||||
return this._config.tap_action || { action: 'more-info' };
|
||||
}
|
||||
|
||||
return { action: 'more-info' };
|
||||
return this._config?.tap_action || { action: 'more-info' };
|
||||
}
|
||||
|
||||
get _hold_action(): ActionConfig {
|
||||
if (this._config) {
|
||||
return this._config.hold_action || { action: 'none' };
|
||||
}
|
||||
|
||||
return { action: 'none' };
|
||||
return this._config?.hold_action || { action: 'none' };
|
||||
}
|
||||
|
||||
get _double_tap_action(): ActionConfig {
|
||||
if (this._config) {
|
||||
return this._config.double_tap_action || { action: 'none' };
|
||||
}
|
||||
|
||||
return { action: 'none' };
|
||||
return this._config?.double_tap_action || { action: 'none' };
|
||||
}
|
||||
|
||||
protected render(): TemplateResult | void {
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
"invalid_configuration": "Ikke gyldig konfiguration",
|
||||
"show_warning": "Vis advarsel"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
import * as en from './languages/en.json';
|
||||
import * as nb from './languages/nb.json';
|
||||
|
||||
var languages: any = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const languages: any = {
|
||||
en: en,
|
||||
nb: nb,
|
||||
};
|
||||
|
||||
export function localize(string: string, search: string = '', replace: string = '') {
|
||||
|
||||
export function localize(string: string, search = '', replace = ''): string {
|
||||
const lang = (localStorage.getItem('selectedLanguage') || 'en').replace(/['"]+/g, '').replace('-', '_');
|
||||
|
||||
var translated: string;
|
||||
let translated: string;
|
||||
|
||||
try {
|
||||
translated = string.split('.').reduce((o, i) => o[i], languages[lang]);
|
||||
|
||||
Reference in New Issue
Block a user