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]
name = "home-assistant-frontend"
version = "20230405.0"
version = "20230406.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
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",
left:
this.chart!.canvas.offsetLeft +
clamp(context.tooltip.caretX, 100, this.clientWidth - 100) -
clamp(
context.tooltip.caretX,
100,
this.clientWidth - 100 - this.paddingYAxis
) -
100 +
"px",
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,7 +18,6 @@ import {
} from "superstruct";
import { fireEvent, HASSDomEvent } from "../../../../common/dom/fire_event";
import { customType } from "../../../../common/structs/is-custom-type";
import { entityId } from "../../../../common/structs/is-entity-id";
import { computeRTLDirection } from "../../../../common/util/compute_rtl";
import "../../../../components/entity/state-badge";
import "../../../../components/ha-card";
@ -184,7 +183,7 @@ const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
title: optional(union([string(), boolean()])),
entity: optional(entityId()),
entity: optional(string()),
theme: optional(string()),
icon: optional(string()),
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 { assert, assign, boolean, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
@ -14,7 +13,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
entity: optional(entityId()),
entity: optional(string()),
name: optional(string()),
icon: optional(string()),
attribute: optional(string()),

View File

@ -12,7 +12,6 @@ import {
string,
} from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
@ -31,7 +30,7 @@ const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
name: optional(string()),
entity: optional(entityId()),
entity: optional(string()),
unit: optional(string()),
min: 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 { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
@ -13,7 +12,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
entity: optional(entityId()),
entity: optional(string()),
name: 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 { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
@ -16,7 +15,7 @@ const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
name: optional(string()),
entity: optional(entityId()),
entity: optional(string()),
theme: optional(string()),
icon: optional(string()),
hold_action: optional(actionConfigStruct),

View File

@ -2,7 +2,6 @@ import { html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/entity/ha-entity-picker";
import "../../../../components/ha-theme-picker";
import { HomeAssistant } from "../../../../types";
@ -14,7 +13,7 @@ import { EditorTarget, EntitiesEditorEvent } from "../types";
const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
entity: optional(entityId()),
entity: 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 { assert, assign, boolean, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
@ -15,7 +14,7 @@ import { configElementStyle } from "./config-elements-style";
const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
entity: optional(entityId()),
entity: optional(string()),
image: optional(string()),
name: 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 { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
@ -13,7 +12,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
entity: optional(entityId()),
entity: optional(string()),
name: optional(string()),
theme: optional(string()),
})

View File

@ -11,7 +11,6 @@ import {
union,
} from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
@ -24,7 +23,7 @@ import { DEFAULT_HOURS_TO_SHOW } from "../../cards/hui-sensor-card";
const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
entity: optional(entityId()),
entity: optional(string()),
name: optional(string()),
icon: optional(string()),
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 { assert, assign, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import { entityId } from "../../../../common/structs/is-entity-id";
import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
@ -13,7 +12,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
const cardConfigStruct = assign(
baseLovelaceCardConfig,
object({
entity: optional(entityId()),
entity: optional(string()),
name: optional(string()),
theme: optional(string()),
})

View File

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

View File

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

View File

@ -26,13 +26,7 @@ import {
PropertyValues,
TemplateResult,
} from "lit";
import {
customElement,
eventOptions,
property,
query,
state,
} from "lit/decorators";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { ifDefined } from "lit/directives/if-defined";
import memoizeOne from "memoize-one";
@ -93,7 +87,7 @@ class HUIRoot extends LitElement {
@state() private _curView?: number | "hass-unused-entities";
@query("#view", true) _view!: HTMLDivElement;
@query("#view", true) _viewRoot!: HTMLDivElement;
private _viewCache?: { [viewId: string]: HUIView };
@ -550,19 +544,14 @@ class HUIRoot extends LitElement {
`
: ""}
</div>
<div
id="view"
@ll-rebuild=${this._debouncedConfigChanged}
@scroll=${this._viewScrolled}
></div>
<div id="view" @ll-rebuild=${this._debouncedConfigChanged}></div>
</div>
`;
}
@eventOptions({ passive: true })
private _viewScrolled(ev) {
private _viewScrolled = (ev) => {
this.toggleAttribute("scrolled", ev.currentTarget.scrollTop !== 0);
}
};
private _isVisible = (view: LovelaceViewConfig) =>
Boolean(
@ -684,10 +673,6 @@ class HUIRoot extends LitElement {
return this.lovelace!.editMode;
}
private get _viewRoot(): HTMLDivElement {
return this.shadowRoot!.getElementById("view") as HTMLDivElement;
}
private get _showButtonMenu(): boolean {
return (
(this.narrow && this._conversation(this.hass.config.components)) ||
@ -874,7 +859,6 @@ class HUIRoot extends LitElement {
const path = this.config.views[viewIndex].path || viewIndex;
this._navigateToView(path);
}
this._view.scrollTo(0, 0);
}
private _selectView(viewIndex: HUIRoot["_curView"], force: boolean): void {
@ -894,6 +878,7 @@ class HUIRoot extends LitElement {
const root = this._viewRoot;
if (root.lastChild) {
root.lastChild.removeEventListener("scroll", this._viewScrolled);
root.removeChild(root.lastChild);
}
@ -928,6 +913,7 @@ class HUIRoot extends LitElement {
view.lovelace = this.lovelace;
view.hass = this.hass;
view.narrow = this.narrow;
view.addEventListener("scroll", this._viewScrolled, { passive: true });
const configBackground = viewConfig.background || this.config.background;
@ -936,6 +922,7 @@ class HUIRoot extends LitElement {
} else {
this.style.removeProperty("--lovelace-background");
}
this.removeAttribute("scrolled");
root.appendChild(view);
// 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]) {
color: var(--error-color);
}
#view {
hui-view {
margin-top: calc(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(
--lovelace-background,
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;
transform: translateZ(0);
display: flex;
}
/**
* 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)
);
}
#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 {
display: none;
}

View File

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

View File

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