mirror of
https://github.com/home-assistant/frontend.git
synced 2026-11-25 14:18:51 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b903846d2 | ||
|
|
af8d129871 | ||
|
|
c4c84361cb |
No files matched your search
@@ -185,6 +185,8 @@ export class HaControlCircularSlider extends LitElement {
|
||||
|
||||
private _lastChanging?: number;
|
||||
|
||||
private _keyboardChanging = false;
|
||||
|
||||
private _getPercentageFromEvent = (e: HammerInput) => {
|
||||
const bound = this._slider.getBoundingClientRect();
|
||||
const x = (2 * (e.center.x - bound.left - bound.width / 2)) / bound.width;
|
||||
@@ -460,6 +462,7 @@ export class HaControlCircularSlider extends LitElement {
|
||||
this._setActiveValue(this._boundedValue(this.max));
|
||||
break;
|
||||
}
|
||||
this._keyboardChanging = true;
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
value: this._getActiveValue(),
|
||||
});
|
||||
@@ -468,8 +471,14 @@ export class HaControlCircularSlider extends LitElement {
|
||||
|
||||
private _handleKeyUp(e: KeyboardEvent) {
|
||||
if (this.disabled || !A11Y_KEY_CODES.has(e.code)) return;
|
||||
this._activeSlider = (e.currentTarget as any).id as ActiveSlider;
|
||||
e.preventDefault();
|
||||
this._endKeyboardChange(e);
|
||||
}
|
||||
|
||||
private _endKeyboardChange(e: Event) {
|
||||
if (!this._keyboardChanging) return;
|
||||
this._keyboardChanging = false;
|
||||
this._activeSlider = (e.currentTarget as any).id as ActiveSlider;
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
value: undefined,
|
||||
});
|
||||
@@ -611,6 +620,7 @@ export class HaControlCircularSlider extends LitElement {
|
||||
)}
|
||||
@keydown=${this._handleKeyDown}
|
||||
@keyup=${this._handleKeyUp}
|
||||
@blur=${this._endKeyboardChange}
|
||||
/>
|
||||
`
|
||||
: nothing
|
||||
|
||||
@@ -82,6 +82,8 @@ export class HaControlScrubber extends LitElement {
|
||||
|
||||
private _mc?: HammerManager;
|
||||
|
||||
private _keyboardChanging = false;
|
||||
|
||||
private get _range() {
|
||||
return this.max - this.min;
|
||||
}
|
||||
@@ -278,12 +280,19 @@ export class HaControlScrubber extends LitElement {
|
||||
e.code === "ArrowLeft" || e.code === "ArrowDown" ? -1 : 1;
|
||||
this.value = this.normalizedValue(current + this.step * multiplier);
|
||||
}
|
||||
this._keyboardChanging = true;
|
||||
fireEvent(this, "slider-moved", { value: this.value });
|
||||
}
|
||||
|
||||
private _handleKeyUp(e: KeyboardEvent) {
|
||||
if (this.disabled || !A11Y_KEY_CODES.has(e.code)) return;
|
||||
e.preventDefault();
|
||||
this._endKeyboardChange();
|
||||
}
|
||||
|
||||
private _endKeyboardChange() {
|
||||
if (!this._keyboardChanging) return;
|
||||
this._keyboardChanging = false;
|
||||
fireEvent(this, "slider-moved", { value: undefined });
|
||||
fireEvent(this, "value-changed", { value: this.value });
|
||||
}
|
||||
@@ -323,6 +332,7 @@ export class HaControlScrubber extends LitElement {
|
||||
aria-orientation="horizontal"
|
||||
@keydown=${this._handleKeyDown}
|
||||
@keyup=${this._handleKeyUp}
|
||||
@blur=${this._endKeyboardChange}
|
||||
>
|
||||
<div class="rail"></div>
|
||||
<div class="track" @transitionend=${this._handleTransitionEnd}></div>
|
||||
|
||||
@@ -308,14 +308,23 @@ export class HaControlSlider extends LitElement {
|
||||
);
|
||||
}
|
||||
this._showTooltip();
|
||||
this._keyboardChanging = true;
|
||||
fireEvent(this, "slider-moved", { value: this.value });
|
||||
}
|
||||
|
||||
private _tooltipTimeout?: number;
|
||||
|
||||
private _keyboardChanging = false;
|
||||
|
||||
private _handleKeyUp(e: KeyboardEvent) {
|
||||
if (!A11Y_KEY_CODES.has(e.code)) return;
|
||||
e.preventDefault();
|
||||
this._endKeyboardChange();
|
||||
}
|
||||
|
||||
private _endKeyboardChange() {
|
||||
if (!this._keyboardChanging) return;
|
||||
this._keyboardChanging = false;
|
||||
this._hideTooltip(500);
|
||||
fireEvent(this, "value-changed", { value: this.value });
|
||||
}
|
||||
@@ -405,6 +414,7 @@ export class HaControlSlider extends LitElement {
|
||||
aria-orientation=${this.vertical ? "vertical" : "horizontal"}
|
||||
@keydown=${this._handleKeyDown}
|
||||
@keyup=${this._handleKeyUp}
|
||||
@blur=${this._endKeyboardChange}
|
||||
>
|
||||
<div class="slider-track-background"></div>
|
||||
<slot name="background"></slot>
|
||||
|
||||
@@ -21,6 +21,11 @@ export class HaIconButtonPrev extends LitElement {
|
||||
|
||||
@property() download?: string;
|
||||
|
||||
static shadowRootOptions: ShadowRootInit = {
|
||||
...LitElement.shadowRootOptions,
|
||||
delegatesFocus: true,
|
||||
};
|
||||
|
||||
@state() private _icon =
|
||||
mainWindow.document.dir === "rtl" ? mdiChevronRight : mdiChevronLeft;
|
||||
|
||||
|
||||
+37
-2
@@ -245,7 +245,17 @@ type ConditionIcons = Record<
|
||||
>;
|
||||
|
||||
export type IconCategory =
|
||||
"entity" | "entity_component" | "services" | "triggers" | "conditions";
|
||||
| "entity"
|
||||
| "entity_component"
|
||||
| "services"
|
||||
| "triggers"
|
||||
| "conditions"
|
||||
| "integration_category";
|
||||
|
||||
export type IntegrationCategoryIcons = Record<
|
||||
string,
|
||||
{ default: string; subcategory?: Record<string, { default: string }> }
|
||||
>;
|
||||
|
||||
interface CategoryType {
|
||||
entity: PlatformIcons;
|
||||
@@ -253,6 +263,7 @@ interface CategoryType {
|
||||
services: ServiceIcons;
|
||||
triggers: TriggerIcons;
|
||||
conditions: ConditionIcons;
|
||||
integration_category: IntegrationCategoryIcons;
|
||||
}
|
||||
|
||||
export const getHassIcons = async <T extends IconCategory>(
|
||||
@@ -321,7 +332,10 @@ export const getComponentIcons = async (
|
||||
};
|
||||
|
||||
export const getCategoryIcons = async <
|
||||
T extends Exclude<IconCategory, "entity" | "entity_component">,
|
||||
T extends Exclude<
|
||||
IconCategory,
|
||||
"entity" | "entity_component" | "integration_category"
|
||||
>,
|
||||
>(
|
||||
connection: Connection,
|
||||
hassConfig: HomeAssistant["config"],
|
||||
@@ -740,3 +754,24 @@ export const domainIcon = async (
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
let integrationCategoryIcons:
|
||||
ReturnType<typeof getHassIcons<"integration_category">> | undefined;
|
||||
|
||||
export const getIntegrationCategoryIcons = async (
|
||||
connection: Connection
|
||||
): Promise<IntegrationCategoryIcons | undefined> => {
|
||||
// Cache the request itself, so callers while it loads share it
|
||||
integrationCategoryIcons ??= getHassIcons(
|
||||
connection,
|
||||
"integration_category",
|
||||
"homeassistant"
|
||||
);
|
||||
try {
|
||||
const result = await integrationCategoryIcons;
|
||||
return result.resources.homeassistant;
|
||||
} catch (_err) {
|
||||
integrationCategoryIcons = undefined;
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
@@ -78,6 +78,8 @@ export interface IntegrationManifest {
|
||||
)[];
|
||||
homekit?: { models?: string[] };
|
||||
integration_type?: IntegrationType;
|
||||
// Categories like `energy` or subcategories like `energy.ev_charging`
|
||||
categories?: string[];
|
||||
loggers?: string[];
|
||||
quality_scale?:
|
||||
| "bronze"
|
||||
|
||||
@@ -13,6 +13,8 @@ export interface Integration {
|
||||
is_built_in?: boolean;
|
||||
overwrites_built_in?: boolean;
|
||||
single_config_entry?: boolean;
|
||||
// Categories like `energy` or subcategories like `energy.ev_charging`
|
||||
categories?: string[];
|
||||
}
|
||||
|
||||
export type Integrations = Record<string, Integration>;
|
||||
|
||||
@@ -76,7 +76,8 @@ export type TranslationCategory =
|
||||
| "selector"
|
||||
| "services"
|
||||
| "triggers"
|
||||
| "conditions";
|
||||
| "conditions"
|
||||
| "integration_category";
|
||||
|
||||
export const subscribeTranslationPreferences = (
|
||||
hass: HomeAssistant,
|
||||
|
||||
@@ -7,6 +7,7 @@ import { watchAudioLevel } from "../../../common/audio/watch-audio-level";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import { 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-button";
|
||||
import "../../../components/camera/ha-camera-player";
|
||||
@@ -32,6 +33,9 @@ import type {
|
||||
} from "../../../external_app/external_messaging";
|
||||
import { showToast } from "../../../util/toast";
|
||||
|
||||
// The padding of the microphone row around its 40px button
|
||||
const MICROPHONE_ROW_HEIGHT = "calc(var(--ha-space-4) * 2 + 40px)";
|
||||
|
||||
@customElement("more-info-camera")
|
||||
class MoreInfoCamera extends LitElement {
|
||||
@state()
|
||||
@@ -93,6 +97,11 @@ class MoreInfoCamera extends LitElement {
|
||||
|
||||
protected updated(changedProps: PropertyValues) {
|
||||
super.updated(changedProps);
|
||||
if (changedProps.has("_supportsTwoWayAudio")) {
|
||||
fireEvent(this, "camera-controls-height-changed", {
|
||||
height: this._supportsTwoWayAudio ? MICROPHONE_ROW_HEIGHT : undefined,
|
||||
});
|
||||
}
|
||||
if (changedProps.has("_microphoneState")) {
|
||||
this._stopMicrophoneMeter();
|
||||
const track = this._cameraStream?.microphoneTrack;
|
||||
@@ -390,4 +399,7 @@ declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"more-info-camera": MoreInfoCamera;
|
||||
}
|
||||
interface HASSDomEvents {
|
||||
"camera-controls-height-changed": { height?: string };
|
||||
}
|
||||
}
|
||||
@@ -154,8 +154,8 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
// The dialog grows with the camera's picture, as high as there is room for
|
||||
@state() private _cameraAspectRatio?: number;
|
||||
|
||||
// The camera's info shows microphone controls below the picture then
|
||||
@state() private _cameraTwoWayAudio = false;
|
||||
// Height of the controls the camera's info shows below the picture
|
||||
@state() private _cameraControlsHeight?: string;
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@@ -200,7 +200,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
// its size again
|
||||
if (params.entityId !== this._entityId) {
|
||||
this._cameraAspectRatio = undefined;
|
||||
this._cameraTwoWayAudio = false;
|
||||
this._cameraControlsHeight = undefined;
|
||||
}
|
||||
this._entityId = params.entityId;
|
||||
if (!this._entityId) {
|
||||
@@ -266,7 +266,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._childViewStack = [];
|
||||
this._returnUrl = undefined;
|
||||
this._cameraAspectRatio = undefined;
|
||||
this._cameraTwoWayAudio = false;
|
||||
this._cameraControlsHeight = undefined;
|
||||
this._isEscapeEnabled = true;
|
||||
window.removeEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||
window.removeEventListener("show-dialog", this._disableEscapeKeyClose);
|
||||
@@ -709,15 +709,13 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
}
|
||||
class=${classMap({ camera: domain === "camera" })}
|
||||
style=${styleMap({
|
||||
"--more-info-camera-controls-height": this._cameraTwoWayAudio
|
||||
? "72px"
|
||||
: undefined,
|
||||
"--more-info-camera-controls-height": this._cameraControlsHeight,
|
||||
"--ha-dialog-width-lg": cameraAspectRatio
|
||||
? `clamp(var(--ha-dialog-width-md, 580px), calc(var(--video-max-height) * ${cameraAspectRatio}), 1920px)`
|
||||
: undefined,
|
||||
})}
|
||||
@camera-aspect-ratio-changed=${this._cameraAspectRatioChanged}
|
||||
@camera-capabilities-changed=${this._cameraCapabilitiesChanged}
|
||||
@camera-controls-height-changed=${this._cameraControlsHeightChanged}
|
||||
.accessibleLabel=${title}
|
||||
@closed=${this._dialogClosed}
|
||||
@opened=${this._handleOpened}
|
||||
@@ -1148,10 +1146,10 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._cameraAspectRatio = ev.detail.aspectRatio;
|
||||
}
|
||||
|
||||
private _cameraCapabilitiesChanged(
|
||||
ev: HASSDomEvent<HASSDomEvents["camera-capabilities-changed"]>
|
||||
private _cameraControlsHeightChanged(
|
||||
ev: HASSDomEvent<HASSDomEvents["camera-controls-height-changed"]>
|
||||
) {
|
||||
this._cameraTwoWayAudio = ev.detail.capabilities?.two_way_audio ?? false;
|
||||
this._cameraControlsHeight = ev.detail.height;
|
||||
}
|
||||
|
||||
private _enlarge() {
|
||||
@@ -1218,8 +1216,8 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
--dialog-content-padding: 0;
|
||||
}
|
||||
|
||||
/* The dialog's margin, its header of about 68px and the microphone
|
||||
controls of about 72px when the camera has them */
|
||||
/* The dialog's margin, its header of about 68px and the controls
|
||||
below the picture */
|
||||
ha-adaptive-dialog.camera {
|
||||
--video-max-height: calc(
|
||||
100vh - var(--ha-space-20) -
|
||||
|
||||
+1
-16
@@ -75,26 +75,11 @@ const clearUrlParams = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// The login page is never cached, so check the server is up before getAuth redirects to it.
|
||||
const loadTokensOrCheckServer = async () => {
|
||||
const tokens = loadTokens();
|
||||
if (!tokens || tokens.hassUrl !== hassUrl) {
|
||||
const response = await fetch(`${hassUrl}/manifest.json`, {
|
||||
mode: "no-cors",
|
||||
cache: "no-store",
|
||||
});
|
||||
if (response.status >= 500) {
|
||||
throw new Error(`Home Assistant responded with ${response.status}`);
|
||||
}
|
||||
}
|
||||
return tokens;
|
||||
};
|
||||
|
||||
const authOptions = {
|
||||
hassUrl,
|
||||
limitHassInstance: true,
|
||||
saveTokens,
|
||||
loadTokens: loadTokensOrCheckServer,
|
||||
loadTokens: () => Promise.resolve(loadTokens()),
|
||||
};
|
||||
|
||||
const getAuthDroppingStaleCallback = async () => {
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import type { IFuseOptions } from "fuse.js";
|
||||
import type { HaListVirtualizedItem } from "../../../components/list/ha-list-virtualized";
|
||||
|
||||
export interface IntegrationListItem extends HaListVirtualizedItem {
|
||||
name: string;
|
||||
domain: string;
|
||||
config_flow?: boolean;
|
||||
is_helper?: boolean;
|
||||
integrations?: string[];
|
||||
domains?: string[];
|
||||
iot_standards?: string[];
|
||||
supported_by?: string;
|
||||
cloud?: boolean;
|
||||
is_built_in?: boolean;
|
||||
overwrites_built_in?: boolean;
|
||||
is_add?: boolean;
|
||||
single_config_entry?: boolean;
|
||||
// A brand title row, not pickable
|
||||
is_header?: boolean;
|
||||
is_end_space?: boolean;
|
||||
result?: "brand" | "category" | "more";
|
||||
category?: string;
|
||||
subcategory?: string;
|
||||
section?: SearchSection;
|
||||
icon?: string;
|
||||
description?: string;
|
||||
categories?: string[];
|
||||
}
|
||||
|
||||
export type BrowseBy = "category" | "brand";
|
||||
|
||||
export type Connection = "local" | "cloud";
|
||||
|
||||
export const CONNECTIONS: Connection[] = ["local", "cloud"];
|
||||
|
||||
export const ofConnection = (
|
||||
item: IntegrationListItem,
|
||||
connection?: Connection
|
||||
) => !connection || (connection === "cloud") === !!item.cloud;
|
||||
|
||||
export type SearchSection = "brand" | "category" | "integration" | "helper";
|
||||
|
||||
export const SEARCH_SECTIONS: SearchSection[] = [
|
||||
"brand",
|
||||
"category",
|
||||
"integration",
|
||||
"helper",
|
||||
];
|
||||
|
||||
export const MAX_SEARCH_ITEMS_PER_SECTION = 5;
|
||||
|
||||
export const searchOptions = (
|
||||
filter: string
|
||||
): IFuseOptions<IntegrationListItem> => ({
|
||||
keys: [
|
||||
{ name: "name", weight: 5 },
|
||||
{ name: "domain", weight: 5 },
|
||||
{ name: "integrations", weight: 2 },
|
||||
"supported_by",
|
||||
"iot_standards",
|
||||
],
|
||||
isCaseSensitive: false,
|
||||
minMatchCharLength: Math.min(filter.length, 2),
|
||||
threshold: 0.2,
|
||||
ignoreDiacritics: true,
|
||||
});
|
||||
|
||||
export interface IntegrationCategory {
|
||||
slug: string;
|
||||
name: string;
|
||||
subcategories: { slug: string; name: string }[];
|
||||
}
|
||||
|
||||
export const inCategory = (
|
||||
categories: string[] | undefined,
|
||||
category?: string,
|
||||
subcategory?: string
|
||||
) =>
|
||||
!category ||
|
||||
(categories || []).some((slug) =>
|
||||
subcategory
|
||||
? slug === `${category}.${subcategory}`
|
||||
: slug === category || slug.startsWith(`${category}.`)
|
||||
);
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,5 @@
|
||||
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||
import { mdiPlus } from "@mdi/js";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||
@@ -11,6 +12,8 @@ import {
|
||||
} from "../../../common/integrations/protocolIntegrationPicked";
|
||||
import { navigate } from "../../../common/navigate";
|
||||
import { caseInsensitiveStringCompare } from "../../../common/string/compare";
|
||||
import "../../../components/ha-button";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import "../../../components/item/ha-list-item-button";
|
||||
import "../../../components/list/ha-list-base";
|
||||
import { localizeConfigFlowTitle } from "../../../data/config_flow";
|
||||
@@ -27,7 +30,7 @@ import { brandsUrl } from "../../../util/brands-url";
|
||||
import "./ha-integration-list-item";
|
||||
import { showYamlIntegrationDialog } from "./show-add-integration-dialog";
|
||||
|
||||
const standardToDomain = { zigbee: "zha", zwave: "zwave_js" } as const;
|
||||
export const standardToDomain = { zigbee: "zha", zwave: "zwave_js" } as const;
|
||||
|
||||
@customElement("ha-domain-integrations")
|
||||
class HaDomainIntegrations extends LitElement {
|
||||
@@ -46,26 +49,86 @@ class HaDomainIntegrations extends LitElement {
|
||||
@property({ attribute: false })
|
||||
public showManageLink = false;
|
||||
|
||||
@property({ type: Boolean, reflect: true }) public boxed = false;
|
||||
|
||||
protected render() {
|
||||
return html`<ha-list-base>
|
||||
${
|
||||
this.flowsInProgress?.length
|
||||
? html`<h3>
|
||||
${this.hass.localize("ui.panel.config.integrations.discovered")}
|
||||
</h3>
|
||||
${this.flowsInProgress.map(
|
||||
(flow) =>
|
||||
html`<ha-list-item-button
|
||||
.flow=${flow}
|
||||
@click=${this._flowInProgressPicked}
|
||||
// Only show manage link if not already on the integrations dashboard
|
||||
const manage =
|
||||
this.showManageLink &&
|
||||
!location.pathname.startsWith("/config/integrations");
|
||||
return html`<div class="box">
|
||||
<ha-list-base>
|
||||
${
|
||||
this.flowsInProgress?.length
|
||||
? html`<h3>
|
||||
${this.hass.localize("ui.panel.config.integrations.discovered")}
|
||||
</h3>
|
||||
${this.flowsInProgress.map(
|
||||
(flow) =>
|
||||
html`<ha-list-item-button
|
||||
.flow=${flow}
|
||||
@click=${this._flowInProgressPicked}
|
||||
>
|
||||
<img
|
||||
alt=""
|
||||
slot="start"
|
||||
loading="lazy"
|
||||
src=${brandsUrl(
|
||||
{
|
||||
domain: flow.handler,
|
||||
type: "icon",
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
},
|
||||
this.hass.auth.data.hassUrl
|
||||
)}
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<span slot="headline"
|
||||
>${localizeConfigFlowTitle(this.hass.localize, flow)}</span
|
||||
>
|
||||
<span slot="supporting-text"
|
||||
>${domainToName(this.hass.localize, flow.handler)}</span
|
||||
>
|
||||
<ha-svg-icon slot="end" .path=${mdiPlus}></ha-svg-icon>
|
||||
</ha-list-item-button>`
|
||||
)}
|
||||
<wa-divider></wa-divider>
|
||||
${
|
||||
this.integration &&
|
||||
"integrations" in this.integration &&
|
||||
this.integration.integrations
|
||||
? html`<h3>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.available_integrations"
|
||||
)}
|
||||
</h3>`
|
||||
: nothing
|
||||
}`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
this.integration?.iot_standards
|
||||
? this.integration.iot_standards
|
||||
.filter((standard) =>
|
||||
(PROTOCOL_INTEGRATIONS as readonly string[]).includes(
|
||||
standardToDomain[standard] || standard
|
||||
)
|
||||
)
|
||||
.map((standard) => {
|
||||
const domain: (typeof PROTOCOL_INTEGRATIONS)[number] =
|
||||
standardToDomain[standard] || standard;
|
||||
return html`<ha-list-item-button
|
||||
.domain=${domain}
|
||||
@click=${this._standardPicked}
|
||||
>
|
||||
<img
|
||||
alt=""
|
||||
slot="start"
|
||||
loading="lazy"
|
||||
alt=""
|
||||
src=${brandsUrl(
|
||||
{
|
||||
domain: flow.handler,
|
||||
domain,
|
||||
type: "icon",
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
},
|
||||
@@ -75,204 +138,169 @@ class HaDomainIntegrations extends LitElement {
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<span slot="headline"
|
||||
>${localizeConfigFlowTitle(this.hass.localize, flow)}</span
|
||||
>
|
||||
<span slot="supporting-text"
|
||||
>${domainToName(this.hass.localize, flow.handler)}</span
|
||||
>${this.hass.localize(
|
||||
`ui.panel.config.integrations.add_${domain}_device`
|
||||
)}</span
|
||||
>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>`
|
||||
)}
|
||||
<wa-divider></wa-divider>
|
||||
${
|
||||
this.integration &&
|
||||
"integrations" in this.integration &&
|
||||
this.integration.integrations
|
||||
? html`<h3>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.available_integrations"
|
||||
)}
|
||||
</h3>`
|
||||
: nothing
|
||||
}`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
this.integration?.iot_standards
|
||||
? this.integration.iot_standards
|
||||
.filter((standard) =>
|
||||
(PROTOCOL_INTEGRATIONS as readonly string[]).includes(
|
||||
standardToDomain[standard] || standard
|
||||
</ha-list-item-button>`;
|
||||
})
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
this.integration &&
|
||||
"integrations" in this.integration &&
|
||||
this.integration.integrations
|
||||
? Object.entries(this.integration.integrations)
|
||||
.filter(([, val]) => val.integration_type !== "hardware")
|
||||
.sort((a, b) => {
|
||||
if (a[1].config_flow && !b[1].config_flow) {
|
||||
return -1;
|
||||
}
|
||||
if (b[1].config_flow && !a[1].config_flow) {
|
||||
return 0;
|
||||
}
|
||||
return caseInsensitiveStringCompare(
|
||||
a[1].name || domainToName(this.hass.localize, a[0]),
|
||||
b[1].name || domainToName(this.hass.localize, b[0]),
|
||||
this.hass.locale.language
|
||||
);
|
||||
})
|
||||
.map(
|
||||
([dom, val]) =>
|
||||
html`<ha-integration-list-item
|
||||
.domain=${dom}
|
||||
.integration=${{
|
||||
...val,
|
||||
domain: dom,
|
||||
name: val.name || domainToName(this.hass.localize, dom),
|
||||
is_built_in: val.is_built_in !== false,
|
||||
cloud: val.iot_class?.startsWith("cloud_"),
|
||||
}}
|
||||
.opensFlow=${!val.iot_standards}
|
||||
@click=${this._integrationPicked}
|
||||
>
|
||||
</ha-integration-list-item>`
|
||||
)
|
||||
)
|
||||
.map((standard) => {
|
||||
const domain: (typeof PROTOCOL_INTEGRATIONS)[number] =
|
||||
standardToDomain[standard] || standard;
|
||||
return html`<ha-list-item-button
|
||||
.domain=${domain}
|
||||
@click=${this._standardPicked}
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
(PROTOCOL_INTEGRATIONS as readonly string[]).includes(this.domain)
|
||||
? html`<ha-list-item-button
|
||||
.domain=${this.domain}
|
||||
@click=${this._standardPicked}
|
||||
>
|
||||
<img
|
||||
slot="start"
|
||||
loading="lazy"
|
||||
alt=""
|
||||
src=${brandsUrl(
|
||||
{
|
||||
domain: this.domain,
|
||||
type: "icon",
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
},
|
||||
this.hass.auth.data.hassUrl
|
||||
)}
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
`ui.panel.config.integrations.add_${
|
||||
this.domain as (typeof PROTOCOL_INTEGRATIONS)[number]
|
||||
}_device`
|
||||
)}</span
|
||||
>
|
||||
<img
|
||||
slot="start"
|
||||
loading="lazy"
|
||||
alt=""
|
||||
src=${brandsUrl(
|
||||
{
|
||||
domain,
|
||||
type: "icon",
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
},
|
||||
this.hass.auth.data.hassUrl
|
||||
)}
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
`ui.panel.config.integrations.add_${domain}_device`
|
||||
)}</span
|
||||
>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>`;
|
||||
})
|
||||
: ""
|
||||
}
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
this.integration &&
|
||||
"config_flow" in this.integration &&
|
||||
this.integration.config_flow
|
||||
? html`${
|
||||
this.flowsInProgress?.length
|
||||
? html`<ha-list-item-button
|
||||
.domain=${this.domain}
|
||||
@click=${this._integrationPicked}
|
||||
.integration=${{
|
||||
...this.integration,
|
||||
domain: this.domain,
|
||||
name:
|
||||
this.integration.name ||
|
||||
domainToName(this.hass.localize, this.domain),
|
||||
is_built_in: this.integration.is_built_in !== false,
|
||||
cloud: this.integration.iot_class?.startsWith("cloud_"),
|
||||
}}
|
||||
>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.new_flow",
|
||||
{
|
||||
integration:
|
||||
this.integration.name ||
|
||||
domainToName(this.hass.localize, this.domain),
|
||||
}
|
||||
)}
|
||||
</span>
|
||||
<ha-svg-icon slot="end" .path=${mdiPlus}></ha-svg-icon>
|
||||
</ha-list-item-button>`
|
||||
: html`<ha-integration-list-item
|
||||
.domain=${this.domain}
|
||||
.integration=${{
|
||||
...this.integration,
|
||||
domain: this.domain,
|
||||
name:
|
||||
this.integration.name ||
|
||||
domainToName(this.hass.localize, this.domain),
|
||||
is_built_in: this.integration.is_built_in !== false,
|
||||
cloud: this.integration.iot_class?.startsWith("cloud_"),
|
||||
}}
|
||||
opens-flow
|
||||
@click=${this._integrationPicked}
|
||||
>
|
||||
</ha-integration-list-item>`
|
||||
}`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
manage && !this.boxed
|
||||
? html`<ha-list-item-button @click=${this._manageDiscovered}>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.integrations.manage_discovered"
|
||||
)}</span
|
||||
>
|
||||
<span slot="supporting-text"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.integrations.manage_discovered_description"
|
||||
)}</span
|
||||
>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>`
|
||||
: nothing
|
||||
}
|
||||
</ha-list-base>
|
||||
${
|
||||
this.integration &&
|
||||
"integrations" in this.integration &&
|
||||
this.integration.integrations
|
||||
? Object.entries(this.integration.integrations)
|
||||
.filter(([, val]) => val.integration_type !== "hardware")
|
||||
.sort((a, b) => {
|
||||
if (a[1].config_flow && !b[1].config_flow) {
|
||||
return -1;
|
||||
}
|
||||
if (b[1].config_flow && !a[1].config_flow) {
|
||||
return 0;
|
||||
}
|
||||
return caseInsensitiveStringCompare(
|
||||
a[1].name || domainToName(this.hass.localize, a[0]),
|
||||
b[1].name || domainToName(this.hass.localize, b[0]),
|
||||
this.hass.locale.language
|
||||
);
|
||||
})
|
||||
.map(
|
||||
([dom, val]) =>
|
||||
html`<ha-integration-list-item
|
||||
.domain=${dom}
|
||||
.integration=${{
|
||||
...val,
|
||||
domain: dom,
|
||||
name: val.name || domainToName(this.hass.localize, dom),
|
||||
is_built_in: val.is_built_in !== false,
|
||||
cloud: val.iot_class?.startsWith("cloud_"),
|
||||
}}
|
||||
@click=${this._integrationPicked}
|
||||
>
|
||||
</ha-integration-list-item>`
|
||||
)
|
||||
: ""
|
||||
}
|
||||
${
|
||||
(PROTOCOL_INTEGRATIONS as readonly string[]).includes(this.domain)
|
||||
? html`<ha-list-item-button
|
||||
.domain=${this.domain}
|
||||
@click=${this._standardPicked}
|
||||
>
|
||||
<img
|
||||
slot="start"
|
||||
loading="lazy"
|
||||
alt=""
|
||||
src=${brandsUrl(
|
||||
{
|
||||
domain: this.domain,
|
||||
type: "icon",
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
},
|
||||
this.hass.auth.data.hassUrl
|
||||
)}
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
`ui.panel.config.integrations.add_${
|
||||
this.domain as (typeof PROTOCOL_INTEGRATIONS)[number]
|
||||
}_device`
|
||||
)}</span
|
||||
>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>`
|
||||
: ""
|
||||
}
|
||||
${
|
||||
this.integration &&
|
||||
"config_flow" in this.integration &&
|
||||
this.integration.config_flow
|
||||
? html`${
|
||||
this.flowsInProgress?.length
|
||||
? html`<ha-list-item-button
|
||||
.domain=${this.domain}
|
||||
@click=${this._integrationPicked}
|
||||
.integration=${{
|
||||
...this.integration,
|
||||
domain: this.domain,
|
||||
name:
|
||||
this.integration.name ||
|
||||
domainToName(this.hass.localize, this.domain),
|
||||
is_built_in: this.integration.is_built_in !== false,
|
||||
cloud: this.integration.iot_class?.startsWith("cloud_"),
|
||||
}}
|
||||
>
|
||||
<span slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.new_flow",
|
||||
{
|
||||
integration:
|
||||
this.integration.name ||
|
||||
domainToName(this.hass.localize, this.domain),
|
||||
}
|
||||
)}
|
||||
</span>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>`
|
||||
: html`<ha-integration-list-item
|
||||
.domain=${this.domain}
|
||||
.integration=${{
|
||||
...this.integration,
|
||||
domain: this.domain,
|
||||
name:
|
||||
this.integration.name ||
|
||||
domainToName(this.hass.localize, this.domain),
|
||||
is_built_in: this.integration.is_built_in !== false,
|
||||
cloud: this.integration.iot_class?.startsWith("cloud_"),
|
||||
}}
|
||||
@click=${this._integrationPicked}
|
||||
>
|
||||
</ha-integration-list-item>`
|
||||
}`
|
||||
: ""
|
||||
}
|
||||
${
|
||||
this.showManageLink &&
|
||||
// Only show manage link if not already on the integrations dashboard
|
||||
!location.pathname.startsWith("/config/integrations")
|
||||
? html`<ha-list-item-button @click=${this._manageDiscovered}>
|
||||
<span slot="headline"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.integrations.manage_discovered"
|
||||
)}</span
|
||||
>
|
||||
<span slot="supporting-text"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.integrations.manage_discovered_description"
|
||||
)}</span
|
||||
>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>`
|
||||
manage && this.boxed
|
||||
? html`<div class="footer">
|
||||
<div class="footer-bar">
|
||||
<ha-button
|
||||
appearance="plain"
|
||||
size="s"
|
||||
@click=${this._manageDiscovered}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.manage_discovered"
|
||||
)}
|
||||
</ha-button>
|
||||
</div>
|
||||
</div>`
|
||||
: nothing
|
||||
}
|
||||
</ha-list-base> `;
|
||||
</div>`;
|
||||
}
|
||||
|
||||
private async _integrationPicked(
|
||||
@@ -380,6 +408,86 @@ class HaDomainIntegrations extends LitElement {
|
||||
ha-icon-next {
|
||||
color: var(--ha-color-text-secondary);
|
||||
}
|
||||
ha-svg-icon[slot="end"] {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
.box {
|
||||
display: contents;
|
||||
}
|
||||
:host([boxed]) {
|
||||
--ha-row-item-padding-inline: var(--ha-space-3);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
:host([boxed]) .box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
/* Bouncing would move the sticky footer */
|
||||
overscroll-behavior: none;
|
||||
}
|
||||
:host([boxed]) ha-list-base {
|
||||
flex-shrink: 0;
|
||||
padding-block-end: var(--ha-space-2);
|
||||
}
|
||||
/* hidden would make it a scroll container and break the sticky title */
|
||||
:host([boxed]) ha-list-base::part(base) {
|
||||
overflow-x: clip;
|
||||
}
|
||||
:host([boxed]) h3 {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
min-height: var(--ha-space-10);
|
||||
margin: 0;
|
||||
padding-block: var(--ha-space-2);
|
||||
padding-inline: var(--ha-space-8) var(--ha-space-3);
|
||||
background-color: var(--card-background-color);
|
||||
color: var(--primary-text-color);
|
||||
font-weight: var(--ha-font-weight-medium);
|
||||
}
|
||||
:host([boxed]) ha-list-item-button {
|
||||
padding: 0 var(--ha-space-4) var(--ha-space-2);
|
||||
box-sizing: border-box;
|
||||
--ha-list-item-focus-radius: var(--ha-border-radius-lg);
|
||||
}
|
||||
:host([boxed]) ha-list-item-button::part(base) {
|
||||
border: 1px solid var(--ha-color-border-neutral-quiet);
|
||||
border-radius: var(--ha-border-radius-lg);
|
||||
overflow: hidden;
|
||||
}
|
||||
:host([boxed]) wa-divider {
|
||||
display: none;
|
||||
}
|
||||
.footer {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
margin-top: auto;
|
||||
padding: var(--ha-space-6) var(--ha-space-4) var(--ha-space-3);
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
transparent,
|
||||
var(--card-background-color) var(--ha-space-6)
|
||||
);
|
||||
pointer-events: none;
|
||||
}
|
||||
.footer-bar {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: var(--ha-space-1);
|
||||
border-radius: var(--ha-border-radius-xl);
|
||||
background-color: var(--ha-color-surface-low);
|
||||
pointer-events: auto;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
import {
|
||||
mdiDevices,
|
||||
mdiFileCodeOutline,
|
||||
mdiPackageVariant,
|
||||
mdiWeb,
|
||||
} from "@mdi/js";
|
||||
import { mdiPackageVariant, mdiPlus, mdiWeb } from "@mdi/js";
|
||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
||||
import { css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consumeLocalize } from "../../../common/decorators/consume-context-entry";
|
||||
import type { LocalizeFunc } from "../../../common/translations/localize";
|
||||
import "../../../components/ha-domain-icon";
|
||||
import "../../../components/ha-icon";
|
||||
import "../../../components/ha-icon-next";
|
||||
import "../../../components/ha-label";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import "../../../components/ha-tooltip";
|
||||
import { HaListItemButton } from "../../../components/item/ha-list-item-button";
|
||||
import { domainToName } from "../../../data/integration";
|
||||
import type { IntegrationListItem } from "./dialog-add-integration";
|
||||
import type { IntegrationListItem } from "./add-integration-list";
|
||||
|
||||
@customElement("ha-integration-list-item")
|
||||
export class HaIntegrationListItem extends HaListItemButton {
|
||||
@property({ attribute: false }) public integration!: IntegrationListItem;
|
||||
|
||||
// Padding, not margin, so the virtualized list measures it
|
||||
@property({ type: Boolean, reflect: true }) public card = false;
|
||||
|
||||
@property({ type: Boolean, attribute: "opens-flow" }) public opensFlow =
|
||||
false;
|
||||
|
||||
@property({ type: Boolean }) public discovered = false;
|
||||
|
||||
@state()
|
||||
@consumeLocalize()
|
||||
private _localize!: LocalizeFunc;
|
||||
@@ -30,11 +35,8 @@ export class HaIntegrationListItem extends HaListItemButton {
|
||||
return html`
|
||||
<div part="start" class="start">
|
||||
${
|
||||
integration.is_discovered
|
||||
? html`<ha-svg-icon
|
||||
class="discovered-icon"
|
||||
.path=${mdiDevices}
|
||||
></ha-svg-icon>`
|
||||
integration.icon
|
||||
? html`<ha-icon .icon=${integration.icon}></ha-icon>`
|
||||
: html`<ha-domain-icon
|
||||
brand-fallback
|
||||
.domain=${integration.domain}
|
||||
@@ -58,6 +60,13 @@ export class HaIntegrationListItem extends HaListItemButton {
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
${
|
||||
integration.description
|
||||
? html`<div part="supporting-text" class="supporting">
|
||||
${integration.description}
|
||||
</div>`
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@@ -65,14 +74,26 @@ export class HaIntegrationListItem extends HaListItemButton {
|
||||
protected override _renderEnd(): TemplateResult {
|
||||
const integration = this.integration;
|
||||
const yamlOnly =
|
||||
!integration.result &&
|
||||
!integration.config_flow &&
|
||||
!integration.integrations &&
|
||||
!integration.iot_standards;
|
||||
return html`
|
||||
<div part="end" class="end">
|
||||
${
|
||||
this.discovered
|
||||
? html`<ha-label dense>
|
||||
${this._localize("ui.panel.config.integrations.discovered")}
|
||||
</ha-label>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
integration.cloud
|
||||
? html`<ha-svg-icon id="icon-cloud" .path=${mdiWeb}></ha-svg-icon>
|
||||
? html`<ha-svg-icon
|
||||
id="icon-cloud"
|
||||
class="status"
|
||||
.path=${mdiWeb}
|
||||
></ha-svg-icon>
|
||||
<ha-tooltip for="icon-cloud" placement="left">
|
||||
${this._localize(
|
||||
"ui.panel.config.integrations.config_entry.depends_on_cloud"
|
||||
@@ -84,9 +105,9 @@ export class HaIntegrationListItem extends HaListItemButton {
|
||||
!integration.is_built_in
|
||||
? html`<ha-svg-icon
|
||||
id="icon-custom"
|
||||
class=${
|
||||
class=${`status ${
|
||||
integration.overwrites_built_in ? "overwrites" : "custom"
|
||||
}
|
||||
}`}
|
||||
.path=${mdiPackageVariant}
|
||||
></ha-svg-icon>
|
||||
<ha-tooltip for="icon-custom" placement="left">
|
||||
@@ -100,17 +121,25 @@ export class HaIntegrationListItem extends HaListItemButton {
|
||||
}
|
||||
${
|
||||
yamlOnly
|
||||
? html`<ha-svg-icon
|
||||
id="icon-yaml"
|
||||
.path=${mdiFileCodeOutline}
|
||||
class="open-in-new"
|
||||
></ha-svg-icon>
|
||||
<ha-tooltip for="icon-yaml" placement="left">
|
||||
? html`<ha-label id="label-yaml" class="yaml" dense>
|
||||
${this._localize(
|
||||
"ui.panel.config.integrations.config_entry.yaml_label"
|
||||
)}
|
||||
</ha-label>
|
||||
<ha-tooltip for="label-yaml" placement="left">
|
||||
${this._localize(
|
||||
"ui.panel.config.integrations.config_entry.yaml_only"
|
||||
)}
|
||||
</ha-tooltip>`
|
||||
: html`<ha-icon-next></ha-icon-next>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
this.opensFlow && !yamlOnly
|
||||
? html`<ha-svg-icon
|
||||
class="add action"
|
||||
.path=${mdiPlus}
|
||||
></ha-svg-icon>`
|
||||
: html`<ha-icon-next class="action"></ha-icon-next>`
|
||||
}
|
||||
</div>
|
||||
`;
|
||||
@@ -119,31 +148,61 @@ export class HaIntegrationListItem extends HaListItemButton {
|
||||
static styles: CSSResultGroup = [
|
||||
HaListItemButton.styles,
|
||||
css`
|
||||
:host([card]) {
|
||||
padding: 0 var(--ha-space-4) var(--ha-space-2);
|
||||
box-sizing: border-box;
|
||||
--ha-list-item-focus-radius: var(--ha-border-radius-lg);
|
||||
}
|
||||
:host([card]) .base {
|
||||
border: 1px solid var(--ha-color-border-neutral-quiet);
|
||||
border-radius: var(--ha-border-radius-lg);
|
||||
overflow: hidden;
|
||||
}
|
||||
.start {
|
||||
--mdc-icon-size: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
/* The inline image's line box pushes it off center */
|
||||
.start ha-domain-icon {
|
||||
display: flex;
|
||||
}
|
||||
.end {
|
||||
color: var(--ha-color-text-secondary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--ha-space-2);
|
||||
gap: var(--ha-space-1);
|
||||
}
|
||||
/* Raise the icons above the row's hit area so their tooltips open */
|
||||
.end ha-svg-icon {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
/* The chevron is decorative, keep it below the row's hit area */
|
||||
.end .status {
|
||||
--mdc-icon-size: 20px;
|
||||
}
|
||||
.end .action {
|
||||
margin-inline-start: var(--ha-space-2);
|
||||
}
|
||||
/* Below the row's hit area */
|
||||
.end ha-icon-next {
|
||||
z-index: -1;
|
||||
color: var(--ha-color-on-neutral-quiet);
|
||||
}
|
||||
.discovered-icon {
|
||||
.end ha-label {
|
||||
border: none;
|
||||
--ha-label-background-color: var(
|
||||
--ha-color-fill-primary-normal-resting
|
||||
);
|
||||
--ha-label-text-color: var(--ha-color-on-primary-normal);
|
||||
}
|
||||
.end .add {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
.open-in-new {
|
||||
--mdc-icon-size: 22px;
|
||||
padding: 1px;
|
||||
.end ha-label.yaml {
|
||||
--ha-label-background-color: var(
|
||||
--ha-color-fill-neutral-normal-resting
|
||||
);
|
||||
--ha-label-text-color: var(--ha-color-on-neutral-normal);
|
||||
}
|
||||
.end .custom {
|
||||
color: var(--warning-color);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
/**
|
||||
* @element ha-integration-list-title
|
||||
* @summary Title above a group of integration cards, like a brand's name.
|
||||
* @slot - The title text.
|
||||
*/
|
||||
@customElement("ha-integration-list-title")
|
||||
export class HaIntegrationListTitle extends LitElement {
|
||||
protected render() {
|
||||
return html`<slot></slot>`;
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
:host {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
min-height: var(--ha-space-10);
|
||||
padding-block: var(--ha-space-2);
|
||||
padding-inline: var(--ha-space-8) var(--ha-space-3);
|
||||
font-weight: var(--ha-font-weight-medium);
|
||||
background-color: var(--card-background-color);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-integration-list-title": HaIntegrationListTitle;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ export interface AddIntegrationDialogParams {
|
||||
initialFilter?: string;
|
||||
integrationFilter?: IntegrationFilter;
|
||||
navigateToResult?: boolean;
|
||||
// Opens on a category like `ai_voice`, or a subcategory like `ai_voice.ai_models`
|
||||
category?: string;
|
||||
}
|
||||
|
||||
export interface YamlIntegrationDialogParams {
|
||||
|
||||
@@ -65,6 +65,8 @@ export class HaGridLayoutSlider extends LitElement {
|
||||
|
||||
private _mc?: HammerManager;
|
||||
|
||||
private _keyboardChanging = false;
|
||||
|
||||
private get _range() {
|
||||
return this.range ?? this.max;
|
||||
}
|
||||
@@ -186,6 +188,7 @@ export class HaGridLayoutSlider extends LitElement {
|
||||
|
||||
this.addEventListener("keydown", this._handleKeyDown);
|
||||
this.addEventListener("keyup", this._handleKeyUp);
|
||||
this.addEventListener("blur", this._endKeyboardChange);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +199,7 @@ export class HaGridLayoutSlider extends LitElement {
|
||||
}
|
||||
this.removeEventListener("keydown", this._handleKeyDown);
|
||||
this.removeEventListener("keyup", this._handleKeyUp);
|
||||
this.removeEventListener("blur", this._endKeyboardChange);
|
||||
}
|
||||
|
||||
private get _tenPercentStep() {
|
||||
@@ -231,12 +235,19 @@ export class HaGridLayoutSlider extends LitElement {
|
||||
this.value = this.max;
|
||||
break;
|
||||
}
|
||||
this._keyboardChanging = true;
|
||||
fireEvent(this, "slider-moved", { value: this.value });
|
||||
}
|
||||
|
||||
private _handleKeyUp(e: KeyboardEvent) {
|
||||
if (!A11Y_KEY_CODES.has(e.code)) return;
|
||||
e.preventDefault();
|
||||
this._endKeyboardChange();
|
||||
}
|
||||
|
||||
private _endKeyboardChange() {
|
||||
if (!this._keyboardChanging) return;
|
||||
this._keyboardChanging = false;
|
||||
fireEvent(this, "value-changed", { value: this.value });
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ class HUIRoot extends KeyboardShortcutMixin(LitElement) {
|
||||
subItems: [
|
||||
{
|
||||
icon: mdiDevices,
|
||||
key: "ui.panel.lovelace.menu.add_device",
|
||||
key: "ui.panel.lovelace.menu.add_device_or_integration",
|
||||
visible: true,
|
||||
action: this._addDevice,
|
||||
overflowAction: this._addDevice,
|
||||
|
||||
@@ -8089,7 +8089,6 @@
|
||||
"description": "Manage integrations with services or devices",
|
||||
"integration": "integration",
|
||||
"discovered": "Discovered",
|
||||
"discovered_devices": "{count, plural,\n one {# discovered device}\n other {# discovered devices}\n}",
|
||||
"manage_discovered": "Manage discovered devices",
|
||||
"manage_discovered_description": "Ignore or configure previously discovered devices",
|
||||
"disabled": "Disabled",
|
||||
@@ -8097,7 +8096,7 @@
|
||||
"new_flow": "Set up another instance of {integration}",
|
||||
"attention": "Attention required",
|
||||
"configured": "Configured",
|
||||
"new": "Select brand",
|
||||
"add_device_or_integration": "Add device or integration",
|
||||
"confirm_new": "Do you want to set up {integration}?",
|
||||
"add_integration": "Add integration",
|
||||
"no_integrations": "Seems like you don't have any integrations configured yet. Press the button below to add your first integration!",
|
||||
@@ -8118,7 +8117,31 @@
|
||||
"search": "Search integrations",
|
||||
"filters": "[%key:ui::components::subpage-data-table::filters%]",
|
||||
"filters_disabled_hidden": "Filters, {number} disabled {number, plural,\n one {integration}\n other {integrations}\n} hidden",
|
||||
"search_brand": "Search for a brand name",
|
||||
"all_integrations": "All integrations",
|
||||
"add_a_device": "Add a device",
|
||||
"browse": "Browse",
|
||||
"browse_by": {
|
||||
"label": "Browse by: {value}",
|
||||
"brand": "Brand",
|
||||
"category": "Category"
|
||||
},
|
||||
"all_brands": "All brands",
|
||||
"search_all": "Search all brands and integrations",
|
||||
"search_section": {
|
||||
"brand": "Brands",
|
||||
"category": "Categories",
|
||||
"integration": "Integrations",
|
||||
"helper": "Helpers"
|
||||
},
|
||||
"search_show_more": "Show {count} more",
|
||||
"subcategories": "Subcategories",
|
||||
"connection": {
|
||||
"label": "Connection: {value}",
|
||||
"all": "All",
|
||||
"local": "Local",
|
||||
"cloud": "Cloud"
|
||||
},
|
||||
"search_no_results": "No results for “{term}”",
|
||||
"search_helper": "Search for a helper",
|
||||
"add_zwave_js_device": "Add Z-Wave device",
|
||||
"add_zha_device": "Add Zigbee device",
|
||||
@@ -8274,6 +8297,7 @@
|
||||
"custom_overwrites_core": "Custom integration that replaces a Core component",
|
||||
"depends_on_cloud": "Requires Internet",
|
||||
"yaml_only": "This integration cannot be set up from the UI",
|
||||
"yaml_label": "YAML",
|
||||
"no_config_flow": "This integration was not set up from the UI",
|
||||
"disabled_polling": "Automatic polling for updated data disabled",
|
||||
"debug_logging_enabled": "Debug logging enabled",
|
||||
@@ -10704,7 +10728,7 @@
|
||||
"exit_edit_mode": "Done",
|
||||
"close": "Close",
|
||||
"add": "Add to Home Assistant",
|
||||
"add_device": "Add device",
|
||||
"add_device_or_integration": "Add device or integration",
|
||||
"create_automation": "Create automation",
|
||||
"create_area": "Create area",
|
||||
"create_area_success": "Area created",
|
||||
|
||||
@@ -146,3 +146,44 @@ describe("ha-control-slider step bounds", () => {
|
||||
expect(values).toEqual([99, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ha-control-slider keyboard focus", () => {
|
||||
const dispatch = (el: HaControlSlider, event: Event) =>
|
||||
el.shadowRoot!.querySelector('[role="slider"]')!.dispatchEvent(event);
|
||||
|
||||
const key = (type: string) =>
|
||||
new KeyboardEvent(type, {
|
||||
code: "ArrowUp",
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
cancelable: true,
|
||||
});
|
||||
|
||||
const changedValues = (el: HaControlSlider) => {
|
||||
const values: (number | undefined)[] = [];
|
||||
el.addEventListener("value-changed", (ev) => {
|
||||
values.push((ev as CustomEvent).detail.value);
|
||||
});
|
||||
return values;
|
||||
};
|
||||
|
||||
it("commits a held key's value when the slider loses focus", async () => {
|
||||
const el = await mountSlider({ min: 0, max: 100, value: 50 });
|
||||
const values = changedValues(el);
|
||||
dispatch(el, key("keydown"));
|
||||
dispatch(el, key("keydown"));
|
||||
dispatch(el, new FocusEvent("blur"));
|
||||
expect(values).toEqual([52]);
|
||||
dispatch(el, key("keyup"));
|
||||
expect(values).toEqual([52]);
|
||||
});
|
||||
|
||||
it("does not commit again when the slider loses focus after the key is released", async () => {
|
||||
const el = await mountSlider({ min: 0, max: 100, value: 50 });
|
||||
const values = changedValues(el);
|
||||
dispatch(el, key("keydown"));
|
||||
dispatch(el, key("keyup"));
|
||||
dispatch(el, new FocusEvent("blur"));
|
||||
expect(values).toEqual([51]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
inCategory,
|
||||
ofConnection,
|
||||
} from "../../../../src/panels/config/integrations/add-integration-list";
|
||||
|
||||
describe("inCategory", () => {
|
||||
it("matches a category, its subcategories, and only those", () => {
|
||||
const categories = ["energy.ev_charging", "climate"];
|
||||
expect(inCategory(categories)).toBe(true);
|
||||
expect(inCategory(categories, "energy")).toBe(true);
|
||||
expect(inCategory(categories, "energy", "ev_charging")).toBe(true);
|
||||
expect(inCategory(categories, "energy", "solar")).toBe(false);
|
||||
expect(inCategory(categories, "climate")).toBe(true);
|
||||
expect(inCategory(categories, "climate", "thermostats")).toBe(false);
|
||||
expect(inCategory(["energy_storage"], "energy")).toBe(false);
|
||||
expect(inCategory(undefined, "energy")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ofConnection", () => {
|
||||
it("keeps everything without a connection, else local or cloud", () => {
|
||||
const local = { id: "a", domain: "a", name: "A" };
|
||||
const cloud = { ...local, cloud: true };
|
||||
expect(ofConnection(local)).toBe(true);
|
||||
expect(ofConnection(cloud)).toBe(true);
|
||||
expect(ofConnection(local, "local")).toBe(true);
|
||||
expect(ofConnection(cloud, "local")).toBe(false);
|
||||
expect(ofConnection(local, "cloud")).toBe(false);
|
||||
expect(ofConnection(cloud, "cloud")).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user