20230406.0 (#16090)

This commit is contained in:
Bram Kragten 2023-04-06 15:50:53 +02:00 committed by GitHub
commit 2750837d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 58 additions and 116 deletions

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "home-assistant-frontend" name = "home-assistant-frontend"
version = "20230405.0" version = "20230406.0"
license = {text = "Apache-2.0"} license = {text = "Apache-2.0"}
description = "The Home Assistant frontend" description = "The Home Assistant frontend"
readme = "README.md" readme = "README.md"

View File

@ -1,17 +0,0 @@
import { refine, string } from "superstruct";
const isEntityId = (value: string): boolean => value.includes(".");
export const entityId = () =>
refine(string(), "entity ID (domain.entity)", isEntityId);
const isEntityIdOrAll = (value: string): boolean => {
if (value === "all") {
return true;
}
return isEntityId(value);
};
export const entityIdOrAll = () =>
refine(string(), "entity ID (domain.entity or all)", isEntityIdOrAll);

View File

@ -276,7 +276,11 @@ export default class HaChartBase extends LitElement {
top: this.chart!.canvas.offsetTop + context.tooltip.caretY + 12 + "px", top: this.chart!.canvas.offsetTop + context.tooltip.caretY + 12 + "px",
left: left:
this.chart!.canvas.offsetLeft + this.chart!.canvas.offsetLeft +
clamp(context.tooltip.caretX, 100, this.clientWidth - 100) - clamp(
context.tooltip.caretX,
100,
this.clientWidth - 100 - this.paddingYAxis
) -
100 + 100 +
"px", "px",
}; };

View File

