Compare commits

..
Author SHA1 Message Date
Maarten Lakerveld 8823dce36c Hide maintenance entities through Lovelace edit mode
The maintenance pencil faked an edit mode: it regenerated the view with every card wrapped in an entity-visibility card, while the Lovelace object kept editMode off. That card type had to be registered with the card factory, so any YAML dashboard could use it.

The panel now turns on real edit mode and sets entityVisibility on the Lovelace object. With that set, view, header, footer, sidebar and badges skip their layout editing chrome, and grid sections wrap each entity card in a hui-card-visibility-edit-mode overlay that toggles it. Cards without an entity are inert while editing, as in regular edit mode. The strategy only takes hidden_entities; while editing, the panel leaves it out so hidden entities show, dimmed.

A toggle saves and hands the view a new Lovelace object with the same config, so nothing is rebuilt and focus stays on the card. The entity-visibility card, its wrapper helper and the edit_visibility strategy option are removed.
2026-11-12 14:08:17 +01:00
83 changed files with 999 additions and 2283 deletions

No files matched your search

+42 -107
View File
@@ -157,99 +157,6 @@ async function pollProcess(lokaliseApi, projectId, processId) {
}
/* eslint-enable no-await-in-loop */
const DRAFTS_ACCEPTED_KEYS = [
// Written per language rather than translated from English, so an English edit doesn't make them outdated
"ui.components.rooms.keywords",
];
async function exportTranslations(lokaliseApi, projectId) {
const exportProcess = await lokaliseApi.files().async_download(projectId, {
format: "json",
original_filenames: false,
replace_breaks: false,
json_unescaped_slashes: true,
export_empty_as: "skip",
filter_data: ["verified"],
});
const finishedProcess = await pollProcess(
lokaliseApi,
projectId,
exportProcess.process_id
);
const bundleUrl = finishedProcess.details.download_url;
console.log(`Downloading translations from: ${bundleUrl}`);
const response = await fetch(bundleUrl);
if (response.status !== 200 && response.status !== 0) {
throw new Error(response.statusText);
}
console.log(`Extracting translations...`);
const contents = await JSZip.loadAsync(await response.arrayBuffer());
const files = {};
await Promise.all(
Object.keys(contents.files).map(async (filename) => {
const file = contents.file(filename);
if (!file) {
// no file, probably a directory
return;
}
files[filename.split("/").splice(-1)[0]] = await file.async("string");
})
);
return files;
}
async function fetchDrafts(lokaliseApi, projectId) {
const english = JSON.parse(
await fs.readFile("src/translations/en.json", { encoding })
);
const keyNames = DRAFTS_ACCEPTED_KEYS.flatMap((key) => {
const keys = key.split(".");
const drafts = keys.reduce((obj, part) => obj?.[part], english) ?? {};
return Object.keys(drafts).map((name) => [...keys, name].join("::"));
});
if (!keyNames.length) {
return [];
}
const { items } = await lokaliseApi.keys().list({
project_id: projectId,
filter_keys: keyNames.join(","),
include_translations: 1,
limit: keyNames.length,
});
return items.flatMap((key) =>
key.translations
.filter(({ translation }) => translation)
.map(({ language_iso, translation }) => ({
filename: `${language_iso}.json`,
path: key.key_name.web.split("::"),
translation,
}))
);
}
function acceptDrafts(files, drafts) {
const data = {};
drafts.forEach(({ filename, path: keyPath, translation }) => {
data[filename] ??= files[filename] ? JSON.parse(files[filename]) : {};
const parent = keyPath.slice(0, -1).reduce((obj, part) => {
obj[part] ??= {};
return obj[part];
}, data[filename]);
parent[keyPath.at(-1)] = translation;
});
Object.entries(data).forEach(([filename, content]) => {
files[filename] = JSON.stringify(content, null, 2);
});
}
gulp.task("fetch-lokalise", async function () {
let apiKey;
try {
@@ -286,24 +193,52 @@ gulp.task("fetch-lokalise", async function () {
await Promise.all(
projects.map(async ([project, projectId]) => {
try {
const [files, drafts] = await Promise.all([
exportTranslations(lokaliseApi, projectId),
project === "frontend"
? fetchDrafts(lokaliseApi, projectId)
: undefined,
]);
if (drafts) {
acceptDrafts(files, drafts);
const exportProcess = await lokaliseApi
.files()
.async_download(projectId, {
format: "json",
original_filenames: false,
replace_breaks: false,
json_unescaped_slashes: true,
export_empty_as: "skip",
filter_data: ["verified"],
});
const finishedProcess = await pollProcess(
lokaliseApi,
projectId,
exportProcess.process_id
);
const bundleUrl = finishedProcess.details.download_url;
console.log(`Downloading translations from: ${bundleUrl}`);
const response = await fetch(bundleUrl);
if (response.status !== 200 && response.status !== 0) {
throw new Error(response.statusText);
}
console.log(`Extracting translations...`);
const contents = await JSZip.loadAsync(await response.arrayBuffer());
await mkdirPromise;
await Promise.all(
Object.entries(files).map(([filename, content]) =>
fs.writeFile(path.join(inDir, project, filename), content, {
flag: "w",
encoding,
})
)
Object.keys(contents.files).map(async (filename) => {
const file = contents.file(filename);
if (!file) {
// no file, probably a directory
return;
}
const content = await file.async("nodebuffer");
await fs.writeFile(
path.join(inDir, project, filename.split("/").splice(-1)[0]),
content,
{ flag: "w", encoding }
);
})
);
} catch (err) {
console.error(err);
-19
View File
@@ -1,19 +0,0 @@
import type { ReactiveElement } from "lit";
import { ContextSubscriptionController } from "../../../src/common/decorators/consume";
import { uiContext } from "../../../src/data/context";
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
// A demo that provides its own hass hides the gallery theme from its children,
// so pass the gallery light or dark mode on to it.
export const followGalleryTheme = (
host: ReactiveElement,
hass: MockHomeAssistant
) =>
new ContextSubscriptionController(host, uiContext, (ui) => {
if (ui) {
hass.updateHass({
themes: ui.themes,
selectedTheme: ui.selectedTheme,
});
}
});
+5 -11
View File
@@ -117,17 +117,11 @@ shared slots/attributes below.
**Attributes**
| Name | Type | Default | Description |
| ---------------------- | ------- | ------- | -------------------------------------------------- |
| `headline` | String | — | Primary text. Overridden by the slot. |
| `supporting-text` | String | — | Secondary text. Overridden by the slot. |
| `wrap-headline` | Boolean | `false` | Wrap the headline instead of truncating it. |
| `wrap-supporting-text` | Boolean | `false` | Wrap the supporting text instead of truncating it. |
| `disabled` | Boolean | `false` | Dims the row and blocks pointer events. |
The headline and the supporting text stay on one line and are truncated with an
ellipsis by default. Set `wrap-headline` or `wrap-supporting-text` on rows whose
text has to stay readable in full, like settings with a description.
| Name | Type | Default | Description |
| ----------------- | ------- | ------- | --------------------------------------- |
| `headline` | String | — | Primary text. Overridden by the slot. |
| `supporting-text` | String | — | Secondary text. Overridden by the slot. |
| `disabled` | Boolean | `false` | Dims the row and blocks pointer events. |
**CSS parts**
-14
View File
@@ -191,20 +191,6 @@ export class DemoHaList extends LitElement {
<ha-list-item-base headline="Disabled row" disabled>
<ha-svg-icon slot="start" .path=${mdiHome}></ha-svg-icon>
</ha-list-item-base>
<ha-list-item-base
headline="Truncated by default, a long headline stays on one line and ends with an ellipsis"
supporting-text="Long supporting text is truncated as well, so every row in the list keeps the same height"
>
<ha-svg-icon slot="start" .path=${mdiHome}></ha-svg-icon>
</ha-list-item-base>
<ha-list-item-base
wrap-headline
wrap-supporting-text
headline="With wrap-headline, a long headline wraps onto as many lines as it needs"
supporting-text="With wrap-supporting-text, long supporting text wraps too, which suits settings with a description"
>
<ha-svg-icon slot="start" .path=${mdiHome}></ha-svg-icon>
</ha-list-item-base>
</ha-list-base>
</ha-card>
@@ -10,7 +10,6 @@ import type {
} from "../../../../src/data/history";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import type { HomeAssistant } from "../../../../src/types";
import { followGalleryTheme } from "../../data/follow-gallery-theme";
const HOUR = 60 * 60 * 1000;
const HOURS = 48;
@@ -167,7 +166,6 @@ export class DemoStateHistoryCharts extends LitElement {
super.firstUpdated(changedProps);
const hass = provideHass(this);
hass.updateTranslations(null, "en");
followGalleryTheme(this, hass);
hass.addEntities(ENTITIES);
}
@@ -1,9 +1,7 @@
import type { PropertyValues } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import type { ChartSelectMode } from "../../../../src/components/chart/ha-chart-base";
import { customElement, property } from "lit/decorators";
import "../../../../src/components/chart/statistics-chart";
import "../../../../src/components/ha-button";
import "../../../../src/components/ha-card";
import type {
Statistics,
@@ -13,9 +11,7 @@ import type {
} from "../../../../src/data/recorder";
import { StatisticMeanType } from "../../../../src/data/recorder";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import type { HASSDomEvent } from "../../../../src/common/dom/fire_event";
import type { HomeAssistant } from "../../../../src/types";
import { followGalleryTheme } from "../../data/follow-gallery-theme";
const HOUR = 60 * 60 * 1000;
const HOURS = 48;
@@ -112,64 +108,6 @@ interface Example {
height?: string;
}
interface TimeRange {
start: number;
end: number;
}
interface RangeExample {
id: string;
title: string;
description: string;
statistics: Statistics;
statTypes: StatisticType[];
chartType: "line" | "bar";
unit: string;
selectMode: ChartSelectMode;
hint: string;
}
const RANGE_EXAMPLES: RangeExample[] = [
{
id: "point",
title: "Point selection",
description:
"With select-mode set to point, a click selects the hour that contains it, and everything outside fades. Dragging still zooms.",
statistics: { [HEAT_PUMP_ID]: HEAT_PUMP },
statTypes: ["change"],
chartType: "bar",
unit: "kWh",
selectMode: "point",
hint: "Click on a bar to select its hour.",
},
{
id: "range-bar",
title: "Range selection on bars",
description:
"With select-mode set to range, dragging selects a time range instead of zooming, so several bars can be selected at once. A click still selects one bar.",
statistics: { [HEAT_PUMP_ID]: HEAT_PUMP },
statTypes: ["change"],
chartType: "bar",
unit: "kWh",
selectMode: "range",
hint: "Click or drag on the chart to select one or more bars.",
},
{
id: "range",
title: "Range selection on lines",
description: "The same on a line chart.",
statistics: { [LIVING_ROOM_ID]: LIVING_ROOM },
statTypes: ["mean", "min", "max"],
chartType: "line",
unit: "°C",
selectMode: "range",
hint: "Click or drag on the chart to select a period.",
},
];
const formatRange = (range: TimeRange) =>
`${new Date(range.start).toLocaleString()} to ${new Date(range.end).toLocaleString()}`;
const EXAMPLES: Example[] = [
{
title: "Sum as bars",
@@ -221,20 +159,17 @@ const EXAMPLES: Example[] = [
export class DemoStatisticsChart extends LitElement {
@property({ attribute: false }) public hass?: HomeAssistant;
@state() private _selections: Record<string, TimeRange | undefined> = {};
protected firstUpdated(changedProps: PropertyValues<this>) {
super.firstUpdated(changedProps);
const hass = provideHass(this);
hass.updateTranslations(null, "en");
followGalleryTheme(this, hass);
}
protected render() {
if (!this.hass) {
return nothing;
}
return html`${EXAMPLES.map(
return EXAMPLES.map(
(example) => html`
<ha-card header=${example.title}>
<div class="card-content">
@@ -256,66 +191,7 @@ export class DemoStatisticsChart extends LitElement {
</div>
</ha-card>
`
)}
${RANGE_EXAMPLES.map((example) => this._renderRangeExample(example))}`;
}
private _renderRangeExample(example: RangeExample) {
const selection = this._selections[example.id];
return html`
<ha-card header=${example.title}>
<div class="card-content">
<p>${example.description}</p>
<statistics-chart
.statisticsData=${example.statistics}
.metadata=${METADATA}
.names=${NAMES}
.statTypes=${example.statTypes}
.chartType=${example.chartType}
period="hour"
.unit=${example.unit}
.startTime=${START}
.endTime=${END}
.highlight=${selection}
.clickForMoreInfo=${false}
data-example=${example.id}
.selectMode=${example.selectMode}
hide-legend
@chart-select=${this._rangeSelected}
></statistics-chart>
<div class="selection">
${
selection
? html`
<span>${formatRange(selection)}</span>
<ha-button
appearance="plain"
size="s"
data-example=${example.id}
@click=${this._clearSelection}
>
Clear
</ha-button>
`
: html`<span class="hint">${example.hint}</span>`
}
</div>
</div>
</ha-card>
`;
}
private _rangeSelected(ev: HASSDomEvent<HASSDomEvents["chart-select"]>) {
const id = (ev.currentTarget as HTMLElement).dataset.example!;
this._selections = {
...this._selections,
[id]: ev.detail,
};
}
private _clearSelection(ev: Event) {
const id = (ev.currentTarget as HTMLElement).dataset.example!;
this._selections = { ...this._selections, [id]: undefined };
);
}
static styles = css`
@@ -326,20 +202,6 @@ export class DemoStatisticsChart extends LitElement {
p {
margin-top: 0;
}
.selection {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--ha-space-2);
min-height: 48px;
margin-top: var(--ha-space-2);
padding: 0 var(--ha-space-2) 0 var(--ha-space-4);
border-radius: var(--ha-border-radius-lg);
background-color: var(--secondary-background-color);
}
.hint {
color: var(--secondary-text-color);
}
`;
}
+12 -12
View File
@@ -54,15 +54,15 @@
"@codemirror/view": "6.43.15",
"@date-fns/tz": "1.5.0",
"@egjs/hammerjs": "2.0.17",
"@formatjs/intl-datetimeformat": "8.0.3",
"@formatjs/intl-displaynames": "8.0.2",
"@formatjs/intl-durationformat": "0.12.4",
"@formatjs/intl-getcanonicallocales": "3.3.1",
"@formatjs/intl-listformat": "9.0.2",
"@formatjs/intl-locale": "5.4.3",
"@formatjs/intl-numberformat": "10.0.3",
"@formatjs/intl-pluralrules": "7.0.3",
"@formatjs/intl-relativetimeformat": "13.0.2",
"@formatjs/intl-datetimeformat": "8.0.2",
"@formatjs/intl-displaynames": "8.0.1",
"@formatjs/intl-durationformat": "0.12.3",
"@formatjs/intl-getcanonicallocales": "3.3.0",
"@formatjs/intl-listformat": "9.0.1",
"@formatjs/intl-locale": "5.4.2",
"@formatjs/intl-numberformat": "10.0.2",
"@formatjs/intl-pluralrules": "7.0.2",
"@formatjs/intl-relativetimeformat": "13.0.1",
"@home-assistant/webawesome": "3.14.0-ha.2",
"@lezer/common": "1.5.5",
"@lezer/highlight": "1.2.5",
@@ -102,7 +102,7 @@
"hls.js": "1.7.4",
"home-assistant-js-websocket": "9.8.1",
"idb-keyval": "6.3.0",
"intl-messageformat": "12.1.5",
"intl-messageformat": "12.1.4",
"js-yaml": "5.5.0",
"leaflet": "1.9.4",
"leaflet.markercluster": "1.5.3",
@@ -180,7 +180,7 @@
"eslint": "10.14.0",
"eslint-config-prettier": "10.1.8",
"eslint-import-resolver-webpack": "0.13.11",
"eslint-plugin-import-x": "4.18.1",
"eslint-plugin-import-x": "4.18.0",
"eslint-plugin-lit": "2.3.1",
"eslint-plugin-lit-a11y": "5.1.3",
"eslint-plugin-unused-imports": "4.4.1",
@@ -215,7 +215,7 @@
"ts-lit-plugin": "2.0.2",
"typescript": "6.0.3",
"typescript-eslint": "8.72.1",
"vite": "8.3.7",
"vite": "8.3.6",
"vite-tsconfig-paths": "6.1.1",
"vitest": "5.1.0",
"webpack-stats-plugin": "1.1.3",
+146 -146
View File
@@ -222,32 +222,32 @@ importers:
specifier: 2.0.17
version: 2.0.17
'@formatjs/intl-datetimeformat':
specifier: 8.0.3
version: 8.0.3
'@formatjs/intl-displaynames':
specifier: 8.0.2
version: 8.0.2
'@formatjs/intl-displaynames':
specifier: 8.0.1
version: 8.0.1
'@formatjs/intl-durationformat':
specifier: 0.12.4
version: 0.12.4
specifier: 0.12.3
version: 0.12.3
'@formatjs/intl-getcanonicallocales':
specifier: 3.3.1
version: 3.3.1
specifier: 3.3.0
version: 3.3.0
'@formatjs/intl-listformat':
specifier: 9.0.2
version: 9.0.2
specifier: 9.0.1
version: 9.0.1
'@formatjs/intl-locale':
specifier: 5.4.3
version: 5.4.3
specifier: 5.4.2
version: 5.4.2
'@formatjs/intl-numberformat':
specifier: 10.0.3
version: 10.0.3
specifier: 10.0.2
version: 10.0.2
'@formatjs/intl-pluralrules':
specifier: 7.0.3
version: 7.0.3
specifier: 7.0.2
version: 7.0.2
'@formatjs/intl-relativetimeformat':
specifier: 13.0.2
version: 13.0.2
specifier: 13.0.1
version: 13.0.1
'@home-assistant/webawesome':
specifier: 3.14.0-ha.2
version: 3.14.0-ha.2(@floating-ui/[email protected])(@types/[email protected])
@@ -366,8 +366,8 @@ importers:
specifier: 6.3.0
version: 6.3.0
intl-messageformat:
specifier: 12.1.5
version: 12.1.5
specifier: 12.1.4
version: 12.1.4
js-yaml:
specifier: 5.5.0
version: 5.5.0
@@ -595,8 +595,8 @@ importers:
specifier: 0.13.11
version: 0.13.11([email protected])
eslint-plugin-import-x:
specifier: 4.18.1
version: 4.18.1(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected])([email protected]))([email protected]([email protected]))([email protected])
specifier: 4.18.0
version: 4.18.0(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected])([email protected]))([email protected]([email protected]))([email protected])
eslint-plugin-lit:
specifier: 2.3.1
version: 2.3.1([email protected]([email protected]))
@@ -700,14 +700,14 @@ importers:
specifier: 8.72.1
version: 8.72.1([email protected]([email protected]))([email protected])([email protected])
vite:
specifier: 8.3.7
version: 8.3.7(@types/[email protected])([email protected])([email protected])
specifier: 8.3.6
version: 8.3.6(@types/[email protected])([email protected])([email protected])
vite-tsconfig-paths:
specifier: 6.1.1
version: 6.1.1([email protected])([email protected])([email protected].7(@types/[email protected])([email protected])([email protected]))
version: 6.1.1([email protected])([email protected])([email protected].6(@types/[email protected])([email protected])([email protected]))
vitest:
specifier: 5.1.0
version: 5.1.0(@types/[email protected])(@vitest/[email protected])([email protected])([email protected].7(@types/[email protected])([email protected])([email protected]))
version: 5.1.0(@types/[email protected])(@vitest/[email protected])([email protected])([email protected].6(@types/[email protected])([email protected])([email protected]))
webpack-stats-plugin:
specifier: 1.1.3
version: 1.1.3
@@ -2021,32 +2021,32 @@ packages:
'@formatjs/[email protected]':
resolution: {integrity: sha512-AfiMi5NOSo2TQImsYAg8UYddsNJ/vUEv/HaNqiFjnI3ZFfWihUtD5QtuX6kHl8+H+d3qvnE/3HZrfzgdWpsLNA==}
'@formatjs/[email protected]3':
resolution: {integrity: sha512-iB1fYfhtSGd8uH9A8b1m01Ujcv6QtQnJasefP3jPApmz72L/zNipzf3BdoinTMd1xuviVChjUJWL60iTwjUQ+w==}
'@formatjs/[email protected]2':
resolution: {integrity: sha512-YuwN+dDKgssfuYwtOyGQD0CSn7K46g9cv1Fp0VgKpjZDDFvv8b8crzP990IcJhRPWHhKzCGsbUSJVIguyyFA5A==}
'@formatjs/[email protected]':
resolution: {integrity: sha512-i4q4V4qslThK4Ig8SxyD76cp3+QJ3sAqr7f6q9VVfeGtxG9OhiAk3y9XF6Q41OymsKzsGQ6OQQoJNY4/lI8TcQ==}
'@formatjs/[email protected]3':
resolution: {integrity: sha512-IdAJ9NrHn7AF0zqncD9UpxQozTYyJtbwwrZnJMEKVxTcOOXtVkUb2XYTpNOGTAv58NCsk0rjRB9G+i2SvBmGAQ==}
'@formatjs/[email protected]2':
resolution: {integrity: sha512-ca7tZMLpfHX3sUD7hP6gE/qr6Iq89EDd3ZLeRhbsB7r0UD55DGJq+tmFLzrGrnx5StahUevQmQQVtbDRHsfDHA==}
'@formatjs/[email protected].3':
resolution: {integrity: sha512-LQed+WhJBlceMJ4Zbe7dDe7Wn15le9t5HXfOFGdJYM/MGDyn56LTHlSzPzFjsJA0rvyp4FjN28jRQiMwtsji6A==}
'@formatjs/[email protected].2':
resolution: {integrity: sha512-isKDo8jeQ8VoYvrweku92ajF/Z9fJ76DDnw2eCmKBTJTwZa5GeGl4u40RJiFYPbR6ROluvN0CsbNtGtnd2NyIQ==}
'@formatjs/[email protected].2':
resolution: {integrity: sha512-9gayLdxgPhzw2UT2nbWBhrRN+7T2xy/cvvrEVFClRLzg1DSJJdXtdYRcbbQ8cdCRlC1O3dQag+bUeW+Kt9bRWA==}
'@formatjs/[email protected].1':
resolution: {integrity: sha512-8RTQvKIGx+SAqI+bvVrrupwzeEZGGzdzJwVbZaK9U5VKuVo34LOFOkn7GX9KfwHuVIKxM7pKv8yYTs6UIkeyTA==}
'@formatjs/[email protected].4':
resolution: {integrity: sha512-EjUHL8isAQOqXuLxGllgsfIQdLrLNo8iCOQHMqUNY4Fvl52hw6TEP0n9tPnOmQWb5wTUa92NeqyGmwhjQ2lvHA==}
'@formatjs/[email protected].3':
resolution: {integrity: sha512-cpyMSdAZxRXVmA0TjZZn38ERjfxV8Kc1nDcp1RBAXyU6pB7Mgox+o3dVUnPLsNfblW5OAr1o281IyPRrod/T6g==}
'@formatjs/[email protected].1':
resolution: {integrity: sha512-GkXdVwb/4Y9qJaZ19BguPv2i9Vr+z5MrlmFa/9HR7WK2tMcCWZathuGhn7W/V3sFqUdAVB3uvmGuOxXwc61DJQ==}
'@formatjs/[email protected].0':
resolution: {integrity: sha512-ndj9jw/LHAftSe34D/A6+lj3Y7GHVfPEZ6FZP2wjd8/beYeh3d1sjlSpZSBlzegSKS3U3mUEIzLCpI0+jKNT6w==}
'@formatjs/[email protected].2':
resolution: {integrity: sha512-Qfsm6eyPyD6y7AgRyiOTJVaq0IBClDXQCm0/6vT3CRiwn89npdoUv3kTuwDykGDs1igLoTPWLBdMR81HIP4qQg==}
'@formatjs/[email protected].1':
resolution: {integrity: sha512-V7kMddXDOLeyXAVCBEp8eBnllmPMBqu39U1GO/82xzlaUyK/Gkc3Qgal+9HJx6n1xfCvUn7XHK5t5dSlF7Y2lA==}
'@formatjs/[email protected].3':
resolution: {integrity: sha512-YdxSbfDifRIew7mukcwITPlhkomfHCcSzzbjEJqOGbod4wrfdUN7SmiZQU2Lr8zs/q/15ntZsthJ8NsW3P30mA==}
'@formatjs/[email protected].2':
resolution: {integrity: sha512-2upVZtpzktEkLMffAk14T2HB62B7ytqrlppZuVX4StnbOHNc4qx5ovimMMMn8mkqvAwFlPX+UZygetny+quqIQ==}
'@formatjs/[email protected]':
resolution: {integrity: sha512-gBqglQK9rXuHsLmM8wzTMBy4Xo4d0jamirIVKuEL8F1rwbskWdpMA1kZarSkny+uvr5q/K6GSzE0Rcq1wZLl3g==}
@@ -2054,17 +2054,17 @@ packages:
'@formatjs/[email protected]':
resolution: {integrity: sha512-ePEgLgVCqi2BBFnTMWPfIghu6FkbZnnBVhO2sSxvLfrdFw7wCHAHiDoM2h4NRgjbaY7+B7HgOLZGkK187pZTZg==}
'@formatjs/[email protected].3':
resolution: {integrity: sha512-Hi/3S+Iru5RIYNkiTJwqCmERsNwNacu3k+anfCcp7Nzn9hxhCpAuhjr6I9Y6CVUs/1D3fGSgfnJTXGukot5aBg==}
'@formatjs/[email protected].2':
resolution: {integrity: sha512-iLS3ly1lGZ/a/IVpcSUgC37RjQUZ2wN6zR9+Zbr2uXsxATfMLD+fBqggiXuFudLmZXpbPueCs4Mz3vDsaOVE9A==}
'@formatjs/[email protected].3':
resolution: {integrity: sha512-moK0Ee0ddD8d8tZnoZ1JDUdNLBURXT5NMG4cnvYQY2bTYLphPhZk2KxgD78y6+lL69J4ihpQJleI+K5KlE39gw==}
'@formatjs/[email protected].2':
resolution: {integrity: sha512-PJ4+ldlqXlo3csmP02u2HqyXw09TDB/fatYpDCyWryfEQeVWl2EbMzij9SBksPaW2U//+q69lXR3IMnCRQAmrw==}
'@formatjs/[email protected].2':
resolution: {integrity: sha512-g7AVCP/0r49+h4R1qnQcNpq78JoEIthwp+QtHv9VkHw1c0bEegmhuz1t03DEr2u5nqP4HE//yAFjQtrv66b67A==}
'@formatjs/[email protected].1':
resolution: {integrity: sha512-Gl5dCHb7elEC19tTzxIyllWLHaHnN+HpQYEaA9xxAt9rKgRLwC3vGty1w8bVGG7p2YcGSPIg5c4qn4KdkGcTqg==}
'@formatjs/[email protected].1':
resolution: {integrity: sha512-+9TU+8tqsUqobFzQJEvfQ8Yukt1PYgL5WxYi/yW+hWVNx422wEo/TlVRLvIfdYqlVS048jfyu8piNagfhOV+2A==}
'@formatjs/[email protected].0':
resolution: {integrity: sha512-9rG37qcIBFyX+HSyPelJKpAatFaO+ElvnWYO/FFMERVZG9e9Wj51CWAvF7+ozYd7B1uKBL2ub6aLzrkWA0UBxA==}
'@formatjs/[email protected]':
resolution: {integrity: sha512-tDkXnA4qpIFcDWac8CyVJq6oW8DR7W44QDUBsfXWIIJD/FYYen0QoH46W7XsVMFfPOVKkvbufjboZrrWbEfmww==}
@@ -2694,98 +2694,98 @@ packages:
'@codemirror/state': ^6.0.0
'@codemirror/view': ^6.0.0
'@rolldown/[email protected]8':
resolution: {integrity: sha512-ubTG+4KlidvioxjOFdsdEa2F6JVGZb8m2ByJUqQ7fYzUeT1cEn194POcsQ10PKH4p//q0YQn4SB3YpSuzcA1Yg==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [android]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-2Xa1t/JeFGTZn5TbzgPppcCftF8sCVnTNvrIvoSdcZhoFzAuVy1L3xxQUQ4sfWDtwVzg1u6Yi1R3SlJugRNV2Q==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-kx5wBiMB6E7TEvpl2B9gjLU004BkvEm2Dr941BFjx/SontPwSzNuQUIoVKxHHoSjpFIfHMmcguyLOtyn0hObRg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [android]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-iUzw9HshVvrWci9gVXjxWS7/M/IcLvNo67vu2c/w9zKBz4hIvPRixdUpIW/iCfhldLaq9ER2hecsI9UY5z0/yA==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-qslZrXnKJU4cUpjoAmtAo/KQM9e2IRMlmpig6Zpwj+8KWxW8v+nkAf9216Bsek9lOC1jvg2yCjygCFo2f83msQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [darwin]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-XuDHFzbFEtZl0QGJi92+fmG67tfnp1iZ9VOeDkwasGyTq2VG3/5PnJnvAr+MTzFh/rNScJ3VhN+XpZyyGsN7Jw==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-FdF+y48ND13eAyM2mQn+85kvAqNlvRWROy2rhgA463X/0Gv4vGtazZtfaF1mRBLscYvtOlh4QnLjOWiFzX69OQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [darwin]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-MM8opLfsLK15oEXDz6iBc0t3ahu+ew9jsAmha+ovZ33hSwYgqo7YmpRITqFTfW7xA71BLEQ3jJdTsaCmhB1c9w==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-ddjqFM5e95AgLbUPtKIS7V1KTVlA0RUgCVr5mn+/IEhsdy3pr+Vuj/HZ7nlMN2FyxIwUktOH1LEPIQXO1v9y1Q==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [freebsd]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-J6EoCWiy5RnFQzHrKyHXXevZ9lukQfGpnchX/zG/k/WC2nc9O9XyS1JgA8kI9VxMFggMbCPjpv7LcikriXfehw==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-tHdKWbFkFBI687iim3LIyIvyL7j66VvQYkDPss5Stn/qyE2tWkR1YD0dXmXPFKKqT/o5ZEJVsaRsWS2meQwGOA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-HIkFuLF7CdDeki+1aCZLLbLq0hk/PHntb+z4/YCTo47JbksTD6jJEELIz92tYROmDmvMrNqUMqBi71BkJLDR+A==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-FJiLGAblPBMlBEdbOqw6kW6QcXDWAf/oJu7gYs9ZJZwmg+K+/zjFLxPTIY9izJUzxzc24FHvmseyA0IvJSl17w==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-4oqWItLLYt7IceOnElCct8T2ek5p7PmD7LN04TRJRXGo5f3HtKTgGH6PhYRFK4C2ICkq/LMUU0BVPvvlAKhm8g==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-hrJpblMsrQ58U9veWpbXzkhV5zStunds6HWLprqq1qauvgBr1E6P+24kLj6lSLI9vjRn/RYpjprhkHQPKGWpNg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-+AkRly5SrCEgnPhGRfub7pucASYEC2fTsxZg7VCcnozpA2+Wn/gCYy1t7LuJS67/xyJu/7noYBJncDUkbwgw2A==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-qJd/dC6j6CwLG9/s/RP2nb1RZ0GIgj7Ioj7x/SYa3RzjVrlzrmH0fhIOpfvqQDeIsdP0loi+kHaMhJzY1PBIaA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-Ttg1r9vVykMnQrE/GwYO9icKtXiuiMfRe/w74xJkeoVuvhRG+WtT6LEMOf58Yl63yd77lhHzO8Y55R8CC3XALA==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-Vx7Xg5uUJuNcujJjI70OICaH0EYj80BtOLZTSN7uOYg8QOLlyKnaG0IW7Fn/J0IpJsaKzmDKMhOQv1JBM9m9vg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-xX1Tt4o5jUMma0vJsXp5eRZA9nOuyigb2dKJMMzZRmzMxLYGE9PaKKSqHPzPvSQgM8ZOEacSTQwDQcwWfh0xmQ==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-TNKhgE3uJTsTzatUSSYt0Kgo+Oa2uSlSjz4r1aEIea7HX6ULBym4fAlYUhG1i6pjNf2njfCUAfKwr6C3E9Xg1w==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-4VVlGI5K2kociZlW3lSN8VjG3TW5yQIlAcfCdBXMgGjJxZll15Fa4ocRHXHvIVVnwlibCw/NQajJrNDiqqpiiw==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-7chXdpjXZ8qG0+mIxECN3cT9kvhZ3/oZhMX6Pp876P7CDrIy8nJswva6Mq357JR7eYXfuskwZxMeV1SzoZdHrA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [musl]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-PApTsgH1jLYuyy3tSCz9De82Gq5qXwi7vImVZhEzTgX1C4150Cp5M2ZfL3pLvbCvbEHL0oJeC6pd6podtv8Y5w==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-Kwjt+7uNTJK5/MDkGWGVO2KQPnj8yAV75dMpfwyHZrJSXWHrniOB0aUEWlVYf3H1hOqFLIStLdM5QXq6bnKmOQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [openharmony]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-J2XjWjx/SP+4x0H4r6dz3Vzb5WVkg7re40Do9K7HJ3sK2/xcmZrWwakXlSwaMvOkvruLJCD4CL/3wqsIR/thgg==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-/LH6WfjDRXXJz/p5xl4TmU+jpcnwcxbKEQBW/GZE0JHfN0lGIyTtsUEGaQ/q/GikkGJ2yLKe6pwm7AnEWO8pdw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [win32]
'@rolldown/[email protected]8':
resolution: {integrity: sha512-XwRJxRQvkuEtS0hIIt29QrqPJ+JzMJSNYHJw4ae/mc6uEarfRG1ceyg4HmmWiBdL/YCb6g7N5BLbSvmRJRYZHw==}
'@rolldown/[email protected]6':
resolution: {integrity: sha512-1lv1KvX0Z871zfk7vw+dnXMMnHNyDwMzWG8Kv3HxDXMOhzCX4SHc7HK319fInP0i+0p9D8brkfzL7pJOaGl+tw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [win32]
@@ -4994,8 +4994,8 @@ packages:
eslint-plugin-import: '>=1.4.0'
webpack: '>=1.11.0'
[email protected].1:
resolution: {integrity: sha512-D1h++38NS2Z40zf8jbd2OHqDrnIFRKpdp8sL0jP4xSDGZj6MNwEQua8F+r3tOWjcHrsWuhHOJ7wASWioJ31tfg==}
[email protected].0:
resolution: {integrity: sha512-UfxHFmV+f9vwybrNn6LQ1rPzfeDMPGi/dRbqQnCFO/jBzYrujSOyX7jxqBSYr/HwXs/V4XJdEGPvC3Re46nzKg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
'@typescript-eslint/utils': ^8.56.0
@@ -5602,8 +5602,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-UmdmHUmp5CIKKjSoE10la5yfU+AYJAaiYLsodbjL4lji83JNvgOQUjGaGhGrpFCb0Uh7sl7qfP1IyILa8Z40ug==}
[email protected].5:
resolution: {integrity: sha512-quhcDFAxy4wr/GrgWgmMjuegoedNUIxGNLORfXgDgdjuv8cBM88ClLTLXmfYC1roMSR1PPc55yUEkpJ5m67W2g==}
[email protected].4:
resolution: {integrity: sha512-JUkmv3cAEyijN3oiRiV3ctel7yVMuUCgfh7Pu8pj1/z6L1DSEPRyhuMaLjVw3pGmGJ5RDH54WVFxfMHZWTwyHw==}
[email protected]:
resolution: {integrity: sha512-7H/2gFSIitxc0hG3nOI1glS8QLo/EHBFFLk8vEUjXY/xu0AdL8jZ9U1IzO2PUm0d2D/ofQcAifb0g6OBkt8U7w==}
@@ -6945,8 +6945,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-OlwfYEgA2RdboZohpldlvJ1xngOins5d7ejqnIBWr9KaMxsnBqotpptRXTyfNRLnFpqzX6sTDt+X+a+6udnU8g==}
[email protected]8:
resolution: {integrity: sha512-C1uuT3UR60SShuCaPQFAAZyefJCWZlAKB02BV3BuPE2Rs4fevRQltEKoFO2tV5W9/eJhU5RieV6vJj3euulfNQ==}
[email protected]6:
resolution: {integrity: sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
@@ -7754,8 +7754,8 @@ packages:
peerDependencies:
vite: '*'
[email protected].7:
resolution: {integrity: sha512-oxh0dMxrayBr33ScJvvBJ2HBQ2jc1TBrXKR2NyL/MJ9WPuX19mN2DXWUmywKdyw5RFVQBo8hmtb2FMC0LHrnng==}
[email protected].6:
resolution: {integrity: sha512-UI7dK29NnS54Fk+mmo7o+jI6U8Fp7hDl+X5Q1k45WH+d4dSlbLVUETGQ+hfkNgvLQGyoElPj837nZyv4MBc0VA==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
peerDependencies:
@@ -9781,41 +9781,41 @@ snapshots:
'@formatjs/icu-skeleton-parser': 1.8.14
tslib: 2.9.1
'@formatjs/[email protected]3':
'@formatjs/[email protected]2':
dependencies:
'@formatjs/icu-skeleton-parser': 2.1.13
'@formatjs/icu-skeleton-parser': 2.1.12
'@formatjs/[email protected]':
dependencies:
'@formatjs/ecma402-abstract': 2.3.4
tslib: 2.9.1
'@formatjs/[email protected]3': {}
'@formatjs/[email protected]2': {}
'@formatjs/[email protected].3':
'@formatjs/[email protected].2':
dependencies:
'@formatjs/bigdecimal': 0.2.10
'@formatjs/intl-localematcher': 0.10.1
'@formatjs/[email protected].2':
'@formatjs/[email protected].1':
dependencies:
'@formatjs/intl-localematcher': 0.10.1
'@formatjs/[email protected].4':
'@formatjs/[email protected].3':
dependencies:
'@formatjs/bigdecimal': 0.2.10
'@formatjs/intl-localematcher': 0.10.1
'@formatjs/[email protected].1': {}
'@formatjs/[email protected].0': {}
'@formatjs/[email protected].2':
'@formatjs/[email protected].1':
dependencies:
'@formatjs/intl-localematcher': 0.10.1
'@formatjs/[email protected].3':
'@formatjs/[email protected].2':
dependencies:
'@formatjs/intl-getcanonicallocales': 3.3.1
'@formatjs/intl-supportedvaluesof': 3.0.1
'@formatjs/intl-getcanonicallocales': 3.3.0
'@formatjs/intl-supportedvaluesof': 3.0.0
'@formatjs/[email protected]':
dependencies:
@@ -9825,21 +9825,21 @@ snapshots:
dependencies:
tslib: 2.9.1
'@formatjs/[email protected].3':
'@formatjs/[email protected].2':
dependencies:
'@formatjs/bigdecimal': 0.2.10
'@formatjs/intl-localematcher': 0.10.1
'@formatjs/[email protected].3':
'@formatjs/[email protected].2':
dependencies:
'@formatjs/bigdecimal': 0.2.10
'@formatjs/intl-localematcher': 0.10.1
'@formatjs/[email protected].2':
'@formatjs/[email protected].1':
dependencies:
'@formatjs/intl-localematcher': 0.10.1
'@formatjs/[email protected].1':
'@formatjs/[email protected].0':
dependencies:
'@formatjs/fast-memoize': 3.1.7
@@ -10658,49 +10658,49 @@ snapshots:
'@codemirror/state': 6.7.6
'@codemirror/view': 6.43.15
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]8':
'@rolldown/[email protected]6':
optional: true
'@rolldown/[email protected]': {}
@@ -11697,7 +11697,7 @@ snapshots:
obug: 3.0.0
std-env: 4.3.0
tinyrainbow: 3.2.0
vitest: 5.1.0(@types/[email protected])(@vitest/[email protected])([email protected])([email protected].7(@types/[email protected])([email protected])([email protected]))
vitest: 5.1.0(@types/[email protected])(@vitest/[email protected])([email protected])([email protected].6(@types/[email protected])([email protected])([email protected]))
'@vitest/[email protected]': {}
@@ -11705,14 +11705,14 @@ snapshots:
dependencies:
'@vitest/istanbul-lib-coverage': 2.1.0
'@vitest/[email protected]([email protected].7(@types/[email protected])([email protected])([email protected]))':
'@vitest/[email protected]([email protected].6(@types/[email protected])([email protected])([email protected]))':
dependencies:
'@jridgewell/trace-mapping': 0.3.31
'@vitest/spy': 5.1.0
estree-walker: 3.0.3
magic-string: 1.4.3
optionalDependencies:
vite: 8.3.7(@types/[email protected])([email protected])([email protected])
vite: 8.3.6(@types/[email protected])([email protected])([email protected])
'@vitest/[email protected]': {}
@@ -12823,7 +12823,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
[email protected].1(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected])([email protected]))([email protected]([email protected]))([email protected]):
[email protected].0(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected])([email protected]))([email protected]([email protected]))([email protected]):
dependencies:
'@typescript-eslint/types': 8.72.1
cjs-module-lexer: 2.3.0
@@ -13543,10 +13543,10 @@ snapshots:
'@formatjs/icu-messageformat-parser': 2.11.2
tslib: 2.9.1
[email protected].5:
[email protected].4:
dependencies:
'@formatjs/fast-memoize': 3.1.7
'@formatjs/icu-messageformat-parser': 3.5.23
'@formatjs/icu-messageformat-parser': 3.5.22
[email protected]: {}
@@ -14942,26 +14942,26 @@ snapshots:
[email protected]: {}
[email protected]8:
[email protected]6:
dependencies:
'@oxc-project/types': 0.156.0
'@rolldown/pluginutils': 1.0.1
optionalDependencies:
'@rolldown/binding-android-arm-eabi': 1.2.18
'@rolldown/binding-android-arm64': 1.2.18
'@rolldown/binding-darwin-arm64': 1.2.18
'@rolldown/binding-darwin-x64': 1.2.18
'@rolldown/binding-freebsd-x64': 1.2.18
'@rolldown/binding-linux-arm-gnueabihf': 1.2.18
'@rolldown/binding-linux-arm64-gnu': 1.2.18
'@rolldown/binding-linux-arm64-musl': 1.2.18
'@rolldown/binding-linux-ppc64-gnu': 1.2.18
'@rolldown/binding-linux-s390x-gnu': 1.2.18
'@rolldown/binding-linux-x64-gnu': 1.2.18
'@rolldown/binding-linux-x64-musl': 1.2.18
'@rolldown/binding-openharmony-arm64': 1.2.18
'@rolldown/binding-win32-arm64-msvc': 1.2.18
'@rolldown/binding-win32-x64-msvc': 1.2.18
'@rolldown/binding-android-arm-eabi': 1.2.16
'@rolldown/binding-android-arm64': 1.2.16
'@rolldown/binding-darwin-arm64': 1.2.16
'@rolldown/binding-darwin-x64': 1.2.16
'@rolldown/binding-freebsd-x64': 1.2.16
'@rolldown/binding-linux-arm-gnueabihf': 1.2.16
'@rolldown/binding-linux-arm64-gnu': 1.2.16
'@rolldown/binding-linux-arm64-musl': 1.2.16
'@rolldown/binding-linux-ppc64-gnu': 1.2.16
'@rolldown/binding-linux-s390x-gnu': 1.2.16
'@rolldown/binding-linux-x64-gnu': 1.2.16
'@rolldown/binding-linux-x64-musl': 1.2.16
'@rolldown/binding-openharmony-arm64': 1.2.16
'@rolldown/binding-win32-arm64-msvc': 1.2.16
'@rolldown/binding-win32-x64-msvc': 1.2.16
[email protected]:
dependencies:
@@ -15909,22 +15909,22 @@ snapshots:
- bare-abort-controller
- react-native-b4a
[email protected]([email protected])([email protected])([email protected].7(@types/[email protected])([email protected])([email protected])):
[email protected]([email protected])([email protected])([email protected].6(@types/[email protected])([email protected])([email protected])):
dependencies:
debug: 4.4.3([email protected])
globrex: 0.1.2
tsconfck: 3.1.6([email protected])
vite: 8.3.7(@types/[email protected])([email protected])([email protected])
vite: 8.3.6(@types/[email protected])([email protected])([email protected])
transitivePeerDependencies:
- supports-color
- typescript
[email protected].7(@types/[email protected])([email protected])([email protected]):
[email protected].6(@types/[email protected])([email protected])([email protected]):
dependencies:
lightningcss: 1.33.0
picomatch: 4.0.7
postcss: 8.5.32
rolldown: 1.2.18
rolldown: 1.2.16
tinyglobby: 0.2.17
optionalDependencies:
'@types/node': 24.19.2
@@ -15932,10 +15932,10 @@ snapshots:
terser: 5.50.0
yaml: 2.9.1
[email protected](@types/[email protected])(@vitest/[email protected])([email protected])([email protected].7(@types/[email protected])([email protected])([email protected])):
[email protected](@types/[email protected])(@vitest/[email protected])([email protected])([email protected].6(@types/[email protected])([email protected])([email protected])):
dependencies:
'@types/chai': 5.2.3
'@vitest/mocker': 5.1.0([email protected].7(@types/[email protected])([email protected])([email protected]))
'@vitest/mocker': 5.1.0([email protected].6(@types/[email protected])([email protected])([email protected]))
chai: 6.3.0
es-module-lexer: 2.3.2
expect-type: 1.4.0
@@ -15946,7 +15946,7 @@ snapshots:
tinybench: 6.2.2
tinyexec: 1.3.1
tinyglobby: 0.2.17
vite: 8.3.7(@types/[email protected])([email protected])([email protected])
vite: 8.3.6(@types/[email protected])([email protected])([email protected])
why-is-node-running: 3.2.1
optionalDependencies:
'@types/node': 24.19.2
+4 -189
View File
@@ -7,10 +7,7 @@ import {
mdiRestart,
} from "@mdi/js";
import { differenceInMinutes } from "date-fns";
import type {
DataZoomComponentOption,
MarkAreaComponentOption,
} from "echarts/components";
import type { DataZoomComponentOption } from "echarts/components";
import type { EChartsType } from "echarts/core";
import type {
ECElementEvent,
@@ -93,29 +90,14 @@ export const DEFAULT_CHART_WIDTH = 500;
// is short enough for a whole screenful; on a desktop that would cover the page.
const VISIBILITY_ROOT_MARGIN_NARROW = "100%";
const VISIBILITY_ROOT_MARGIN = "300px";
const CLICK_DRAG_TOLERANCE = 4;
// The selection is shown by the mask, not by the brush
const BRUSH_STYLE = {
color: "rgba(0, 0, 0, 0)",
borderColor: "rgba(0, 0, 0, 0)",
};
export type ZoomSliderMode = "auto" | "always" | "never";
export type ChartSelectMode = "none" | "point" | "range";
const DEFERRED_PROPS = [
"options",
"data",
"_hiddenDatasets",
"_isZoomed",
"highlight",
] as const;
const MASK_OPACITY = 0.7;
export interface ChartTimeRange {
start: number;
end: number;
}
type RawSeriesOption = Exclude<
NonNullable<ECOption["series"]>,
@@ -194,18 +176,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
@property({ attribute: "grow-for-zoom-slider", type: Boolean })
public growForZoomSlider = false;
// "point" selects on click, "range" also selects on drag instead of zooming
@property({ attribute: "select-mode" })
public selectMode: ChartSelectMode = "none";
// Everything outside this time range fades
@property({ attribute: false }) public highlight?: ChartTimeRange;
// Rounds a selection to the periods of the data, or drops it
@property({ attribute: false }) public snapSelection?: (
range: ChartTimeRange
) => ChartTimeRange | undefined;
// extraComponents is not reactive and should not trigger updates
public extraComponents?: any[];
@@ -231,14 +201,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
@state() private _isZoomed = false;
private _pointerDownX?: number;
private _selectingRange?: ChartTimeRange;
private _maskColor = "";
private _maskShown = false;
// Separate from _isZoomed, whose touch handling reruns graph layouts
@state() private _isGraphRoamed = false;
@@ -492,9 +454,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
if (!this.chart) {
return;
}
if (changedProps.has("selectMode")) {
this._updateSelectMode();
}
const themeChanged = changedProps.has("_themes") && this.hasUpdated;
if (!themeChanged && !DEFERRED_PROPS.some((p) => changedProps.has(p))) {
return;
@@ -540,8 +499,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
) {
this._disposeSonification();
}
} else if (changedProps.has("highlight")) {
this._updateMask();
}
if (changedProps.has("options")) {
chartOptions = { ...chartOptions, ...this._createOptions() };
@@ -931,9 +888,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
const style = getComputedStyle(this);
echarts.registerTheme("custom", this._createTheme(style));
this._maskColor =
style.getPropertyValue("--card-background-color").trim() ||
style.getPropertyValue("--primary-background-color").trim();
this.chart = echarts.init(this._chartContainer!, "custom");
this._dragToZoom = false;
@@ -1016,9 +970,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
this._legendItemCount = this._getLegendItems()?.length;
this._updateSankeyRoam();
this._updateDragToZoom();
if (this.selectMode !== "none") {
this._updateSelectMode();
}
if (zoomStart !== 0 || zoomEnd !== 100) {
this.zoom(zoomStart, zoomEnd, true);
}
@@ -1070,10 +1021,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
// A chart can switch type (e.g. pie and bar) without being rebuilt
private _updateDragToZoom() {
const active =
!this._touchInput &&
this._hasZoomableXAxis() &&
this.selectMode !== "range";
const active = !this._touchInput && this._hasZoomableXAxis();
if (!this.chart || active === this._dragToZoom) {
return;
}
@@ -1085,127 +1033,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
});
}
private _snapRange(range: ChartTimeRange) {
return this.snapSelection ? this.snapSelection(range) : range;
}
private _getMaskArea(): MarkAreaComponentOption | undefined {
const range = this._selectingRange ?? this.highlight;
if (!range) {
return undefined;
}
this._maskShown = true;
return {
silent: true,
z: 10,
itemStyle: {
color: this._maskColor,
opacity: MASK_OPACITY,
},
data: [
[{ xAxis: -Infinity }, { xAxis: range.start }],
[{ xAxis: range.end }, { xAxis: Infinity }],
],
};
}
// Only the first series carries the mask, merged in without resending data
private _updateMask() {
this.chart?.setOption({
series: [{ markArea: this._getMaskArea() ?? { data: [] } }],
});
}
private _handleSelectPointerDown = (e: ECElementEvent) => {
this._pointerDownX = e.offsetX;
};
private _handleSelectClick = (e: ECElementEvent) => {
const point = [e.offsetX, e.offsetY];
// A drag that ends on the plot is not a click
const dragged =
this._pointerDownX !== undefined &&
Math.abs(e.offsetX - this._pointerDownX) > CLICK_DRAG_TOLERANCE;
if (dragged || !this.chart?.containPixel("grid", point)) {
return;
}
const [x] = this.chart.convertFromPixel("grid", point) as number[];
const selection = this._snapRange({ start: x, end: x });
if (selection) {
fireEvent(this, "chart-select", selection);
}
};
private _handleBrush = (e: any) => {
const range = e.areas?.[0]?.coordRange as number[] | undefined;
if (range) {
this._selectingRange = this._snapRange({
start: range[0],
end: range[1],
});
this._updateMask();
}
};
private _handleBrushEnd = (e: any) => {
const range = e.areas?.[0]?.coordRange as number[] | undefined;
this.chart?.dispatchAction({ type: "brush", areas: [] });
this._selectingRange = undefined;
this._updateMask();
const selection =
range && this._snapRange({ start: range[0], end: range[1] });
if (selection) {
fireEvent(this, "chart-select", selection);
}
};
private _updateSelectMode() {
if (!this.chart) {
return;
}
const zr = this.chart.getZr();
zr.off("mousedown", this._handleSelectPointerDown);
zr.off("click", this._handleSelectClick);
this.chart.off("brush", this._handleBrush);
this.chart.off("brushEnd", this._handleBrushEnd);
if (this.selectMode !== "none") {
zr.on("mousedown", this._handleSelectPointerDown);
zr.on("click", this._handleSelectClick);
}
const selectRange = this.selectMode === "range";
if (selectRange) {
this.chart.on("brush", this._handleBrush);
this.chart.on("brushEnd", this._handleBrushEnd);
this.chart.setOption({
brush: {
xAxisIndex: 0,
// Only measures the range, the mask fades what is outside
seriesIndex: [],
transformable: false,
brushStyle: BRUSH_STYLE,
},
});
}
const brushCursor = {
type: "takeGlobalCursor",
key: "brush",
brushOption: {
brushType: selectRange ? "lineX" : false,
brushMode: "single",
brushStyle: BRUSH_STYLE,
},
};
// Brush and drag to zoom share the global cursor, the last one taken wins
if (selectRange) {
this._updateDragToZoom();
this.chart.dispatchAction(brushCursor);
} else {
this.chart.dispatchAction(brushCursor);
this._dragToZoom = false;
this._updateDragToZoom();
}
}
private _hasZoomableXAxis() {
const xAxis = ensureArray(this.options?.xAxis)?.[0] as
XAXisOption | undefined;
@@ -1648,8 +1475,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
private _getSeries() {
const xAxis = (this.options?.xAxis?.[0] ?? this.options?.xAxis) as
XAXisOption | undefined;
const maskArea = this._getMaskArea();
const series = ensureArray(this.data).map((s, index) => {
const series = ensureArray(this.data).map((s) => {
const data = this._hiddenDatasets.has(String(s.id ?? s.name))
? undefined
: s.data;
@@ -1687,16 +1513,6 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
} as HaECSeriesItem;
}
}
// ECharts merges series by id and would keep a mask left out here
if (this._maskShown && (s.type === "line" || s.type === "bar")) {
result = {
...result,
markArea:
index === 0 && maskArea
? maskArea
: ((s as LineSeriesOption).markArea ?? { data: [] }),
} as HaECSeriesItem;
}
return processSeriesTooltipFormatter(result);
});
return series as ECOption["series"];
@@ -1946,7 +1762,7 @@ export class HaChartBase extends MobileAwareMixin(LitElement) {
// it, so a quick drag out would lose the release and its selection
if (
ev.type === "pointerdown" &&
(this._dragToZoom || this.selectMode === "range") &&
this._dragToZoom &&
this._isZoomPress(ev)
) {
this.chart
@@ -2521,7 +2337,6 @@ declare global {
"dataset-hidden": { id: string };
"dataset-unhidden": { id: string };
"chart-click": ECElementEvent;
"chart-select": ChartTimeRange;
"legend-label-click": { id: string };
"chart-zoom": {
start: number;
+2 -50
View File
@@ -5,7 +5,7 @@ import type {
import type { HassConfig, HassEntities } from "home-assistant-js-websocket";
import type { PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { customElement, property, state } from "lit/decorators";
import { styleMap } from "lit/directives/style-map";
import memoizeOne from "memoize-one";
import { isComponentLoaded } from "../../common/config/is_component_loaded";
@@ -49,13 +49,7 @@ import type {
HomeAssistantUI,
} from "../../types";
import { getPeriodicAxisLabelConfig } from "./axis-label";
import type {
ChartSelectMode,
ChartTimeRange,
CustomLegendOption,
HaChartBase,
ZoomSliderMode,
} from "./ha-chart-base";
import type { CustomLegendOption } from "./ha-chart-base";
import "./ha-chart-base";
import { sideTooltipPosition } from "./chart-tooltip-position";
import "./ha-chart-tooltip-marker";
@@ -134,16 +128,6 @@ export class StatisticsChart extends LitElement {
@property({ attribute: "expand-legend", type: Boolean })
public expandLegend?: boolean;
@property({ attribute: "select-mode" })
public selectMode: ChartSelectMode = "none";
@property({ attribute: "zoom-slider" })
public zoomSlider: ZoomSliderMode = "auto";
@property({ attribute: false }) public highlight?: ChartTimeRange;
@query("ha-chart-base") private _chartBase?: HaChartBase;
@state() private _chartData: (LineSeriesOption | BarSeriesOption)[] = [];
@state() private _legendData: CustomLegendOption["data"];
@@ -260,12 +244,8 @@ export class StatisticsChart extends LitElement {
return html`
<ha-chart-base
.data=${this._chartData}
.highlight=${this.highlight}
.snapSelection=${this._snapSelection}
.options=${this._chartOptions}
.height=${this.height}
.selectMode=${this.selectMode}
.zoomSlider=${this.zoomSlider}
style=${styleMap({ height: this.height })}
@dataset-hidden=${this._datasetHidden}
@dataset-unhidden=${this._datasetUnhidden}
@@ -279,34 +259,6 @@ export class StatisticsChart extends LitElement {
`;
}
public resetZoom() {
this._chartBase?.zoom(0, 100);
}
// A click selects the period that contains it, a drag every period it
// touches
private _snapSelection = (
range: ChartTimeRange
): ChartTimeRange | undefined => {
let start: number | undefined;
let end: number | undefined;
Object.values(this.statisticsData ?? {}).forEach((values) =>
values.forEach((value) => {
const touched =
range.start === range.end
? value.start <= range.start && range.start < value.end
: value.start < range.end && value.end > range.start;
if (touched) {
start = Math.min(start ?? value.start, value.start);
end = Math.max(end ?? value.end, value.end);
}
})
);
return start === undefined || end === undefined
? undefined
: { start, end };
};
private _datasetHidden(ev: HASSDomEvent<HASSDomEvents["dataset-hidden"]>) {
this._hiddenStats.add(ev.detail.id);
this.requestUpdate("_hiddenStats");
+94 -55
View File
@@ -6,7 +6,7 @@ import { repeat } from "lit/directives/repeat";
import { styleMap } from "lit/directives/style-map";
import memoizeOne from "memoize-one";
import { consume } from "../common/decorators/consume";
import { fireEvent, type HASSDomEvent } from "../common/dom/fire_event";
import { fireEvent } from "../common/dom/fire_event";
import { supportsFeature } from "../common/entity/supports-feature";
import {
CameraEntityFeature,
@@ -17,14 +17,8 @@ import {
STREAM_TYPE_WEB_RTC,
type CameraCapabilities,
type CameraEntity,
type StreamType,
} from "../data/camera";
import {
MJPEG_STREAM,
selectCameraStreams,
type CameraStream,
type CameraStreamTracks,
type CameraStreamType,
} from "../data/camera-streams";
import {
apiContext,
configContext,
@@ -35,7 +29,14 @@ import "./ha-hls-player";
import "./ha-web-rtc-player";
import type { HaWebRtcPlayer } from "./ha-web-rtc-player";
export type { CameraStreamType } from "../data/camera-streams";
const MJPEG_STREAM = "mjpeg";
export type CameraStreamType = StreamType | typeof MJPEG_STREAM;
interface Stream {
type: CameraStreamType;
visible: boolean;
}
@customElement("ha-camera-stream")
export class HaCameraStream extends LitElement {
@@ -77,15 +78,13 @@ export class HaCameraStream extends LitElement {
@state() private _capabilities?: CameraCapabilities;
@state() private _hlsStreams?: CameraStreamTracks;
@state() private _hlsStreams?: { hasAudio: boolean; hasVideo: boolean };
@state() private _webRtcStreams?: CameraStreamTracks;
@state() private _webRtcStreams?: { hasAudio: boolean; hasVideo: boolean };
@query("ha-web-rtc-player") private _webRtcPlayer?: HaWebRtcPlayer;
private _visibleStreamType?: CameraStreamType;
private _capabilitiesRequest = 0;
private _visibleStreamType?: Stream["type"];
private _thumbnailApi = memoizeOne(
(
@@ -133,10 +132,6 @@ export class HaCameraStream extends LitElement {
public connectedCallback() {
super.connectedCallback();
this._connected = true;
if (this.hasUpdated) {
// The players start again when reattached, so their results do as well
this._resetStreams();
}
}
public disconnectedCallback() {
@@ -151,8 +146,9 @@ export class HaCameraStream extends LitElement {
capabilities: this._capabilities,
});
}
const streams = this._currentStreams();
const visibleStreamType = streams.find((stream) => stream.visible)?.type;
const visibleStreamType = this._currentStreams().find(
(stream) => stream.visible
)?.type;
if (visibleStreamType !== this._visibleStreamType) {
this._visibleStreamType = visibleStreamType;
fireEvent(this, "stream-type-changed", { type: visibleStreamType });
@@ -171,7 +167,7 @@ export class HaCameraStream extends LitElement {
)}`;
}
private _renderStream(stream: CameraStream) {
private _renderStream(stream: Stream) {
if (!this.stateObj) {
return nothing;
}
@@ -233,14 +229,15 @@ export class HaCameraStream extends LitElement {
return this._streams(
this._capabilities?.frontend_stream_types,
this._hlsStreams,
this._webRtcStreams
this._webRtcStreams,
this.muted
);
}
private async _getCapabilities() {
this._capabilities = undefined;
this._resetStreams();
const request = ++this._capabilitiesRequest;
this._hlsStreams = undefined;
this._webRtcStreams = undefined;
if (!supportsFeature(this.stateObj!, CameraEntityFeature.STREAM)) {
this._capabilities = {
frontend_stream_types: [],
@@ -248,19 +245,10 @@ export class HaCameraStream extends LitElement {
};
return;
}
const capabilities = await fetchCameraCapabilities(
this._capabilities = await fetchCameraCapabilities(
this._api,
this.stateObj!.entity_id
);
if (request !== this._capabilitiesRequest) {
return;
}
this._capabilities = capabilities;
}
private _resetStreams() {
this._hlsStreams = undefined;
this._webRtcStreams = undefined;
}
private async _getPosterUrl(): Promise<void> {
@@ -281,38 +269,89 @@ export class HaCameraStream extends LitElement {
fireEvent(this, "load");
}
private _handleHlsStreams(ev: HASSDomEvent<HASSDomEvents["streams"]>) {
private _handleHlsStreams(ev: CustomEvent) {
this._hlsStreams = ev.detail;
}
private _handleWebRtcStreams(ev: HASSDomEvent<HASSDomEvents["streams"]>) {
if (
!ev.detail.hasVideo &&
!ev.detail.hasAudio &&
this._capabilities?.frontend_stream_types.length === 1 &&
typeof RTCPeerConnection !== "undefined"
) {
// Without another stream type, keep the player to show why it failed.
// Only a browser without WebRTC falls back to MJPEG.
return;
}
private _handleWebRtcStreams(ev: CustomEvent) {
this._webRtcStreams = ev.detail;
}
private _streams = memoizeOne(
(
supportedTypes?: CameraCapabilities["frontend_stream_types"],
hlsStreams?: CameraStreamTracks,
webRtcStreams?: CameraStreamTracks
): CameraStream[] => {
supportedTypes?: StreamType[],
hlsStreams?: { hasAudio: boolean; hasVideo: boolean },
webRtcStreams?: { hasAudio: boolean; hasVideo: boolean },
muted?: boolean
): Stream[] => {
if (__DEMO__) {
return [{ type: MJPEG_STREAM, visible: true }];
}
return selectCameraStreams({
supportedTypes,
hlsStreams,
webRtcStreams,
});
if (!supportedTypes) {
return [];
}
if (supportedTypes.length === 0) {
// doesn't support any stream type, fallback to mjpeg
return [{ type: MJPEG_STREAM, visible: true }];
}
if (supportedTypes.length === 1) {
// only 1 stream type, no need to choose
if (
(supportedTypes[0] === STREAM_TYPE_HLS &&
hlsStreams?.hasVideo === false) ||
(supportedTypes[0] === STREAM_TYPE_WEB_RTC &&
webRtcStreams?.hasVideo === false)
) {
// stream failed to load, fallback to mjpeg
return [{ type: MJPEG_STREAM, visible: true }];
}
return [{ type: supportedTypes[0], visible: true }];
}
if (hlsStreams && webRtcStreams) {
// fully loaded
if (
hlsStreams.hasVideo &&
hlsStreams.hasAudio &&
!webRtcStreams.hasAudio &&
!muted
) {
// webRTC stream is missing audio and audio is not muted, use HLS
return [{ type: STREAM_TYPE_HLS, visible: true }];
}
if (webRtcStreams.hasVideo) {
return [{ type: STREAM_TYPE_WEB_RTC, visible: true }];
}
// both streams failed to load, fallback to mjpeg
return [{ type: MJPEG_STREAM, visible: true }];
}
if (hlsStreams?.hasVideo !== webRtcStreams?.hasVideo) {
// one of the two streams is loaded, or errored
// choose the one that has video or is still loading
if (hlsStreams?.hasVideo) {
return [
{ type: STREAM_TYPE_HLS, visible: true },
{ type: STREAM_TYPE_WEB_RTC, visible: false },
];
}
if (hlsStreams?.hasVideo === false) {
return [{ type: STREAM_TYPE_WEB_RTC, visible: true }];
}
if (webRtcStreams?.hasVideo) {
return [
{ type: STREAM_TYPE_WEB_RTC, visible: true },
{ type: STREAM_TYPE_HLS, visible: false },
];
}
if (webRtcStreams?.hasVideo === false) {
return [{ type: STREAM_TYPE_HLS, visible: true }];
}
}
return [
{ type: STREAM_TYPE_HLS, visible: true },
{ type: STREAM_TYPE_WEB_RTC, visible: false },
];
}
);
-4
View File
@@ -112,9 +112,6 @@ export class HaGenericPicker extends PickerMixin(LitElement) {
@property({ type: Boolean, attribute: "no-sort" }) public noSort = false;
@property({ attribute: "pin-block" })
public pinBlock?: "start" | "center" | "end" | "nearest";
// Skip the "unknown value" highlight and note for a value that is not in the
// list but that the value renderer presents on its own.
@property({ type: Boolean, attribute: "no-unknown-state" })
@@ -350,7 +347,6 @@ export class HaGenericPicker extends PickerMixin(LitElement) {
.searchKeys=${this.searchKeys}
.customValueLabel=${this.customValueLabel}
.noSort=${this.noSort}
.pinBlock=${this.pinBlock}
></ha-picker-combo-box>
`;
}
+2 -7
View File
@@ -180,14 +180,13 @@ class HaHLSPlayer extends LitElement {
return;
}
const entityId = this.entityid;
if (!entityId) {
if (!this.entityid) {
return;
}
try {
const { url } = await fetchStreamUrl(
{ callWS: this._api.callWS, hassUrl: this._connection.hassUrl },
entityId
this.entityid
);
this._url = this._connection.hassUrl(url);
@@ -199,10 +198,6 @@ class HaHLSPlayer extends LitElement {
// eslint-disable-next-line
console.error(err);
if (!this.isConnected || entityId !== this.entityid) {
// Removed or switched camera while fetching, the result is outdated
return;
}
fireEvent(this, "streams", { hasAudio: false, hasVideo: false });
}
}
+17 -61
View File
@@ -1,17 +1,13 @@
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
import type { PropertyValues, TemplateResult } from "lit";
import type { TemplateResult } from "lit";
import { LitElement, css, html } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { consumeLocalize } from "../common/decorators/consume-context-entry";
import { fireEvent } from "../common/dom/fire_event";
import { caseInsensitiveStringCompare } from "../common/string/compare";
import type { LocalizeFunc } from "../common/translations/localize";
import { customIcons } from "../data/custom_icons";
import type { ValueChangedEvent } from "../types";
import "./ha-combo-box-item";
import "./ha-generic-picker";
import type { HaGenericPicker } from "./ha-generic-picker";
import "./ha-icon";
import type { PickerComboBoxItem } from "./ha-picker-combo-box";
@@ -54,17 +50,16 @@ const createIconItem = (icon: IconData, prefix: string): PickerComboBoxItem => {
const loadIcons = async () => {
ICONS_LOADED = true;
const sortIcons = (icons: PickerComboBoxItem[]) =>
icons.sort((a, b) => caseInsensitiveStringCompare(a.id, b.id));
const iconList = await import("../../build/mdi/iconList.json");
const mdiIcons = iconList.default.map((icon) => createIconItem(icon, "mdi"));
ICONS = sortIcons([...mdiIcons]);
ICONS = iconList.default.map((icon) => createIconItem(icon, "mdi"));
const customIconItems = await Promise.all(
Object.keys(customIcons).map(loadCustomIconItems)
);
ICONS = sortIcons([...mdiIcons, ...customIconItems.flat()]);
const customIconLoads: Promise<PickerComboBoxItem[]>[] = [];
Object.keys(customIcons).forEach((iconSet) => {
customIconLoads.push(loadCustomIconItems(iconSet));
});
(await Promise.all(customIconLoads)).forEach((customIconItems) => {
ICONS.push(...customIconItems);
});
};
const loadCustomIconItems = async (
@@ -86,8 +81,8 @@ const loadCustomIconItems = async (
const rowRenderer: RenderItemFunction<PickerComboBoxItem> = (item) => html`
<ha-combo-box-item>
<ha-icon .icon=${item.icon ?? item.id} slot="start"></ha-icon>
${item.icon ?? item.id}
<ha-icon .icon=${item.id} slot="start"></ha-icon>
${item.id}
</ha-combo-box-item>
`;
@@ -109,32 +104,12 @@ export class HaIconPicker extends LitElement {
@property({ type: Boolean }) public invalid = false;
@property({ attribute: false }) public suggestedIcons?: string[];
@state() @consumeLocalize() private _localize!: LocalizeFunc;
@query("ha-generic-picker") private _picker?: HaGenericPicker;
private _getIconPickerItems = () =>
this._itemsWithSuggestions(ICONS, this.suggestedIcons, this._localize);
protected updated(changedProps: PropertyValues) {
super.updated(changedProps);
if (changedProps.has("suggestedIcons") || changedProps.has("_localize")) {
this._picker?.refreshItems();
}
}
private _getIconPickerItems = (): PickerComboBoxItem[] => ICONS;
protected render(): TemplateResult {
return html`
<ha-generic-picker
allow-custom-value
no-sort
.pinBlock=${
this.value && this.suggestedIcons?.includes(this.value)
? "end"
: undefined
}
.getItems=${this._getIconPickerItems}
.helper=${this.helper}
.disabled=${this.disabled}
@@ -153,35 +128,15 @@ export class HaIconPicker extends LitElement {
`;
}
private _itemsWithSuggestions = memoizeOne(
(
icons: PickerComboBoxItem[],
suggestedIcons: string[] | undefined,
localize: LocalizeFunc
): (PickerComboBoxItem | string)[] => {
if (!suggestedIcons?.length) {
return icons;
}
const suggested = new Set(suggestedIcons);
return [
localize("ui.components.icon_picker.suggested"),
...suggestedIcons.map((icon) => ({ id: icon, primary: icon, icon })),
localize("ui.components.icon_picker.all_icons"),
...icons.filter((item) => !suggested.has(item.id)),
];
}
);
// Filter can take a significant chunk of frame (up to 3-5 ms)
private _filterIcons = memoizeOne(
(
filter: string,
filteredItems: PickerComboBoxItem[],
_allItems: PickerComboBoxItem[]
allItems: PickerComboBoxItem[]
): PickerComboBoxItem[] => {
const normalizedFilter = filter.toLowerCase().replace(/\s+/g, "-");
// The full list also holds the suggestions and their section titles
const iconItems = ICONS.length ? ICONS : filteredItems;
const iconItems = allItems?.length ? allItems : filteredItems;
if (!normalizedFilter.length) {
return iconItems;
@@ -220,7 +175,8 @@ export class HaIconPicker extends LitElement {
protected firstUpdated() {
if (!ICONS_LOADED) {
loadIcons().then(() => {
this._picker?.refreshItems();
this._getIconPickerItems = (): PickerComboBoxItem[] => ICONS;
this.requestUpdate();
});
}
}
+2 -12
View File
@@ -201,9 +201,6 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) {
@property({ type: Boolean, attribute: "no-sort" }) public noSort = false;
@property({ attribute: "pin-block" })
public pinBlock?: "start" | "center" | "end" | "nearest";
@query(".list") private _list?: HaListBase;
@query("ha-input-search") private _searchFieldElement?: HaInputSearch;
@@ -456,7 +453,6 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) {
this.value
)}
.pinIndex=${this.value ? this._getInitialSelectedIndex() : undefined}
.pinBlock=${this.pinBlock ?? "center"}
@mousedown=${this._preventBlur}
@focus=${this._focusList}
@blur=${this._resetSelectedItem}
@@ -689,11 +685,6 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) {
fireEvent(this, "index-selected", { index, item, newTab });
}
// Fuse indexes every row as text when the first one is a section title
private _searchableItems = memoizeOne((items: PickerComboBoxItem[]) =>
items.filter((item) => typeof item !== "string")
);
private _fuseIndex = memoizeOne(
(states: PickerComboBoxItem[], searchKeys?: FuseWeightedKey[]) =>
Fuse.createIndex(searchKeys || DEFAULT_SEARCH_KEYS, states)
@@ -717,11 +708,10 @@ export class HaPickerComboBox extends ScrollableFadeMixin(LitElement) {
return;
}
const searchableItems = this._searchableItems(this._allItems);
const index = this._fuseIndex(searchableItems, this.searchKeys);
const index = this._fuseIndex(this._allItems, this.searchKeys);
let filteredItems = multiTermSortedSearch<PickerComboBoxItem>(
searchableItems,
this._allItems,
searchString,
(item) => item.id,
index
+12 -129
View File
@@ -24,23 +24,8 @@ import { showToast } from "../util/toast";
const HIDDEN_CLEANUP_DELAY = 60000;
// How long the backend gets to answer the offer, it has to connect to the camera
const ANSWER_TIMEOUT = 20000;
// How long finding a network path gets after the answer. Browsers can take
// minutes to give up on their own, or never do.
const ICE_TIMEOUT = 30000;
// How often a stream that lost its connection or got a backend error is
// started again. A new connection that gets no answer or finds no path is not
// retried, as a retry would most likely end the same way.
const MAX_RETRIES = 1;
// Gives the backend time to tear down the failed session before the next one
const RETRY_DELAY = 1000;
interface WebRtcPlayerError {
type: "not_supported" | "start_failed" | "connect_failed" | "no_connection";
type: "not_supported" | "start_failed" | "connect_failed";
message?: string;
}
@@ -114,7 +99,7 @@ export class HaWebRtcPlayer extends LitElement {
if (this._microphoneDenied) {
return "denied";
}
if (this._microphoneConnecting || this._retryMicrophoneTrack) {
if (this._microphoneConnecting) {
return "connecting";
}
return this._localReturnAudioTrack ? "on" : "off";
@@ -125,17 +110,11 @@ export class HaWebRtcPlayer extends LitElement {
}
public async toggleMicrophone() {
if (
this._localReturnAudioTrack ||
this._microphoneConnecting ||
this._retryMicrophoneTrack
) {
if (this._localReturnAudioTrack || this._microphoneConnecting) {
// Stop (not disable) so the browser releases the microphone, also cancels connecting
this._microphoneRequest++;
this._localReturnAudioTrack?.stop();
this._localReturnAudioTrack = undefined;
this._retryMicrophoneTrack?.stop();
this._retryMicrophoneTrack = undefined;
this._microphoneConnecting = false;
this._fireMicrophoneChanged();
await this._microphoneSender?.replaceTrack(null).catch(() => undefined);
@@ -218,18 +197,6 @@ export class HaWebRtcPlayer extends LitElement {
private _cleanUpCount = 0;
private _connectTimeout?: number;
private _retryTimeout?: number;
private _retryMicrophoneTrack?: MediaStreamTrack;
private _retries = 0;
// The stream showed video since it was started, so a lost connection is
// worth a retry
private _hasPlayed = false;
private _handleVisibilityChange = () => {
if (document.pictureInPictureElement) {
// video is playing in picture-in-picture mode, don't do anything
@@ -245,7 +212,7 @@ export class HaWebRtcPlayer extends LitElement {
clearTimeout(this._hiddenCleanupTimeout);
this._hiddenCleanupTimeout = undefined;
} else {
this._restartWebRtc();
this._startWebRtc();
}
};
@@ -286,7 +253,7 @@ export class HaWebRtcPlayer extends LitElement {
public override connectedCallback() {
super.connectedCallback();
if (this.hasUpdated && this.entityid) {
this._restartWebRtc();
this._startWebRtc();
}
document.addEventListener("visibilitychange", this._handleVisibilityChange);
}
@@ -307,13 +274,6 @@ export class HaWebRtcPlayer extends LitElement {
if (!changedProperties.has("entityid")) {
return;
}
this._restartWebRtc();
}
/** Starts a new stream, not a retry of the current one. */
private _restartWebRtc() {
this._retries = 0;
this._hasPlayed = false;
this._startWebRtc();
}
@@ -455,7 +415,7 @@ export class HaWebRtcPlayer extends LitElement {
while (this._candidatesList.length) {
const candidate = this._candidatesList.pop();
if (candidate) {
candidates += `a=${candidate.candidate}\r\n`;
candidates += `a=${candidate}\r\n`;
}
}
@@ -463,8 +423,6 @@ export class HaWebRtcPlayer extends LitElement {
this._logEvent("start webRtcOffer", offer_sdp);
this._startConnectTimeout(ANSWER_TIMEOUT);
this._unsub = webRtcOffer(
this._connection,
this.entityid,
@@ -485,61 +443,11 @@ export class HaWebRtcPlayer extends LitElement {
"ice connection state change",
this._peerConnection?.iceConnectionState
);
const iceState = this._peerConnection?.iceConnectionState;
if (iceState === "connected" || iceState === "completed") {
clearTimeout(this._connectTimeout);
this._connectTimeout = undefined;
} else if (iceState === "failed") {
// An ICE restart needs a new offer, which the backend answers from a new
// peer that can't continue this connection, so start a new one instead.
this._retryOrFail({ type: "no_connection" });
if (this._peerConnection?.iceConnectionState === "failed") {
this._peerConnection.restartIce();
}
};
private _startConnectTimeout(timeout: number) {
clearTimeout(this._connectTimeout);
this._connectTimeout = window.setTimeout(() => {
this._connectTimeout = undefined;
this._logEvent("connect timeout");
this._retryOrFail({ type: "no_connection" });
}, timeout);
}
private _retryOrFail(error: WebRtcPlayerError) {
if (
this._retries >= MAX_RETRIES ||
// No answer or no path for a stream that never played, a retry would
// most likely end the same way
(error.type === "no_connection" && !this._hasPlayed) ||
// A microphone connect the user started is handled by starting again
// without the microphone. A retry keeps the microphone of the stream.
(this._localReturnAudioTrack &&
this._microphoneConnecting &&
this._retries === 0)
) {
this._failStart(error);
return;
}
this._retries++;
this._logEvent("retry", this._retries, error);
// Keep showing the last frame instead of the poster while starting again
this._captureReconnectFrame();
// Taken out before the clean up, so a running microphone is not stopped
const microphoneTrack = this._localReturnAudioTrack;
this._localReturnAudioTrack = undefined;
this._cleanUp();
if (microphoneTrack) {
this._retryMicrophoneTrack = microphoneTrack;
this._fireMicrophoneChanged();
}
this._retryTimeout = window.setTimeout(() => {
this._retryTimeout = undefined;
const track = this._retryMicrophoneTrack;
this._retryMicrophoneTrack = undefined;
this._startWebRtc(track);
}, RETRY_DELAY);
}
private async _handleOfferEvent(
peerConnection: RTCPeerConnection,
event: WebRtcOfferEvent
@@ -562,10 +470,6 @@ export class HaWebRtcPlayer extends LitElement {
this._candidatesList = [];
}
if (event.type === "answer") {
const iceState = peerConnection.iceConnectionState;
if (iceState !== "connected" && iceState !== "completed") {
this._startConnectTimeout(ICE_TIMEOUT);
}
this._logEvent("answer", event.answer);
this._handleAnswer(peerConnection, event);
@@ -591,8 +495,7 @@ export class HaWebRtcPlayer extends LitElement {
}
}
if (event.type === "error") {
// Often temporary, like the backend still closing the previous session
this._retryOrFail({ type: "start_failed", message: event.message });
this._failStart({ type: "start_failed", message: event.message });
}
}
@@ -684,13 +587,8 @@ export class HaWebRtcPlayer extends LitElement {
}
private _failStart(error: WebRtcPlayerError) {
// The camera can reject the microphone, keep the video running without it.
// After retries it is the connection that failed, not the microphone.
if (
this._localReturnAudioTrack &&
this._microphoneConnecting &&
this._retries === 0
) {
// The camera can reject the microphone, keep the video running without it
if (this._localReturnAudioTrack && this._microphoneConnecting) {
showToast(this, {
message: this._localize(
"ui.components.web-rtc-player.microphone_connect_failed",
@@ -701,19 +599,12 @@ export class HaWebRtcPlayer extends LitElement {
return;
}
this._error = error;
this._reconnectPoster = undefined;
this._cleanUp();
// Tell the camera stream this player has no video, so it can fall back
fireEvent(this, "streams", { hasAudio: false, hasVideo: false });
}
private _cleanUp() {
this._cleanUpCount++;
this._microphoneRequest++;
clearTimeout(this._connectTimeout);
this._connectTimeout = undefined;
clearTimeout(this._retryTimeout);
this._retryTimeout = undefined;
if (this._remoteStream) {
this._remoteStream.getTracks().forEach((track) => {
track.stop();
@@ -721,15 +612,9 @@ export class HaWebRtcPlayer extends LitElement {
this._remoteStream = undefined;
}
if (
this._localReturnAudioTrack ||
this._microphoneConnecting ||
this._retryMicrophoneTrack
) {
if (this._localReturnAudioTrack || this._microphoneConnecting) {
this._localReturnAudioTrack?.stop();
this._localReturnAudioTrack = undefined;
this._retryMicrophoneTrack?.stop();
this._retryMicrophoneTrack = undefined;
this._microphoneConnecting = false;
this._fireMicrophoneChanged();
}
@@ -781,8 +666,6 @@ export class HaWebRtcPlayer extends LitElement {
this._logEvent("loadedData", data);
this._stopTimer();
this._retries = 0;
this._hasPlayed = true;
// Without a track the microphone is still waiting for permission
if (this._microphoneConnecting && this._localReturnAudioTrack) {
-12
View File
@@ -34,8 +34,6 @@ import type { HASSDomTargetEvent } from "../../common/dom/fire_event";
*
* @attr {string} headline - Primary text. Overridden by the `headline` slot.
* @attr {string} supporting-text - Secondary text. Overridden by the `supporting-text` slot.
* @attr {boolean} wrap-headline - Wraps the headline onto multiple lines instead of truncating it.
* @attr {boolean} wrap-supporting-text - Wraps the supporting text onto multiple lines instead of truncating it.
* @attr {boolean} disabled - Dims the row and blocks pointer events.
*/
@customElement("ha-row-item")
@@ -45,12 +43,6 @@ export class HaRowItem extends LitElement {
@property({ type: String, attribute: "supporting-text" })
public supportingText?: string;
@property({ type: Boolean, reflect: true, attribute: "wrap-headline" })
public wrapHeadline = false;
@property({ type: Boolean, reflect: true, attribute: "wrap-supporting-text" })
public wrapSupportingText = false;
@property({ type: Boolean, reflect: true }) public disabled = false;
protected readonly _slotController = new HasSlotController(
@@ -200,10 +192,6 @@ export class HaRowItem extends LitElement {
text-overflow: ellipsis;
white-space: nowrap;
}
:host([wrap-headline]) .headline,
:host([wrap-supporting-text]) .supporting {
white-space: normal;
}
`;
}
@@ -1,128 +0,0 @@
import type { CSSResultGroup, TemplateResult } from "lit";
import { css, html, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { HaListItemButton } from "../item/ha-list-item-button";
import "./ha-media-browser-thumbnail";
/**
* @element ha-media-player-browse-list-item
* @extends {HaListItemButton}
*
* @summary
* Row of the media browser list. Always reserves a graphic next to the title
* so titles line up, and shows a thumbnail with an optional play button over
* it. Without `interactive` the row is plain text, used for the "not shown"
* row. The row is rendered inside the shadow root of `ha-list-virtualized`, so
* it carries its own styles.
*
* @slot start - Play or pick button, shown over the thumbnail.
* @slot headline - Title of the row.
*
* @csspart start - The graphic container.
*
* @attr {string} thumbnail - URL of the thumbnail. Shown inside the graphic.
*/
@customElement("ha-media-player-browse-list-item")
export class HaMediaPlayerBrowseListItem extends HaListItemButton {
@property() public thumbnail?: string;
// The "not shown" row is plain text, not a button
protected override _renderControl(content: TemplateResult): TemplateResult {
if (!this.interactive) {
return content;
}
return super._renderControl(content);
}
// Always reserve the graphic, so titles line up across rows
protected override _renderStart(): TemplateResult {
return html`<div part="start" class="start">
<div class="graphic">
${
this.thumbnail
? html`<ha-media-browser-thumbnail
.url=${this.thumbnail}
></ha-media-browser-thumbnail>`
: nothing
}
<slot name="start"></slot>
</div>
</div>`;
}
static styles: CSSResultGroup = [
HaListItemButton.styles,
css`
:host {
direction: var(--direction);
--ha-row-item-padding-block: 0;
--ha-row-item-min-height: 48px;
}
:host(.show-images) {
--ha-row-item-padding-block: var(--ha-space-1);
--ha-row-item-min-height: 64px;
}
:host(.not-shown) {
font-style: italic;
color: var(--secondary-text-color);
cursor: default;
}
::slotted(ha-svg-icon) {
color: var(--secondary-text-color);
}
.graphic {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: var(--ha-border-radius-sm);
overflow: hidden;
}
:host(.show-images) .graphic {
width: 56px;
height: 56px;
}
ha-media-browser-thumbnail {
position: absolute;
inset: 0;
}
::slotted(.play) {
position: absolute;
inset: 0;
margin: auto;
width: 40px;
height: 40px;
opacity: 0;
transition: all 0.5s;
background-color: rgba(var(--rgb-card-background-color), 0.5);
border-radius: var(--ha-border-radius-circle);
--ha-icon-button-size: 40px;
}
:host(:hover) ::slotted(.play) {
opacity: 1;
color: var(--primary-text-color);
}
::slotted(.play.show) {
opacity: 1;
background-color: transparent;
}
`,
];
}
declare global {
interface HTMLElementTagNameMap {
"ha-media-player-browse-list-item": HaMediaPlayerBrowseListItem;
}
}
@@ -77,6 +77,7 @@ import "../ha-svg-icon";
import "../ha-tooltip";
import "../input/ha-input-search";
import type { HaInputSearch } from "../input/ha-input-search";
import { HaListItemButton } from "../item/ha-list-item-button";
import "../list/ha-list-virtualized";
import type {
HaListVirtualized,
@@ -87,7 +88,6 @@ import type { ManualMediaPickedEvent } from "./ha-browse-media-manual";
import "./ha-browse-media-tts";
import type { TtsMediaPickedEvent } from "./ha-browse-media-tts";
import "./ha-media-browser-thumbnail";
import "./ha-media-player-browse-list-item";
declare global {
interface HASSDomEvents {
@@ -120,6 +120,105 @@ type MediaBrowseListRow =
count: number;
});
@customElement("ha-media-player-browse-list-item")
export class HaMediaPlayerBrowseListItem extends HaListItemButton {
@property() public thumbnail?: string;
// The "not shown" row is plain text, not a button
protected override _renderControl(content: TemplateResult): TemplateResult {
if (!this.interactive) {
return content;
}
return super._renderControl(content);
}
// Always reserve the graphic, so titles line up across rows
protected override _renderStart(): TemplateResult {
return html`<div part="start" class="start">
<div class="graphic">
${
this.thumbnail
? html`<ha-media-browser-thumbnail
.url=${this.thumbnail}
></ha-media-browser-thumbnail>`
: nothing
}
<slot name="start"></slot>
</div>
</div>`;
}
static styles: CSSResultGroup = [
HaListItemButton.styles,
css`
:host {
direction: var(--direction);
--ha-row-item-padding-block: 0;
--ha-row-item-min-height: 48px;
}
:host(.show-images) {
--ha-row-item-padding-block: var(--ha-space-1);
--ha-row-item-min-height: 64px;
}
:host(.not-shown) {
font-style: italic;
color: var(--secondary-text-color);
cursor: default;
}
::slotted(ha-svg-icon) {
color: var(--secondary-text-color);
}
.graphic {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: var(--ha-border-radius-sm);
overflow: hidden;
}
:host(.show-images) .graphic {
width: 56px;
height: 56px;
}
ha-media-browser-thumbnail {
position: absolute;
inset: 0;
}
::slotted(.play) {
position: absolute;
inset: 0;
margin: auto;
width: 40px;
height: 40px;
opacity: 0;
transition: all 0.5s;
background-color: rgba(var(--rgb-card-background-color), 0.5);
border-radius: var(--ha-border-radius-circle);
--ha-icon-button-size: 40px;
}
:host(:hover) ::slotted(.play) {
opacity: 1;
color: var(--primary-text-color);
}
::slotted(.play.show) {
opacity: 1;
background-color: transparent;
}
`,
];
}
/** Folders with at least this many items get a filter field when their source cannot search. */
const FILTER_MIN_CHILDREN = 10;
@@ -1846,5 +1945,6 @@ export class HaMediaPlayerBrowse extends LitElement {
declare global {
interface HTMLElementTagNameMap {
"ha-media-player-browse": HaMediaPlayerBrowse;
"ha-media-player-browse-list-item": HaMediaPlayerBrowseListItem;
}
}
-201
View File
@@ -1,201 +0,0 @@
import type { LocalizeFunc } from "../common/translations/localize";
export const ROOM_ICONS = {
living_room: [
"mdi:sofa",
"mdi:sofa-single",
"mdi:television",
"mdi:fireplace",
"mdi:floor-lamp",
],
bedroom: ["mdi:bed", "mdi:bed-king", "mdi:bed-double", "mdi:lamp"],
kids_room: ["mdi:teddy-bear", "mdi:toy-brick", "mdi:bunk-bed", "mdi:cradle"],
kitchen: [
"mdi:stove",
"mdi:fridge",
"mdi:countertop",
"mdi:chef-hat",
"mdi:pot-steam",
"mdi:coffee-maker",
],
dining_room: [
"mdi:silverware-fork-knife",
"mdi:table-chair",
"mdi:table-furniture",
"mdi:glass-wine",
],
bathroom: [
"mdi:shower",
"mdi:bathtub",
"mdi:shower-head",
"mdi:toothbrush",
"mdi:hair-dryer",
],
toilet: ["mdi:toilet", "mdi:paper-roll"],
office: [
"mdi:desk",
"mdi:laptop",
"mdi:monitor",
"mdi:chair-rolling",
"mdi:bookshelf",
],
laundry_room: [
"mdi:washing-machine",
"mdi:tumble-dryer",
"mdi:iron",
"mdi:hanger",
],
hallway: ["mdi:door", "mdi:door-open", "mdi:coat-rack", "mdi:key"],
stairs: ["mdi:stairs", "mdi:stairs-up", "mdi:stairs-down"],
garage: ["mdi:garage", "mdi:garage-variant", "mdi:car", "mdi:tools"],
garden: [
"mdi:flower",
"mdi:tree",
"mdi:grass",
"mdi:sprout",
"mdi:watering-can",
"mdi:greenhouse",
],
terrace: [
"mdi:balcony",
"mdi:grill",
"mdi:umbrella-outline",
"mdi:coach-lamp",
"mdi:patio-heater",
],
basement: [
"mdi:home-floor-negative-1",
"mdi:stairs-down",
"mdi:water-boiler",
],
attic: ["mdi:home-roof", "mdi:package-variant-closed"],
storage: ["mdi:archive", "mdi:package-variant-closed", "mdi:warehouse"],
utility_room: [
"mdi:water-boiler",
"mdi:heat-pump",
"mdi:server-network",
"mdi:flash",
],
pool: ["mdi:pool", "mdi:swim"],
media_room: [
"mdi:theater",
"mdi:projector",
"mdi:television",
"mdi:movie-open",
],
game_room: [
"mdi:gamepad-variant",
"mdi:billiards",
"mdi:cards-playing",
"mdi:dice-multiple",
],
music_room: ["mdi:piano", "mdi:guitar-acoustic", "mdi:music"],
library: ["mdi:bookshelf", "mdi:book-open-variant", "mdi:library"],
bar: [
"mdi:glass-cocktail",
"mdi:glass-mug-variant",
"mdi:bottle-wine",
"mdi:beer",
],
dressing_room: [
"mdi:hanger",
"mdi:wardrobe",
"mdi:tshirt-crew",
"mdi:shoe-heel",
],
workshop: ["mdi:tools", "mdi:hammer-wrench", "mdi:toolbox", "mdi:saw-blade"],
server_room: ["mdi:server-network", "mdi:server", "mdi:router-network"],
safe_room: ["mdi:shield-home", "mdi:shield-lock", "mdi:safe"],
prayer_room: ["mdi:hands-pray", "mdi:meditation", "mdi:candle"],
sauna: ["mdi:spa", "mdi:hot-tub", "mdi:thermometer-high"],
outdoor_kitchen: ["mdi:grill", "mdi:grill-outline", "mdi:pizza"],
driveway: ["mdi:road-variant", "mdi:car", "mdi:gate"],
} as const satisfies Record<string, readonly string[]>;
export type RoomType = keyof typeof ROOM_ICONS;
type RoomKeywords = Partial<Record<RoomType, string[]>>;
export const ROOM_TYPES = Object.keys(ROOM_ICONS) as RoomType[];
export const isRoomType = (value: string): value is RoomType =>
(ROOM_TYPES as string[]).includes(value);
// Languages written without spaces between words
const NO_WORD_SPACING =
/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}]/u;
const normalizeRoomText = (text: string): string =>
text
.normalize("NFD")
.replace(/\p{M}/gu, "")
.toLowerCase()
.replace(/['’]/g, "")
.replace(/[^\p{L}\p{N}]+/gu, " ")
.trim();
interface RoomMatch {
room: RoomType;
start: number;
end: number;
}
const findMatches = (name: string, keywords: RoomKeywords): RoomMatch[] => {
const text = ` ${normalizeRoomText(name)} `;
const candidates: RoomMatch[] = [];
for (const room of ROOM_TYPES) {
for (const keyword of keywords[room] ?? []) {
const phrase = normalizeRoomText(keyword);
if (!phrase) {
continue;
}
const needle = NO_WORD_SPACING.test(phrase) ? phrase : ` ${phrase} `;
const start = text.indexOf(needle);
if (start !== -1) {
candidates.push({ room, start, end: start + needle.length });
}
}
}
// The longest phrase wins, so "guest bedroom" is not also read as "bedroom"
candidates.sort((a, b) => b.end - b.start - (a.end - a.start));
const kept: RoomMatch[] = [];
for (const match of candidates) {
const overlaps = kept.some(
(other) => match.start < other.end - 1 && other.start < match.end - 1
);
if (!overlaps) {
kept.push(match);
}
}
return kept.sort((a, b) => a.start - b.start);
};
const matchRoomTypes = (
names: string[],
keywords: RoomKeywords
): RoomType[] => {
const rooms = new Set<RoomType>();
for (const name of names) {
for (const match of findMatches(name, keywords)) {
rooms.add(match.room);
}
}
return [...rooms];
};
const roomIconSuggestions = (rooms: RoomType[]): string[] => [
...new Set(rooms.flatMap((room) => ROOM_ICONS[room])),
];
export const getAreaIconSuggestions = (
names: string[],
localize: LocalizeFunc
): string[] => {
const keywords: RoomKeywords = Object.fromEntries(
ROOM_TYPES.map((room) => [
room,
localize(`ui.components.rooms.keywords.${room}`).split("|"),
])
);
return roomIconSuggestions(matchRoomTypes(names, keywords));
};
-80
View File
@@ -1,80 +0,0 @@
export const STREAM_TYPE_HLS = "hls";
export const STREAM_TYPE_WEB_RTC = "web_rtc";
export type StreamType = typeof STREAM_TYPE_HLS | typeof STREAM_TYPE_WEB_RTC;
export const MJPEG_STREAM = "mjpeg";
export type CameraStreamType = StreamType | typeof MJPEG_STREAM;
export interface CameraStream {
type: CameraStreamType;
visible: boolean;
}
/** What a player reported, `hasVideo: false` means it failed to load. */
export interface CameraStreamTracks {
hasAudio: boolean;
hasVideo: boolean;
}
export interface CameraStreamSelectionOptions {
supportedTypes?: StreamType[];
hlsStreams?: CameraStreamTracks;
webRtcStreams?: CameraStreamTracks;
}
/**
* Decides which players are rendered and which one is shown. Hidden players
* are still loading in the background.
*/
export const selectCameraStreams = ({
supportedTypes,
hlsStreams,
webRtcStreams,
}: CameraStreamSelectionOptions): CameraStream[] => {
if (!supportedTypes) {
return [];
}
if (supportedTypes.length === 0) {
// doesn't support any stream type, fallback to mjpeg
return [{ type: MJPEG_STREAM, visible: true }];
}
if (supportedTypes.length === 1) {
// only 1 stream type, no need to choose
if (
(supportedTypes[0] === STREAM_TYPE_HLS &&
hlsStreams?.hasVideo === false) ||
(supportedTypes[0] === STREAM_TYPE_WEB_RTC &&
webRtcStreams?.hasVideo === false)
) {
// stream failed to load, fallback to mjpeg
return [{ type: MJPEG_STREAM, visible: true }];
}
return [{ type: supportedTypes[0], visible: true }];
}
const hlsFailed = hlsStreams?.hasVideo === false;
if (webRtcStreams?.hasVideo) {
// WebRTC is preferred whenever it plays, it has the lowest latency
return [{ type: STREAM_TYPE_WEB_RTC, visible: true }];
}
if (webRtcStreams?.hasVideo === false) {
if (hlsFailed) {
// both streams failed to load, fallback to mjpeg
return [{ type: MJPEG_STREAM, visible: true }];
}
return [{ type: STREAM_TYPE_HLS, visible: true }];
}
// WebRTC is still loading
if (hlsFailed) {
return [{ type: STREAM_TYPE_WEB_RTC, visible: true }];
}
return [
{ type: STREAM_TYPE_HLS, visible: true },
{ type: STREAM_TYPE_WEB_RTC, visible: false },
];
};
+4 -6
View File
@@ -7,15 +7,13 @@ import { timeCacheEntityPromiseFunc } from "../common/util/time-cache-entity-pro
import type { HomeAssistant, HomeAssistantApi } from "../types";
import { fileDownload } from "../util/file_download";
import { getSignedPath } from "./auth";
import type { StreamType } from "./camera-streams";
export const CAMERA_ORIENTATIONS = [1, 2, 3, 4, 6, 8];
export {
STREAM_TYPE_HLS,
STREAM_TYPE_WEB_RTC,
type StreamType,
} from "./camera-streams";
export const STREAM_TYPE_HLS = "hls";
export const STREAM_TYPE_WEB_RTC = "web_rtc";
export type StreamType = typeof STREAM_TYPE_HLS | typeof STREAM_TYPE_WEB_RTC;
export { CameraEntityFeature } from "./feature/camera_entity_feature";
+7 -11
View File
@@ -209,15 +209,7 @@ export const watchForNewMatterDevice = (
callback: (device: DeviceRegistryEntry) => void
): UnsubscribeFunc => {
let curMatterDevices: Set<string> | undefined;
let unsubDeviceReg: UnsubscribeFunc | undefined;
// Callers also unsubscribe after a find. The registry collection counts its
// subscribers, so a second unsubscribe would stop its updates for everyone.
const unsubscribe = () => {
unsubDeviceReg?.();
unsubDeviceReg = undefined;
curMatterDevices = undefined;
};
unsubDeviceReg = subscribeDeviceRegistry(hass.connection, (entries) => {
const unsubDeviceReg = subscribeDeviceRegistry(hass.connection, (entries) => {
if (!curMatterDevices) {
curMatterDevices = new Set(
Object.values(entries)
@@ -234,11 +226,15 @@ export const watchForNewMatterDevice = (
!curMatterDevices!.has(device.id)
);
if (newMatterDevices.length) {
unsubscribe();
unsubDeviceReg();
curMatterDevices = undefined;
callback(newMatterDevices[0]);
}
});
return unsubscribe;
return () => {
unsubDeviceReg();
curMatterDevices = undefined;
};
};
export const redirectOnNewMatterDevice = (
@@ -167,12 +167,16 @@ export class HaMoreInfoFavorites extends LitElement {
display: flex;
align-items: center;
justify-content: center;
gap: var(--ha-space-4);
margin: calc(var(--ha-space-2) * -1);
flex-wrap: wrap;
max-width: var(--favorite-items-max-width, 250px);
user-select: none;
}
.container > * {
margin: var(--ha-space-2);
}
.favorite {
display: block;
}
+8 -16
View File
@@ -60,25 +60,14 @@
/* Margins, not flex `gap` (Safari 14.1). */
#ha-launch-screen .ha-launch-screen-actions {
display: flex;
flex-direction: column;
align-items: center;
margin: 0 16px;
}
#ha-launch-screen .ha-launch-screen-actions label {
display: flex;
align-items: center;
margin-top: 8px;
padding: 8px 16px;
font-size: 14px;
cursor: pointer;
}
#ha-launch-screen .ha-launch-screen-actions input {
margin: 0 8px 0 0;
accent-color: #009ac7;
flex-wrap: wrap;
justify-content: center;
margin: -4px 16px;
}
#ha-launch-screen .ha-launch-screen-actions button {
margin: 4px;
padding: 8px 16px;
border: 1px solid currentColor;
border: 1px solid transparent;
border-radius: 18px;
background: none;
color: #009ac7;
@@ -87,6 +76,9 @@
font-weight: 500;
cursor: pointer;
}
#ha-launch-screen .ha-launch-screen-actions .ha-launch-screen-continue {
border-color: currentColor;
}
.ohf-logo {
margin: 48px 0;
display: flex;
+22 -25
View File
@@ -116,33 +116,30 @@
actions.className = "ha-launch-screen-actions";
box.appendChild(actions);
var always = null;
var button = document.createElement("button");
button.type = "button";
button.textContent = "Continue anyway";
button.addEventListener("click", function () {
try {
localStorage.setItem(
ACCEPTED_KEY,
always && always.checked ? "always" : String(Date.now())
);
} catch (_err) {
// Continue this time only.
}
box.removeChild(actions);
loadApp();
});
actions.appendChild(button);
function addButton(label, value) {
var button = document.createElement("button");
button.type = "button";
button.textContent = label;
button.addEventListener("click", function () {
try {
localStorage.setItem(ACCEPTED_KEY, value());
} catch (_err) {
// Continue this time only.
}
box.removeChild(actions);
loadApp();
});
actions.appendChild(button);
return button;
}
// From the first reminder on. A checkbox, so it is not chosen by
// accident.
addButton("Continue anyway", function () {
return String(Date.now());
}).className = "ha-launch-screen-continue";
if (acceptedAt) {
var label = document.createElement("label");
always = document.createElement("input");
always.type = "checkbox";
label.appendChild(always);
label.appendChild(document.createTextNode("Don't show again"));
actions.appendChild(label);
addButton("Don't show again", function () {
return "always";
});
}
})();
}
@@ -816,7 +816,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
this._currentAddon.version
? html`
<wa-divider></wa-divider>
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.i18n.localize(
"ui.panel.config.apps.dashboard.option.boot.title"
@@ -842,7 +842,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
${
this._currentAddon.startup !== "once"
? html`
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.i18n.localize(
"ui.panel.config.apps.dashboard.option.watchdog.title"
@@ -867,7 +867,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
`
: nothing
}
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.i18n.localize(
"ui.panel.config.apps.dashboard.option.auto_update.title"
@@ -893,7 +893,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
!this._computeCannotIngressSidebar &&
this._currentAddon.ingress
? html`
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.i18n.localize(
"ui.panel.config.apps.dashboard.option.ingress_panel.title"
@@ -923,7 +923,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
${
this._computeUsesProtectedOptions
? html`
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.i18n.localize(
"ui.panel.config.apps.dashboard.option.protected.title"
@@ -954,7 +954,7 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
${
this._currentAddon.version && this._currentAddon.state === "started"
? html`<wa-divider></wa-divider>
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="supporting-text">
${this.i18n.localize(
"ui.panel.config.apps.dashboard.hostname"
@@ -1630,6 +1630,10 @@ class SupervisorAppInfo extends MobileAwareMixin(LitElement) {
color: var(--ha-color-text-secondary);
}
.controls ha-row-item::part(supporting-text) {
white-space: normal;
}
.controls .content {
display: flex;
flex-direction: column;
@@ -1,5 +1,5 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { CSSResultGroup, PropertyValues } from "lit";
import type { CSSResultGroup } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../common/dom/fire_event";
@@ -29,10 +29,6 @@ import type {
AreaRegistryEntryMutableParams,
} from "../../../data/area/area_registry";
import { deleteAreaRegistryEntry } from "../../../data/area/area_registry";
import {
getAreaIconSuggestions,
ROOM_ICONS,
} from "../../../data/area_icon_suggestions";
import {
SENSOR_DEVICE_CLASS_HUMIDITY,
SENSOR_DEVICE_CLASS_TEMPERATURE,
@@ -100,10 +96,6 @@ class DialogAreaDetail
@state() private _submitting = false;
@state() private _suggestedIcons?: string[];
private _iconFollowsName = false;
@state() private _open = false;
@state() private _suggestionInclude: MetadataSuggestionInclude = {
@@ -136,7 +128,6 @@ class DialogAreaDetail
this._temperatureEntity = null;
this._humidityEntity = null;
}
this._iconFollowsName = !this._params.entry;
this._open = true;
this._initDirtyTracking({ type: "deep" }, this._currentState());
await this.updateComplete;
@@ -160,30 +151,6 @@ class DialogAreaDetail
return true;
}
protected willUpdate(changedProps: PropertyValues) {
super.willUpdate(changedProps);
if (changedProps.has("_name") || changedProps.has("_aliases")) {
this._updateSuggestedIcons();
}
}
private _updateSuggestedIcons() {
const icons = getAreaIconSuggestions(
[this._name ?? "", ...(this._aliases ?? [])],
this.hass.localize
);
this._suggestedIcons = icons;
if (this._iconFollowsName) {
const untouched = !this.isDirtyState;
this._icon = icons[0] ?? null;
if (untouched) {
this._initDirtyTracking({ type: "deep" }, this._currentState());
} else {
this._updateDirtyState(this._currentState());
}
}
}
private _entityName(entityId: string | null): string | null {
const stateObj = entityId ? this.hass.states[entityId] : undefined;
return stateObj ? this.hass.formatEntityName(stateObj) : null;
@@ -226,7 +193,6 @@ class DialogAreaDetail
.value=${this._icon}
@value-changed=${this._iconChanged}
.label=${this.hass.localize("ui.panel.config.areas.editor.icon")}
.suggestedIcons=${this._suggestedIcons}
></ha-icon-picker>
<ha-floor-picker
@@ -334,7 +300,6 @@ class DialogAreaDetail
this._suggestionInclude = {
...this._suggestionInclude,
name: this._name.trim() === "",
room: !this._icon || this._iconFollowsName,
};
return generateMetadataSuggestionTask<{
@@ -384,11 +349,6 @@ class DialogAreaDetail
this._floor = processed.floor;
}
if (processed.room && (!this._icon || this._iconFollowsName)) {
this._icon = ROOM_ICONS[processed.room][0];
this._iconFollowsName = false;
}
this._updateDirtyState(this._currentState());
}
@@ -504,7 +464,6 @@ class DialogAreaDetail
private _iconChanged(ev) {
this._error = undefined;
this._icon = ev.detail.value;
this._iconFollowsName = false;
this._updateDirtyState(this._currentState());
}
@@ -21,7 +21,7 @@ class HaBackupConfigAddon extends LitElement {
protected render() {
return html`
<ha-list-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
`ui.panel.config.backup.schedule.update_preference.label`
@@ -55,7 +55,7 @@ class HaBackupConfigAddon extends LitElement {
]}
></ha-select>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(`ui.panel.config.backup.schedule.retention`)}
</span>
@@ -113,6 +113,10 @@ class HaBackupConfigAddon extends LitElement {
ha-list-base {
--ha-row-item-padding-inline: 0;
}
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: wrap;
}
ha-select {
min-width: 210px;
}
@@ -197,7 +197,7 @@ class HaBackupConfigAgents extends LitElement {
!this.cloudStatus.active_subscription;
return html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
${this._renderAgentIcon(agentId)}
<div slot="headline" class="name">${name}</div>
${
@@ -248,7 +248,7 @@ class HaBackupConfigAgents extends LitElement {
);
return html`
<ha-list-item-base wrap-headline>
<ha-list-item-base>
${this._renderAgentIcon(agentId)}
<div slot="headline" class="name">${name}</div>
<ha-icon-button
@@ -317,6 +317,10 @@ class HaBackupConfigAgents extends LitElement {
--mdc-icon-size: 48px;
color: var(--primary-text-color);
}
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: wrap;
}
ha-list-item-base::part(end) {
gap: var(--ha-space-2);
}
@@ -239,7 +239,7 @@ class HaBackupConfigData extends LitElement {
return html`
${this._renderSizeEstimate()}
<ha-list-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<ha-svg-icon slot="start" .path=${mdiCog}></ha-svg-icon>
<span slot="headline">
${this.hass.localize("ui.panel.config.backup.data.ha_settings")}
@@ -266,7 +266,7 @@ class HaBackupConfigData extends LitElement {
${
this._showDbOption
? html`<ha-list-item-base wrap-headline wrap-supporting-text>
? html`<ha-list-item-base>
<ha-svg-icon slot="start" .path=${mdiChartBox}></ha-svg-icon>
<span slot="headline">
${this.hass.localize("ui.panel.config.backup.data.history")}
@@ -288,7 +288,7 @@ class HaBackupConfigData extends LitElement {
${
isHassio
? html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<ha-svg-icon
slot="start"
.path=${mdiPlayBoxMultiple}
@@ -309,7 +309,7 @@ class HaBackupConfigData extends LitElement {
></ha-switch>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<ha-svg-icon slot="start" .path=${mdiFolder}></ha-svg-icon>
<span slot="headline">
${this.hass.localize(
@@ -332,7 +332,7 @@ class HaBackupConfigData extends LitElement {
${
this._hasLocalAddons(this._addons)
? html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<ha-svg-icon
slot="start"
.path=${mdiFolder}
@@ -360,7 +360,7 @@ class HaBackupConfigData extends LitElement {
${
this._addons.length
? html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<ha-svg-icon
slot="start"
.path=${mdiPuzzle}
@@ -566,6 +566,10 @@ class HaBackupConfigData extends LitElement {
ha-list-base {
--ha-row-item-padding-inline: 0;
}
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: wrap;
}
ha-list-item-base::part(start) {
color: var(--ha-color-text-secondary);
}
@@ -25,7 +25,7 @@ class HaBackupConfigEncryptionKey extends LitElement {
if (this._value) {
return html`
<ha-list-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.encryption_key.download_emergency_kit"
@@ -48,7 +48,7 @@ class HaBackupConfigEncryptionKey extends LitElement {
)}
</ha-button>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.encryption_key.show_encryption_key"
@@ -70,7 +70,7 @@ class HaBackupConfigEncryptionKey extends LitElement {
)}
</ha-button>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.encryption_key.change_encryption_key"
@@ -99,7 +99,7 @@ class HaBackupConfigEncryptionKey extends LitElement {
return html`
<ha-list-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.encryption_key.set_encryption_key"
@@ -152,6 +152,10 @@ class HaBackupConfigEncryptionKey extends LitElement {
ha-list-base {
--ha-row-item-padding-inline: 0;
}
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: wrap;
}
ha-button[size="s"] ha-svg-icon {
--mdc-icon-size: 16px;
}
@@ -105,7 +105,7 @@ class HaBackupConfigRetention extends LitElement {
}
return html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${
this.headline ??
@@ -256,6 +256,11 @@ class HaBackupConfigRetention extends LitElement {
ha-row-item::part(end) {
align-items: flex-start;
}
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: wrap;
}
ha-select {
min-width: 210px;
}
@@ -121,7 +121,7 @@ class HaBackupConfigSchedule extends LitElement {
return html`
<ha-list-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.schedule.schedule"
@@ -154,7 +154,7 @@ class HaBackupConfigSchedule extends LitElement {
)}
outlined
>
<ha-row-item wrap-headline class="days">
<ha-row-item class="days">
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.schedule.backup_every"
@@ -186,7 +186,7 @@ class HaBackupConfigSchedule extends LitElement {
(data.recurrence === BackupScheduleRecurrence.CUSTOM_DAYS &&
data.days.length > 0)
? html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.schedule.time"
@@ -231,7 +231,7 @@ class HaBackupConfigSchedule extends LitElement {
)}
outlined
>
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.schedule.custom_time_label"
@@ -266,7 +266,7 @@ class HaBackupConfigSchedule extends LitElement {
${
this.supervisor
? html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
`ui.panel.config.backup.schedule.update_preference.label`
@@ -415,6 +415,12 @@ class HaBackupConfigSchedule extends LitElement {
ha-list-base {
--ha-row-item-padding-inline: 0;
}
ha-row-item::part(headline),
ha-row-item::part(supporting-text),
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: wrap;
}
ha-select {
min-width: 210px;
}
@@ -65,7 +65,7 @@ class HaBackupOverviewBackups extends LitElement {
return html`
<ha-backup-summary-card .heading=${heading} .status=${status}>
<ha-list-base>
<ha-list-item-base wrap-headline>
<ha-list-item-base>
<ha-svg-icon slot="start" .path=${mdiBackupRestore}></ha-svg-icon>
<span slot="headline" class=${headline === null ? "skeleton" : ""}
>${headline}</span
@@ -74,7 +74,7 @@ class HaBackupOverviewBackups extends LitElement {
${
description || description === null
? html`
<ha-list-item-base wrap-headline>
<ha-list-item-base>
<ha-svg-icon
slot="start"
.path=${mdiCalendar}
@@ -367,6 +367,9 @@ class HaBackupOverviewBackups extends LitElement {
ha-list-item-base::part(start) {
color: var(--ha-color-text-secondary);
}
ha-list-item-base::part(headline) {
white-space: wrap;
}
span.skeleton {
position: relative;
display: block;
@@ -152,7 +152,7 @@ class HaConfigBackupDetails extends LitElement {
${
CLOUD_AGENT === this.agentId
? html`
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.location.encryption.location_encrypted"
@@ -179,7 +179,7 @@ class HaConfigBackupDetails extends LitElement {
`
: encrypted
? html`
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.location.encryption.location_encrypted"
@@ -213,7 +213,7 @@ class HaConfigBackupDetails extends LitElement {
"ui.panel.config.backup.location.encryption.warning_encryption_turn_off_description"
)}
</ha-alert>
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.backup.location.encryption.location_unencrypted"
@@ -364,6 +364,9 @@ class HaConfigBackupDetails extends LitElement {
ha-backup-data-picker {
display: block;
}
ha-row-item::part(supporting-text) {
white-space: wrap;
}
.dot {
display: block;
position: relative;
@@ -170,7 +170,7 @@ export class CloudRemotePref extends LitElement {
>
<div class="card-content">
<ha-list-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.cloud.account.remote.external_activation"
@@ -187,7 +187,7 @@ export class CloudRemotePref extends LitElement {
@change=${this._toggleAllowRemoteEnabledChanged}
></ha-switch>
</ha-list-item-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.cloud.account.remote.certificate_info"
@@ -311,6 +311,9 @@ export class CloudRemotePref extends LitElement {
ha-list-base {
--ha-row-item-padding-inline: 0;
}
ha-list-item-base::part(supporting-text) {
white-space: normal;
}
ha-tip {
max-width: 600px;
margin: 0 auto;
@@ -199,7 +199,7 @@ export class CloudWebhooks extends LitElement {
private _renderHookRow(entry: Webhook) {
return html`
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${entry.name}
${
@@ -374,6 +374,7 @@ export class CloudWebhooks extends LitElement {
}
ha-row-item::part(headline),
ha-row-item::part(supporting-text) {
white-space: wrap;
word-break: break-all;
}
`,
@@ -1,7 +1,5 @@
import { dump } from "js-yaml";
import type { AITaskStructure, GenDataTaskResult } from "../../../data/ai_task";
import type { RoomType } from "../../../data/area_icon_suggestions";
import { isRoomType, ROOM_TYPES } from "../../../data/area_icon_suggestions";
import type { HomeAssistant } from "../../../types";
import type { SuggestWithAIGenerateTask } from "../../../components/ha-suggest-with-ai-button";
import {
@@ -16,7 +14,6 @@ export interface MetadataSuggestionResult {
category?: string;
labels?: string[];
floor?: string;
room?: RoomType;
}
export type MetadataSuggestionDomain =
@@ -28,7 +25,6 @@ export interface MetadataSuggestionInclude {
categories?: boolean;
labels?: boolean;
floor?: boolean;
room?: boolean;
}
export const SUGGESTION_INCLUDE_DEFAULT: MetadataSuggestionInclude = {
@@ -90,7 +86,6 @@ export async function generateMetadataSuggestionTask<T>(
// providers reject a select/enum schema with an empty options list.
const includeCategories = categoryOptions.length > 0;
const includeFloor = floorOptions.length > 0;
const includeRoom = Boolean(include.room) && domain === "area";
const structure: AITaskStructure = {
...(include.name && {
@@ -144,20 +139,6 @@ export async function generateMetadataSuggestionTask<T>(
},
},
}),
...(includeRoom && {
room: {
description: `The type of room that best matches the ${domain}`,
required: false,
selector: {
select: {
options: ROOM_TYPES.map((room) => ({
value: room,
label: room.replace(/_/g, " "),
})),
},
},
},
}),
};
const requestedParts = [
@@ -166,7 +147,6 @@ export async function generateMetadataSuggestionTask<T>(
includeCategories ? "a category" : null,
include.labels ? "labels" : null,
includeFloor ? "a floor" : null,
includeRoom ? "a room type" : null,
].filter((entry): entry is string => entry !== null);
const categoryLabels: string[] = [
@@ -253,10 +233,6 @@ export async function processMetadataSuggestion(
const processed: MetadataSuggestionResult = {
name: include.name ? result.data.name : undefined,
description: include.description ? result.data.description : undefined,
room:
include.room && result.data.room && isRoomType(result.data.room)
? result.data.room
: undefined,
};
// Convert category name to ID
@@ -542,7 +542,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
return html`
${
!this.hideName && this._device
? html`<ha-row-item wrap-supporting-text class="main-entity">
? html`<ha-row-item class="main-entity">
<span slot="headline"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.main_entity",
@@ -740,7 +740,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
${
SWITCH_AS_DOMAINS_INVERT.includes(this._switchAsDomain)
? html`
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.invert.label"
@@ -1017,7 +1017,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
${
this._cameraPrefs
? html`
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.stream.preload_stream"
@@ -1035,7 +1035,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
@change=${this._handleCameraPrefsChanged}
></ha-switch>
</ha-row-item>
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.stream.stream_orientation"
@@ -1074,7 +1074,6 @@ export class EntityRegistrySettingsEditor extends LitElement {
this.helperConfigEntry.domain !== "switch_as_x"
? html`
<ha-list-item-button
wrap-supporting-text
class="menu-item"
.disabled=${this.disabled}
@click=${this._showOptionsFlow}
@@ -1107,7 +1106,6 @@ export class EntityRegistrySettingsEditor extends LitElement {
: nothing
}
<ha-list-item-button
wrap-supporting-text
class="menu-item"
.disabled=${this.disabled}
@click=${this._handleVoiceAssistantsClicked}
@@ -1136,7 +1134,6 @@ export class EntityRegistrySettingsEditor extends LitElement {
supportsFeature(stateObj, VacuumEntityFeature.CLEAN_AREA)
? html`
<ha-list-item-button
wrap-supporting-text
class="menu-item"
.disabled=${this.disabled}
@click=${this._handleVacuumSegmentMappingClicked}
@@ -1174,7 +1171,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
: nothing
}
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.enabled_label"
@@ -1214,7 +1211,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
: nothing
}
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.visible_label"
@@ -1236,7 +1233,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
${
this.entry.device_id
? html`
<ha-row-item wrap-supporting-text class="device-area">
<ha-row-item class="device-area">
<span slot="headline"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.use_device_area"
@@ -2016,6 +2013,11 @@ export class EntityRegistrySettingsEditor extends LitElement {
ha-input.entityId ha-icon-button:last-child {
margin-inline-start: 0;
}
ha-row-item::part(supporting-text),
ha-list-item-button::part(supporting-text) {
white-space: normal;
}
ha-row-item {
--ha-row-item-padding-inline: 0;
}
@@ -127,8 +127,7 @@ class DialogMatterAddDevice extends LitElement {
private get _waitForCommissioningFinish(): boolean {
// When the app supports reporting Matter commissioning status, defer
// advancing past the spinner of its own flow until we receive
// matter/commission/finish.
// advancing past the spinner until we receive matter/commission/finish.
return !!this.hass.auth.external?.config.hasMatterStatusReport;
}
@@ -136,13 +135,7 @@ class DialogMatterAddDevice extends LitElement {
if (!this._newDevice) {
return;
}
// Only the app's own flow, started from the "new" step, reports back.
// The other steps commission through core or another app.
if (
this._step === "new" &&
this._waitForCommissioningFinish &&
!this._commissioningFinished
) {
if (this._waitForCommissioningFinish && !this._commissioningFinished) {
return;
}
this._step = "device_added";
@@ -156,8 +149,6 @@ class DialogMatterAddDevice extends LitElement {
if (this._newDevice) {
// Device already showed up in the registry — ignore the failure signal
// and let the user finish the rename flow.
this._commissioningFinished = true;
this._maybeShowDeviceAdded();
return;
}
showToast(this, {
@@ -178,7 +178,6 @@ export class MatterConfigDashboard extends LitElement {
)}
>
<ha-list-item-button
wrap-headline
href=${`/config/devices/dashboard?historyBack=1&config_entry=${this._configEntry?.entry_id}&status=disabled`}
>
<ha-svg-icon slot="start" .path=${mdiDevices}></ha-svg-icon>
@@ -191,7 +190,6 @@ export class MatterConfigDashboard extends LitElement {
<ha-icon-next slot="end"></ha-icon-next>
</ha-list-item-button>
<ha-list-item-button
wrap-headline
href=${`/config/entities?historyBack=1&config_entry=${this._configEntry?.entry_id}`}
>
<ha-svg-icon slot="start" .path=${mdiShape}></ha-svg-icon>
@@ -218,11 +216,7 @@ export class MatterConfigDashboard extends LitElement {
"ui.panel.config.matter.panel.options_title"
)}
>
<ha-list-item-button
wrap-headline
wrap-supporting-text
href="/config/matter/options"
>
<ha-list-item-button href="/config/matter/options">
<ha-svg-icon slot="start" .path=${mdiTune}></ha-svg-icon>
<div slot="headline">
${this.hass.localize(
@@ -238,11 +232,7 @@ export class MatterConfigDashboard extends LitElement {
</ha-list-item-button>
${
isComponentLoaded(this.hass.config, "thread")
? html`<ha-list-item-button
wrap-headline
wrap-supporting-text
href="/config/thread"
>
? html`<ha-list-item-button href="/config/thread">
<ha-svg-icon
slot="start"
.path=${THREAD_ICON}
@@ -309,6 +299,11 @@ export class MatterConfigDashboard extends LitElement {
max-width: var(--ha-content-width-narrow);
}
ha-list-item-button::part(headline),
ha-list-item-button::part(supporting-text) {
white-space: normal;
}
.nav-card {
overflow: hidden;
}
@@ -56,7 +56,7 @@ class MatterOptionsPage extends LitElement {
}
${
canCommissionMatterExternal(this.hass)
? html`<ha-row-item wrap-headline wrap-supporting-text>
? html`<ha-row-item>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.matter.panel.mobile_app_commisioning"
@@ -80,7 +80,7 @@ class MatterOptionsPage extends LitElement {
</ha-row-item>`
: nothing
}
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.matter.panel.commission_device"
@@ -102,7 +102,7 @@ class MatterOptionsPage extends LitElement {
)}
</ha-button>
</ha-row-item>
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.matter.panel.add_shared_device"
@@ -124,7 +124,7 @@ class MatterOptionsPage extends LitElement {
)}
</ha-button>
</ha-row-item>
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.matter.panel.set_wifi_credentials"
@@ -146,7 +146,7 @@ class MatterOptionsPage extends LitElement {
)}
</ha-button>
</ha-row-item>
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.matter.panel.set_thread_credentials"
@@ -320,6 +320,11 @@ class MatterOptionsPage extends LitElement {
max-width: var(--ha-content-width-narrow);
margin: auto;
}
ha-row-item::part(headline),
ha-row-item::part(supporting-text) {
white-space: normal;
}
`,
];
}
@@ -221,7 +221,6 @@ export class MQTTConfigPanel extends LitElement {
)}
>
<ha-list-item-button
wrap-headline
href=${`/config/devices/dashboard?historyBack=1&config_entry=${this._configEntry?.entry_id}&status=disabled`}
>
<ha-svg-icon slot="start" .path=${mdiDevices}></ha-svg-icon>
@@ -233,7 +232,6 @@ export class MQTTConfigPanel extends LitElement {
<ha-icon-next slot="end"></ha-icon-next>
</ha-list-item-button>
<ha-list-item-button
wrap-headline
href=${`/config/entities?historyBack=1&config_entry=${this._configEntry?.entry_id}`}
>
<ha-svg-icon slot="start" .path=${mdiShape}></ha-svg-icon>
@@ -255,11 +253,7 @@ export class MQTTConfigPanel extends LitElement {
<ha-card class="nav-card">
<div class="card-content">
<ha-list-base>
<ha-list-item-button
wrap-headline
wrap-supporting-text
@click=${this._openOptionFlow}
>
<ha-list-item-button @click=${this._openOptionFlow}>
<ha-svg-icon slot="start" .path=${mdiTune}></ha-svg-icon>
<div slot="headline">
${this.hass.localize("ui.panel.config.mqtt.option_flow")}
@@ -271,11 +265,7 @@ export class MQTTConfigPanel extends LitElement {
</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-list-item-button>
<ha-list-item-button
wrap-headline
wrap-supporting-text
@click=${this._openConfigFlow}
>
<ha-list-item-button @click=${this._openConfigFlow}>
<ha-svg-icon slot="start" .path=${mdiMqttLogo}></ha-svg-icon>
<div slot="headline">
${this.hass.localize("ui.panel.config.mqtt.config_flow")}
@@ -450,6 +440,10 @@ export class MQTTConfigPanel extends LitElement {
margin: 0 auto var(--ha-space-4);
max-width: var(--ha-content-width-narrow);
}
ha-list-item-button::part(headline),
ha-list-item-button::part(supporting-text) {
white-space: normal;
}
ha-select {
width: 96px;
margin: 0 8px;
@@ -159,7 +159,7 @@ class ThreadNetworkInfoPage extends LitElement {
if (value === null) {
return nothing;
}
return html`<ha-list-item-base wrap-supporting-text>
return html`<ha-list-item-base>
<span slot="headline">${label}</span>
<span slot="supporting-text">${value}</span>
</ha-list-item-base>`;
@@ -180,6 +180,7 @@ class ThreadNetworkInfoPage extends LitElement {
ha-list-item-base::part(supporting-text) {
font-size: var(--ha-font-size-m);
white-space: normal;
overflow-wrap: anywhere;
}
`,
@@ -237,7 +237,6 @@ class ZHAConfigDashboard extends LitElement {
)}
>
<ha-list-item-button
wrap-headline
href=${`/config/devices/dashboard?historyBack=1&config_entry=${this._configEntry?.entry_id}&status=disabled`}
>
<ha-svg-icon slot="start" .path=${mdiDevices}></ha-svg-icon>
@@ -250,7 +249,6 @@ class ZHAConfigDashboard extends LitElement {
<ha-icon-next slot="end"></ha-icon-next>
</ha-list-item-button>
<ha-list-item-button
wrap-headline
href=${`/config/entities?historyBack=1&config_entry=${this._configEntry?.entry_id}`}
>
<ha-svg-icon slot="start" .path=${mdiShape}></ha-svg-icon>
@@ -262,7 +260,7 @@ class ZHAConfigDashboard extends LitElement {
</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-list-item-button>
<ha-list-item-button wrap-headline href="/config/zha/groups">
<ha-list-item-button href="/config/zha/groups">
<ha-svg-icon
slot="start"
.path=${mdiFolderMultipleOutline}
@@ -309,11 +307,7 @@ class ZHAConfigDashboard extends LitElement {
"ui.panel.config.zha.configuration_page.options_title"
)}
>
<ha-list-item-button
wrap-headline
wrap-supporting-text
href="/config/zha/options"
>
<ha-list-item-button href="/config/zha/options">
<ha-svg-icon slot="start" .path=${mdiTune}></ha-svg-icon>
<div slot="headline">
${this.hass.localize(
@@ -327,11 +321,7 @@ class ZHAConfigDashboard extends LitElement {
</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-list-item-button>
<ha-list-item-button
wrap-headline
wrap-supporting-text
href="/config/zha/network-info"
>
<ha-list-item-button href="/config/zha/network-info">
<ha-svg-icon
slot="start"
.path=${mdiInformationOutline}
@@ -350,10 +340,7 @@ class ZHAConfigDashboard extends LitElement {
</ha-list-item-button>
${dynamicSections.map(
(section) => html`
<ha-list-item-button
wrap-headline
href=${`/config/zha/section/${section}`}
>
<ha-list-item-button href=${`/config/zha/section/${section}`}>
<ha-svg-icon slot="start" .path=${mdiTune}></ha-svg-icon>
<div slot="headline">
${
@@ -377,7 +364,7 @@ class ZHAConfigDashboard extends LitElement {
<ha-card class="nav-card">
<div class="card-content">
<ha-list-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.zha.configuration_page.download_backup"
@@ -402,7 +389,7 @@ class ZHAConfigDashboard extends LitElement {
)}
</ha-progress-button>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.zha.configuration_page.migrate_radio"
@@ -536,6 +523,13 @@ class ZHAConfigDashboard extends LitElement {
max-width: var(--ha-content-width-narrow);
}
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text),
ha-list-item-button::part(headline),
ha-list-item-button::part(supporting-text) {
white-space: normal;
}
.nav-card .card-header {
display: flex;
align-items: center;
@@ -54,7 +54,7 @@ class ZHANetworkInfoPage extends LitElement {
${
this._networkSettings
? html`<ha-list-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.channel_label"
@@ -74,7 +74,7 @@ class ZHANetworkInfoPage extends LitElement {
@click=${this._showChannelMigrationDialog}
></ha-icon-button>
</ha-list-item-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">PAN ID</span>
<span slot="supporting-text"
>${
@@ -82,7 +82,7 @@ class ZHANetworkInfoPage extends LitElement {
}</span
>
</ha-list-item-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">Extended PAN ID</span>
<span slot="supporting-text"
>${
@@ -91,13 +91,13 @@ class ZHANetworkInfoPage extends LitElement {
}</span
>
</ha-list-item-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">Coordinator IEEE</span>
<span slot="supporting-text"
>${this._networkSettings.settings.node_info.ieee}</span
>
</ha-list-item-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.radio_type"
@@ -107,7 +107,7 @@ class ZHANetworkInfoPage extends LitElement {
>${this._networkSettings.radio_type}</span
>
</ha-list-item-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.serial_port"
@@ -121,7 +121,7 @@ class ZHANetworkInfoPage extends LitElement {
this._networkSettings.device.baudrate &&
!this._networkSettings.device.path.startsWith("socket://")
? html`
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.baudrate"
@@ -177,6 +177,7 @@ class ZHANetworkInfoPage extends LitElement {
ha-list-item-base::part(supporting-text) {
font-size: var(--ha-font-size-m);
white-space: normal;
}
`,
];
@@ -116,7 +116,7 @@ class ZHAOptionsPage extends LitElement {
this._configuration
? html`
<ha-list-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.enable_identify_on_join_label"
@@ -136,7 +136,7 @@ class ZHAOptionsPage extends LitElement {
@change=${this._enableIdentifyOnJoinChanged}
></ha-switch>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.default_light_transition_label"
@@ -161,7 +161,7 @@ class ZHAOptionsPage extends LitElement {
<span slot="end">s</span>
</ha-input>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.enhanced_light_transition_label"
@@ -181,7 +181,7 @@ class ZHAOptionsPage extends LitElement {
@change=${this._enhancedLightTransitionChanged}
></ha-switch>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.light_transitioning_flag_label"
@@ -201,7 +201,7 @@ class ZHAOptionsPage extends LitElement {
@change=${this._lightTransitioningFlagChanged}
></ha-switch>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.group_members_assume_state_label"
@@ -221,7 +221,7 @@ class ZHAOptionsPage extends LitElement {
@change=${this._groupMembersAssumeStateChanged}
></ha-switch>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.consider_unavailable_mains_label"
@@ -265,7 +265,7 @@ class ZHAOptionsPage extends LitElement {
`
: nothing
}
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.consider_unavailable_battery_label"
@@ -309,7 +309,7 @@ class ZHAOptionsPage extends LitElement {
`
: nothing
}
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.zha.configuration_page.enable_mains_startup_polling_label"
@@ -463,6 +463,11 @@ class ZHAOptionsPage extends LitElement {
margin: auto;
}
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: normal;
}
ha-select,
ha-input {
min-width: 210px;
@@ -78,7 +78,7 @@ class ZWaveJSControllerStatistics extends SubscribeMixin(LitElement) {
private _renderStat(key: string) {
return html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
`ui.panel.config.zwave_js.dashboard.statistics.${key}.label`
@@ -104,6 +104,11 @@ class ZWaveJSControllerStatistics extends SubscribeMixin(LitElement) {
max-width: var(--ha-content-width-narrow);
}
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: normal;
}
span[slot="end"] {
font-size: 0.95em;
color: var(--primary-text-color);
@@ -50,7 +50,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
${
this._network
? html`<ha-list-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.zwave_js.dashboard.home_id"
@@ -66,7 +66,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
}
</span>
</ha-list-item-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.zwave_js.dashboard.driver_version"
@@ -76,7 +76,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
${this._network.client.driver_version}
</span>
</ha-list-item-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.zwave_js.dashboard.server_version"
@@ -86,7 +86,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
${this._network.client.server_version}
</span>
</ha-list-item-base>
<ha-list-item-base wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.zwave_js.dashboard.server_url"
@@ -120,6 +120,7 @@ class ZWaveJSNetworkInfoPage extends LitElement {
ha-list-item-base::part(supporting-text) {
font-size: var(--ha-font-size-m);
white-space: normal;
}
`,
];
@@ -62,7 +62,7 @@ class ZWaveJSOptionsPage extends LitElement {
${
this._network
? html`<ha-list-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.zwave_js.common.rebuild_network_routes"
@@ -85,7 +85,7 @@ class ZWaveJSOptionsPage extends LitElement {
)}
</ha-button>
</ha-list-item-base>
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline">
${this.hass.localize(
"ui.panel.config.zwave_js.common.remove_node"
@@ -149,6 +149,11 @@ class ZWaveJSOptionsPage extends LitElement {
max-width: var(--ha-content-width-narrow);
margin: auto;
}
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: normal;
}
`,
];
}
@@ -64,11 +64,7 @@ class HaConfigSectionNetwork extends LitElement {
>
${NETWORK_BROWSERS.map(
(domain) => html`
<ha-list-item-button
wrap-headline
wrap-supporting-text
href="/config/${domain}"
>
<ha-list-item-button href="/config/${domain}">
<div slot="headline">
${this.hass.localize(
`ui.panel.config.network.discovery.${domain}`
@@ -108,6 +104,10 @@ class HaConfigSectionNetwork extends LitElement {
display: block;
margin-bottom: 24px;
}
.discovery-card ha-list-item-button::part(headline),
.discovery-card ha-list-item-button::part(supporting-text) {
white-space: normal;
}
`;
}
@@ -1,5 +1,5 @@
import type { TemplateResult } from "lit";
import { html, LitElement } from "lit";
import { css, html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../../components/item/ha-list-item-base";
import "../../../../components/ha-switch";
@@ -14,7 +14,7 @@ class HaDebugConnectionRow extends LitElement {
protected render(): TemplateResult {
return html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.tools.tabs.debug.debug_connection.title"
@@ -43,6 +43,13 @@ class HaDebugConnectionRow extends LitElement {
setDebugConnection(debugConnection);
storeState(this.hass);
}
static styles = css`
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: normal;
}
`;
}
declare global {
@@ -1,5 +1,5 @@
import type { TemplateResult } from "lit";
import { html, LitElement } from "lit";
import { css, html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import { storage } from "../../../../common/decorators/storage";
import { setViewTransitionDisabled } from "../../../../common/util/view-transition";
@@ -17,7 +17,7 @@ class HaDebugDisableViewTransitionRow extends LitElement {
protected render(): TemplateResult {
return html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.tools.tabs.debug.disable_view_transition.title"
@@ -41,6 +41,13 @@ class HaDebugDisableViewTransitionRow extends LitElement {
this._disabled = (ev.target as HaSwitch).checked;
setViewTransitionDisabled(this._disabled);
}
static styles = css`
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: normal;
}
`;
}
declare global {
@@ -1,4 +1,4 @@
import { html, LitElement } from "lit";
import { css, html, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import { consumeLocalize } from "../../../../common/decorators/consume-context-entry";
import { storage } from "../../../../common/decorators/storage";
@@ -19,7 +19,7 @@ class HaDebugSafeAreaToolRow extends LitElement {
protected render() {
return html`
<ha-list-item-base wrap-headline wrap-supporting-text>
<ha-list-item-base>
<span slot="headline"
>${this._localize(
"ui.panel.config.tools.tabs.debug.safe_area_tool.title"
@@ -42,6 +42,13 @@ class HaDebugSafeAreaToolRow extends LitElement {
private _checkedChanged(ev: Event) {
this._enabled = (ev.target as HaSwitch).checked;
}
static styles = css`
ha-list-item-base::part(headline),
ha-list-item-base::part(supporting-text) {
white-space: normal;
}
`;
}
declare global {
@@ -212,7 +212,7 @@ export class AssistPref extends LitElement {
)}
<ha-svg-icon slot="start" .path=${mdiPlus}></ha-svg-icon>
</ha-button>
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass!.localize(
"ui.panel.config.voice_assistants.expose.expose_new_entities"
@@ -415,6 +415,10 @@ export class AssistPref extends LitElement {
a {
color: var(--primary-color);
}
ha-row-item::part(headline),
ha-row-item::part(supporting-text) {
white-space: normal;
}
.header-actions {
position: absolute;
right: 0px;
@@ -139,7 +139,7 @@ export class CloudAlexaPref extends LitElement {
</ha-alert>`
: nothing
}
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass!.localize(
"ui.panel.config.cloud.account.alexa.expose_new_entities"
@@ -160,7 +160,7 @@ export class CloudAlexaPref extends LitElement {
${
alexa_registered
? html`
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass!.localize(
"ui.panel.config.cloud.account.alexa.enable_state_reporting"
@@ -265,6 +265,10 @@ export class CloudAlexaPref extends LitElement {
ha-row-item {
--ha-row-item-padding-inline: 0;
}
ha-row-item::part(headline),
ha-row-item::part(supporting-text) {
white-space: normal;
}
.header-actions {
position: absolute;
right: 24px;
@@ -138,7 +138,7 @@ export class CloudGooglePref extends LitElement {
`
: nothing
}
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass!.localize(
"ui.panel.config.cloud.account.google.expose_new_entities"
@@ -183,7 +183,7 @@ export class CloudGooglePref extends LitElement {
`
: nothing
}
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass!.localize(
"ui.panel.config.cloud.account.google.enable_state_reporting"
@@ -201,7 +201,7 @@ export class CloudGooglePref extends LitElement {
></ha-switch>
</ha-row-item>
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass.localize(
"ui.panel.config.cloud.account.google.security_devices"
@@ -347,6 +347,10 @@ export class CloudGooglePref extends LitElement {
ha-row-item {
--ha-row-item-padding-inline: 0;
}
ha-row-item::part(headline),
ha-row-item::part(supporting-text) {
white-space: normal;
}
ha-input {
width: 250px;
margin-top: 8px;
@@ -193,7 +193,7 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
const exposedToAssist = this.exposed.conversation;
return html`
<ha-row-item wrap-headline>
<ha-row-item>
<h3 slot="headline">
${this.hass.localize("ui.dialogs.voice-settings.expose_header")}
</h3>
@@ -227,7 +227,7 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
this._googleEntity?.might_2fa;
return html`
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<voice-assistant-brand-icon
slot="start"
.voiceAssistantId=${key}
@@ -324,7 +324,7 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
)}
</ha-alert>`
: html`
<ha-row-item wrap-headline wrap-supporting-text>
<ha-row-item>
<span slot="headline">${this._computedName(this.entry)}</span>
<span slot="supporting-text">
${this.hass.localize(
@@ -457,6 +457,10 @@ export class EntityVoiceSettings extends SubscribeMixin(LitElement) {
ha-row-item {
--ha-row-item-padding-inline: 0;
}
ha-row-item::part(headline),
ha-row-item::part(supporting-text) {
white-space: normal;
}
img {
height: 32px;
width: 32px;
@@ -16,6 +16,7 @@ import "../../../components/ha-svg-icon";
import "../components/hui-badge-edit-mode";
import { moveAtPath } from "../editor/lovelace-path";
import type { Lovelace } from "../types";
import { isLayoutEditMode } from "../types";
import type { HuiBadge } from "./hui-badge";
const BADGE_SORTABLE_OPTIONS: HaSortableOptions = {
@@ -46,7 +47,8 @@ export class HuiViewBadges extends LitElement {
private _checkAllHidden() {
const allHidden =
!this.lovelace.editMode && this.badges.every((section) => section.hidden);
!isLayoutEditMode(this.lovelace) &&
this.badges.every((section) => section.hidden);
this.toggleAttribute("hidden", allHidden);
}
@@ -125,7 +127,7 @@ export class HuiViewBadges extends LitElement {
render() {
if (!this.lovelace) return nothing;
const editMode = this.lovelace.editMode;
const editMode = isLayoutEditMode(this.lovelace);
const badges = this.badges;
@@ -1,193 +0,0 @@
import { mdiEye, mdiEyeOff } from "@mdi/js";
import type { CSSResultGroup, PropertyValues } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import type { HASSDomEvent } from "../../../common/dom/fire_event";
import { fireEvent } from "../../../common/dom/fire_event";
import "../../../components/ha-svg-icon";
import type { HomeAssistant } from "../../../types";
import "./hui-card";
import type { HuiCard } from "./hui-card";
import type { LovelaceCard, LovelaceGridOptions } from "../types";
import type { EntityVisibilityCardConfig } from "./types";
@customElement("hui-entity-visibility-card")
export class HuiEntityVisibilityCard
extends LitElement
implements LovelaceCard
{
@property({ attribute: false }) public hass?: HomeAssistant;
@property({ type: Boolean }) public preview = false;
@state() private _config?: EntityVisibilityCardConfig;
private _card?: HuiCard;
public setConfig(config: EntityVisibilityCardConfig): void {
if (!config.entity) {
throw new Error("No entity configured");
}
if (!config.card) {
throw new Error("No card configured");
}
this._config = config;
this._card = document.createElement("hui-card");
this._card.hass = this.hass;
this._card.preview = this.preview;
this._card.config = config.card;
this._card.inert = true;
this._card.load();
}
public getCardSize(): number | Promise<number> {
return this._card?.getCardSize() ?? 1;
}
public getGridOptions(): LovelaceGridOptions {
return this._card?.getGridOptions() ?? {};
}
public connectedCallback(): void {
super.connectedCallback();
window.addEventListener(
"entity-visibility-changed",
this._entityVisibilityChanged
);
}
public disconnectedCallback(): void {
super.disconnectedCallback();
window.removeEventListener(
"entity-visibility-changed",
this._entityVisibilityChanged
);
}
protected willUpdate(changedProps: PropertyValues<this>): void {
super.willUpdate(changedProps);
if (!this._card) {
return;
}
if (changedProps.has("hass")) {
this._card.hass = this.hass;
}
if (changedProps.has("preview")) {
this._card.preview = this.preview;
}
}
protected render() {
if (!this._config || !this.hass || !this._card) {
return nothing;
}
const hidden = Boolean(this._config.hidden);
const stateObj = this.hass.states[this._config.entity];
const name = stateObj
? this.hass.formatEntityName(stateObj)
: this._config.entity;
return html`
<div class="wrapper" ?hidden-entity=${hidden}>
${this._card}
<button
class="control"
aria-label=${this.hass.localize(
`ui.components.items-display-editor.${hidden ? "show" : "hide"}`,
{ label: name }
)}
@click=${this._toggle}
>
<ha-svg-icon .path=${hidden ? mdiEyeOff : mdiEye}></ha-svg-icon>
</button>
</div>
`;
}
private _entityVisibilityChanged = (
ev: HASSDomEvent<HASSDomEvents["entity-visibility-changed"]>
) => {
if (
this._config?.hidden === undefined ||
ev.detail.entity !== this._config.entity ||
ev.detail.hidden === this._config.hidden
) {
return;
}
this._config = { ...this._config, hidden: ev.detail.hidden };
};
private _toggle(): void {
if (!this._config) {
return;
}
const hidden = !this._config.hidden;
this._config = { ...this._config, hidden };
fireEvent(this, "entity-visibility-changed", {
entity: this._config.entity,
hidden,
});
}
static styles: CSSResultGroup = css`
.wrapper {
position: relative;
height: 100%;
border-radius: var(--ha-card-border-radius, var(--ha-border-radius-lg));
}
hui-card {
display: block;
height: 100%;
}
.wrapper[hidden-entity] hui-card {
opacity: 0.8;
}
.wrapper[hidden-entity]::after {
content: "";
position: absolute;
inset: 0;
border: 2px dotted var(--secondary-text-color);
border-radius: inherit;
pointer-events: none;
}
.control {
position: absolute;
inset: 0;
z-index: 1;
display: flex;
align-items: flex-end;
justify-content: flex-end;
margin: 0;
padding: var(--ha-space-2);
border: none;
background: none;
border-radius: inherit;
cursor: pointer;
color: var(--primary-text-color);
}
.control:focus-visible {
outline: 2px solid var(--primary-color);
}
.control ha-svg-icon {
display: flex;
padding: var(--ha-space-1);
border-radius: var(--ha-border-radius-circle);
background: var(--secondary-background-color);
box-shadow: var(--ha-box-shadow-s);
--mdc-icon-size: 20px;
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"hui-entity-visibility-card": HuiEntityVisibilityCard;
}
interface GlobalEventHandlersEventMap {
"entity-visibility-changed": HASSDomEvent<
HASSDomEvents["entity-visibility-changed"]
>;
}
interface HASSDomEvents {
"entity-visibility-changed": { entity: string; hidden: boolean };
}
}
-6
View File
@@ -71,12 +71,6 @@ export interface ConditionalCardConfig extends LovelaceCardConfig {
conditions: VisibilityCondition[];
}
export interface EntityVisibilityCardConfig extends LovelaceCardConfig {
entity: string;
hidden?: boolean;
card: LovelaceCardConfig;
}
export interface EmptyStateButtonConfig {
text: string;
icon?: string;
@@ -36,10 +36,6 @@ declare global {
const DOUBLE_CLICK_TIME = 250;
// How far (px) a finger may move before a press counts as a drag or scroll,
// in line with the touch slop of the native platforms.
const TOUCH_SLOP = 10;
// The coordinates of the pointer that changed: for touch events the finger
// that just went down/up (touches[0] would be the *first* finger during a
// multi-touch), for mouse events the pointer itself.
@@ -63,9 +59,6 @@ class ActionHandler extends HTMLElement implements ActionHandlerType {
private cancelled = false;
// Where the finger of the touch in flight went down.
private touchStart?: { x: number; y: number };
private dblClickTimeout?: number;
// The double-tap window only pairs two taps on the same target; a quick tap
@@ -92,47 +85,28 @@ class ActionHandler extends HTMLElement implements ActionHandlerType {
transition: "transform 180ms ease-in-out",
});
const cancel = () => {
this.cancelled = true;
if (this.timer) {
this._stopAnimation();
clearTimeout(this.timer);
this.timer = undefined;
}
};
// pointercancel is how the browser says it took over the touch, e.g. to
// scroll a nested scroller whose scroll event never reaches the document.
[
"touchcancel",
"pointercancel",
"mouseout",
"mouseup",
"touchmove",
"mousewheel",
"wheel",
"scroll",
].forEach((ev) => {
document.addEventListener(ev, cancel, { passive: true });
});
// A finger always moves a little while it is down, so only movement past
// the touch slop turns a tap or hold into a drag.
document.addEventListener(
"touchmove",
(ev: TouchEvent) => {
if (this.touchStart && activeTouchCount(ev) <= 1) {
const { x, y } = eventCoordinates(ev);
if (
Math.hypot(x - this.touchStart.x, y - this.touchStart.y) <=
TOUCH_SLOP
) {
return;
document.addEventListener(
ev,
() => {
this.cancelled = true;
if (this.timer) {
this._stopAnimation();
clearTimeout(this.timer);
this.timer = undefined;
}
}
cancel();
},
{ passive: true }
);
},
{ passive: true }
);
});
}
public bind(
@@ -192,7 +166,6 @@ class ActionHandler extends HTMLElement implements ActionHandlerType {
element.actionHandler.start = (ev: Event) => {
this.cancelled = false;
const { x, y } = eventCoordinates(ev);
this.touchStart = ev.type === "touchstart" ? { x, y } : undefined;
if (options.resolve) {
this.resolved = undefined;
@@ -0,0 +1,127 @@
import { mdiEye, mdiEyeOff } from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { CSSResultGroup } from "lit";
import { LitElement, css, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import { consume } from "../../../common/decorators/consume";
import {
consumeEntityState,
consumeLocalize,
} from "../../../common/decorators/consume-context-entry";
import type { HASSDomEvent } from "../../../common/dom/fire_event";
import { fireEvent } from "../../../common/dom/fire_event";
import type { LocalizeFunc } from "../../../common/translations/localize";
import "../../../components/ha-svg-icon";
import { formattersContext } from "../../../data/context";
import type { HomeAssistantFormatters } from "../../../types";
@customElement("hui-card-visibility-edit-mode")
export class HuiCardVisibilityEditMode extends LitElement {
@property() public entity!: string;
@property({ type: Boolean, reflect: true, attribute: "entity-hidden" })
public entityHidden = false;
@state()
@consumeLocalize()
private _localize!: LocalizeFunc;
@state()
@consumeEntityState({ entityIdPath: ["entity"] })
private _stateObj?: HassEntity;
@state()
@consume({ context: formattersContext, subscribe: true })
private _formatters!: HomeAssistantFormatters;
protected render() {
const name = this._stateObj
? this._formatters.formatEntityName(this._stateObj)
: this.entity;
return html`
<div class="card-wrapper" inert><slot></slot></div>
<button
class="control"
aria-label=${this._localize(
`ui.components.items-display-editor.${this.entityHidden ? "show" : "hide"}`,
{ label: name }
)}
@click=${this._toggle}
>
<ha-svg-icon
.path=${this.entityHidden ? mdiEyeOff : mdiEye}
></ha-svg-icon>
</button>
`;
}
private _toggle(): void {
fireEvent(this, "entity-visibility-changed", {
entity: this.entity,
hidden: !this.entityHidden,
});
}
static styles: CSSResultGroup = css`
:host {
display: block;
position: relative;
height: 100%;
border-radius: var(--ha-card-border-radius, var(--ha-border-radius-lg));
}
.card-wrapper {
height: 100%;
}
:host([entity-hidden]) .card-wrapper {
opacity: 0.8;
}
:host([entity-hidden])::after {
content: "";
position: absolute;
inset: 0;
border: 2px dotted var(--secondary-text-color);
border-radius: inherit;
pointer-events: none;
}
.control {
position: absolute;
inset: 0;
z-index: 1;
display: flex;
align-items: flex-end;
justify-content: flex-end;
margin: 0;
padding: var(--ha-space-2);
border: none;
background: none;
border-radius: inherit;
cursor: pointer;
color: var(--primary-text-color);
}
.control:focus-visible {
outline: 2px solid var(--primary-color);
}
.control ha-svg-icon {
display: flex;
padding: var(--ha-space-1);
border-radius: var(--ha-border-radius-circle);
background: var(--secondary-background-color);
box-shadow: var(--ha-box-shadow-s);
--mdc-icon-size: 20px;
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"hui-card-visibility-edit-mode": HuiCardVisibilityEditMode;
}
interface GlobalEventHandlersEventMap {
"entity-visibility-changed": HASSDomEvent<
HASSDomEvents["entity-visibility-changed"]
>;
}
interface HASSDomEvents {
"entity-visibility-changed": { entity: string; hidden: boolean };
}
}
@@ -38,7 +38,6 @@ const LAZY_LOAD_TYPES = {
area: () => import("../cards/hui-area-card"),
calendar: () => import("../cards/hui-calendar-card"),
conditional: () => import("../cards/hui-conditional-card"),
"entity-visibility": () => import("../cards/hui-entity-visibility-card"),
"empty-state": () => import("../cards/hui-empty-state-card"),
"energy-compare": () => import("../cards/energy/hui-energy-compare-card"),
"energy-carbon-consumed-gauge": () =>
@@ -118,7 +118,7 @@ export class HuiCardLayoutEditor extends LitElement {
`
: nothing
}
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass.localize(
"ui.panel.lovelace.editor.edit_card.layout.recommended_size"
@@ -151,7 +151,7 @@ export class HuiCardLayoutEditor extends LitElement {
.columnMax=${gridOptions.max_columns}
.step=${this._preciseMode ? 1 : GRID_COLUMN_MULTIPLIER}
></ha-grid-size-picker>
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass.localize(
"ui.panel.lovelace.editor.edit_card.layout.fit_content"
@@ -169,7 +169,7 @@ export class HuiCardLayoutEditor extends LitElement {
name="auto-height"
></ha-switch>
</ha-row-item>
<ha-row-item wrap-supporting-text>
<ha-row-item>
<span slot="headline"
>${this.hass.localize(
"ui.panel.lovelace.editor.edit_card.layout.full_width"
@@ -425,6 +425,9 @@ export class HuiCardLayoutEditor extends LitElement {
opacity: 0.5;
pointer-events: none;
}
ha-row-item::part(supporting-text) {
white-space: normal;
}
ha-grid-size-picker {
display: block;
margin: 16px auto;
@@ -18,8 +18,10 @@ import type { HomeAssistant } from "../../../types";
import type { HuiCard } from "../cards/hui-card";
import { computeCardGridSize } from "../common/compute-card-grid-size";
import "../components/hui-card-edit-mode";
import "../components/hui-card-visibility-edit-mode";
import { moveAtPath } from "../editor/lovelace-path";
import type { Lovelace } from "../types";
import { isLayoutEditMode } from "../types";
const CARD_SORTABLE_OPTIONS: HaSortableOptions = {
delay: 100,
@@ -78,7 +80,10 @@ export class GridSection extends LitElement implements LovelaceSectionElement {
const cardsConfig = this._config?.cards ?? [];
const editMode = Boolean(this.lovelace?.editMode && !this.isStrategy);
const editMode = isLayoutEditMode(this.lovelace) && !this.isStrategy;
const visibility = this.lovelace?.editMode
? this.lovelace.entityVisibility
: undefined;
const sortableOptions = this.importOnly
? IMPORT_MODE_CARD_SORTABLE_OPTIONS
@@ -104,7 +109,7 @@ export class GridSection extends LitElement implements LovelaceSectionElement {
${repeat(
cardsConfig,
(cardConfig) => this._getKey(cardConfig),
(_cardConfig, idx) => {
(cardConfig, idx) => {
const card = this.cards![idx];
card.layout = "grid";
const gridOptions = card.getGridOptions();
@@ -126,6 +131,10 @@ export class GridSection extends LitElement implements LovelaceSectionElement {
"full-width": columns === "full",
hidden: !editMode && card.hidden,
})}"
?inert=${
visibility !== undefined &&
typeof cardConfig.entity !== "string"
}
.sortableData=${cardPath}
>
${
@@ -141,7 +150,18 @@ export class GridSection extends LitElement implements LovelaceSectionElement {
${card}
</hui-card-edit-mode>
`
: card
: visibility && typeof cardConfig.entity === "string"
? html`
<hui-card-visibility-edit-mode
.entity=${cardConfig.entity}
.entityHidden=${visibility.hiddenEntities.includes(
cardConfig.entity
)}
>
${card}
</hui-card-visibility-edit-mode>
`
: card
}
</div>
`;
@@ -1,13 +0,0 @@
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
import type { EntityVisibilityCardConfig } from "../../cards/types";
export type ComputeEntityCard = (entityId: string) => LovelaceCardConfig;
export const wrapEntityVisibility =
(hiddenEntities: Set<string>, computeCard: ComputeEntityCard) =>
(entityId: string): EntityVisibilityCardConfig => ({
type: "entity-visibility",
entity: entityId,
hidden: hiddenEntities.has(entityId),
card: computeCard(entityId),
});
+8
View File
@@ -48,8 +48,16 @@ export interface Lovelace {
* window's history and scroll position.
*/
embedded?: boolean;
/**
* Limits edit mode to showing and hiding the entity cards of a generated
* view, instead of editing its layout.
*/
entityVisibility?: { hiddenEntities: string[] };
}
export const isLayoutEditMode = (lovelace?: Lovelace): boolean =>
Boolean(lovelace?.editMode && !lovelace.entityVisibility);
export interface LovelaceBadge extends HTMLElement {
hass?: HomeAssistant;
preview?: boolean;
@@ -37,6 +37,7 @@ import {
sectionContainerStyles,
} from "../sections/section-container";
import type { Lovelace } from "../types";
import { isLayoutEditMode } from "../types";
import { generateDefaultSection } from "./default-section";
import "./hui-view-footer";
import "./hui-view-header";
@@ -191,7 +192,7 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
if (!this.lovelace) return nothing;
const sections = this.sections;
const editMode = this.lovelace.editMode;
const editMode = isLayoutEditMode(this.lovelace);
const hasSidebar =
this._config?.sidebar && (this._sidebarVisible || editMode);
const singleColumn = this._maxColumns <= 1;
+5 -4
View File
@@ -19,6 +19,7 @@ import { showCreateCardDialog } from "../editor/card-editor/show-create-card-dia
import { setAtPath } from "../editor/lovelace-path";
import { showEditViewFooterDialog } from "../editor/view-footer/show-edit-view-footer-dialog";
import type { Lovelace } from "../types";
import { isLayoutEditMode } from "../types";
@customElement("hui-view-footer")
export class HuiViewFooter extends LitElement {
@@ -53,7 +54,7 @@ export class HuiViewFooter extends LitElement {
this.card.hass = this.hass;
}
if (changedProperties.has("lovelace")) {
this.card.preview = this.lovelace.editMode;
this.card.preview = isLayoutEditMode(this.lovelace);
}
}
@@ -69,7 +70,7 @@ export class HuiViewFooter extends LitElement {
private _checkHidden() {
const hidden =
!this.lovelace?.editMode &&
!isLayoutEditMode(this.lovelace) &&
(!this.card || this.card.hasAttribute("hidden"));
this.toggleAttribute("hidden", hidden);
this.toggleAttribute("sticky", Boolean(this.card));
@@ -78,7 +79,7 @@ export class HuiViewFooter extends LitElement {
private _createCardElement(cardConfig: LovelaceCardConfig) {
const element = document.createElement("hui-card");
element.hass = this.hass;
element.preview = this.lovelace.editMode;
element.preview = isLayoutEditMode(this.lovelace);
element.layout = "grid";
element.config = cardConfig;
element.addEventListener("card-updated", (ev: Event) => {
@@ -150,7 +151,7 @@ export class HuiViewFooter extends LitElement {
render() {
if (!this.lovelace) return nothing;
const editMode = Boolean(this.lovelace?.editMode);
const editMode = isLayoutEditMode(this.lovelace);
const card = this.card;
if (!editMode && !card) {
+7 -5
View File
@@ -22,6 +22,7 @@ import { showEditCardDialog } from "../editor/card-editor/show-edit-card-dialog"
import { setAtPath } from "../editor/lovelace-path";
import { showEditViewHeaderDialog } from "../editor/view-header/show-edit-view-header-dialog";
import type { Lovelace } from "../types";
import { isLayoutEditMode } from "../types";
export const DEFAULT_VIEW_HEADER_LAYOUT = "center";
export const DEFAULT_VIEW_HEADER_BADGES_POSITION = "bottom";
@@ -44,7 +45,7 @@ export class HuiViewHeader extends LitElement {
private _checkHidden() {
const allHidden =
!this.card &&
!this.lovelace.editMode &&
!isLayoutEditMode(this.lovelace) &&
this.badges.every((badges) => badges.hidden);
this.toggleAttribute("hidden", allHidden);
}
@@ -87,7 +88,8 @@ export class HuiViewHeader extends LitElement {
if (changedProperties.has("config") || changedProperties.has("lovelace")) {
this._dragScrollController.enabled =
!this.lovelace.editMode && this.config?.badges_wrap === "scroll";
!isLayoutEditMode(this.lovelace) &&
this.config?.badges_wrap === "scroll";
}
if (changedProperties.has("config")) {
@@ -105,7 +107,7 @@ export class HuiViewHeader extends LitElement {
this.card.hass = this.hass;
}
if (changedProperties.has("lovelace")) {
this.card.preview = this.lovelace.editMode;
this.card.preview = isLayoutEditMode(this.lovelace);
}
}
}
@@ -113,7 +115,7 @@ export class HuiViewHeader extends LitElement {
private _createCardElement(cardConfig: LovelaceCardConfig) {
const element = document.createElement("hui-card");
element.hass = this.hass;
element.preview = this.lovelace.editMode;
element.preview = isLayoutEditMode(this.lovelace);
element.config = cardConfig;
element.load();
return element;
@@ -163,7 +165,7 @@ export class HuiViewHeader extends LitElement {
render() {
if (!this.lovelace) return nothing;
const editMode = Boolean(this.lovelace?.editMode);
const editMode = isLayoutEditMode(this.lovelace);
const card = this.card;
@@ -13,6 +13,7 @@ import {
sectionContainerStyles,
} from "../sections/section-container";
import type { Lovelace } from "../types";
import { isLayoutEditMode } from "../types";
import type { LovelaceSectionConfig } from "../../../data/lovelace/config/section";
export const DEFAULT_VIEW_SIDEBAR_LAYOUT = "start";
@@ -74,7 +75,7 @@ export class HuiViewSidebar extends ConditionalListenerMixin<LovelaceViewSidebar
<hui-section
.config=${section}
.hass=${this.hass}
.preview=${this.lovelace.editMode}
.preview=${isLayoutEditMode(this.lovelace)}
.path=${sectionPath}
></hui-section>
`;
+7 -6
View File
@@ -66,6 +66,7 @@ import {
generateLovelaceViewStrategy,
} from "../strategies/get-strategy";
import type { Lovelace } from "../types";
import { isLayoutEditMode } from "../types";
import { PANEL_VIEW_LAYOUT, SIDEBAR_VIEW_LAYOUT } from "./const";
import { getViewType } from "./get-view-type";
@@ -378,7 +379,7 @@ export class HUIView extends ReactiveElement {
private _createCardElement(cardConfig: LovelaceCardConfig) {
const element = document.createElement("hui-card");
element.hass = this.hass;
element.preview = this.lovelace.editMode;
element.preview = isLayoutEditMode(this.lovelace);
element.config = cardConfig;
element.addEventListener("card-updated", (ev: Event) => {
ev.stopPropagation();
@@ -391,7 +392,7 @@ export class HUIView extends ReactiveElement {
public createBadgeElement(badgeConfig: LovelaceBadgeConfig) {
const element = document.createElement("hui-badge");
element.hass = this.hass;
element.preview = this.lovelace.editMode;
element.preview = isLayoutEditMode(this.lovelace);
element.config = badgeConfig;
element.addEventListener("badge-updated", (ev: Event) => {
ev.stopPropagation();
@@ -407,7 +408,7 @@ export class HUIView extends ReactiveElement {
element.hass = this.hass;
element.lovelace = this.lovelace;
element.config = sectionConfig;
element.preview = this.lovelace.editMode;
element.preview = isLayoutEditMode(this.lovelace);
element.addEventListener(
"ll-rebuild",
(ev: Event) => {
@@ -516,16 +517,16 @@ export class HUIView extends ReactiveElement {
try {
element.hass = this.hass;
element.lovelace = this.lovelace;
element.preview = this.lovelace.editMode;
element.preview = isLayoutEditMode(this.lovelace);
} catch (e: any) {
this._rebuildSection(element, createErrorSectionConfig(e.message));
}
});
this._cards.forEach((element) => {
element.preview = this.lovelace.editMode;
element.preview = isLayoutEditMode(this.lovelace);
});
this._badges.forEach((element) => {
element.preview = this.lovelace.editMode;
element.preview = isLayoutEditMode(this.lovelace);
});
}
if (changedProperties.has("_cards")) {
+48 -22
View File
@@ -13,6 +13,7 @@ import {
queueFrontendSystemDataSave,
type MaintenanceFrontendSystemData,
} from "../../data/frontend";
import type { LovelaceConfig } from "../../data/lovelace/config/types";
import type { LovelaceStrategyViewConfig } from "../../data/lovelace/config/view";
import { ChildPanelReady } from "../../layouts/panel-ready";
import { haStyle } from "../../resources/styles";
@@ -42,7 +43,7 @@ class PanelMaintenance extends LitElement {
@state() private _config?: MaintenanceFrontendSystemData;
@state() private _editVisibility = false;
@state() private _editMode = false;
@state() private _searchParams = new URLSearchParams(window.location.search);
@@ -122,7 +123,7 @@ class PanelMaintenance extends LitElement {
if (revision !== this._loadConfigRevision) {
return;
}
this._editVisibility = false;
this._editMode = false;
// eslint-disable-next-line no-console
console.error("Failed to load maintenance configuration:", err);
showToast(this, {
@@ -152,12 +153,12 @@ class PanelMaintenance extends LitElement {
${
!this.hass.user?.is_admin
? nothing
: this._editVisibility
: this._editMode
? html`<ha-button
slot="actionItems"
appearance="filled"
size="s"
@click=${this._stopEditVisibility}
@click=${this._exitEditMode}
>
${this.hass.localize("ui.panel.lovelace.menu.exit_edit_mode")}
</ha-button>`
@@ -166,7 +167,7 @@ class PanelMaintenance extends LitElement {
slot="actionItems"
.path=${mdiPencil}
.label=${this.hass.localize("ui.panel.maintenance.editor.title")}
@click=${this._startEditVisibility}
@click=${this._enterEditMode}
></ha-icon-button>`
: nothing
}
@@ -201,8 +202,9 @@ class PanelMaintenance extends LitElement {
{
strategy: {
...MAINTENANCE_LOVELACE_VIEW_CONFIG.strategy,
hidden_entities: this._config?.hidden_entities,
edit_visibility: this._editVisibility || undefined,
hidden_entities: this._editMode
? undefined
: this._config?.hidden_entities,
},
},
this.hass
@@ -212,42 +214,63 @@ class PanelMaintenance extends LitElement {
return;
}
const config = { views: [viewConfig] };
const rawConfig = { views: [MAINTENANCE_LOVELACE_VIEW_CONFIG] };
const config =
!force &&
this._lovelace &&
deepEqual(viewConfig, this._lovelace.config.views[0])
? this._lovelace.config
: { views: [viewConfig] };
if (!force && deepEqual(config, this._lovelace?.config)) {
if (
config === this._lovelace?.config &&
this._lovelace.editMode === this._editMode &&
deepEqual(
this._lovelace.entityVisibility?.hiddenEntities,
this._config?.hidden_entities ?? []
)
) {
return;
}
this._childPanelReady ??= new ChildPanelReady(this);
this._lovelace = {
this._lovelace = this._createLovelace(config);
}
private _createLovelace(config: LovelaceConfig): Lovelace {
return {
config: config,
rawConfig: rawConfig,
editMode: false,
rawConfig: { views: [MAINTENANCE_LOVELACE_VIEW_CONFIG] },
editMode: this._editMode,
entityVisibility: {
hiddenEntities: this._config?.hidden_entities ?? [],
},
urlPath: "maintenance",
mode: "generated",
locale: this.hass.locale,
enableFullEditMode: () => undefined,
saveConfig: async () => undefined,
deleteConfig: async () => undefined,
setEditMode: () => undefined,
setEditMode: this._setEditMode,
showToast: () => undefined,
};
}
private _startEditVisibility = () => {
this._editVisibility = true;
this._setLovelace();
};
private _stopEditVisibility = () => {
this._editVisibility = false;
if (!this._config) {
private _setEditMode = (editMode: boolean) => {
this._editMode = editMode;
if (!editMode && !this._config) {
this._loadConfigPromise = this._loadConfig();
}
this._setLovelace();
};
private _enterEditMode = () => {
this._setEditMode(true);
};
private _exitEditMode = () => {
this._setEditMode(false);
};
private _visibilityChanged = (
ev: HASSDomEvent<HASSDomEvents["entity-visibility-changed"]>
) => {
@@ -265,6 +288,9 @@ class PanelMaintenance extends LitElement {
...this._config,
hidden_entities: hiddenEntities.length ? hiddenEntities : undefined,
});
if (this._lovelace) {
this._lovelace = this._createLovelace(this._lovelace.config);
}
};
private _saveConfig(config: MaintenanceFrontendSystemData): Promise<void> {
@@ -14,10 +14,6 @@ import type { LovelaceSectionRawConfig } from "../../../data/lovelace/config/sec
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
import type { HomeAssistant } from "../../../types";
import type { TileCardConfig } from "../../lovelace/cards/types";
import {
wrapEntityVisibility,
type ComputeEntityCard,
} from "../../lovelace/strategies/helpers/entity-visibility";
import { BINARY_STATE_ON } from "../../../common/const";
import { computeDomain } from "../../../common/entity/compute_domain";
import { getDeviceEntityDisplayLookup } from "../../../data/device/device_registry";
@@ -26,7 +22,6 @@ import { findBatteryChargingEntity } from "../../../data/entity/entity_registry"
export interface MaintenanceViewStrategyConfig {
type: "maintenance";
hidden_entities?: string[];
edit_visibility?: boolean;
}
export const maintenanceEntityFilters: EntityFilter[] = [
@@ -127,8 +122,7 @@ const computeMaintenanceTileCard = (
const processAreasForBattery = (
areaIds: string[],
hass: HomeAssistant,
entities: string[],
computeCard: ComputeEntityCard
entities: string[]
): LovelaceCardConfig[] => {
const cards: LovelaceCardConfig[] = [];
@@ -150,7 +144,9 @@ const processAreasForBattery = (
const areaCards: LovelaceCardConfig[] = [];
for (const entityId of areaBatteryEntities) {
areaCards.push(computeCard(entityId));
areaCards.push(
computeMaintenanceTileCard(hass.states, hass.entities, entityId)
);
}
if (areaCards.length > 0) {
@@ -174,8 +170,7 @@ const processAreasForBattery = (
const processUnassignedEntities = (
hass: HomeAssistant,
entities: string[],
computeCard: ComputeEntityCard
entities: string[]
): LovelaceCardConfig[] => {
const unassignedFilter = generateEntityFilter(
hass.states,
@@ -191,7 +186,9 @@ const processUnassignedEntities = (
const cards: LovelaceCardConfig[] = [];
for (const entityId of unassignedEntities) {
cards.push(computeCard(entityId));
cards.push(
computeMaintenanceTileCard(hass.states, hass.entities, entityId)
);
}
return cards;
@@ -209,16 +206,7 @@ export class MaintenanceViewStrategy extends ReactiveElement {
const sections: LovelaceSectionRawConfig[] = [];
const entities = findMaintenanceEntities(
hass,
config.edit_visibility ? undefined : config.hidden_entities
);
const computeTileCard = (entityId: string) =>
computeMaintenanceTileCard(hass.states, hass.entities, entityId);
const computeCard: ComputeEntityCard = config.edit_visibility
? wrapEntityVisibility(new Set(config.hidden_entities), computeTileCard)
: computeTileCard;
const entities = findMaintenanceEntities(hass, config.hidden_entities);
const floorCount =
hierarchy.floors.length + (hierarchy.areas.length ? 1 : 0);
@@ -244,12 +232,7 @@ export class MaintenanceViewStrategy extends ReactiveElement {
],
};
const areaCards = processAreasForBattery(
areaIds,
hass,
entities,
computeCard
);
const areaCards = processAreasForBattery(areaIds, hass, entities);
if (areaCards.length > 0) {
section.cards!.push(...areaCards);
@@ -275,12 +258,7 @@ export class MaintenanceViewStrategy extends ReactiveElement {
],
};
const areaCards = processAreasForBattery(
hierarchy.areas,
hass,
entities,
computeCard
);
const areaCards = processAreasForBattery(hierarchy.areas, hass, entities);
if (areaCards.length > 0) {
section.cards!.push(...areaCards);
@@ -289,11 +267,7 @@ export class MaintenanceViewStrategy extends ReactiveElement {
}
// Process unassigned entities
const unassignedCards = processUnassignedEntities(
hass,
entities,
computeCard
);
const unassignedCards = processUnassignedEntities(hass, entities);
if (unassignedCards.length > 0) {
const section: LovelaceSectionRawConfig = {
-8
View File
@@ -15,8 +15,6 @@ import {
DataZoomComponent,
VisualMapComponent,
ToolboxComponent,
MarkAreaComponent,
BrushComponent,
} from "echarts/components";
// Features like Universal Transition and Label Layout
@@ -50,8 +48,6 @@ import type {
GridComponentOption,
DataZoomComponentOption,
VisualMapComponentOption,
MarkAreaComponentOption,
BrushComponentOption,
} from "echarts/components";
import type { ComposeOption } from "echarts/core";
@@ -66,8 +62,6 @@ export type ECOption = ComposeOption<
| GridComponentOption
| DataZoomComponentOption
| VisualMapComponentOption
| MarkAreaComponentOption
| BrushComponentOption
| SankeySeriesOption
| GraphSeriesOption
| SunburstSeriesOption
@@ -97,8 +91,6 @@ echarts.use([
UniversalTransition,
CanvasRenderer,
ToolboxComponent,
MarkAreaComponent,
BrushComponent,
]);
export { LinearGradient };
+3 -44
View File
@@ -1106,46 +1106,6 @@
"failed_create_floor": "Failed to create floor.",
"unknown": "Unknown floor selected"
},
"rooms": {
"keywords": {
"living_room": "living room|lounge|family room|sitting room|den|living",
"bedroom": "bedroom|guest room|master bedroom|master suite|bed room",
"kids_room": "kids room|kids' room|kid's room|children's room|nursery|playroom|baby room",
"kitchen": "kitchen|kitchenette",
"dining_room": "dining room|dining area|dining",
"bathroom": "bathroom|bath|shower room|ensuite|washroom",
"toilet": "toilet|wc|restroom|powder room|loo|lavatory",
"office": "office|study|home office|workspace|workroom",
"laundry_room": "laundry|laundry room",
"hallway": "hallway|hall|corridor|entrance|entryway|foyer|mudroom",
"stairs": "stairs|staircase|stairway|stairwell|landing",
"garage": "garage|carport",
"garden": "garden|yard|backyard|front yard|lawn|greenhouse",
"terrace": "terrace|patio|balcony|deck|porch|veranda",
"basement": "basement|cellar",
"attic": "attic|loft",
"storage": "storage|storage room|pantry|closet|shed|storeroom",
"utility_room": "utility room|boiler room|technical room|plant room",
"pool": "pool|swimming pool|pool house",
"media_room": "media room|home cinema|home theater|home theatre|cinema room|movie room|tv room",
"game_room": "game room|games room|gaming room|recreation room|rec room|billiard room",
"music_room": "music room|music studio|piano room|practice room",
"library": "library|reading room|book room",
"bar": "bar|home bar|pub|wine room|wine cellar",
"dressing_room": "dressing room|walk-in closet|walk-in wardrobe",
"workshop": "workshop|tool room|craft room|hobby room",
"server_room": "server room|network room|rack room",
"safe_room": "safe room|panic room|shelter|storm shelter|bunker",
"prayer_room": "prayer room|chapel|meditation room",
"sauna": "sauna|steam room",
"outdoor_kitchen": "outdoor kitchen|summer kitchen|barbecue area|bbq area|grill area",
"driveway": "driveway|parking|parking space"
}
},
"icon_picker": {
"suggested": "Suggested",
"all_icons": "All icons"
},
"area-filter": {
"title": "Areas",
"no_areas": "No areas",
@@ -1373,7 +1333,6 @@
"not_supported": "WebRTC is not supported in this browser.",
"start_failed": "Failed to start the WebRTC stream: {message}",
"connect_failed": "Failed to connect the WebRTC stream: {message}",
"no_connection": "Could not connect the WebRTC stream.",
"microphone_failed": "Could not access the microphone: {message}",
"microphone_connect_failed": "Could not connect the microphone to the camera: {message}"
},
@@ -3285,13 +3244,13 @@
},
"mcp": {
"header": "Model Context Protocol",
"description": "Add one of the URLs below to your AI app. See the {documentation_link} for app-specific instructions.",
"description_disabled": "See the {documentation_link} to learn how to connect your AI app to Home Assistant.",
"description": "Add one of the URLs below to your AI agent. See the {documentation_link} for agent-specific instructions.",
"description_disabled": "See the {documentation_link} to learn how to connect your AI agent to Home Assistant.",
"documentation": "documentation",
"enable": "[%key:ui::common::enable%]",
"disable": "[%key:ui::common::disable%]",
"disable_confirm_title": "Disable the Model Context Protocol server?",
"disable_confirm_text": "AI apps connected to the server will lose access to Home Assistant.",
"disable_confirm_text": "AI agents connected to the server will lose access to Home Assistant.",
"your_api_header": "Main URL",
"apis_header": "Individual URLs",
"copy_url": "Copy URL",
-45
View File
@@ -1,45 +0,0 @@
import { describe, expect, it } from "vitest";
import {
selectCameraStreams,
type CameraStreamSelectionOptions,
} from "../../src/data/camera-streams";
const ok = { hasVideo: true, hasAudio: true };
const silent = { hasVideo: true, hasAudio: false };
const failed = { hasVideo: false, hasAudio: false };
const select = (
options: Omit<CameraStreamSelectionOptions, "supportedTypes">
) =>
selectCameraStreams({ supportedTypes: ["web_rtc", "hls"], ...options })
.map((stream) => (stream.visible ? stream.type : `(${stream.type})`))
.join(" ");
// The player has no other fallback: a wrong choice here shows a broken or
// silent stream while a working one is available.
describe("selectCameraStreams", () => {
it("works", () => {
expect(selectCameraStreams({})).toEqual([]);
expect(selectCameraStreams({ supportedTypes: [] })).toEqual([
{ type: "mjpeg", visible: true },
]);
expect(
selectCameraStreams({ supportedTypes: ["hls"], hlsStreams: failed })
).toEqual([{ type: "mjpeg", visible: true }]);
// Loading: HLS is shown until WebRTC is ready
expect(select({})).toBe("hls (web_rtc)");
expect(select({ hlsStreams: ok })).toBe("hls (web_rtc)");
expect(select({ hlsStreams: failed })).toBe("web_rtc");
// WebRTC loaded: always preferred, also when only HLS has audio
expect(select({ webRtcStreams: ok })).toBe("web_rtc");
expect(select({ webRtcStreams: silent, hlsStreams: ok })).toBe("web_rtc");
expect(select({ webRtcStreams: ok, hlsStreams: failed })).toBe("web_rtc");
// WebRTC failed
expect(select({ webRtcStreams: failed })).toBe("hls");
expect(select({ webRtcStreams: failed, hlsStreams: ok })).toBe("hls");
expect(select({ webRtcStreams: failed, hlsStreams: failed })).toBe("mjpeg");
});
});
+1 -69
View File
@@ -1,80 +1,12 @@
import type { Connection } from "home-assistant-js-websocket";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import type { MatterCommissioningParameters } from "../../src/data/matter";
import {
matterShareRemainingSeconds,
matterShareTargetExternal,
watchForNewMatterDevice,
} from "../../src/data/matter";
import { subscribeDeviceRegistry } from "../../src/data/ws-device_registry";
import type { ExternalConfig } from "../../src/external_app/external_messaging";
import type { HomeAssistant } from "../../src/types";
// The device registry collection unsubscribes from its updates once no
// subscriber is left, so an extra unsubscribe silently breaks every other one.
describe("watchForNewMatterDevice", () => {
beforeEach(() => {
vi.useFakeTimers();
});
afterEach(() => {
vi.useRealTimers();
});
const fakeRegistry = () => {
const devices: string[] = ["existing"];
const eventCallbacks = new Set<() => void>();
const connection = {
connected: true,
sendMessagePromise: vi.fn(async () =>
devices.map((id) => ({
id,
identifiers: [["matter", id]],
connections: [],
}))
),
subscribeEvents: vi.fn(async (callback: () => void) => {
eventCallbacks.add(callback);
return async () => {
eventCallbacks.delete(callback);
};
}),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
} as unknown as Connection;
return {
connection,
eventCallbacks,
addDevice: (id: string) => {
devices.push(id);
eventCallbacks.forEach((callback) => callback());
},
};
};
it("keeps the registry subscribed when the caller unsubscribes after a find", async () => {
const registry = fakeRegistry();
const hass = { connection: registry.connection } as HomeAssistant;
subscribeDeviceRegistry(registry.connection, () => undefined);
const found = vi.fn();
const unsub = watchForNewMatterDevice(hass, found);
await vi.advanceTimersByTimeAsync(10);
registry.addDevice("new");
await vi.advanceTimersByTimeAsync(600);
expect(found).toHaveBeenCalledExactlyOnceWith(
expect.objectContaining({ id: "new" })
);
// The add device dialog unsubscribes again when it closes.
unsub();
// Past the collection's grace period for unsubscribing.
await vi.advanceTimersByTimeAsync(6000);
expect(registry.eventCallbacks.size).toBe(1);
});
});
const codesOnly: MatterCommissioningParameters = {
setup_pin_code: 20202021,
setup_manual_code: "34970112332",
+19 -21
View File
@@ -105,7 +105,6 @@ const run = ({
tag === "dialog"
? { showModal: dialog ? () => undefined : undefined }
: fakeElement(tag),
createTextNode: (text) => ({ tag: "#text", textContent: text }),
getElementById: (id) => (id === "ha-launch-screen-info-box" ? box : null),
};
// eslint-disable-next-line no-new-func
@@ -125,15 +124,13 @@ const run = ({
{ now: () => now },
(src) => started.push(src)
);
const actions =
box.children.find((child) => child.tag === "div")?.children ?? [];
const continueAnyway = actions.find((child) => child.tag === "button")
?.listeners.click;
const checkbox = actions
.find((child) => child.tag === "label")
?.children.find((child) => child.tag === "input");
const buttons = Object.fromEntries(
(box.children.find((child) => child.tag === "div")?.children ?? []).map(
(button) => [button.textContent, button.listeners.click]
)
);
const shown = box.children.map((child) => child.tag);
return { started, box, store, continueAnyway, checkbox, shown };
return { started, box, store, buttons, shown };
};
describe("index.html legacy browser check", () => {
@@ -147,11 +144,11 @@ describe("index.html legacy browser check", () => {
["BigInt", { bigInt: false, dialog: true }],
["native dialog", { bigInt: true, dialog: false }],
])("offers to continue without %s", (_, browser) => {
const { started, box, store, continueAnyway, checkbox } = run(browser);
const { started, box, store, buttons } = run(browser);
expect(started).toEqual([]);
expect(checkbox).toBeUndefined();
expect(Object.keys(buttons)).toEqual(["Continue anyway"]);
continueAnyway();
buttons["Continue anyway"]();
expect(started).toEqual([ENTRY]);
expect(store[ACCEPTED_KEY]).toBe(String(NOW));
// The message stays up while the app loads.
@@ -168,16 +165,17 @@ describe("index.html legacy browser check", () => {
const stored = String(NOW - 30 * DAY);
const reminder = run({ stored });
expect(reminder.started).toEqual([]);
expect(reminder.checkbox.type).toBe("checkbox");
expect(Object.keys(reminder.buttons)).toEqual([
"Continue anyway",
"Don't show again",
]);
// Unchecked: starts the next month.
const continued = run({ stored });
continued.continueAnyway();
continued.buttons["Continue anyway"]();
expect(continued.started).toEqual([ENTRY]);
expect(continued.store[ACCEPTED_KEY]).toBe(String(NOW));
reminder.checkbox.checked = true;
reminder.continueAnyway();
reminder.buttons["Don't show again"]();
expect(reminder.started).toEqual([ENTRY]);
expect(reminder.store[ACCEPTED_KEY]).toBe("always");
expect(run({ stored: "always", now: NOW + 3650 * DAY }).started).toEqual([
@@ -187,15 +185,15 @@ describe("index.html legacy browser check", () => {
// A tablet that lost its clock.
it("asks again when the clock is behind the stored time", () => {
const { started, continueAnyway } = run({ stored: String(NOW + DAY) });
const { started, buttons } = run({ stored: String(NOW + DAY) });
expect(started).toEqual([]);
expect(continueAnyway).toBeDefined();
expect(buttons["Continue anyway"]).toBeDefined();
});
it("still continues when storage is unavailable", () => {
const { started, continueAnyway } = run({ storageThrows: true });
const { started, buttons } = run({ storageThrows: true });
expect(started).toEqual([]);
continueAnyway();
buttons["Continue anyway"]();
expect(started).toEqual([ENTRY]);
});
});
@@ -209,76 +209,6 @@ describe("action-handler container (resolve) bindings", () => {
});
});
describe("action-handler touch movement", () => {
let el: HTMLElement;
let actions: string[];
beforeEach(() => {
vi.useFakeTimers();
el = document.createElement("div");
document.body.appendChild(el);
actions = actionsOn(el);
actionHandlerBind(el, { hasHold: true });
});
afterEach(() => {
vi.runOnlyPendingTimers();
vi.useRealTimers();
el.remove();
});
it("still taps when the finger moves a few pixels", () => {
el.dispatchEvent(touch("touchstart", { x: 10, y: 10 }));
el.dispatchEvent(touch("touchmove", { x: 14, y: 17 }));
const end = touch("touchend", { x: 14, y: 17 });
el.dispatchEvent(end);
expect(actions).toEqual(["tap"]);
// No emulated click follows, so the tap fires once.
expect(end.defaultPrevented).toBe(true);
});
it("still holds when the finger moves a few pixels", () => {
el.dispatchEvent(touch("touchstart", { x: 10, y: 10 }));
el.dispatchEvent(touch("touchmove", { x: 12, y: 18 }));
vi.advanceTimersByTime(500);
el.dispatchEvent(touch("touchend", { x: 12, y: 18 }));
expect(actions).toEqual(["hold"]);
});
it("drops the press once the finger moves past the slop", () => {
el.dispatchEvent(touch("touchstart", { x: 10, y: 10 }));
el.dispatchEvent(touch("touchmove", { x: 14, y: 17 }));
el.dispatchEvent(touch("touchmove", { x: 10, y: 40 }));
el.dispatchEvent(touch("touchend", { x: 10, y: 40 }));
vi.advanceTimersByTime(500);
expect(actions).toEqual([]);
});
it("drops the press when the page scrolls", () => {
el.dispatchEvent(touch("touchstart", { x: 10, y: 10 }));
document.dispatchEvent(new Event("scroll"));
el.dispatchEvent(touch("touchend", { x: 10, y: 10 }));
expect(actions).toEqual([]);
});
it("drops the press when the browser takes over the touch", () => {
// A nested scroller: its scroll event never reaches the document, but the
// composed pointercancel does.
const host = document.createElement("div");
const inner = document.createElement("div");
host.attachShadow({ mode: "open" }).appendChild(inner);
el.appendChild(host);
el.dispatchEvent(touch("touchstart", { x: 10, y: 10 }));
el.dispatchEvent(touch("touchmove", { x: 14, y: 14 }));
inner.dispatchEvent(
new Event("pointercancel", { bubbles: true, composed: true })
);
el.dispatchEvent(touch("touchend", { x: 14, y: 14 }));
vi.advanceTimersByTime(500);
expect(actions).toEqual([]);
});
});
describe("action-handler keyboard-only bindings", () => {
beforeEach(() => vi.useFakeTimers());
afterEach(() => {
@@ -311,40 +311,4 @@ describe("MaintenanceViewStrategy.generate", () => {
},
]);
});
it("keeps hidden entities as hidden visibility wrappers while editing", async () => {
const view = await MaintenanceViewStrategy.generate(
{
type: "maintenance",
hidden_entities: ["sensor.car_target_charge"],
edit_visibility: true,
},
createBatteryHass()
);
const section = view.sections?.[0] as LovelaceSectionConfig;
expect(section.cards?.slice(1)).toEqual([
{
type: "entity-visibility",
entity: "sensor.car_target_charge",
hidden: true,
card: {
type: "tile",
entity: "sensor.car_target_charge",
name: { type: "entity" },
},
},
{
type: "entity-visibility",
entity: "sensor.remote_battery",
hidden: false,
card: {
type: "tile",
entity: "sensor.remote_battery",
name: { type: "entity" },
},
},
]);
});
});