Prefer nothing over empty templates (#15633)

This commit is contained in:
Steve Repsher 2023-02-28 05:02:47 -05:00 committed by GitHub
parent 4031d9cc78
commit 9ce4563dd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
362 changed files with 1533 additions and 1435 deletions

View File

@ -119,7 +119,6 @@
"lit/no-template-map": "off",
"lit/no-native-attributes": "warn",
"lit/no-this-assign-in-render": "warn",
"lit/prefer-nothing": "warn",
"lit-a11y/click-events-have-key-events": ["off"],
"lit-a11y/no-autofocus": "off",
"lit-a11y/alt-text": "warn",

View File

@ -1,4 +1,4 @@
import { html, TemplateResult } from "lit";
import { html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { mockHistory } from "../../../../demo/src/stubs/history";
import { LovelaceConfig } from "../../../../src/data/lovelace";
@ -18,9 +18,9 @@ class HcDemo extends HassElement {
@state() private _lovelaceConfig?: LovelaceConfig;
protected render(): TemplateResult {
protected render() {
if (!this._lovelaceConfig) {
return html``;
return nothing;
}
return html`
<hc-lovelace

View File

@ -1,5 +1,5 @@
import { mdiTelevision } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, state } from "lit/decorators";
import { CastManager } from "../../../src/cast/cast_manager";
import { castSendShowDemo } from "../../../src/cast/receiver_messages";
@ -20,12 +20,12 @@ class CastDemoRow extends LitElement implements LovelaceRow {
// No config possible.
}
protected render(): TemplateResult {
protected render() {
if (
!this._castManager ||
this._castManager.castState === "NO_DEVICES_AVAILABLE"
) {
return html``;
return nothing;
}
return html`
<ha-svg-icon .path=${mdiTelevision}></ha-svg-icon>

View File

@ -1,5 +1,5 @@
import "@material/mwc-button";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { until } from "lit/directives/until";
import "../../../src/components/ha-card";
@ -30,9 +30,9 @@ export class HADemoCard extends LitElement implements LovelaceCard {
public setConfig(_config: LovelaceCardConfig) {}
protected render(): TemplateResult {
protected render() {
if (this._hidden) {
return html``;
return nothing;
}
return html`
<ha-card>

View File

@ -1,4 +1,4 @@
import { html, css } from "lit";
import { css, html, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { until } from "lit/directives/until";
import { HaMarkdown } from "../../../src/components/ha-markdown";
@ -10,7 +10,7 @@ class PageDescription extends HaMarkdown {
render() {
if (!PAGES[this.page].description) {
return html``;
return nothing;
}
return html`

View File

@ -1,5 +1,5 @@
import { dump } from "js-yaml";
import { html, css, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-yaml-editor";
@ -127,9 +127,9 @@ export class DemoAutomationDescribeAction extends LitElement {
@state() _action = initialAction;
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`
<ha-card header="Actions">

View File

@ -1,5 +1,5 @@
import { dump } from "js-yaml";
import { css, html, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-yaml-editor";
@ -53,9 +53,9 @@ export class DemoAutomationDescribeCondition extends LitElement {
@state() _condition = initialCondition;
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`

View File

@ -1,5 +1,5 @@
import { dump } from "js-yaml";
import { css, html, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-yaml-editor";
@ -64,9 +64,9 @@ export class DemoAutomationDescribeTrigger extends LitElement {
@state() _trigger = initialTrigger;
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`

View File

@ -1,5 +1,6 @@
/* eslint-disable lit/no-template-arrow */
import { html, css, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/trace/hat-script-graph";
@ -29,9 +30,9 @@ const traces: DemoTrace[] = [
export class DemoAutomationTraceTimeline extends LitElement {
@property({ attribute: false }) hass?: HomeAssistant;
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`
${traces.map(

View File

@ -1,14 +1,15 @@
/* eslint-disable lit/no-template-arrow */
import { html, css, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/trace/hat-script-graph";
import "../../../../src/components/trace/hat-trace-timeline";
import { customElement, property, state } from "lit/decorators";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import { HomeAssistant } from "../../../../src/types";
import { DemoTrace } from "../../data/traces/types";
import { basicTrace } from "../../data/traces/basic_trace";
import { motionLightTrace } from "../../data/traces/motion-light-trace";
import { DemoTrace } from "../../data/traces/types";
const traces: DemoTrace[] = [basicTrace, motionLightTrace];
@ -18,9 +19,9 @@ export class DemoAutomationTrace extends LitElement {
@state() private _selected = {};
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`
${traces.map(

View File

@ -2,7 +2,7 @@ import {
HassEntity,
HassEntityAttributeBase,
} from "home-assistant-js-websocket";
import { css, html, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { computeDomain } from "../../../../src/common/entity/compute_domain";
@ -387,9 +387,9 @@ export class DemoEntityState extends LitElement {
hass.updateTranslations("config", "en");
}
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`

View File

@ -1,22 +1,22 @@
import { html, css, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import "../../../../src/components/ha-formfield";
import "../../../../src/components/ha-switch";
import { classMap } from "lit/directives/class-map";
import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { IntegrationManifest } from "../../../../src/data/integration";
import { DeviceRegistryEntry } from "../../../../src/data/device_registry";
import { EntityRegistryEntry } from "../../../../src/data/entity_registry";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import { HomeAssistant } from "../../../../src/types";
import "../../../../src/panels/config/integrations/ha-integration-card";
import "../../../../src/panels/config/integrations/ha-ignored-config-entry-card";
import "../../../../src/panels/config/integrations/ha-config-flow-card";
import type {
ConfigEntryExtended,
DataEntryFlowProgressExtended,
} from "../../../../src/panels/config/integrations/ha-config-integrations";
import { DeviceRegistryEntry } from "../../../../src/data/device_registry";
import { EntityRegistryEntry } from "../../../../src/data/entity_registry";
import "../../../../src/panels/config/integrations/ha-ignored-config-entry-card";
import "../../../../src/panels/config/integrations/ha-integration-card";
import { HomeAssistant } from "../../../../src/types";
const createConfigEntry = (
title: string,
@ -231,9 +231,9 @@ export class DemoIntegrationCard extends LitElement {
@state() isCloud = false;
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`
<div class="container">

View File

@ -6,6 +6,7 @@ import {
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
TemplateResult,
} from "lit";
@ -73,8 +74,8 @@ export class HassioAddonStore extends LitElement {
}
}
protected render(): TemplateResult {
let repos: TemplateResult[] = [];
protected render() {
let repos: (TemplateResult | typeof nothing)[] = [];
if (this.supervisor.store.repositories) {
repos = this.addonRepositories(
@ -173,7 +174,7 @@ export class HassioAddonStore extends LitElement {
.supervisor=${this.supervisor}
></hassio-addon-repository>
`
: html``;
: nothing;
})
);

View File

@ -4,7 +4,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
@ -47,9 +47,9 @@ class HassioAddonNetwork extends LitElement {
this._setNetworkConfig();
}
protected render(): TemplateResult {
protected render() {
if (!this._config) {
return html``;
return nothing;
}
const hasHiddenOptions = Object.keys(this._config).find(

View File

@ -8,7 +8,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
@ -160,9 +160,9 @@ export class HassioBackups extends LitElement {
}))
);
protected render(): TemplateResult {
protected render() {
if (!this.supervisor) {
return html``;
return nothing;
}
return html`
<hass-tabs-subpage-data-table

View File

@ -1,6 +1,13 @@
import { mdiFolder, mdiHomeAssistant, mdiPuzzle } from "@mdi/js";
import { PaperInputElement } from "@polymer/paper-input/paper-input";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import {
css,
CSSResultGroup,
html,
LitElement,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, query } from "lit/decorators";
import { atLeastVersion } from "../../../src/common/config/version";
import { formatDate } from "../../../src/common/datetime/format_date";
@ -11,9 +18,9 @@ import "../../../src/components/ha-formfield";
import "../../../src/components/ha-radio";
import type { HaRadio } from "../../../src/components/ha-radio";
import {
HassioBackupDetail,
HassioFullBackupCreateParams,
HassioPartialBackupCreateParams,
HassioBackupDetail,
} from "../../../src/data/hassio/backup";
import { Supervisor } from "../../../src/data/supervisor/supervisor";
import { PolymerChangedEvent } from "../../../src/polymer-types";
@ -115,9 +122,9 @@ export class SupervisorBackupContent extends LitElement {
this.supervisor?.localize(`backup.${key}`) ||
this.localize!(`ui.panel.page-onboarding.restore.${key}`);
protected render(): TemplateResult {
protected render() {
if (!this.onboarding && !this.supervisor) {
return html``;
return nothing;
}
const foldersSection =
this.backupType === "partial" ? this._getSection("folders") : undefined;

View File

@ -1,6 +1,6 @@
import "@material/mwc-button";
import { mdiHomeAssistant } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import "../../../src/components/buttons/ha-progress-button";
@ -33,14 +33,14 @@ export class HassioUpdate extends LitElement {
).length
);
protected render(): TemplateResult {
protected render() {
if (!this.supervisor) {
return html``;
return nothing;
}
const updatesAvailable = this._pendingUpdates(this.supervisor);
if (!updatesAvailable) {
return html``;
return nothing;
}
return html`
@ -80,9 +80,9 @@ export class HassioUpdate extends LitElement {
name: string,
key: string,
object: HassioHomeAssistantInfo | HassioSupervisorInfo | HassioHassOSInfo
): TemplateResult {
) {
if (!object.update_available) {
return html``;
return nothing;
}
return html`
<ha-card outlined>

View File

@ -1,5 +1,5 @@
import { mdiClose } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import "../../../../src/components/ha-header-bar";
@ -36,9 +36,9 @@ export class DialogHassioBackupUpload
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._dialogParams) {
return html``;
return nothing;
}
return html`

View File

@ -1,9 +1,11 @@
import { ActionDetail } from "@material/mwc-list";
import "@material/mwc-list/mwc-list-item";
import { mdiClose, mdiDotsVertical } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { atLeastVersion } from "../../../../src/common/config/version";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import { stopPropagation } from "../../../../src/common/dom/stop_propagation";
import { slugify } from "../../../../src/common/string/slugify";
import "../../../../src/components/buttons/ha-progress-button";
import "../../../../src/components/ha-alert";
@ -11,11 +13,11 @@ import "../../../../src/components/ha-button-menu";
import "../../../../src/components/ha-header-bar";
import "../../../../src/components/ha-icon-button";
import { getSignedPath } from "../../../../src/data/auth";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import {
fetchHassioBackupInfo,
HassioBackupDetail,
} from "../../../../src/data/hassio/backup";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import {
showAlertDialog,
showConfirmationDialog,
@ -27,8 +29,6 @@ import { fileDownload } from "../../../../src/util/file_download";
import "../../components/supervisor-backup-content";
import type { SupervisorBackupContent } from "../../components/supervisor-backup-content";
import { HassioBackupDialogParams } from "./show-dialog-hassio-backup";
import { atLeastVersion } from "../../../../src/common/config/version";
import { stopPropagation } from "../../../../src/common/dom/stop_propagation";
@customElement("dialog-hassio-backup")
class HassioBackupDialog
@ -62,9 +62,9 @@ class HassioBackupDialog
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._dialogParams || !this._backup) {
return html``;
return nothing;
}
return html`
<ha-dialog

View File

@ -1,15 +1,15 @@
import "@material/mwc-button";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import "../../../../src/components/ha-alert";
import "../../../../src/components/buttons/ha-progress-button";
import "../../../../src/components/ha-alert";
import { createCloseHeading } from "../../../../src/components/ha-dialog";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import {
createHassioFullBackup,
createHassioPartialBackup,
} from "../../../../src/data/hassio/backup";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import { showAlertDialog } from "../../../../src/dialogs/generic/show-dialog-box";
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
import { HomeAssistant } from "../../../../src/types";
@ -42,9 +42,9 @@ class HassioCreateBackupDialog extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._dialogParams) {
return html``;
return nothing;
}
return html`
<ha-dialog

View File

@ -1,5 +1,5 @@
import "@material/mwc-list/mwc-list-item";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../../src/common/dom/fire_event";
@ -55,9 +55,9 @@ class HassioDatadiskDialog extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this.dialogParams) {
return html``;
return nothing;
}
return html`
<ha-dialog

8
hassio/src/dialogs/hardware/dialog-hassio-hardware.ts Executable file → Normal file
View File

@ -1,13 +1,13 @@
import { mdiClose } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import "../../../../src/components/search-input";
import { stringCompare } from "../../../../src/common/string/compare";
import "../../../../src/components/ha-dialog";
import "../../../../src/components/ha-expansion-panel";
import "../../../../src/components/ha-icon-button";
import "../../../../src/components/search-input";
import { HassioHardwareInfo } from "../../../../src/data/hassio/hardware";
import { dump } from "../../../../src/resources/js-yaml-dump";
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
@ -53,9 +53,9 @@ class HassioHardwareDialog extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._dialogParams) {
return html``;
return nothing;
}
const devices = _filterDevices(

View File

@ -1,4 +1,4 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { createCloseHeading } from "../../../../src/components/ha-dialog";
import "../../../../src/components/ha-markdown";
@ -27,9 +27,9 @@ class HassioMarkdownDialog extends LitElement {
this._opened = false;
}
protected render(): TemplateResult {
protected render() {
if (!this._opened) {
return html``;
return nothing;
}
return html`
<ha-dialog

View File

@ -5,7 +5,7 @@ import "@material/mwc-tab";
import "@material/mwc-tab-bar";
import { mdiClose } from "@mdi/js";
import { PaperInputElement } from "@polymer/paper-input/paper-input";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { cache } from "lit/directives/cache";
import { fireEvent } from "../../../../src/common/dom/fire_event";
@ -83,9 +83,9 @@ export class DialogHassioNetwork
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._params || !this._interface) {
return html``;
return nothing;
}
return html`

View File

@ -1,11 +1,11 @@
import "@polymer/paper-tooltip/paper-tooltip";
import "@material/mwc-button/mwc-button";
import { mdiDelete, mdiDeleteOff } from "@mdi/js";
import "@polymer/paper-input/paper-input";
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
import "@polymer/paper-item/paper-item";
import "@polymer/paper-item/paper-item-body";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import "@polymer/paper-tooltip/paper-tooltip";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../../src/common/dom/fire_event";
@ -19,14 +19,14 @@ import {
HassioAddonRepository,
} from "../../../../src/data/hassio/addon";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
import type { HomeAssistant } from "../../../../src/types";
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
import {
addStoreRepository,
fetchStoreRepositories,
removeStoreRepository,
} from "../../../../src/data/supervisor/store";
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
import type { HomeAssistant } from "../../../../src/types";
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
@customElement("dialog-hassio-repositories")
class HassioRepositoriesDialog extends LitElement {
@ -82,9 +82,9 @@ class HassioRepositoriesDialog extends LitElement {
.map((repo) => repo.slug)
);
protected render(): TemplateResult {
protected render() {
if (!this._dialogParams?.supervisor || this._repositories === undefined) {
return html``;
return nothing;
}
const repositories = this._filteredRepositories(this._repositories);
const usedRepositories = this._filteredUsedRepositories(

View File

@ -1,5 +1,5 @@
import { sanitizeUrl } from "@braintree/sanitize-url";
import { html, LitElement, TemplateResult } from "lit";
import { html, LitElement, TemplateResult, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { navigate } from "../../src/common/navigate";
import {
@ -101,13 +101,13 @@ class HassioMyRedirect extends LitElement {
navigate(url, { replace: true });
}
protected render(): TemplateResult {
protected render() {
if (this._error) {
return html`<hass-error-screen
.error=${this._error}
></hass-error-screen>`;
}
return html``;
return nothing;
}
private _createRedirectUrl(redirect: Redirect): string {

View File

@ -5,7 +5,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
@ -116,12 +116,12 @@ class UpdateAvailableCard extends LitElement {
storeAddons.find((addon) => addon.slug === slug)
);
protected render(): TemplateResult {
protected render() {
if (
!this._updateType ||
(this._updateType === "addon" && !this._addonInfo)
) {
return html``;
return nothing;
}
const changelog = changelogUrl(this._updateType, this._version_latest);

View File

@ -5,8 +5,8 @@ import {
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
TemplateResult,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import "../components/ha-alert";
@ -134,11 +134,11 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
}, 500);
}
private _renderForm(): TemplateResult {
private _renderForm() {
switch (this._state) {
case "step":
if (this._step == null) {
return html``;
return nothing;
}
return html`
${this._renderStep(this._step)}
@ -176,11 +176,11 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
</ha-alert>
`;
default:
return html``;
return nothing;
}
}
private _renderStep(step: DataEntryFlowStep): TemplateResult {
private _renderStep(step: DataEntryFlowStep) {
switch (step.type) {
case "abort":
return html`
@ -202,7 +202,7 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
.content=${this._computeStepDescription(step)}
></ha-markdown>
`
: html``}
: nothing}
<ha-form
.data=${this._stepData}
.schema=${autocompleteLoginFields(step.data_schema)}
@ -228,7 +228,7 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
: ""}
`;
default:
return html``;
return nothing;
}
}

View File

@ -4,11 +4,12 @@ import {
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
TemplateResult,
} from "lit";
import { customElement, property, state, eventOptions } from "lit/decorators";
import { customElement, eventOptions, property, state } from "lit/decorators";
import { isComponentLoaded } from "../../common/config/is_component_loaded";
import { restoreScroll } from "../../common/decorators/restore-scroll";
import {
HistoryResult,
LineChartUnit,
@ -17,7 +18,6 @@ import {
import type { HomeAssistant } from "../../types";
import "./state-history-chart-line";
import "./state-history-chart-timeline";
import { restoreScroll } from "../../common/decorators/restore-scroll";
const CANVAS_TIMELINE_ROWS_CHUNK = 10; // Split up the canvases to avoid hitting the render limit
@ -71,7 +71,7 @@ export class StateHistoryCharts extends LitElement {
// @ts-ignore
@restoreScroll(".container") private _savedScrollPos?: number;
protected render(): TemplateResult {
protected render() {
if (!isComponentLoaded(this.hass, "history")) {
return html`<div class="info">
${this.hass.localize("ui.components.history_charts.history_disabled")}
@ -130,9 +130,9 @@ export class StateHistoryCharts extends LitElement {
private _renderHistoryItem = (
item: TimelineEntity[] | LineChartUnit,
index: number
): TemplateResult => {
) => {
if (!item || index === undefined) {
return html``;
return nothing;
}
if (!Array.isArray(item)) {
return html`<div class="entry-container">

View File

@ -6,6 +6,7 @@ import {
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
TemplateResult,
} from "lit";
@ -73,7 +74,7 @@ export interface DataTableColumnData<T = any> extends DataTableSortColumnData {
title: TemplateResult | string;
label?: TemplateResult | string;
type?: "numeric" | "icon" | "icon-button" | "overflow-menu";
template?: (data: any, row: T) => TemplateResult | string;
template?: (data: any, row: T) => TemplateResult | string | typeof nothing;
width?: string;
maxWidth?: string;
grows?: boolean;
@ -352,13 +353,10 @@ export class HaDataTable extends LitElement {
`;
}
private _renderRow = (
row: DataTableRowData,
index: number
): TemplateResult => {
private _renderRow = (row: DataTableRowData, index: number) => {
// not sure how this happens...
if (!row) {
return html``;
return nothing;
}
if (row.append) {
return html` <div class="mdc-data-table__row">${row.content}</div> `;

View File

@ -1,7 +1,7 @@
import "@material/mwc-button/mwc-button";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event";
@ -230,9 +230,9 @@ export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
}
}
protected render(): TemplateResult {
protected render() {
if (!this._devices || !this._areas || !this._entities) {
return html``;
return nothing;
}
const areas = this._getAreasWithDevices(
this._devices,

View File

@ -1,5 +1,5 @@
import "@material/mwc-list/mwc-list-item";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { property, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import {
@ -85,9 +85,9 @@ export abstract class HaDeviceAutomationPicker<
return `${this._automations[idx].device_id}_${idx}`;
}
protected render(): TemplateResult {
protected render() {
if (this._renderEmpty) {
return html``;
return nothing;
}
const value = this._value;
return html`

View File

@ -1,4 +1,4 @@
import { css, html, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { PolymerChangedEvent } from "../../polymer-types";
@ -49,9 +49,9 @@ class HaDevicesPicker extends LitElement {
@property() public entityFilter?: HaDevicePickerEntityFilterFunc;
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
const currentDevices = this._currentDevices;

View File

@ -1,5 +1,5 @@
import type { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event";
@ -76,9 +76,9 @@ class HaEntitiesPickerLight extends LitElement {
@property() public entityFilter?: HaEntityPickerEntityFilterFunc;
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
const currentEntities = this._currentEntities;

View File

@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property, query } from "lit/decorators";
import { formatAttributeName } from "../../data/entity_attributes";
import { PolymerChangedEvent } from "../../polymer-types";
@ -60,9 +60,9 @@ class HaEntityAttributePicker extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`

View File

@ -1,14 +1,14 @@
import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property, query } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { computeStateDisplay } from "../../common/entity/compute_state_display";
import { PolymerChangedEvent } from "../../polymer-types";
import { getStates } from "../../common/entity/get_states";
import { formatAttributeValue } from "../../data/entity_attributes";
import { PolymerChangedEvent } from "../../polymer-types";
import { HomeAssistant } from "../../types";
import "../ha-combo-box";
import type { HaComboBox } from "../ha-combo-box";
import { formatAttributeValue } from "../../data/entity_attributes";
import { fireEvent } from "../../common/dom/fire_event";
export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean;
@ -64,9 +64,9 @@ class HaEntityStatePicker extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`

View File

@ -1,4 +1,4 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import type { PolymerChangedEvent } from "../../polymer-types";
@ -56,9 +56,9 @@ class HaStatisticsPicker extends LitElement {
})
public ignoreRestrictionsOnFirstStatistic = false;
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
const ignoreRestriction =

View File

@ -6,7 +6,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { property, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
@ -45,7 +45,7 @@ export class StateBadge extends LitElement {
return this.stateColor || (domain === "light" && this.stateColor !== false);
}
protected render(): TemplateResult {
protected render() {
const stateObj = this.stateObj;
// We either need a `stateObj` or one override
@ -56,7 +56,7 @@ export class StateBadge extends LitElement {
}
if (!this._showIcon) {
return html``;
return nothing;
}
const domain = stateObj ? computeStateDomain(stateObj) : undefined;

View File

@ -1,6 +1,6 @@
import "@polymer/paper-tooltip/paper-tooltip";
import type { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { computeStateName } from "../../common/entity/compute_state_name";
import { computeRTL } from "../../common/util/compute_rtl";
@ -21,9 +21,9 @@ class StateInfo extends LitElement {
@property() public color?: string;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
const name = computeStateName(this.stateObj);

View File

@ -1,5 +1,5 @@
import { html, LitElement, TemplateResult } from "lit";
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
import { html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { isComponentLoaded } from "../common/config/is_component_loaded";
import { fireEvent } from "../common/dom/fire_event";
@ -54,9 +54,9 @@ class HaAddonPicker extends LitElement {
this._getAddons();
}
protected render(): TemplateResult {
protected render() {
if (!this._addons) {
return html``;
return nothing;
}
return html`
<ha-combo-box

View File

@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
import { SubscribeMixin } from "../mixins/subscribe-mixin";
@ -60,9 +60,9 @@ export class HaAreasPicker extends SubscribeMixin(LitElement) {
@property({ type: Boolean }) public required?: boolean;
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
const currentAreas = this._currentAreas;

View File

@ -1,5 +1,12 @@
import { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import {
css,
CSSResultGroup,
html,
LitElement,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import {
formatAttributeName,
@ -21,9 +28,9 @@ class HaAttributes extends LitElement {
@state() private _expanded = false;
protected render(): TemplateResult {
protected render() {
if (!this.stateObj) {
return html``;
return nothing;
}
const attributes = this.computeDisplayAttributes(
@ -32,7 +39,7 @@ class HaAttributes extends LitElement {
)
);
if (attributes.length === 0) {
return html``;
return nothing;
}
return html`

View File

@ -1,5 +1,5 @@
import "@material/mwc-list/mwc-list-item";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../common/dom/fire_event";
@ -51,9 +51,9 @@ class HaBluePrintPicker extends LitElement {
);
});
protected render(): TemplateResult {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`
<ha-select

View File

@ -4,7 +4,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { isComponentLoaded } from "../common/config/is_component_loaded";
@ -76,9 +76,9 @@ export class HaCameraStream extends LitElement {
this._connected = false;
}
protected render(): TemplateResult {
protected render() {
if (!this.stateObj) {
return html``;
return nothing;
}
if (__DEMO__ || this._shouldRenderMJPEG) {
return html`<img
@ -102,7 +102,7 @@ export class HaCameraStream extends LitElement {
.url=${this._url}
.posterUrl=${this._posterUrl}
></ha-hls-player>`
: html``;
: nothing;
}
if (this.stateObj.attributes.frontend_stream_type === STREAM_TYPE_WEB_RTC) {
return html`<ha-web-rtc-player
@ -115,7 +115,7 @@ export class HaCameraStream extends LitElement {
.posterUrl=${this._posterUrl}
></ha-web-rtc-player>`;
}
return html``;
return nothing;
}
private get _shouldRenderMJPEG() {

View File

@ -1,4 +1,4 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
@customElement("ha-card")
@ -70,11 +70,11 @@ export class HaCard extends LitElement {
`;
}
protected render(): TemplateResult {
protected render() {
return html`
${this.header
? html`<h1 class="card-header">${this.header}</h1>`
: html``}
: nothing}
<slot></slot>
`;
}

View File

@ -1,16 +1,16 @@
import "@material/mwc-list/mwc-list-item";
import { html, LitElement, TemplateResult } from "lit";
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
import { html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
import { PolymerChangedEvent } from "../polymer-types";
import { HomeAssistant } from "../types";
import type { HaComboBox } from "./ha-combo-box";
import { caseInsensitiveStringCompare } from "../common/string/compare";
import { ConfigEntry, getConfigEntries } from "../data/config_entries";
import { domainToName } from "../data/integration";
import { caseInsensitiveStringCompare } from "../common/string/compare";
import { PolymerChangedEvent } from "../polymer-types";
import { HomeAssistant } from "../types";
import { brandsUrl } from "../util/brands-url";
import "./ha-combo-box";
import type { HaComboBox } from "./ha-combo-box";
export interface ConfigEntryExtended extends ConfigEntry {
localized_domain_name?: string;
@ -72,9 +72,9 @@ class HaConfigEntryPicker extends LitElement {
/>
</mwc-list-item>`;
protected render(): TemplateResult {
protected render() {
if (!this._configEntries) {
return html``;
return nothing;
}
return html`
<ha-combo-box

View File

@ -1,5 +1,5 @@
import { mdiStop } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { computeCloseIcon, computeOpenIcon } from "../common/entity/cover_icon";
@ -20,9 +20,9 @@ class HaCoverControls extends LitElement {
@property({ attribute: false }) public stateObj!: CoverEntity;
protected render(): TemplateResult {
protected render() {
if (!this.stateObj) {
return html``;
return nothing;
}
return html`

View File

@ -1,5 +1,5 @@
import { mdiArrowBottomLeft, mdiArrowTopRight, mdiStop } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { supportsFeature } from "../common/entity/supports-feature";
@ -19,9 +19,9 @@ class HaCoverTiltControls extends LitElement {
@property({ attribute: false }) stateObj!: CoverEntity;
protected render(): TemplateResult {
protected render() {
if (!this.stateObj) {
return html``;
return nothing;
}
return html` <ha-icon-button

View File

@ -1,6 +1,6 @@
import "@material/mwc-button/mwc-button";
import "app-datepicker";
import { css, html, LitElement } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
import { nextRender } from "../common/util/render-status";
@ -38,7 +38,7 @@ export class HaDialogDatePicker extends LitElement {
render() {
if (!this._params) {
return html``;
return nothing;
}
return html`<ha-dialog open @closed=${this.closeDialog}>
<app-datepicker

View File

@ -5,7 +5,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
@ -156,9 +156,9 @@ export class HaIcon extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (!this.icon) {
return html``;
return nothing;
}
if (this._legacy) {
return html`<iron-icon .icon=${this.icon}></iron-icon>`;

View File

@ -1,4 +1,4 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import "./ha-markdown-element";
@ -15,9 +15,9 @@ export class HaMarkdown extends LitElement {
@property({ type: Boolean }) public breaks = false;
protected render(): TemplateResult {
protected render() {
if (!this.content) {
return html``;
return nothing;
}
return html`<ha-markdown-element

View File

@ -54,9 +54,9 @@ export class HaNetwork extends LitElement {
@state() private _expanded?: boolean;
protected render(): TemplateResult {
protected render() {
if (this.networkConfig === undefined) {
return html``;
return nothing;
}
const configured_adapters = this.networkConfig.configured_adapters || [];
return html`

View File

@ -5,7 +5,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
@ -70,9 +70,9 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
}
}
protected render(): TemplateResult {
protected render() {
if (!this._related) {
return html``;
return nothing;
}
if (Object.keys(this._related).length === 0) {
return html`

View File

@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { ensureArray } from "../../common/array/ensure-array";
@ -61,9 +61,9 @@ export class HaAreaSelector extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (this._hasIntegration(this.selector) && !this._entitySources) {
return html``;
return nothing;
}
if (!this.selector.area?.multiple) {

View File

@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement } from "lit";
import { html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { ensureArray } from "../../common/array/ensure-array";
@ -66,7 +66,7 @@ export class HaDeviceSelector extends LitElement {
protected render() {
if (this._hasIntegration(this.selector) && !this._entitySources) {
return html``;
return nothing;
}
if (!this.selector.device?.multiple) {

View File

@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues } from "lit";
import { html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { ensureArray } from "../../common/array/ensure-array";
import {
@ -39,7 +39,7 @@ export class HaEntitySelector extends LitElement {
protected render() {
if (this._hasIntegration(this.selector) && !this._entitySources) {
return html``;
return nothing;
}
if (!this.selector.entity?.multiple) {

View File

@ -5,7 +5,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
@ -70,9 +70,9 @@ export class HaTargetSelector extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (this._hasIntegration(this.selector) && !this._entitySources) {
return html``;
return nothing;
}
return html`<ha-target-picker

View File

@ -29,6 +29,7 @@ import {
html,
LitElement,
PropertyValues,
nothing,
} from "lit";
import { customElement, eventOptions, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
@ -241,7 +242,7 @@ class HaSidebar extends SubscribeMixin(LitElement) {
protected render() {
if (!this.hass) {
return html``;
return nothing;
}
// prettier-ignore

View File

@ -12,7 +12,7 @@ import {
import "@polymer/paper-tooltip/paper-tooltip";
import { ComboBoxLightOpenedChangedEvent } from "@vaadin/combo-box/vaadin-combo-box-light";
import { HassEntity, HassServiceTarget } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, unsafeCSS } from "lit";
import { css, CSSResultGroup, html, LitElement, unsafeCSS, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { ensureArray } from "../common/array/ensure-array";
@ -278,7 +278,7 @@ export class HaTargetPicker extends LitElement {
private _renderPicker() {
if (!this._addMode) {
return html``;
return nothing;
}
return html`<mwc-menu-surface
open

View File

@ -1,6 +1,6 @@
import { mdiLightbulbOutline } from "@mdi/js";
import { css, html, LitElement, TemplateResult } from "lit";
import { property, customElement } from "lit/decorators";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { HomeAssistant } from "../types";
import "./ha-svg-icon";
@ -9,9 +9,9 @@ import "./ha-svg-icon";
class HaTip extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
public render(): TemplateResult {
public render() {
if (!this.hass) {
return html``;
return nothing;
}
return html`

View File

@ -1,5 +1,5 @@
import { DEFAULT_SCHEMA, dump, load, Schema } from "js-yaml";
import { html, LitElement, TemplateResult } from "lit";
import { html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
import type { HomeAssistant } from "../types";
@ -56,9 +56,9 @@ export class HaYamlEditor extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (this._yaml === undefined) {
return html``;
return nothing;
}
return html`
${this.label

View File

@ -2,7 +2,7 @@ import { animate } from "@lit-labs/motion";
import "@material/mwc-list/mwc-list";
import "@material/mwc-list/mwc-list-item";
import { mdiClose, mdiDelete } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { repeat } from "lit/directives/repeat";
import { fireEvent } from "../../common/dom/fire_event";
@ -18,11 +18,11 @@ import {
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
import { haStyleDialog } from "../../resources/styles";
import type { HomeAssistant } from "../../types";
import "../ha-check-list-item";
import "../ha-circular-progress";
import "../ha-dialog";
import "../ha-header-bar";
import "../ha-svg-icon";
import "../ha-check-list-item";
import "./ha-media-player-browse";
import "./ha-media-upload-button";
import type { MediaManageDialogParams } from "./show-media-manage-dialog";
@ -60,9 +60,9 @@ class DialogMediaManage extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._params) {
return html``;
return nothing;
}
const children =

View File

@ -1,6 +1,5 @@
import "../ha-header-bar";
import { mdiArrowLeft, mdiClose } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { fireEvent, HASSDomEvent } from "../../common/dom/fire_event";
import { computeRTLDirection } from "../../common/util/compute_rtl";
@ -12,8 +11,9 @@ import type {
import { haStyleDialog } from "../../resources/styles";
import type { HomeAssistant } from "../../types";
import "../ha-dialog";
import "./ha-media-player-browse";
import "../ha-header-bar";
import "./ha-media-manage-button";
import "./ha-media-player-browse";
import type {
HaMediaPlayerBrowse,
MediaPlayerItemId,
@ -49,9 +49,9 @@ class DialogMediaPlayerBrowse extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._params || !this._navigateIds) {
return html``;
return nothing;
}
return html`

View File

@ -1,13 +1,13 @@
import { mdiFolderEdit } from "@mdi/js";
import "@material/mwc-button";
import { css, html, LitElement, TemplateResult } from "lit";
import { mdiFolderEdit } from "@mdi/js";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { MediaPlayerItem } from "../../data/media-player";
import "../ha-svg-icon";
import { isLocalMediaSourceContentId } from "../../data/media_source";
import type { HomeAssistant } from "../../types";
import "../ha-svg-icon";
import { showMediaManageDialog } from "./show-media-manage-dialog";
import { fireEvent } from "../../common/dom/fire_event";
declare global {
interface HASSDomEvents {
@ -23,12 +23,12 @@ class MediaManageButton extends LitElement {
@state() _uploading = 0;
protected render(): TemplateResult {
protected render() {
if (
!this.currentItem ||
!isLocalMediaSourceContentId(this.currentItem.media_content_id || "")
) {
return html``;
return nothing;
}
return html`
<mwc-button

View File

@ -13,6 +13,7 @@ import {
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import {
customElement,
@ -311,7 +312,7 @@ export class HaMediaPlayerBrowse extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (this._error) {
return html`
<div class="container">
@ -388,7 +389,7 @@ export class HaMediaPlayerBrowse extends LitElement {
: ""}
</div>
`
: html``}
: nothing}
<div class="header-info">
<div class="breadcrumb">
<h1 class="title">${currentItem.title}</h1>

View File

@ -1,17 +1,17 @@
import { mdiUpload } from "@mdi/js";
import "@material/mwc-button";
import { css, html, LitElement, TemplateResult } from "lit";
import { mdiUpload } from "@mdi/js";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { MediaPlayerItem } from "../../data/media-player";
import "../ha-circular-progress";
import "../ha-svg-icon";
import {
isLocalMediaSourceContentId,
uploadLocalMedia,
} from "../../data/media_source";
import type { HomeAssistant } from "../../types";
import { showAlertDialog } from "../../dialogs/generic/show-dialog-box";
import type { HomeAssistant } from "../../types";
import "../ha-circular-progress";
import "../ha-svg-icon";
declare global {
interface HASSDomEvents {
@ -28,12 +28,12 @@ class MediaUploadButton extends LitElement {
@state() _uploading = 0;
protected render(): TemplateResult {
protected render() {
if (
!this.currentItem ||
!isLocalMediaSourceContentId(this.currentItem.media_content_id || "")
) {
return html``;
return nothing;
}
return html`
<mwc-button

View File

@ -14,6 +14,7 @@ import {
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
@ -595,9 +596,9 @@ export class HaAutomationTracer extends LitElement {
];
}
protected render(): TemplateResult {
protected render() {
if (!this.trace) {
return html``;
return nothing;
}
const entries: TemplateResult[] = [];

View File

@ -1,4 +1,4 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { styleMap } from "lit/directives/style-map";
@ -9,9 +9,9 @@ import { computeUserInitials } from "../../data/user";
class PersonBadge extends LitElement {
@property({ attribute: false }) public person?: Person;
protected render(): TemplateResult {
protected render() {
if (!this.person) {
return html``;
return nothing;
}
const picture = this.person.picture;

View File

@ -4,7 +4,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
@ -47,9 +47,9 @@ class UserBadge extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.user) {
return html``;
return nothing;
}
const picture = this._personPicture;

View File

@ -1,5 +1,5 @@
import { mdiClose } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { guard } from "lit/directives/guard";
import memoizeOne from "memoize-one";
@ -34,9 +34,9 @@ class HaUsersPickerLight extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.users) {
return html``;
return nothing;
}
const notSelectedUsers = this._notSelectedUsers(this.users, this.value);

View File

@ -1,6 +1,6 @@
import "@material/mwc-button/mwc-button";
import { mdiDeleteOutline, mdiPlus } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import "../../components/ha-alert";
@ -40,9 +40,9 @@ class DialogAliases extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._params) {
return html``;
return nothing;
}
return html`

View File

@ -1,5 +1,5 @@
import "@material/mwc-button/mwc-button";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { computeRTLDirection } from "../../common/util/compute_rtl";
@ -45,9 +45,9 @@ class DialogConfigEntrySystemOptions extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._params) {
return html``;
return nothing;
}
return html`

View File

@ -7,7 +7,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, state } from "lit/decorators";
import { fireEvent, HASSDomEvent } from "../../common/dom/fire_event";
@ -202,9 +202,9 @@ class DataEntryFlowDialog extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._params) {
return html``;
return nothing;
}
return html`

View File

@ -1,19 +1,13 @@
import "@material/mwc-button";
import {
CSSResultGroup,
html,
LitElement,
TemplateResult,
PropertyValues,
} from "lit";
import { CSSResultGroup, html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { DataEntryFlowStepAbort } from "../../data/data_entry_flow";
import { HomeAssistant } from "../../types";
import { showAddApplicationCredentialDialog } from "../../panels/config/application_credentials/show-dialog-add-application-credential";
import { configFlowContentStyles } from "./styles";
import { DataEntryFlowDialogParams } from "./show-dialog-data-entry-flow";
import { HomeAssistant } from "../../types";
import { showConfigFlowDialog } from "./show-dialog-config-flow";
import { DataEntryFlowDialogParams } from "./show-dialog-data-entry-flow";
import { configFlowContentStyles } from "./styles";
@customElement("step-flow-abort")
class StepFlowAbort extends LitElement {
@ -32,9 +26,9 @@ class StepFlowAbort extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (this.step.reason === "missing_credentials") {
return html``;
return nothing;
}
return html`
<h2>${this.hass.localize(`component.${this.domain}.title`)}</h2>

View File

@ -1,5 +1,5 @@
import "@material/mwc-button/mwc-button";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { createCloseHeading } from "../../components/ha-dialog";
@ -29,9 +29,9 @@ class DomainTogglerDialog
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render(): TemplateResult {
protected render() {
if (!this._params) {
return html``;
return nothing;
}
const domains = this._params.domains

View File

@ -1,6 +1,6 @@
import "@material/mwc-button/mwc-button";
import { mdiAlertOutline } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { ifDefined } from "lit/directives/if-defined";
@ -35,9 +35,9 @@ class DialogBox extends LitElement {
return true;
}
protected render(): TemplateResult {
protected render() {
if (!this._params) {
return html``;
return nothing;
}
const confirmPrompt = this._params.confirmation || this._params.prompt;

View File

@ -8,7 +8,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../../components/ha-button-toggle-group";
@ -62,9 +62,9 @@ class MoreInfoViewLightColorPicker extends LitElement {
: undefined;
}
protected render(): TemplateResult {
protected render() {
if (!this.params || !this.stateObj) {
return html``;
return nothing;
}
const supportsRgbww = lightSupportsColorMode(

View File

@ -1,15 +1,15 @@
import "@material/mwc-button";
import type { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, state, query } from "lit/decorators";
import { css, html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import "../../../components/ha-textfield";
import { supportsFeature } from "../../../common/entity/supports-feature";
import "../../../components/ha-textfield";
import type { HaTextField } from "../../../components/ha-textfield";
import {
AlarmControlPanelEntityFeature,
callAlarmAction,
FORMAT_NUMBER,
AlarmControlPanelEntityFeature,
} from "../../../data/alarm_control_panel";
import type { HomeAssistant } from "../../../types";
@ -67,9 +67,9 @@ export class MoreInfoAlarmControlPanel extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
return html`

View File

@ -1,6 +1,6 @@
import "@material/mwc-button";
import { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../components/ha-relative-time";
import { triggerAutomationActions } from "../../../data/automation";
@ -13,9 +13,9 @@ class MoreInfoAutomation extends LitElement {
@property({ attribute: false }) public stateObj?: HassEntity;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
return html`

View File

@ -1,4 +1,4 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { property, state } from "lit/decorators";
import "../../../components/ha-camera-stream";
import { CameraEntity } from "../../../data/camera";
@ -21,9 +21,9 @@ class MoreInfoCamera extends LitElement {
this._attached = false;
}
protected render(): TemplateResult {
protected render() {
if (!this._attached || !this.hass || !this.stateObj) {
return html``;
return nothing;
}
return html`

View File

@ -5,7 +5,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { property } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
@ -36,9 +36,9 @@ class MoreInfoClimate extends LitElement {
private _resizeDebounce?: number;
protected render(): TemplateResult {
protected render() {
if (!this.stateObj) {
return html``;
return nothing;
}
const hass = this.hass;

View File

@ -1,6 +1,6 @@
import "@material/mwc-button";
import type { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../components/ha-alert";
import "../../../components/ha-circular-progress";
@ -18,9 +18,9 @@ export class MoreInfoConfigurator extends LitElement {
private _fieldInput = {};
protected render(): TemplateResult {
protected render() {
if (this.stateObj?.state !== "configure") {
return html``;
return nothing;
}
return html`

View File

@ -1,6 +1,6 @@
import "@material/mwc-button";
import { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { isUnavailableState } from "../../../data/entity";
import { HomeAssistant } from "../../../types";
@ -11,9 +11,9 @@ class MoreInfoCounter extends LitElement {
@property() public stateObj?: HassEntity;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
const disabled = isUnavailableState(this.stateObj!.state);

View File

@ -1,4 +1,4 @@
import { css, CSSResult, html, LitElement, TemplateResult } from "lit";
import { css, CSSResult, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { attributeClassNames } from "../../../common/entity/attribute_class_names";
import {
@ -30,9 +30,9 @@ class MoreInfoCover extends LitElement {
@property({ attribute: false }) public stateObj!: CoverEntity;
protected render(): TemplateResult {
protected render() {
if (!this.stateObj) {
return html``;
return nothing;
}
const _isTiltOnly = isTiltOnly(this.stateObj);
@ -71,7 +71,7 @@ class MoreInfoCover extends LitElement {
slot="extra"
.stateObj=${this.stateObj}
></ha-cover-tilt-controls> `
: html``}
: nothing}
</ha-labeled-slider>`
: !_isTiltOnly
? html`
@ -83,7 +83,7 @@ class MoreInfoCover extends LitElement {
.stateObj=${this.stateObj}
></ha-cover-tilt-controls>
`
: html``}
: nothing}
</div>
</div>
<ha-attributes

View File

@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement, TemplateResult } from "lit";
import { html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../components/ha-attributes";
import { HomeAssistant } from "../../../types";
@ -10,9 +10,9 @@ class MoreInfoDefault extends LitElement {
@property() public stateObj?: HassEntity;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
return html`<ha-attributes

View File

@ -5,7 +5,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { property, state } from "lit/decorators";
import { dynamicElement } from "../../../common/dom/dynamic-element-directive";
@ -70,9 +70,9 @@ class MoreInfoGroup extends LitElement {
}
}
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
return html`${this._moreInfoType
? dynamicElement(this._moreInfoType, {

View File

@ -5,7 +5,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { property } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
@ -29,9 +29,9 @@ class MoreInfoHumidifier extends LitElement {
private _resizeDebounce?: number;
protected render(): TemplateResult {
protected render() {
if (!this.stateObj) {
return html``;
return nothing;
}
const hass = this.hass;

View File

@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../components/ha-date-input";
import "../../../components/ha-time-input";
@ -16,9 +16,9 @@ class MoreInfoInputDatetime extends LitElement {
@property({ attribute: false }) public stateObj?: HassEntity;
protected render(): TemplateResult {
protected render() {
if (!this.stateObj) {
return html``;
return nothing;
}
return html`

View File

@ -1,6 +1,6 @@
import "@material/mwc-button";
import type { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query } from "lit/decorators";
import "../../../components/ha-attributes";
import "../../../components/ha-textfield";
@ -15,9 +15,9 @@ class MoreInfoLock extends LitElement {
@query("ha-textfield") private _textfield?: HaTextField;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
return html`
${this.stateObj.attributes.code_format

View File

@ -9,7 +9,7 @@ import {
mdiVolumeOff,
mdiVolumePlus,
} from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { stopPropagation } from "../../../common/dom/stop_propagation";
import { supportsFeature } from "../../../common/entity/supports-feature";
@ -36,9 +36,9 @@ class MoreInfoMediaPlayer extends LitElement {
@property({ attribute: false }) public stateObj?: MediaPlayerEntity;
protected render(): TemplateResult {
protected render() {
if (!this.stateObj) {
return html``;
return nothing;
}
const stateObj = this.stateObj;

View File

@ -1,6 +1,6 @@
import "@material/mwc-button";
import { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../common/dom/fire_event";
@ -17,9 +17,9 @@ class MoreInfoPerson extends LitElement {
private _entityArray = memoizeOne((entityId: string) => [entityId]);
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
return html`

View File

@ -1,12 +1,12 @@
import { html, LitElement, TemplateResult } from "lit";
import "@material/mwc-list/mwc-list";
import "@material/mwc-list/mwc-list-item";
import { html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { stopPropagation } from "../../../common/dom/stop_propagation";
import { supportsFeature } from "../../../common/entity/supports-feature";
import "../../../components/ha-attributes";
import { RemoteEntity, REMOTE_SUPPORT_ACTIVITY } from "../../../data/remote";
import { HomeAssistant } from "../../../types";
import "@material/mwc-list/mwc-list-item";
import "@material/mwc-list/mwc-list";
import { stopPropagation } from "../../../common/dom/stop_propagation";
const filterExtraAttributes = "activity_list,current_activity";
@ -16,9 +16,9 @@ class MoreInfoRemote extends LitElement {
@property() public stateObj?: RemoteEntity;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
const stateObj = this.stateObj;

View File

@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../components/ha-relative-time";
import { HomeAssistant } from "../../../types";
@ -10,9 +10,9 @@ class MoreInfoScript extends LitElement {
@property() public stateObj?: HassEntity;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
return html`

View File

@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { formatTime } from "../../../common/datetime/format_time";
import { formatNumber } from "../../../common/number/format_number";
@ -12,9 +12,9 @@ class MoreInfoSun extends LitElement {
@property() public stateObj?: HassEntity;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
const risingDate = new Date(this.stateObj.attributes.next_rising);

View File

@ -1,5 +1,5 @@
import "@material/mwc-button";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../components/ha-attributes";
import { TimerEntity } from "../../../data/timer";
@ -11,9 +11,9 @@ class MoreInfoTimer extends LitElement {
@property() public stateObj?: TimerEntity;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
return html`

View File

@ -1,12 +1,13 @@
import "../../../components/ha-alert";
import "../../../components/ha-faded";
import "@material/mwc-button/mwc-button";
import "@material/mwc-linear-progress/mwc-linear-progress";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { BINARY_STATE_OFF } from "../../../common/const";
import { supportsFeature } from "../../../common/entity/supports-feature";
import "../../../components/ha-alert";
import "../../../components/ha-checkbox";
import "../../../components/ha-circular-progress";
import "../../../components/ha-faded";
import "../../../components/ha-formfield";
import "../../../components/ha-markdown";
import { isUnavailableState } from "../../../data/entity";
@ -21,7 +22,6 @@ import {
UPDATE_SUPPORT_SPECIFIC_VERSION,
} from "../../../data/update";
import type { HomeAssistant } from "../../../types";
import { BINARY_STATE_OFF } from "../../../common/const";
@customElement("more-info-update")
class MoreInfoUpdate extends LitElement {
@ -33,13 +33,13 @@ class MoreInfoUpdate extends LitElement {
@state() private _error?: string;
protected render(): TemplateResult {
protected render() {
if (
!this.hass ||
!this.stateObj ||
isUnavailableState(this.stateObj.state)
) {
return html``;
return nothing;
}
const skippedVersion =

View File

@ -9,7 +9,7 @@ import {
mdiStop,
mdiTargetVariant,
} from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { stopPropagation } from "../../../common/dom/stop_propagation";
import { supportsFeature } from "../../../common/entity/supports-feature";
@ -90,9 +90,9 @@ class MoreInfoVacuum extends LitElement {
@property() public stateObj?: VacuumEntity;
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
const stateObj = this.stateObj;

View File

@ -11,7 +11,7 @@ import {
html,
LitElement,
PropertyValues,
TemplateResult,
nothing,
} from "lit";
import { customElement, property } from "lit/decorators";
import { formatDateWeekdayDay } from "../../../common/datetime/format_date";
@ -50,9 +50,9 @@ class MoreInfoWeather extends LitElement {
return false;
}
protected render(): TemplateResult {
protected render() {
if (!this.hass || !this.stateObj) {
return html``;
return nothing;
}
const hourly = isForecastHourly(this.stateObj.attributes.forecast);

View File

@ -1,24 +1,24 @@
import { startOfYesterday, subHours } from "date-fns/esm";
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { isComponentLoaded } from "../../common/config/is_component_loaded";
import { fireEvent } from "../../common/dom/fire_event";
import { computeDomain } from "../../common/entity/compute_domain";
import "../../components/chart/state-history-charts";
import "../../components/chart/statistics-chart";
import {
computeHistory,
HistoryResult,
subscribeHistoryStatesTimeWindow,
computeHistory,
} from "../../data/history";
import {
fetchStatistics,
getStatisticMetadata,
Statistics,
StatisticsTypes,
StatisticsMetaData,
StatisticsTypes,
} from "../../data/recorder";
import { HomeAssistant } from "../../types";
import "../../components/chart/statistics-chart";
import { computeDomain } from "../../common/entity/compute_domain";
declare global {
interface HASSDomEvents {
@ -50,9 +50,9 @@ export class MoreInfoHistory extends LitElement {
private _metadata?: Record<string, StatisticsMetaData>;
protected render(): TemplateResult {
protected render() {
if (!this.entityId) {
return html``;
return nothing;
}
return html` ${isComponentLoaded(this.hass, "history")

View File

@ -1,5 +1,5 @@
import { startOfYesterday } from "date-fns/esm";
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { isComponentLoaded } from "../../common/config/is_component_loaded";
@ -19,14 +19,14 @@ export class MoreInfoLogbook extends LitElement {
private _entityIdAsList = memoizeOne((entityId: string) => [entityId]);
protected render(): TemplateResult {
protected render() {
if (!isComponentLoaded(this.hass, "logbook") || !this.entityId) {
return html``;
return nothing;
}
const stateObj = this.hass.states[this.entityId];
if (!stateObj) {
return html``;
return nothing;
}
return html`

Some files were not shown because too many files have changed in this diff Show More