@ -2,9 +2,9 @@ import "@lrnwebcomponents/simple-tooltip/simple-tooltip";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event"; import { fireEvent } from "../common/dom/fire_event";
import { LocalizeFunc } from "../common/translations/localize";
import type { Analytics, AnalyticsPreferences } from "../data/analytics"; import type { Analytics, AnalyticsPreferences } from "../data/analytics";
import { haStyle } from "../resources/styles"; import { haStyle } from "../resources/styles";
import type { HomeAssistant } from "../types";
import "./ha-settings-row"; import "./ha-settings-row";
import "./ha-switch"; import "./ha-switch";
import type { HaSwitch } from "./ha-switch"; import type { HaSwitch } from "./ha-switch";
@ -19,7 +19,7 @@ declare global {
@customElement("ha-analytics") @customElement("ha-analytics")
export class HaAnalytics extends LitElement { export class HaAnalytics extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public localize!: LocalizeFunc;
@property({ attribute: false }) public analytics?: Analytics; @property({ attribute: false }) public analytics?: Analytics;
@ -34,12 +34,12 @@ export class HaAnalytics extends LitElement {
return html` return html`
<ha-settings-row> <ha-settings-row>
<span slot="heading" data-for="base"> <span slot="heading" data-for="base">
${this.hass.localize( ${this.localize(
`ui.panel.${this.translationKeyPanel}.analytics.preferences.base.title` `ui.panel.${this.translationKeyPanel}.analytics.preferences.base.title`
)} )}
</span> </span>
<span slot="description" data-for="base"> <span slot="description" data-for="base">
${this.hass.localize( ${this.localize(
`ui.panel.${this.translationKeyPanel}.analytics.preferences.base.description` `ui.panel.${this.translationKeyPanel}.analytics.preferences.base.description`
)} )}
</span> </span>
@ -57,12 +57,12 @@ export class HaAnalytics extends LitElement {
html` html`
<ha-settings-row> <ha-settings-row>
<span slot="heading" data-for=${preference}> <span slot="heading" data-for=${preference}>
${this.hass.localize( ${this.localize(
`ui.panel.${this.translationKeyPanel}.analytics.preferences.${preference}.title` `ui.panel.${this.translationKeyPanel}.analytics.preferences.${preference}.title`
)} )}
</span> </span>
<span slot="description" data-for=${preference}> <span slot="description" data-for=${preference}>
${this.hass.localize( ${this.localize(
`ui.panel.${this.translationKeyPanel}.analytics.preferences.${preference}.description` `ui.panel.${this.translationKeyPanel}.analytics.preferences.${preference}.description`
)} )}
</span> </span>
@ -77,7 +77,7 @@ export class HaAnalytics extends LitElement {
${!baseEnabled ${!baseEnabled
? html` ? html`
<simple-tooltip animation-delay="0" position="right"> <simple-tooltip animation-delay="0" position="right">
${this.hass.localize( ${this.localize(
`ui.panel.${this.translationKeyPanel}.analytics.need_base_enabled` `ui.panel.${this.translationKeyPanel}.analytics.need_base_enabled`
)} )}
</simple-tooltip> </simple-tooltip>
@ -89,12 +89,12 @@ export class HaAnalytics extends LitElement {
)} )}
<ha-settings-row> <ha-settings-row>
<span slot="heading" data-for="diagnostics"> <span slot="heading" data-for="diagnostics">
${this.hass.localize( ${this.localize(
`ui.panel.${this.translationKeyPanel}.analytics.preferences.diagnostics.title` `ui.panel.${this.translationKeyPanel}.analytics.preferences.diagnostics.title`
)} )}
</span> </span>
<span slot="description" data-for="diagnostics"> <span slot="description" data-for="diagnostics">
${this.hass.localize( ${this.localize(
`ui.panel.${this.translationKeyPanel}.analytics.preferences.diagnostics.description` `ui.panel.${this.translationKeyPanel}.analytics.preferences.diagnostics.description`
)} )}
</span> </span>

View File

@ -23,11 +23,11 @@ class OnboardingAnalytics extends LitElement {
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`
<p>${this.hass.localize("ui.panel.page-onboarding.analytics.intro")}</p> <p>${this.localize("ui.panel.page-onboarding.analytics.intro")}</p>
<ha-analytics <ha-analytics
translation_key_panel="page-onboarding" translation_key_panel="page-onboarding"
@analytics-preferences-changed=${this._preferencesChanged} @analytics-preferences-changed=${this._preferencesChanged}
.hass=${this.hass} .localize=${this.localize}
.analytics=${this._analyticsDetails} .analytics=${this._analyticsDetails}
> >
</ha-analytics> </ha-analytics>
@ -41,7 +41,7 @@ class OnboardingAnalytics extends LitElement {
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
> >
${this.hass.localize("ui.panel.page-onboarding.analytics.learn_more")} ${this.localize("ui.panel.page-onboarding.analytics.learn_more")}
</a> </a>
</div> </div>
`; `;

View File

@ -45,7 +45,7 @@ class ConfigAnalytics extends LitElement {
<ha-analytics <ha-analytics
translation_key_panel="config" translation_key_panel="config"
@analytics-preferences-changed=${this._preferencesChanged} @analytics-preferences-changed=${this._preferencesChanged}
.hass=${this.hass} .localize=${this.hass.localize}
.analytics=${this._analyticsDetails} .analytics=${this._analyticsDetails}
></ha-analytics> ></ha-analytics>
</div> </div>

View File

@ -663,7 +663,7 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
)} )}
</ha-select>` </ha-select>`
: ""} : ""}
${this._helperConfigEntry ${this._helperConfigEntry && this._helperConfigEntry.supports_options
? html` ? html`
<div class="row"> <div class="row">
<mwc-button <mwc-button

View File

@ -453,9 +453,9 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
"ui.panel.config.integrations.search" "ui.panel.config.integrations.search"
)} )}
> >
${!this._showDisabled && disabledCount <div class="filters" slot="suffix">
? html`<div class="filters" slot="suffix"> ${!this._showDisabled && disabledCount
<div ? html`<div
class="active-filters" class="active-filters"
@click=${this._preventDefault} @click=${this._preventDefault}
> >
@ -469,10 +469,10 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
"ui.panel.config.integrations.disable.show" "ui.panel.config.integrations.disable.show"
)} )}
></mwc-button> ></mwc-button>
</div> </div>`
${filterMenu} : ""}
</div>` ${filterMenu}
: ""} </div>
</search-input> </search-input>
</div> </div>
`} `}

View File

@ -518,10 +518,6 @@ class HaPanelHistory extends SubscribeMixin(LitElement) {
padding-bottom: max(env(safe-area-inset-bottom), 16px); padding-bottom: max(env(safe-area-inset-bottom), 16px);
} }
state-history-charts {
overflow-x: hidden;
}
:host([virtualize]) { :host([virtualize]) {
height: 100%; height: 100%;
} }

View File

@ -3,7 +3,6 @@ import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { array, assert, assign, object, optional, string } from "superstruct"; import { array, assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import type { LocalizeFunc } from "../../../../common/translations/localize"; import type { LocalizeFunc } from "../../../../common/translations/localize";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
@ -15,7 +14,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
name: optional(string()), name: optional(string()),
states: optional(array()), states: optional(array()),
theme: optional(string()), theme: optional(string()),

View File

@ -2,7 +2,6 @@ import { CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { assert, assign, boolean, object, optional, string } from "superstruct"; import { assert, assign, boolean, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@ -15,7 +14,7 @@ import { configElementStyle } from "./config-elements-style";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
name: optional(string()), name: optional(string()),
show_name: optional(boolean()), show_name: optional(boolean()),
icon: optional(string()), icon: optional(string()),

View File

@ -18,7 +18,6 @@ import {
} from "superstruct"; } from "superstruct";
import { fireEvent, HASSDomEvent } from "../../../../common/dom/fire_event"; import { fireEvent, HASSDomEvent } from "../../../../common/dom/fire_event";
import { customType } from "../../../../common/structs/is-custom-type"; import { customType } from "../../../../common/structs/is-custom-type";
import { entityId } from "../../../../common/structs/is-entity-id";
import { computeRTLDirection } from "../../../../common/util/compute_rtl"; import { computeRTLDirection } from "../../../../common/util/compute_rtl";
import "../../../../components/entity/state-badge"; import "../../../../components/entity/state-badge";
import "../../../../components/ha-card"; import "../../../../components/ha-card";
@ -184,7 +183,7 @@ const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
title: optional(union([string(), boolean()])), title: optional(union([string(), boolean()])),
entity: optional(entityId()), entity: optional(string()),
theme: optional(string()), theme: optional(string()),
icon: optional(string()), icon: optional(string()),
show_header_toggle: optional(boolean()), show_header_toggle: optional(boolean()),

View File

@ -2,7 +2,6 @@ import { html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { assert, assign, boolean, object, optional, string } from "superstruct"; import { assert, assign, boolean, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@ -14,7 +13,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
name: optional(string()), name: optional(string()),
icon: optional(string()), icon: optional(string()),
attribute: optional(string()), attribute: optional(string()),

View File

@ -12,7 +12,6 @@ import {
string, string,
} from "superstruct"; } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@ -31,7 +30,7 @@ const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
name: optional(string()), name: optional(string()),
entity: optional(entityId()), entity: optional(string()),
unit: optional(string()), unit: optional(string()),
min: optional(number()), min: optional(number()),
max: optional(number()), max: optional(number()),

View File

@ -2,7 +2,6 @@ import { html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { assert, assign, object, optional, string } from "superstruct"; import { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@ -13,7 +12,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
name: optional(string()), name: optional(string()),
theme: optional(string()), theme: optional(string()),
}) })

View File

@ -2,7 +2,6 @@ import { CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { assert, assign, object, optional, string } from "superstruct"; import { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@ -16,7 +15,7 @@ const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
name: optional(string()), name: optional(string()),
entity: optional(entityId()), entity: optional(string()),
theme: optional(string()), theme: optional(string()),
icon: optional(string()), icon: optional(string()),
hold_action: optional(actionConfigStruct), hold_action: optional(actionConfigStruct),

View File

@ -2,7 +2,6 @@ import { html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { assert, assign, object, optional, string } from "superstruct"; import { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/entity/ha-entity-picker"; import "../../../../components/entity/ha-entity-picker";
import "../../../../components/ha-theme-picker"; import "../../../../components/ha-theme-picker";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
@ -14,7 +13,7 @@ import { EditorTarget, EntitiesEditorEvent } from "../types";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
theme: optional(string()), theme: optional(string()),
}) })
); );

View File

@ -2,7 +2,6 @@ import { CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { assert, assign, boolean, object, optional, string } from "superstruct"; import { assert, assign, boolean, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@ -15,7 +14,7 @@ import { configElementStyle } from "./config-elements-style";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
image: optional(string()), image: optional(string()),
name: optional(string()), name: optional(string()),
camera_image: optional(string()), camera_image: optional(string()),

View File

@ -2,7 +2,6 @@ import { html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { assert, assign, object, optional, string } from "superstruct"; import { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@ -13,7 +12,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
name: optional(string()), name: optional(string()),
theme: optional(string()), theme: optional(string()),
}) })

View File

@ -11,7 +11,6 @@ import {
union, union,
} from "superstruct"; } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@ -24,7 +23,7 @@ import { DEFAULT_HOURS_TO_SHOW } from "../../cards/hui-sensor-card";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
name: optional(string()), name: optional(string()),
icon: optional(string()), icon: optional(string()),
graph: optional(union([literal("line"), literal("none")])), graph: optional(union([literal("line"), literal("none")])),

View File

@ -2,7 +2,6 @@ import { html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { assert, assign, object, optional, string } from "superstruct"; import { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types"; import type { HomeAssistant } from "../../../../types";
@ -13,7 +12,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
name: optional(string()), name: optional(string()),
theme: optional(string()), theme: optional(string()),
}) })

View File

@ -14,7 +14,6 @@ import {
string, string,
} from "superstruct"; } from "superstruct";
import { fireEvent, HASSDomEvent } from "../../../../common/dom/fire_event"; import { fireEvent, HASSDomEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import { LocalizeFunc } from "../../../../common/translations/localize"; import { LocalizeFunc } from "../../../../common/translations/localize";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
@ -35,7 +34,7 @@ import "./hui-tile-card-features-editor";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
name: optional(string()), name: optional(string()),
icon: optional(string()), icon: optional(string()),
color: optional(string()), color: optional(string()),

View File

@ -3,7 +3,6 @@ import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { assert, assign, boolean, object, optional, string } from "superstruct"; import { assert, assign, boolean, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import type { LocalizeFunc } from "../../../../common/translations/localize"; import type { LocalizeFunc } from "../../../../common/translations/localize";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types"; import type { SchemaUnion } from "../../../../components/ha-form/types";
@ -18,7 +17,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
object({ object({
entity: optional(entityId()), entity: optional(string()),
name: optional(string()), name: optional(string()),
theme: optional(string()), theme: optional(string()),
show_current: optional(boolean()), show_current: optional(boolean()),

View File

@ -26,13 +26,7 @@ import {
PropertyValues, PropertyValues,
TemplateResult, TemplateResult,
} from "lit"; } from "lit";
import { import { customElement, property, query, state } from "lit/decorators";
customElement,
eventOptions,
property,
query,
state,
} from "lit/decorators";
import { classMap } from "lit/directives/class-map"; import { classMap } from "lit/directives/class-map";
import { ifDefined } from "lit/directives/if-defined"; import { ifDefined } from "lit/directives/if-defined";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
@ -93,7 +87,7 @@ class HUIRoot extends LitElement {
@state() private _curView?: number | "hass-unused-entities"; @state() private _curView?: number | "hass-unused-entities";
@query("#view", true) _view!: HTMLDivElement; @query("#view", true) _viewRoot!: HTMLDivElement;
private _viewCache?: { [viewId: string]: HUIView }; private _viewCache?: { [viewId: string]: HUIView };
@ -550,19 +544,14 @@ class HUIRoot extends LitElement {
` `
: ""} : ""}
</div> </div>
<div <div id="view" @ll-rebuild=${this._debouncedConfigChanged}></div>
id="view"
@ll-rebuild=${this._debouncedConfigChanged}
@scroll=${this._viewScrolled}
></div>
</div> </div>
`; `;
} }
@eventOptions({ passive: true }) private _viewScrolled = (ev) => {
private _viewScrolled(ev) {
this.toggleAttribute("scrolled", ev.currentTarget.scrollTop !== 0); this.toggleAttribute("scrolled", ev.currentTarget.scrollTop !== 0);
} };
private _isVisible = (view: LovelaceViewConfig) => private _isVisible = (view: LovelaceViewConfig) =>
Boolean( Boolean(
@ -684,10 +673,6 @@ class HUIRoot extends LitElement {
return this.lovelace!.editMode; return this.lovelace!.editMode;
} }
private get _viewRoot(): HTMLDivElement {
return this.shadowRoot!.getElementById("view") as HTMLDivElement;
}
private get _showButtonMenu(): boolean { private get _showButtonMenu(): boolean {
return ( return (
(this.narrow && this._conversation(this.hass.config.components)) || (this.narrow && this._conversation(this.hass.config.components)) ||
@ -874,7 +859,6 @@ class HUIRoot extends LitElement {
const path = this.config.views[viewIndex].path || viewIndex; const path = this.config.views[viewIndex].path || viewIndex;
this._navigateToView(path); this._navigateToView(path);
} }
this._view.scrollTo(0, 0);
} }
private _selectView(viewIndex: HUIRoot["_curView"], force: boolean): void { private _selectView(viewIndex: HUIRoot["_curView"], force: boolean): void {
@ -894,6 +878,7 @@ class HUIRoot extends LitElement {
const root = this._viewRoot; const root = this._viewRoot;
if (root.lastChild) { if (root.lastChild) {
root.lastChild.removeEventListener("scroll", this._viewScrolled);
root.removeChild(root.lastChild); root.removeChild(root.lastChild);
} }
@ -928,6 +913,7 @@ class HUIRoot extends LitElement {
view.lovelace = this.lovelace; view.lovelace = this.lovelace;
view.hass = this.hass; view.hass = this.hass;
view.narrow = this.narrow; view.narrow = this.narrow;
view.addEventListener("scroll", this._viewScrolled, { passive: true });
const configBackground = viewConfig.background || this.config.background; const configBackground = viewConfig.background || this.config.background;
@ -936,6 +922,7 @@ class HUIRoot extends LitElement {
} else { } else {
this.style.removeProperty("--lovelace-background"); this.style.removeProperty("--lovelace-background");
} }
this.removeAttribute("scrolled");
root.appendChild(view); root.appendChild(view);
// Recalculate to see if we need to adjust content area for tab bar // Recalculate to see if we need to adjust content area for tab bar
@ -1046,18 +1033,20 @@ class HUIRoot extends LitElement {
mwc-button.warning:not([disabled]) { mwc-button.warning:not([disabled]) {
color: var(--error-color); color: var(--error-color);
} }
#view { hui-view {
margin-top: calc(var(--header-height) + env(safe-area-inset-top)); margin-top: calc(var(--header-height) + env(safe-area-inset-top));
height: calc(100vh - var(--header-height) - env(safe-area-inset-top)); height: calc(100vh - var(--header-height) - env(safe-area-inset-top));
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
background: var( background: var(
--lovelace-background, --lovelace-background,
var(--primary-background-color) var(--primary-background-color)
); );
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
width: 100%;
padding-bottom: env(safe-area-inset-bottom);
display: block;
overflow: auto; overflow: auto;
transform: translateZ(0); transform: translateZ(0);
display: flex;
} }
/** /**
* In edit mode we have the tab bar on a new line * * In edit mode we have the tab bar on a new line *
@ -1070,21 +1059,6 @@ class HUIRoot extends LitElement {
var(--header-height) + 48px + env(safe-area-inset-top) var(--header-height) + 48px + env(safe-area-inset-top)
); );
} }
#view > * {
/**
* The view could get larger than the window in Firefox
* to prevent that we set the max-width to 100%
* flex-grow: 1 and flex-basis: 100% should make sure the view
* stays full width.
*
* https://github.com/home-assistant/home-assistant-polymer/pull/3806
*/
flex: 1 1 100%;
height: 100%;
max-width: 100%;
padding-bottom: env(safe-area-inset-bottom);
display: block;
}
.hide-tab { .hide-tab {
display: none; display: none;
} }

View File

@ -161,9 +161,8 @@ export class HUIView extends ReactiveElement {
| undefined; | undefined;
if ( if (
!oldHass || changedProperties.has("hass") &&
this.hass.themes !== oldHass.themes || (!oldHass || this.hass.themes !== oldHass.themes)
this.hass.selectedTheme !== oldHass.selectedTheme
) { ) {
applyThemesOnElement(this, this.hass.themes, this._viewConfigTheme); applyThemesOnElement(this, this.hass.themes, this._viewConfigTheme);
} }

View File

@ -901,7 +901,7 @@
} }
}, },
"zone": { "zone": {
"graph_unit": "People home" "graph_unit": "People in zone"
}, },
"light": { "light": {
"toggle": "Toggle", "toggle": "Toggle",