mirror of
https://github.com/home-assistant/frontend.git
synced 2026-12-04 10:40:30 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cc5f644e9 |
No files matched your search
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"_comment": "Initial JS budget (raw/uncompressed bytes) for the cold-load critical entrypoints. Enforced by build-scripts/check-bundle-size.cjs in CI. Re-seed after an intentional change with `--update --headroom=<percent>`.",
|
||||
"frontend-modern": {
|
||||
"app": 655843,
|
||||
"core": 58038,
|
||||
"authorize": 620096,
|
||||
"onboarding": 753790
|
||||
"app": 627654,
|
||||
"core": 57901,
|
||||
"authorize": 593862,
|
||||
"onboarding": 709255
|
||||
},
|
||||
"frontend-legacy": {
|
||||
"app": 755140,
|
||||
"core": 146919,
|
||||
"authorize": 723005,
|
||||
"onboarding": 861854
|
||||
"app": 724225,
|
||||
"core": 163115,
|
||||
"authorize": 693913,
|
||||
"onboarding": 812415
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ export interface DemoArea {
|
||||
picture?: string;
|
||||
temperature_entity_id?: string;
|
||||
humidity_entity_id?: string;
|
||||
occupancy_entity_id?: string;
|
||||
}
|
||||
|
||||
let areas: AreaRegistryEntry[] = [];
|
||||
@@ -22,7 +21,6 @@ export const toAreaRegistryEntry = (area: DemoArea): AreaRegistryEntry => ({
|
||||
icon: area.icon ?? null,
|
||||
temperature_entity_id: area.temperature_entity_id ?? null,
|
||||
humidity_entity_id: area.humidity_entity_id ?? null,
|
||||
occupancy_entity_id: area.occupancy_entity_id ?? null,
|
||||
aliases: [],
|
||||
labels: [],
|
||||
picture: area.picture ?? null,
|
||||
|
||||
@@ -122,7 +122,6 @@ const AREAS: AreaRegistryEntry[] = [
|
||||
labels: [],
|
||||
temperature_entity_id: null,
|
||||
humidity_entity_id: null,
|
||||
occupancy_entity_id: null,
|
||||
created_at: 0,
|
||||
modified_at: 0,
|
||||
},
|
||||
@@ -136,7 +135,6 @@ const AREAS: AreaRegistryEntry[] = [
|
||||
labels: [],
|
||||
temperature_entity_id: null,
|
||||
humidity_entity_id: null,
|
||||
occupancy_entity_id: null,
|
||||
created_at: 0,
|
||||
modified_at: 0,
|
||||
},
|
||||
|
||||
@@ -118,7 +118,6 @@ const area = (areaId: string, name: string): AreaRegistryEntry => ({
|
||||
labels: [],
|
||||
temperature_entity_id: null,
|
||||
humidity_entity_id: null,
|
||||
occupancy_entity_id: null,
|
||||
created_at: 0,
|
||||
modified_at: 0,
|
||||
});
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@
|
||||
"@formatjs/intl-numberformat": "10.1.2",
|
||||
"@formatjs/intl-pluralrules": "7.1.2",
|
||||
"@formatjs/intl-relativetimeformat": "13.0.5",
|
||||
"@home-assistant/webawesome": "3.15.0-ha.0",
|
||||
"@home-assistant/webawesome": "3.14.0-ha.2",
|
||||
"@lezer/common": "1.5.7",
|
||||
"@lezer/highlight": "1.2.5",
|
||||
"@lit-labs/motion": "1.1.0",
|
||||
@@ -156,7 +156,7 @@
|
||||
"@octokit/rest": "22.0.1",
|
||||
"@playwright/test": "1.65.1",
|
||||
"@rsdoctor/rspack-plugin": "1.6.5",
|
||||
"@rspack/core": "2.3.5",
|
||||
"@rspack/core": "2.3.4",
|
||||
"@rspack/dev-server": "2.2.3",
|
||||
"@types/babel__plugin-transform-runtime": "7.9.5",
|
||||
"@types/chromecast-caf-receiver": "7.0.1",
|
||||
|
||||
@@ -102,12 +102,6 @@ import type { HacCard } from "@home-assistant/components/card/scoped";
|
||||
The package has no root entry point: each element and the scoped helpers
|
||||
(`@home-assistant/components/scoped`) have their own.
|
||||
|
||||
## Events
|
||||
|
||||
Events are named after the element that fires them, like
|
||||
`hac-popover-show`, and bubble out of shadow roots. A listener further out
|
||||
can therefore tell a popover closing from a dialog closing around it.
|
||||
|
||||
## Theming
|
||||
|
||||
Each component exposes its own `--hac-*` custom properties, documented in its
|
||||
@@ -137,10 +131,8 @@ src/components/card/ <hac-card> -> @home-assistant/components/card
|
||||
```
|
||||
|
||||
Shared code lives in `src/utils/`: `registration/` for defining elements
|
||||
(global and scoped), `element/` for helpers that components use
|
||||
themselves, like slot checks, and `popup/` for the base of floating elements
|
||||
like `hac-popover`, positioned with
|
||||
[Floating UI](https://floating-ui.com).
|
||||
(global and scoped) and `element/` for helpers that components use
|
||||
themselves, like slot checks.
|
||||
|
||||
Every element has its own version in `info.ts`.
|
||||
|
||||
|
||||
@@ -41,9 +41,6 @@ const publicApiOnly = () => ({
|
||||
declaration.members = declaration.members?.filter(
|
||||
(member) => !member.privacy || member.privacy === "public"
|
||||
);
|
||||
// Events dispatched with a computed name, like the popup base's, have no
|
||||
// name here; the element documents them with @fires instead
|
||||
declaration.events = declaration.events?.filter((event) => event.name);
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -75,8 +72,7 @@ const distPaths = () => {
|
||||
};
|
||||
|
||||
export default {
|
||||
// Base classes are analyzed too, so elements list the members they inherit
|
||||
globs: ["src/components/**/hac-*.ts", "src/utils/popup/*.ts"],
|
||||
globs: ["src/components/**/hac-*.ts"],
|
||||
outdir: "dist",
|
||||
litelement: true,
|
||||
plugins: [
|
||||
|
||||
@@ -48,9 +48,6 @@
|
||||
"dev": "rslib build --watch",
|
||||
"prepublishOnly": "pnpm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@floating-ui/dom": "^1.8.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"lit": "^3.3.0"
|
||||
},
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { define } from "../../utils/registration/define";
|
||||
import { HacPopover } from "./hac-popover";
|
||||
import { TAG_NAME } from "./info";
|
||||
|
||||
// Registers <hac-popover> in the global registry, as used by Home Assistant
|
||||
define(TAG_NAME, HacPopover);
|
||||
|
||||
export { HacPopover };
|
||||
@@ -1,274 +0,0 @@
|
||||
import type { Placement } from "@floating-ui/dom";
|
||||
import { css, type PropertyValues } from "lit";
|
||||
import { property } from "lit/decorators.js";
|
||||
import { containsComposed, deepActiveElement } from "../../utils/element/focus";
|
||||
import { setAriaExpanded } from "../../utils/element/aria";
|
||||
import { listen } from "../../utils/element/listen";
|
||||
import { PopupBase, type PopupHideDetail } from "../../utils/popup/popup-base";
|
||||
import { TAG_NAME } from "./info";
|
||||
|
||||
/**
|
||||
* Works like a disclosure: the anchor gets `aria-expanded`, and focus stays on
|
||||
* the anchor when the popover opens.
|
||||
*
|
||||
* - Set `for` to the id of a `<button>`, or of a button component that
|
||||
* passes the `ariaExpanded` property on to its inner button.
|
||||
* - Place the popover right after its anchor, so Tab and screen readers move
|
||||
* from the anchor into the content.
|
||||
* - Give an icon-only anchor a name, like `aria-label="About logging in"`.
|
||||
* - Keep it to a few links or buttons. Tab moves on past the last one and
|
||||
* closes the popover, so use a dialog for forms and other tasks.
|
||||
* - Not a tooltip: it doesn't open on focus and isn't announced as a
|
||||
* description, so don't use it to label an icon.
|
||||
* - With `trigger="manual"` the parent opens it, like a picker. The parent
|
||||
* then adds the roles and keys, like `role="combobox"` and arrow keys.
|
||||
*
|
||||
* @element hac-popover
|
||||
*
|
||||
* @summary
|
||||
* Panel opened from a button for content people read or interact with, like
|
||||
* help text with links.
|
||||
*
|
||||
* @slot - The popover's content.
|
||||
*
|
||||
* @csspart body - The popover's container.
|
||||
*
|
||||
* @cssprop --hac-popover-background-color - Background of the popover.
|
||||
* @cssprop --hac-popover-max-width - Maximum width. Defaults to `280px`.
|
||||
* @cssprop --hac-popover-max-height - Maximum height. Defaults to `360px`.
|
||||
* @cssprop --hac-popover-box-shadow - Shadow of the popover.
|
||||
* @cssprop --hac-popover-border - Border shorthand. Set to `none` to remove it.
|
||||
* @cssprop --hac-popover-border-radius - Corner radius. Defaults to `24px`.
|
||||
* @cssprop --hac-popover-padding - Padding around the content. Defaults to `16px`.
|
||||
*
|
||||
* @fires hac-popover-show - The popover is about to open. Cancelable.
|
||||
* @fires hac-popover-after-show - The popover opened.
|
||||
* @fires hac-popover-hide - The popover is about to close. Cancelable. `detail.reason` says why.
|
||||
* @fires hac-popover-after-hide - The popover closed. `detail.reason` says why.
|
||||
*/
|
||||
export class HacPopover extends PopupBase {
|
||||
/**
|
||||
* What opens the popover. `hover` also opens it while a mouse rests on the
|
||||
* anchor; a click still works, for touch and keyboard. `manual` leaves it to
|
||||
* `show()`, `hide()` and `open`.
|
||||
*/
|
||||
@property() public trigger: "click" | "hover" | "manual" = "click";
|
||||
|
||||
/**
|
||||
* Preferred placement relative to the anchor: `top`, `right`, `bottom` or
|
||||
* `left`, optionally followed by `-start` or `-end`. Flips to the other
|
||||
* side when there is no room.
|
||||
*/
|
||||
@property({ reflect: true }) public placement: Placement = "bottom-start";
|
||||
|
||||
protected readonly eventPrefix = TAG_NAME;
|
||||
|
||||
private _pinned = false;
|
||||
|
||||
private _timer?: number;
|
||||
|
||||
public disconnectedCallback(): void {
|
||||
super.disconnectedCallback();
|
||||
clearTimeout(this._timer);
|
||||
}
|
||||
|
||||
protected willUpdate(changedProps: PropertyValues<this>): void {
|
||||
super.willUpdate(changedProps);
|
||||
if (changedProps.has("open")) {
|
||||
if (this.anchor) {
|
||||
setAriaExpanded(this.anchor, this.open);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues<this>): void {
|
||||
super.updated(changedProps);
|
||||
// A cancelled hide has set `open` back by now, so it stays pinned
|
||||
if (changedProps.has("open") && !this.open) {
|
||||
this._pinned = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected anchorChanged(
|
||||
anchor: HTMLElement | null,
|
||||
oldAnchor: HTMLElement | null
|
||||
): void {
|
||||
if (oldAnchor && oldAnchor !== anchor) {
|
||||
setAriaExpanded(oldAnchor, null);
|
||||
}
|
||||
if (anchor) {
|
||||
setAriaExpanded(anchor, this.open);
|
||||
}
|
||||
}
|
||||
|
||||
protected attachAnchor(anchor: HTMLElement): (() => void)[] {
|
||||
return [
|
||||
listen(anchor, "click", this._handleClick),
|
||||
listen(anchor, "pointerenter", this._handleEnter),
|
||||
listen(anchor, "pointerleave", this._handleLeave),
|
||||
listen(anchor, "focusout", this._handleFocusOut),
|
||||
listen(this, "pointerenter", this._handleEnter),
|
||||
listen(this, "pointerleave", this._handleLeave),
|
||||
listen(this, "focusout", this._handleFocusOut),
|
||||
];
|
||||
}
|
||||
|
||||
protected async handleEscape(): Promise<void> {
|
||||
const focusInside = this._focusInside();
|
||||
this.close("escape-key");
|
||||
await this.updateComplete;
|
||||
// A listener may have cancelled the hide
|
||||
if (focusInside && !this.open) {
|
||||
this.anchor?.focus();
|
||||
}
|
||||
}
|
||||
|
||||
private _focusInside(): boolean {
|
||||
const root = this.getRootNode();
|
||||
const active = deepActiveElement(
|
||||
root instanceof ShadowRoot ? root : document
|
||||
);
|
||||
return (
|
||||
containsComposed(this, active) ||
|
||||
(this.anchor ? containsComposed(this.anchor, active) : false)
|
||||
);
|
||||
}
|
||||
|
||||
private _opensOnClick(): boolean {
|
||||
return this.trigger !== "manual";
|
||||
}
|
||||
|
||||
private _handleClick = (): void => {
|
||||
if (!this._opensOnClick()) {
|
||||
return;
|
||||
}
|
||||
clearTimeout(this._timer);
|
||||
// Only hover opens it unpinned; a click then pins it instead of closing
|
||||
if (this.open && (this._pinned || this.trigger !== "hover")) {
|
||||
this.close("anchor-click");
|
||||
return;
|
||||
}
|
||||
this._pinned = true;
|
||||
this.open = true;
|
||||
};
|
||||
|
||||
private _handleEnter = (ev: PointerEvent): void => {
|
||||
if (ev.pointerType !== "mouse" || this.trigger !== "hover") {
|
||||
return;
|
||||
}
|
||||
clearTimeout(this._timer);
|
||||
if (!this.open) {
|
||||
this._timer = window.setTimeout(() => {
|
||||
// The trigger may have changed while waiting
|
||||
if (this.trigger === "hover") {
|
||||
this.open = true;
|
||||
}
|
||||
}, 150);
|
||||
}
|
||||
};
|
||||
|
||||
private _handleLeave = (ev: PointerEvent): void => {
|
||||
if (
|
||||
ev.pointerType !== "mouse" ||
|
||||
this.trigger !== "hover" ||
|
||||
this._pinned
|
||||
) {
|
||||
return;
|
||||
}
|
||||
clearTimeout(this._timer);
|
||||
this._timer = window.setTimeout(() => {
|
||||
// Keyboard users may have moved into the content; focusout closes it
|
||||
if (this.trigger === "hover" && !this._focusInside()) {
|
||||
this.close("mouse-leave");
|
||||
}
|
||||
}, 150);
|
||||
};
|
||||
|
||||
private _handleFocusOut = (ev: FocusEvent): void => {
|
||||
const next = ev.relatedTarget as Node | null;
|
||||
if (!this.open || !next) {
|
||||
return;
|
||||
}
|
||||
const insideAnchor = this.anchor
|
||||
? containsComposed(this.anchor, next)
|
||||
: false;
|
||||
const insidePopover = containsComposed(this, next);
|
||||
if (!insideAnchor && !insidePopover) {
|
||||
this.close("focus-out");
|
||||
}
|
||||
};
|
||||
|
||||
static styles = [
|
||||
PopupBase.styles,
|
||||
css`
|
||||
.body {
|
||||
max-width: min(
|
||||
var(--hac-popover-max-width, 280px),
|
||||
var(--available-width, 100vw)
|
||||
);
|
||||
max-height: min(
|
||||
var(--hac-popover-max-height, 360px),
|
||||
var(--available-height, 100vh)
|
||||
);
|
||||
overflow: auto;
|
||||
padding: var(--hac-popover-padding, var(--ha-space-4, 16px));
|
||||
border: var(
|
||||
--hac-popover-border,
|
||||
1px solid var(--ha-color-border-neutral-quiet, rgba(0, 0, 0, 0.12))
|
||||
);
|
||||
border-radius: var(
|
||||
--hac-popover-border-radius,
|
||||
var(--ha-border-radius-3xl, 24px)
|
||||
);
|
||||
background-color: var(
|
||||
--hac-popover-background-color,
|
||||
var(--ha-color-surface-default, #fff)
|
||||
);
|
||||
color: var(--ha-color-text-primary, #141414);
|
||||
box-shadow: var(
|
||||
--hac-popover-box-shadow,
|
||||
0 8px 28px rgba(0, 0, 0, 0.18)
|
||||
);
|
||||
font-family: var(--ha-font-family-body, inherit);
|
||||
font-size: var(--ha-font-size-m, 14px);
|
||||
line-height: 1.45;
|
||||
overflow-wrap: anywhere;
|
||||
animation: hac-popover-in 160ms ease;
|
||||
}
|
||||
|
||||
@keyframes hac-popover-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(4px);
|
||||
}
|
||||
}
|
||||
|
||||
/* min() needs Chrome 79; without it the whole max-width is dropped */
|
||||
@supports not (max-width: min(1px, 2px)) {
|
||||
.body {
|
||||
max-width: var(--hac-popover-max-width, 280px);
|
||||
max-height: var(--available-height, 100vh);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.body {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"hac-popover": HacPopover;
|
||||
}
|
||||
|
||||
interface HTMLElementEventMap {
|
||||
"hac-popover-show": CustomEvent<null>;
|
||||
"hac-popover-after-show": CustomEvent<null>;
|
||||
"hac-popover-hide": CustomEvent<PopupHideDetail>;
|
||||
"hac-popover-after-hide": CustomEvent<PopupHideDetail>;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
/** Tag name of the element. */
|
||||
export const TAG_NAME = "hac-popover";
|
||||
|
||||
/** Version of <hac-popover>. */
|
||||
export const VERSION = "0.1.0";
|
||||
@@ -1,15 +0,0 @@
|
||||
import type { ElementDefinition } from "../../utils/registration/definition";
|
||||
import { HacPopover } from "./hac-popover";
|
||||
import { TAG_NAME } from "./info";
|
||||
|
||||
export { HacPopover };
|
||||
|
||||
/**
|
||||
* The bundled <hac-popover> for a scoped registry:
|
||||
* `ScopedElementsMixin(LitElement, [hacPopover])` or
|
||||
* `createScopedElementRegistry([hacPopover])`.
|
||||
*/
|
||||
export const hacPopover: ElementDefinition<typeof HacPopover> = {
|
||||
tagName: TAG_NAME,
|
||||
element: HacPopover,
|
||||
};
|
||||
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* Sets `aria-expanded` through the `ariaExpanded` property, so a button
|
||||
* component can pass it on to the button inside it instead of getting the
|
||||
* attribute on its host. Falls back to the attribute where browsers lack ARIA
|
||||
* reflection, before Chrome 81 and Firefox 119.
|
||||
*/
|
||||
export const setAriaExpanded = (
|
||||
element: HTMLElement,
|
||||
expanded: boolean | null
|
||||
): void => {
|
||||
const value = expanded === null ? null : String(expanded);
|
||||
const target: object = element;
|
||||
if ("ariaExpanded" in target) {
|
||||
element.ariaExpanded = value;
|
||||
} else if (value === null) {
|
||||
element.removeAttribute("aria-expanded");
|
||||
} else {
|
||||
element.setAttribute("aria-expanded", value);
|
||||
}
|
||||
};
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Like `Node.contains`, but follows slots and shadow hosts, so slotted content
|
||||
* counts as inside the element it is slotted into.
|
||||
*/
|
||||
export const containsComposed = (
|
||||
container: Node,
|
||||
node: Node | null
|
||||
): boolean => {
|
||||
let current: Node | null = node;
|
||||
while (current) {
|
||||
if (current === container) {
|
||||
return true;
|
||||
}
|
||||
current =
|
||||
(current as Element).assignedSlot ??
|
||||
current.parentNode ??
|
||||
(current as ShadowRoot).host ??
|
||||
null;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* The focused element, looking into open shadow roots. Pass the root an
|
||||
* element lives in to also find focus inside a closed shadow root.
|
||||
*/
|
||||
export const deepActiveElement = (
|
||||
root: Document | ShadowRoot = document
|
||||
): Element | null => {
|
||||
let active = root.activeElement;
|
||||
while (active?.shadowRoot?.activeElement) {
|
||||
active = active.shadowRoot.activeElement;
|
||||
}
|
||||
return active;
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Adds an event listener and returns a function that removes it. Unlike the
|
||||
* `signal` option, this also works before Chrome 90 and Safari 15.
|
||||
*/
|
||||
export const listen = <K extends keyof HTMLElementEventMap>(
|
||||
target: EventTarget,
|
||||
type: K,
|
||||
listener: (ev: HTMLElementEventMap[K]) => void,
|
||||
options?: boolean | AddEventListenerOptions
|
||||
): (() => void) => {
|
||||
target.addEventListener(type, listener as EventListener, options);
|
||||
return () =>
|
||||
target.removeEventListener(type, listener as EventListener, options);
|
||||
};
|
||||
@@ -1,485 +0,0 @@
|
||||
import {
|
||||
autoUpdate,
|
||||
computePosition,
|
||||
flip,
|
||||
hide,
|
||||
limitShift,
|
||||
offset,
|
||||
type Placement,
|
||||
shift,
|
||||
type SideObject,
|
||||
size,
|
||||
} from "@floating-ui/dom";
|
||||
import {
|
||||
css,
|
||||
type CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
nothing,
|
||||
type PropertyValues,
|
||||
type TemplateResult,
|
||||
} from "lit";
|
||||
import { property, query } from "lit/decorators.js";
|
||||
import { containsComposed } from "../element/focus";
|
||||
import { listen } from "../element/listen";
|
||||
|
||||
const supportsPopover =
|
||||
typeof HTMLElement !== "undefined" &&
|
||||
Object.prototype.hasOwnProperty.call(HTMLElement.prototype, "popover");
|
||||
|
||||
// Open popups, newest last, so Escape closes only the topmost one. Kept on
|
||||
// window, so scoped copies of the library on one page share it.
|
||||
const popupRegistry = (typeof window === "undefined" ? {} : window) as Record<
|
||||
symbol,
|
||||
PopupBase[]
|
||||
>;
|
||||
const OPEN_POPUPS = Symbol.for("hac-open-popups");
|
||||
popupRegistry[OPEN_POPUPS] ??= [];
|
||||
const openPopups = popupRegistry[OPEN_POPUPS];
|
||||
|
||||
const VIEWPORT_PADDING = 8;
|
||||
|
||||
/**
|
||||
* Why a popup closed. `programmatic` covers `hide()`, setting `open`,
|
||||
* `disabled` and the anchor going away.
|
||||
*/
|
||||
export type PopupHideReason =
|
||||
| "anchor-click"
|
||||
| "click-outside"
|
||||
| "escape-key"
|
||||
| "focus-out"
|
||||
| "mouse-leave"
|
||||
| "programmatic";
|
||||
|
||||
export interface PopupHideDetail {
|
||||
reason: PopupHideReason;
|
||||
}
|
||||
|
||||
const SIDES = ["top", "right", "bottom", "left"] as const;
|
||||
|
||||
// Distance to keep from each viewport edge: the padding plus the safe area,
|
||||
// like a notch or the Android navigation bar, which flip, shift and size
|
||||
// otherwise ignore
|
||||
const edgePadding = (body: HTMLElement): SideObject => {
|
||||
const styles = getComputedStyle(body);
|
||||
const padding = {} as SideObject;
|
||||
for (const side of SIDES) {
|
||||
padding[side] =
|
||||
VIEWPORT_PADDING +
|
||||
(parseFloat(styles.getPropertyValue(`--_safe-area-${side}`)) || 0);
|
||||
}
|
||||
return padding;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base of floating elements like hac-popover: finds the anchor by id, shows
|
||||
* the body in the top layer where the Popover API exists (fixed positioning
|
||||
* otherwise), positions it with floating-ui and closes it with Escape or a
|
||||
* press outside. Events are named after the element, like
|
||||
* `hac-popover-show`, so a listener further out can tell them apart from
|
||||
* those of a dialog or menu around it.
|
||||
*/
|
||||
export abstract class PopupBase extends LitElement {
|
||||
/** The id of the anchor element, in the same root as the popup. */
|
||||
@property() public for?: string;
|
||||
|
||||
/** Whether the popup is shown. */
|
||||
@property({ type: Boolean, reflect: true }) public open = false;
|
||||
|
||||
/**
|
||||
* Preferred placement relative to the anchor: `top`, `right`, `bottom` or
|
||||
* `left`, optionally followed by `-start` or `-end`. Flips to the other
|
||||
* side when there is no room.
|
||||
*/
|
||||
@property({ reflect: true }) public placement: Placement = "top";
|
||||
|
||||
/** Distance from the anchor in pixels. */
|
||||
@property({ type: Number }) public distance = 8;
|
||||
|
||||
/** Offset along the anchor in pixels. */
|
||||
@property({ type: Number }) public skidding = 0;
|
||||
|
||||
/** Prevents the popup from opening. */
|
||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||
|
||||
@query(".body", true) protected body?: HTMLElement;
|
||||
|
||||
protected anchor: HTMLElement | null = null;
|
||||
|
||||
/** Prefix of the events, usually the tag name. */
|
||||
protected abstract readonly eventPrefix: string;
|
||||
|
||||
// Whether the body is shown. `open` can briefly differ while a show or hide
|
||||
// event is being cancelled.
|
||||
private _shown = false;
|
||||
|
||||
private _hideReason?: PopupHideReason;
|
||||
|
||||
private _insidePress?: Event;
|
||||
|
||||
private _detachAnchor: (() => void)[] = [];
|
||||
|
||||
private _detachDocument: (() => void)[] = [];
|
||||
|
||||
private _detachRoot: (() => void)[] = [];
|
||||
|
||||
private _stopAutoUpdate?: () => void;
|
||||
|
||||
public show(): void {
|
||||
this.open = true;
|
||||
}
|
||||
|
||||
public hide(): void {
|
||||
this.open = false;
|
||||
}
|
||||
|
||||
public connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
// A parent may render a new anchor with the same id. Capture listeners on
|
||||
// the root run before the anchor's own, so they can bind the new one in
|
||||
// time for the event.
|
||||
const root = this.getRootNode();
|
||||
this._detachRoot = [
|
||||
listen(root, "click", this._refreshAnchor, true),
|
||||
listen(root, "pointerover", this._refreshAnchor, true),
|
||||
listen(root, "focusin", this._refreshAnchor, true),
|
||||
listen(this, "pointerdown", this._markInsidePress, true),
|
||||
];
|
||||
if (this.hasUpdated) {
|
||||
this._resolveAnchor();
|
||||
}
|
||||
}
|
||||
|
||||
public disconnectedCallback(): void {
|
||||
super.disconnectedCallback();
|
||||
this._detachRoot.forEach((detach) => detach());
|
||||
this._detachRoot = [];
|
||||
this._setAnchor(null);
|
||||
this._teardownOpen();
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues<this>): void {
|
||||
super.updated(changedProps);
|
||||
// Also retry while the anchor is missing, as it may render after the popup
|
||||
if (changedProps.has("for") || (this.for && !this.anchor?.isConnected)) {
|
||||
this._resolveAnchor();
|
||||
}
|
||||
if (changedProps.has("disabled") && this.disabled && this.open) {
|
||||
this.open = false;
|
||||
}
|
||||
if (changedProps.has("open")) {
|
||||
this._syncOpen();
|
||||
}
|
||||
if (
|
||||
this._shown &&
|
||||
(changedProps.has("placement") ||
|
||||
changedProps.has("distance") ||
|
||||
changedProps.has("skidding"))
|
||||
) {
|
||||
this._reposition();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listeners that open and close the popup to the anchor. Returns
|
||||
* the functions that remove them again.
|
||||
*/
|
||||
protected abstract attachAnchor(anchor: HTMLElement): (() => void)[];
|
||||
|
||||
/** Called after the anchor changed, to update its ARIA attributes. */
|
||||
protected anchorChanged(
|
||||
_anchor: HTMLElement | null,
|
||||
_oldAnchor: HTMLElement | null
|
||||
): void {
|
||||
// Does nothing by default
|
||||
}
|
||||
|
||||
/** Closes the popup and passes the reason to the hide events. */
|
||||
protected close(reason: PopupHideReason): void {
|
||||
if (this.open) {
|
||||
this._hideReason = reason;
|
||||
this.open = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Closes the popup on Escape. Subclasses may also move focus. */
|
||||
protected handleEscape(): void {
|
||||
this.close("escape-key");
|
||||
}
|
||||
|
||||
protected renderBody(): TemplateResult {
|
||||
return html`<slot></slot>`;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`<div
|
||||
part="body"
|
||||
class="body"
|
||||
popover=${supportsPopover ? "manual" : nothing}
|
||||
?hidden=${!this.open}
|
||||
>
|
||||
${this.renderBody()}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
private _resolveAnchor(): void {
|
||||
// A popup outside the document has an element as its root, which can't
|
||||
// look up ids
|
||||
const root = this.getRootNode();
|
||||
const anchor =
|
||||
this.for && (root instanceof Document || root instanceof ShadowRoot)
|
||||
? root.getElementById(this.for)
|
||||
: null;
|
||||
if (anchor !== this.anchor) {
|
||||
this._setAnchor(anchor);
|
||||
}
|
||||
}
|
||||
|
||||
private _setAnchor(anchor: HTMLElement | null): void {
|
||||
const oldAnchor = this.anchor;
|
||||
this._detachAnchor.forEach((detach) => detach());
|
||||
this.anchor = anchor;
|
||||
this._detachAnchor = anchor
|
||||
? [
|
||||
...this.attachAnchor(anchor),
|
||||
listen(anchor, "pointerdown", this._markInsidePress, true),
|
||||
]
|
||||
: [];
|
||||
this.anchorChanged(anchor, oldAnchor);
|
||||
if (!anchor && this.open) {
|
||||
this.open = false;
|
||||
}
|
||||
if (anchor && this._shown) {
|
||||
this._startAutoUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// Runs a show or hide when `open` and the shown state differ. A cancelled
|
||||
// event resets `open`, which then matches again and runs nothing.
|
||||
private _syncOpen(): void {
|
||||
const reason = this._hideReason ?? "programmatic";
|
||||
this._hideReason = undefined;
|
||||
if (this.open === this._shown) {
|
||||
return;
|
||||
}
|
||||
if (this.open) {
|
||||
if (!this.anchor?.isConnected) {
|
||||
this._resolveAnchor();
|
||||
}
|
||||
if (this.disabled || !this.anchor) {
|
||||
this.open = false;
|
||||
return;
|
||||
}
|
||||
const canceled = this._fire("show", true);
|
||||
if (canceled) {
|
||||
this.open = false;
|
||||
return;
|
||||
}
|
||||
this._showBody();
|
||||
this._fire("after-show");
|
||||
return;
|
||||
}
|
||||
const detail: PopupHideDetail = { reason };
|
||||
const canceled = this._fire("hide", true, detail);
|
||||
if (canceled) {
|
||||
this.open = true;
|
||||
return;
|
||||
}
|
||||
this._teardownOpen();
|
||||
this._fire("after-hide", false, detail);
|
||||
}
|
||||
|
||||
private _showBody(): void {
|
||||
const body = this.body;
|
||||
if (!body) {
|
||||
return;
|
||||
}
|
||||
this._shown = true;
|
||||
if (supportsPopover && !body.matches(":popover-open")) {
|
||||
body.showPopover();
|
||||
}
|
||||
openPopups.push(this);
|
||||
this._detachDocument = [
|
||||
// Capture phase on window, so Escape closes the popup before a dialog
|
||||
// around it sees the key
|
||||
listen(window, "keydown", this._handleKeyDown, true),
|
||||
listen(document, "pointerdown", this._handlePointerDown, true),
|
||||
];
|
||||
this._startAutoUpdate();
|
||||
}
|
||||
|
||||
private _startAutoUpdate(): void {
|
||||
this._stopAutoUpdate?.();
|
||||
const body = this.body;
|
||||
this._stopAutoUpdate =
|
||||
this.anchor && body
|
||||
? autoUpdate(this.anchor, body, () => this._reposition())
|
||||
: undefined;
|
||||
}
|
||||
|
||||
private _teardownOpen(): void {
|
||||
if (!this._shown) {
|
||||
return;
|
||||
}
|
||||
this._shown = false;
|
||||
this._detachDocument.forEach((detach) => detach());
|
||||
this._detachDocument = [];
|
||||
this._stopAutoUpdate?.();
|
||||
this._stopAutoUpdate = undefined;
|
||||
const index = openPopups.indexOf(this);
|
||||
if (index !== -1) {
|
||||
openPopups.splice(index, 1);
|
||||
}
|
||||
const body = this.body;
|
||||
if (supportsPopover && body?.matches(":popover-open")) {
|
||||
body.hidePopover();
|
||||
}
|
||||
}
|
||||
|
||||
private async _reposition(): Promise<void> {
|
||||
// autoUpdate's ResizeObserver also fires when the anchor leaves the DOM,
|
||||
// so rebind to a replacement here, or close when there is none
|
||||
if (this.anchor && !this.anchor.isConnected) {
|
||||
this._refreshAnchor();
|
||||
return;
|
||||
}
|
||||
const anchor = this.anchor;
|
||||
const body = this.body;
|
||||
if (!anchor || !body || !this._shown) {
|
||||
return;
|
||||
}
|
||||
const padding = edgePadding(body);
|
||||
const position = await computePosition(anchor, body, {
|
||||
strategy: "fixed",
|
||||
placement: this.placement,
|
||||
middleware: [
|
||||
offset({ mainAxis: this.distance, crossAxis: this.skidding }),
|
||||
flip({ padding }),
|
||||
// Keeps it at the anchor, not at the edge of the screen
|
||||
shift({ padding, limiter: limitShift() }),
|
||||
size({
|
||||
padding,
|
||||
apply: ({ availableWidth, availableHeight }) => {
|
||||
body.style.setProperty(
|
||||
"--available-width",
|
||||
`${Math.max(0, availableWidth)}px`
|
||||
);
|
||||
body.style.setProperty(
|
||||
"--available-height",
|
||||
`${Math.max(0, availableHeight)}px`
|
||||
);
|
||||
},
|
||||
}),
|
||||
// The top layer isn't clipped by scrolling containers, so hide it
|
||||
// while its anchor is scrolled out of view
|
||||
hide(),
|
||||
],
|
||||
});
|
||||
const { x, y, placement, middlewareData } = position;
|
||||
body.style.left = `${x}px`;
|
||||
body.style.top = `${y}px`;
|
||||
body.style.visibility = middlewareData.hide?.referenceHidden
|
||||
? "hidden"
|
||||
: "";
|
||||
body.dataset.placement = placement;
|
||||
}
|
||||
|
||||
private _refreshAnchor = (): void => {
|
||||
if (this.for && !this.anchor?.isConnected) {
|
||||
this._resolveAnchor();
|
||||
}
|
||||
};
|
||||
|
||||
private _handleKeyDown = (ev: KeyboardEvent): void => {
|
||||
if (
|
||||
ev.key !== "Escape" ||
|
||||
ev.isComposing ||
|
||||
openPopups[openPopups.length - 1] !== this
|
||||
) {
|
||||
return;
|
||||
}
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
this.handleEscape();
|
||||
};
|
||||
|
||||
private _markInsidePress = (ev: PointerEvent): void => {
|
||||
this._insidePress = ev;
|
||||
};
|
||||
|
||||
private _handlePointerDown = (ev: PointerEvent): void => {
|
||||
const path = ev.composedPath();
|
||||
if (path.includes(this) || (this.anchor && path.includes(this.anchor))) {
|
||||
return;
|
||||
}
|
||||
// In a closed shadow root the path stops at its host. The popup's and
|
||||
// anchor's own listeners see the press later, so decide after them.
|
||||
const target = ev.target as Node | null;
|
||||
if (target && containsComposed(target, this)) {
|
||||
setTimeout(() => {
|
||||
if (this._insidePress !== ev) {
|
||||
this.close("click-outside");
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.close("click-outside");
|
||||
};
|
||||
|
||||
// Returns whether a listener canceled the event
|
||||
private _fire(
|
||||
type: string,
|
||||
cancelable = false,
|
||||
detail: PopupHideDetail | null = null
|
||||
): boolean {
|
||||
return !this.dispatchEvent(
|
||||
new CustomEvent(`${this.eventPrefix}-${type}`, {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
cancelable,
|
||||
detail,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
static styles: CSSResultGroup = css`
|
||||
:host {
|
||||
display: contents;
|
||||
/* Home Assistant's insets include the companion app's */
|
||||
--_safe-area-top: var(
|
||||
--safe-area-inset-top,
|
||||
env(safe-area-inset-top, 0px)
|
||||
);
|
||||
--_safe-area-right: var(
|
||||
--safe-area-inset-right,
|
||||
env(safe-area-inset-right, 0px)
|
||||
);
|
||||
--_safe-area-bottom: var(
|
||||
--safe-area-inset-bottom,
|
||||
env(safe-area-inset-bottom, 0px)
|
||||
);
|
||||
--_safe-area-left: var(
|
||||
--safe-area-inset-left,
|
||||
env(safe-area-inset-left, 0px)
|
||||
);
|
||||
}
|
||||
|
||||
.body {
|
||||
position: fixed;
|
||||
inset: auto;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 1000;
|
||||
box-sizing: border-box;
|
||||
width: max-content;
|
||||
max-width: var(--available-width, 100vw);
|
||||
margin: 0;
|
||||
border: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.body[hidden] {
|
||||
display: none;
|
||||
}
|
||||
`;
|
||||
}
|
||||
@@ -1,285 +0,0 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import "../src/components/popover/global";
|
||||
import type { HacPopover } from "../src/components/popover/hac-popover";
|
||||
|
||||
const mount = async () => {
|
||||
document.body.innerHTML = `
|
||||
<button id="anchor">More info</button>
|
||||
<hac-popover for="anchor"><a id="link" href="#">Learn more</a></hac-popover>
|
||||
<button id="outside">Next</button>
|
||||
`;
|
||||
const popover = document.querySelector("hac-popover") as HacPopover;
|
||||
await popover.updateComplete;
|
||||
const get = (id: string) => document.getElementById(id) as HTMLElement;
|
||||
return {
|
||||
popover,
|
||||
anchor: get("anchor"),
|
||||
link: get("link"),
|
||||
outside: get("outside"),
|
||||
};
|
||||
};
|
||||
|
||||
const pressEscape = () =>
|
||||
window.dispatchEvent(
|
||||
new KeyboardEvent("keydown", { key: "Escape", bubbles: true })
|
||||
);
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
// Keyboard and screen reader users rely on the anchor's state and on focus
|
||||
// coming back to the anchor; nothing else shows them the popover closed.
|
||||
describe("hac-popover", () => {
|
||||
it("links the anchor and toggles on click", async () => {
|
||||
const { popover, anchor } = await mount();
|
||||
expect(anchor.getAttribute("aria-expanded")).toBe("false");
|
||||
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(true);
|
||||
expect(anchor.getAttribute("aria-expanded")).toBe("true");
|
||||
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(false);
|
||||
expect(anchor.getAttribute("aria-expanded")).toBe("false");
|
||||
});
|
||||
|
||||
it("returns focus to the anchor on Escape from inside", async () => {
|
||||
const { popover, anchor, link } = await mount();
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
link.focus();
|
||||
|
||||
pressEscape();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(false);
|
||||
expect(document.activeElement).toBe(anchor);
|
||||
});
|
||||
|
||||
it("closes when focus leaves the anchor and the content", async () => {
|
||||
const { popover, anchor, link, outside } = await mount();
|
||||
anchor.focus();
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
|
||||
link.focus();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(true);
|
||||
|
||||
outside.focus();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(false);
|
||||
});
|
||||
|
||||
it("stays open while focus is inside when the mouse leaves", async () => {
|
||||
const { popover, anchor, link } = await mount();
|
||||
popover.trigger = "hover";
|
||||
const mouse = (type: string) =>
|
||||
anchor.dispatchEvent(new PointerEvent(type, { pointerType: "mouse" }));
|
||||
mouse("pointerenter");
|
||||
await new Promise((resolve) => {
|
||||
setTimeout(resolve, 200);
|
||||
});
|
||||
expect(popover.open).toBe(true);
|
||||
|
||||
link.focus();
|
||||
mouse("pointerleave");
|
||||
await new Promise((resolve) => {
|
||||
setTimeout(resolve, 200);
|
||||
});
|
||||
expect(popover.open).toBe(true);
|
||||
});
|
||||
|
||||
it("runs each transition once when one is cancelled", async () => {
|
||||
const { popover, anchor } = await mount();
|
||||
const fired: string[] = [];
|
||||
for (const type of ["show", "after-show", "hide", "after-hide"]) {
|
||||
popover.addEventListener(`hac-popover-${type}`, () => fired.push(type));
|
||||
}
|
||||
popover.addEventListener("hac-popover-hide", (ev) => ev.preventDefault(), {
|
||||
once: true,
|
||||
});
|
||||
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
popover.hide();
|
||||
await popover.updateComplete;
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(true);
|
||||
expect(fired).toEqual(["show", "after-show", "hide"]);
|
||||
});
|
||||
|
||||
// A picker cancels some hides; the popover must then behave as if still open
|
||||
it("keeps focus and pinning when a hide is cancelled", async () => {
|
||||
const { popover, anchor, link } = await mount();
|
||||
popover.addEventListener("hac-popover-hide", (ev) => ev.preventDefault(), {
|
||||
once: true,
|
||||
});
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
link.focus();
|
||||
|
||||
pressEscape();
|
||||
await popover.updateComplete;
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(true);
|
||||
expect(document.activeElement).toBe(link);
|
||||
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(false);
|
||||
});
|
||||
|
||||
// Lit re-renders can swap the anchor for a new element with the same id
|
||||
it("follows an anchor that was replaced", async () => {
|
||||
const { popover, anchor } = await mount();
|
||||
const replacement = document.createElement("button");
|
||||
anchor.replaceWith(replacement);
|
||||
replacement.id = "anchor";
|
||||
|
||||
replacement.click();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(true);
|
||||
expect(replacement.getAttribute("aria-expanded")).toBe("true");
|
||||
});
|
||||
|
||||
it("closes on an anchor click after opening from code", async () => {
|
||||
const { popover, anchor } = await mount();
|
||||
popover.show();
|
||||
await popover.updateComplete;
|
||||
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(false);
|
||||
});
|
||||
|
||||
it("rebinds or closes when the anchor changes while open", async () => {
|
||||
const { popover, anchor } = await mount();
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
|
||||
const replacement = document.createElement("button");
|
||||
replacement.id = "anchor";
|
||||
anchor.replaceWith(replacement);
|
||||
// Browsers report the removal through ResizeObserver, which jsdom lacks
|
||||
window.dispatchEvent(new Event("resize"));
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(true);
|
||||
expect(replacement.getAttribute("aria-expanded")).toBe("true");
|
||||
|
||||
replacement.remove();
|
||||
window.dispatchEvent(new Event("resize"));
|
||||
await popover.updateComplete;
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(false);
|
||||
});
|
||||
|
||||
// A custom card may put the popover in a closed shadow root, which hides it
|
||||
// from the document's view of events and focus
|
||||
it("works inside a closed shadow root", async () => {
|
||||
const host = document.createElement("div");
|
||||
document.body.append(host);
|
||||
const root = host.attachShadow({ mode: "closed" });
|
||||
root.innerHTML = `
|
||||
<button id="anchor">More info</button>
|
||||
<hac-popover for="anchor"><a id="link" href="#">Learn more</a></hac-popover>
|
||||
`;
|
||||
const popover = root.querySelector("hac-popover") as HacPopover;
|
||||
const anchor = root.getElementById("anchor") as HTMLElement;
|
||||
const link = root.getElementById("link") as HTMLElement;
|
||||
const press = (target: Element) =>
|
||||
target.dispatchEvent(
|
||||
new PointerEvent("pointerdown", { bubbles: true, composed: true })
|
||||
);
|
||||
const settle = () =>
|
||||
new Promise((resolve) => {
|
||||
setTimeout(resolve);
|
||||
});
|
||||
await popover.updateComplete;
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
|
||||
press(link);
|
||||
await settle();
|
||||
expect(popover.open).toBe(true);
|
||||
|
||||
link.focus();
|
||||
pressEscape();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(false);
|
||||
expect(root.activeElement).toBe(anchor);
|
||||
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
press(document.body);
|
||||
await settle();
|
||||
expect(popover.open).toBe(false);
|
||||
});
|
||||
|
||||
// Parents like a picker react differently to Escape than to a press outside
|
||||
it("tells why it closed", async () => {
|
||||
const { popover, anchor, outside } = await mount();
|
||||
const reasons: string[] = [];
|
||||
popover.addEventListener("hac-popover-after-hide", (ev) =>
|
||||
reasons.push(ev.detail.reason)
|
||||
);
|
||||
const closeWith = async (close: () => void) => {
|
||||
anchor.click();
|
||||
await popover.updateComplete;
|
||||
close();
|
||||
await popover.updateComplete;
|
||||
};
|
||||
|
||||
await closeWith(() => anchor.click());
|
||||
await closeWith(pressEscape);
|
||||
await closeWith(() =>
|
||||
outside.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true }))
|
||||
);
|
||||
await closeWith(() => popover.hide());
|
||||
expect(reasons).toEqual([
|
||||
"anchor-click",
|
||||
"escape-key",
|
||||
"click-outside",
|
||||
"programmatic",
|
||||
]);
|
||||
});
|
||||
|
||||
it("finds an anchor rendered after the popover", async () => {
|
||||
document.body.innerHTML = `<hac-popover for="late">Text</hac-popover>`;
|
||||
const popover = document.querySelector("hac-popover") as HacPopover;
|
||||
await popover.updateComplete;
|
||||
const anchor = document.createElement("button");
|
||||
anchor.id = "late";
|
||||
popover.before(anchor);
|
||||
|
||||
popover.show();
|
||||
await popover.updateComplete;
|
||||
expect(popover.open).toBe(true);
|
||||
expect(anchor.getAttribute("aria-expanded")).toBe("true");
|
||||
});
|
||||
|
||||
// Button components put the state on their inner button; on the host it
|
||||
// would be announced a second time
|
||||
it("hands aria-expanded to a button component as a property", async () => {
|
||||
document.body.innerHTML = `<hac-popover for="anchor">Text</hac-popover>`;
|
||||
const popover = document.querySelector("hac-popover") as HacPopover;
|
||||
// Stands in for a component that overrides the ariaExpanded property
|
||||
const anchor = document.createElement("span");
|
||||
anchor.id = "anchor";
|
||||
let expanded: string | null = null;
|
||||
Object.defineProperty(anchor, "ariaExpanded", {
|
||||
get: () => expanded,
|
||||
set: (value: string | null) => {
|
||||
expanded = value;
|
||||
},
|
||||
});
|
||||
popover.before(anchor);
|
||||
|
||||
popover.show();
|
||||
await popover.updateComplete;
|
||||
expect(expanded).toBe("true");
|
||||
expect(anchor.hasAttribute("aria-expanded")).toBe(false);
|
||||
});
|
||||
});
|
||||
Generated
+132
-150
@@ -269,8 +269,8 @@ importers:
|
||||
specifier: 13.0.5
|
||||
version: 13.0.5
|
||||
'@home-assistant/webawesome':
|
||||
specifier: 3.15.0-ha.0
|
||||
version: 3.15.0-ha.0(@floating-ui/[email protected])(@types/[email protected])
|
||||
specifier: 3.14.0-ha.2
|
||||
version: 3.14.0-ha.2(@floating-ui/[email protected])(@types/[email protected])
|
||||
'@lezer/common':
|
||||
specifier: 1.5.7
|
||||
version: 1.5.7
|
||||
@@ -541,13 +541,13 @@ importers:
|
||||
version: 1.65.1
|
||||
'@rsdoctor/rspack-plugin':
|
||||
specifier: 1.6.5
|
||||
version: 1.6.5(@emnapi/[email protected].2)(@emnapi/[email protected].2)(@rsbuild/[email protected]([email protected]))(@rspack/[email protected].5(@swc/[email protected]))([email protected])
|
||||
version: 1.6.5(@emnapi/[email protected].3)(@emnapi/[email protected].3)(@rsbuild/[email protected]([email protected]))(@rspack/[email protected].4(@swc/[email protected]))([email protected])
|
||||
'@rspack/core':
|
||||
specifier: 2.3.5
|
||||
version: 2.3.5(@swc/[email protected])
|
||||
specifier: 2.3.4
|
||||
version: 2.3.4(@swc/[email protected])
|
||||
'@rspack/dev-server':
|
||||
specifier: 2.2.3
|
||||
version: 2.2.3(@rspack/[email protected].5(@swc/[email protected]))
|
||||
version: 2.2.3(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@types/babel__plugin-transform-runtime':
|
||||
specifier: 7.9.5
|
||||
version: 7.9.5
|
||||
@@ -595,7 +595,7 @@ importers:
|
||||
version: 5.1.2([email protected])
|
||||
babel-loader:
|
||||
specifier: 10.1.1
|
||||
version: 10.1.1(@babel/[email protected])(@rspack/[email protected].5(@swc/[email protected]))
|
||||
version: 10.1.1(@babel/[email protected])(@rspack/[email protected].4(@swc/[email protected]))
|
||||
babel-plugin-polyfill-corejs3:
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0(@babel/[email protected])
|
||||
@@ -703,7 +703,7 @@ importers:
|
||||
version: 3.10.1
|
||||
rspack-manifest-plugin:
|
||||
specifier: 5.2.2
|
||||
version: 5.2.2(@rspack/[email protected].5(@swc/[email protected]))
|
||||
version: 5.2.2(@rspack/[email protected].4(@swc/[email protected]))
|
||||
serve:
|
||||
specifier: 14.2.8
|
||||
version: 14.2.8([email protected])
|
||||
@@ -739,16 +739,12 @@ importers:
|
||||
version: 1.1.3
|
||||
webpackbar:
|
||||
specifier: 7.0.0
|
||||
version: 7.0.0(@rspack/[email protected].5(@swc/[email protected]))
|
||||
version: 7.0.0(@rspack/[email protected].4(@swc/[email protected]))
|
||||
workbox-build:
|
||||
specifier: 7.4.1
|
||||
version: 7.4.1(patch_hash=75e6346ad8d8af554c167f77ac7d9b9652f010398efdc6b399925a4795133099)([email protected])
|
||||
|
||||
packages/components:
|
||||
dependencies:
|
||||
'@floating-ui/dom':
|
||||
specifier: ^1.8.0
|
||||
version: 1.8.0
|
||||
devDependencies:
|
||||
'@custom-elements-manifest/analyzer':
|
||||
specifier: 0.11.0
|
||||
@@ -1909,8 +1905,8 @@ packages:
|
||||
'@emnapi/[email protected]':
|
||||
resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==}
|
||||
|
||||
'@emnapi/[email protected].4':
|
||||
resolution: {integrity: sha512-AhU/vMMXtGgLCrWsL3PjZGSpCWXlGETabnyyB2pBUd6h7AMy2toffJO2T7yXOYXtw8FyD6dYK/5b3u5eRK3yhw==}
|
||||
'@emnapi/[email protected].3':
|
||||
resolution: {integrity: sha512-KA+gOBtbifRATmUa/Gpf5C2B2EJ0r4brHUT3XSgACeHREcuiObXH56xd+B3fFsEFbUT04VBEe6MuZiCtMp0tQg==}
|
||||
|
||||
'@emnapi/[email protected]':
|
||||
resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==}
|
||||
@@ -1921,8 +1917,8 @@ packages:
|
||||
'@emnapi/[email protected]':
|
||||
resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==}
|
||||
|
||||
'@emnapi/[email protected].4':
|
||||
resolution: {integrity: sha512-UKxc3beuftD67T1mPCVf0mnwRKOBsq9XrhLCDGGQKsbG9jx6osvGyjIbJm9DsucyUtFSMTV2ZxsjiuTMjEqWkA==}
|
||||
'@emnapi/[email protected].3':
|
||||
resolution: {integrity: sha512-ayb/PyyLzpwRyFVxeC0uoEHu59QlB1iWGcGsOpXQcaB/Dc+uGfBmNmpCHp3HmTT0t8lSsMmg3j7+tdJW/TlHjQ==}
|
||||
|
||||
'@emnapi/[email protected]':
|
||||
resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}
|
||||
@@ -2096,8 +2092,8 @@ packages:
|
||||
resolution: {integrity: sha512-kjotm7XJrJ6v+7knhPaRgaT6q8F8K2jiafwYdNHLzmV0uGLuZY43FK6smNSHUPrhq5kX2slCUy+RGG/xGqmIKA==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
|
||||
'@home-assistant/[email protected]5.0-ha.0':
|
||||
resolution: {integrity: sha512-s1L2M8oaPNfDXdG2M5afeEpEJOP3s0t2GICl8XYgL6SVLVFDNOwWLG2SysbI/Iw7VhIos/4TIbOKr8IEOdLceQ==}
|
||||
'@home-assistant/[email protected]4.0-ha.2':
|
||||
resolution: {integrity: sha512-EX1qiX5h3LAoTjuE3rgfuRlNq3Rds5tGrgDGlHoFbxhXaCSTTtuYU6tdR8vgOXKGUDi5gBDrcoNdLYKFXSrknA==}
|
||||
engines: {node: '>=14.17.0'}
|
||||
|
||||
'@html-eslint/[email protected]':
|
||||
@@ -3053,88 +3049,88 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-A5XnBdSoJvcYV4t2Y+XJiCF0UZ42nOKE2D0ZlegfErGhzlQG1t3hDOzskSB2fPD3z+w5QeREoclqQ0zFOZyBpw==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-eBD71fbmoJKnxcHD03bukbAIOP5r7nD0Ehs+mUrUQlZ6N53EhuJsTeJ1oYdg5L4GoSeQ+KecCqME81Nm0COLrA==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-iZrweqTIj2cM4f0ADRj6FXn9a0FOpD1Mx/++zrsbrQzmnY0c8wmfpvZ5xA5Zfcq9O6nuUBS6GnhkmoFTgviHwQ==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-CqdfzTLPVFQCniOy/GDVWbg+rqg31qfdzbFf8NYCzdDkCQg+p15hU2HsckD/1sLsaNB8Y55EjGz4ZyGDny0cHg==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-aWE9V0ZhmclKsJNuO37cxUMLtXMjhLtFzrWDWC82mksUX6qM2rzOpPuye9i/c9NGqyrIH7EFQre8bskJvNHGuQ==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-T/Y1FYiSegcNc+oHuDOLRGIcc+eSdBnfbS70d51EWQj4+0TG/tlfuqFKeAIL3mnKUV5lDLaTz3vsoD0Sws5Fxw==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-I8ENTXdv7Th/OHEYhL7uu3B7DA9r1oTWSifkGHJtuT1XJ0KDsxoA6ORpYz1R2qIs87l+8+5QUnRH7iWyZrnroA==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-WZHCzZ532UfXFXNU8XyM8jb+I6wddegbs/7IXsyw7xiPwwZX1D/M6iKFVpBYdvKcupUM8bS8Uw2REirR/cERVw==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-ps5do0cKf4aTBWd+LHqvwm8Gdn7J/gvzmx9pWJhAIThvzii45wJREFjGOzJNxdQl+pzKq8JFuzbShNskCN9k2w==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-WeizqeI6HIh7Ax9w2tlmpTtipJWxXcdgt3QqI3N9LOixymlMD5yMBMZNPqwZ6cHXT9gOQ69SvPcVgMwxsdmceQ==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-3XXIEMS4SSr1/9wIAGgPT1oj1SzhnlejAG5xeVbGJR5y6iFp/oFKYzUPqyuuzZCkWph2/hJ+Q16sa+BJn1YIkg==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-h+001Vbq8LyGwPMNkeRWidPOVKwlAbwNPskY3CjNlSw3euHkVchfhM3uo6+1h0GyTtb3rzsWqsfm1kar7m/tiQ==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-z2DbQNcLbUEY9OvUa3gahsHey+dW4acLc9d3QlyJm7TJE//rL9C/XBk4kETvCgtdhqrwBSfWrZfislBPKODjvA==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-S1rlaCnNVG5s4WZ9odLsqN3ySh5TEdNTLXWapEK8x3iQl56aLtdvqXTfbJWHWnYLJuS7M1WqnQGdJNdjy2NDsA==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-n2UudDpzt9G2AOmycVS7uWRMcNMd2k4ubU4b4SX3FfU/uT6mfSNzuwhBhCi0RSZQAGBU0ombJ+sqw8vKXjGGbw==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-0SkgGrgulVMam3xel5dMNKQ+U7BEpCczhF1avGT1DzDVIbMfIOsbb32gApQNSz0E7RfAQ/Pa5eWiA9oyRq7ZMQ==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-1sxASGJXg9luaYsFSmAQxSFbUbnMnPA5Mr94yIlLsq4q94sHUIn5YjG1XGcT+cPhUYF9fHkCsKRmQlzrN9fR8A==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-q7E6x3rJJ/9fJyLuRe5+KyEPi23BF/xkAU4xCM5VwLkTf+rVyOkDZfu0qOkxmILjrxllQPV+b/ojBL/ZaIeQPw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-/S4pe1wAo8CBTs0X8DNKu1ZOJ2vQcnThLBKS2CxOPiuQXI7UfAsJCEABBoa8yCrZANWh63fJ90UwLb/s245Gsw==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-rey4Tyasui/WeMn6KfhH5xyZGOMt+Ny+GDK7nGh9TSz/cb3/bisxqGzpbu6GJK8leDmTUDD5ZdpODexytA5rzQ==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-GQnswrv6AyBdDCcTy8dTVhD0JqnvmgewzPz6qnOYWGKxpCY99Bv6FL4jvxI1yh64Uk3ykEfbwhrPnaA8Px4KJA==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-sDt2MSXZrIaMBa6UaEqmXEqebwpTOPAXLdo9CYJ2Fa9FJWP4TCYbn30mbvV38ZC2n5YX411DRbjck+s97CceIg==}
|
||||
cpu: [wasm32]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-XVKu3Zs5KGr+P5Seh6NtSNU0UQ1GSgSDFANQRZlT1uFZ1NpBCX+9NB8FVZB0hBBoBKI1kU4b0Cr6Df1Xx0K4nQ==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-24YC1YSodLAJ8VsMQJmJSHCNvHTqK9JP5hj50T50WE8lCHNsNl/rIYXO9V0VlCYT/HshE6EHHzAeKdahiEOtcw==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-ejCqSuctPcOev2dyi0ayZyfIUY3fJdYHYvrTfSVrrGC19TspuRATXu+RLyu3xvB6TrQF3+JEF4KeG4/ZeWuXOg==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-xmUNu6kgV9lLEkRP1Zb+t6i1Z1ZMEWXmLlMalPx8tHqndz2RflNMBBx6kjB2nAPQBIZgWufwm7dVGS0HKomCmw==}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-IPvkjM3xAwL1z2N4Jp/GBcZUme703uDy5vrP1IMtXJEl/EOLLfwl7cRb4sSzdeOYGDDHs5dPYDcpgP5eRSRauA==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-WY+AkJqpbLtLEZiG1fE7CVJZ54y0qHeCiVmLxGBsh4OOGIDCs6v2Ub5COcPrYVzGJFGyeHUS29dV7JAs93qIHw==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-W3x7zw5d/mIH9WhWt4pO9RKYURoqgdUxeLSV5IhDCajnhXdRr7R59u5S2j5ZXzSk3eMGUC0PenfKIIdW7t0ufQ==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-wSOT16LVITL/IKeIiLXgN5Q5jZIDqnQ7Gmk+wzKOSZ6OHYNfEBXAKhSJuYtCBq8ovJuGl8cJjdqatAlHE5XKIA==}
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
resolution: {integrity: sha512-4TG6zGTemEU/FU7bymDgeFOO7CRdd7ucn0CmXo+3cG6EhYmY5+hpAFYBRgxDbDuL4Bwo/s5GsgUvZuI7rLqVbQ==}
|
||||
'@rspack/[email protected].4':
|
||||
resolution: {integrity: sha512-T8HGkIjPVDlGlIN8st/ICe8Gfixq8te75g/8crSdNSf8F+6884sBcKNky0CRdfPxao1C5SXV+Vjv1XJTjyu83w==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
peerDependencies:
|
||||
'@module-federation/runtime-tools': ^0.24.1 || ^2.0.0
|
||||
@@ -4820,8 +4816,8 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-bgy+iHRFjsBxBCriXkTuFuHRJGSGZISuqDGhDQG7gLK0F7qOzhH06bdXzGf4b0bZSQ+mApakybiW9xvKnS9dbg==}
|
||||
|
||||
cross-spawn@7.1.2:
|
||||
resolution: {integrity: sha512-8BPK2r+sKWC8sDinRwLwrFMq2lXTBBwzYYEB9LiCznfMurOi4FOvQflq3XOLGG+HPdMSVpe+k/s96+AtDEOgPg==}
|
||||
cross-spawn@7.0.6:
|
||||
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
[email protected]:
|
||||
@@ -6611,10 +6607,6 @@ packages:
|
||||
resolution: {integrity: sha512-j2gvsGUFeS/53WdYLl9H5G2YtMZX9G/PlCvV3E5Pf4j5XSnK19DwazU6wki7OTcKeYKed7+qujRDLhy8NV2zBg==}
|
||||
engines: {node: '>=22.12.0'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-XFUHmKclX4taKWVpYkqJ/GlfUS27FzQTCph1u3v9OwkmQJGXry3Pk1e7SivLz6xGOCxRVyi3DSrztF3e460jrg==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==}
|
||||
engines: {node: '>=8.6'}
|
||||
@@ -10127,7 +10119,7 @@ snapshots:
|
||||
tslib: 2.9.1
|
||||
optional: true
|
||||
|
||||
'@emnapi/[email protected].4':
|
||||
'@emnapi/[email protected].3':
|
||||
dependencies:
|
||||
'@emnapi/wasi-threads': 2.2.0
|
||||
tslib: 2.9.1
|
||||
@@ -10148,7 +10140,7 @@ snapshots:
|
||||
tslib: 2.9.1
|
||||
optional: true
|
||||
|
||||
'@emnapi/[email protected].4':
|
||||
'@emnapi/[email protected].3':
|
||||
dependencies:
|
||||
tslib: 2.9.1
|
||||
optional: true
|
||||
@@ -10339,7 +10331,7 @@ snapshots:
|
||||
dependencies:
|
||||
is-negated-glob: 1.0.0
|
||||
|
||||
'@home-assistant/[email protected]5.0-ha.0(@floating-ui/[email protected])(@types/[email protected])':
|
||||
'@home-assistant/[email protected]4.0-ha.2(@floating-ui/[email protected])(@types/[email protected])':
|
||||
dependencies:
|
||||
'@ctrl/tinycolor': 4.1.0
|
||||
'@floating-ui/dom': 1.8.0
|
||||
@@ -10353,7 +10345,6 @@ snapshots:
|
||||
composed-offset-position: 0.0.6(@floating-ui/[email protected])
|
||||
lit: 3.3.3
|
||||
marked: 11.2.0
|
||||
microlighter: 2.2.0
|
||||
nanoid: 5.1.16
|
||||
transitivePeerDependencies:
|
||||
- '@floating-ui/utils'
|
||||
@@ -10710,17 +10701,10 @@ snapshots:
|
||||
'@tybys/wasm-util': 0.10.3
|
||||
optional: true
|
||||
|
||||
'@napi-rs/[email protected](@emnapi/[email protected].2)(@emnapi/[email protected].2)':
|
||||
'@napi-rs/[email protected](@emnapi/[email protected].3)(@emnapi/[email protected].3)':
|
||||
dependencies:
|
||||
'@emnapi/core': 2.0.0-beta.2
|
||||
'@emnapi/runtime': 2.0.0-beta.2
|
||||
'@tybys/wasm-util': 0.10.3
|
||||
optional: true
|
||||
|
||||
'@napi-rs/[email protected](@emnapi/[email protected])(@emnapi/[email protected])':
|
||||
dependencies:
|
||||
'@emnapi/core': 2.0.0-beta.4
|
||||
'@emnapi/runtime': 2.0.0-beta.4
|
||||
'@emnapi/core': 2.0.0-beta.3
|
||||
'@emnapi/runtime': 2.0.0-beta.3
|
||||
'@tybys/wasm-util': 0.10.3
|
||||
optional: true
|
||||
|
||||
@@ -11315,7 +11299,7 @@ snapshots:
|
||||
|
||||
'@rsbuild/[email protected]([email protected])':
|
||||
dependencies:
|
||||
'@rspack/core': 2.3.5(@swc/[email protected])
|
||||
'@rspack/core': 2.3.4(@swc/[email protected])
|
||||
'@swc/helpers': 0.5.24
|
||||
optionalDependencies:
|
||||
core-js: 3.51.0
|
||||
@@ -11334,14 +11318,14 @@ snapshots:
|
||||
|
||||
'@rsdoctor/[email protected]': {}
|
||||
|
||||
'@rsdoctor/[email protected](@emnapi/[email protected].2)(@emnapi/[email protected].2)(@rsbuild/[email protected]([email protected]))(@rspack/[email protected].5(@swc/[email protected]))([email protected])':
|
||||
'@rsdoctor/[email protected](@emnapi/[email protected].3)(@emnapi/[email protected].3)(@rsbuild/[email protected]([email protected]))(@rspack/[email protected].4(@swc/[email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@rsbuild/plugin-check-syntax': 1.6.1(@rsbuild/[email protected]([email protected]))
|
||||
'@rsdoctor/graph': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/sdk': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))([email protected])
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/utils': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rspack/resolver': 0.2.8(@emnapi/[email protected].2)(@emnapi/[email protected].2)
|
||||
'@rsdoctor/graph': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@rsdoctor/sdk': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))([email protected])
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@rsdoctor/utils': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@rspack/resolver': 0.2.8(@emnapi/[email protected].3)(@emnapi/[email protected].3)
|
||||
browserslist-load-config: 1.0.3
|
||||
enhanced-resolve: 5.26.0
|
||||
es-toolkit: 1.50.0
|
||||
@@ -11359,10 +11343,10 @@ snapshots:
|
||||
- utf-8-validate
|
||||
- webpack
|
||||
|
||||
'@rsdoctor/[email protected](@rspack/[email protected].5(@swc/[email protected]))':
|
||||
'@rsdoctor/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
|
||||
dependencies:
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/utils': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@rsdoctor/utils': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
es-toolkit: 1.50.0
|
||||
path-browserify: 1.0.1
|
||||
source-map: 0.7.6
|
||||
@@ -11370,15 +11354,15 @@ snapshots:
|
||||
- '@rspack/core'
|
||||
- webpack
|
||||
|
||||
'@rsdoctor/[email protected](@emnapi/[email protected].2)(@emnapi/[email protected].2)(@rsbuild/[email protected]([email protected]))(@rspack/[email protected].5(@swc/[email protected]))([email protected])':
|
||||
'@rsdoctor/[email protected](@emnapi/[email protected].3)(@emnapi/[email protected].3)(@rsbuild/[email protected]([email protected]))(@rspack/[email protected].4(@swc/[email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@rsdoctor/core': 1.6.5(@emnapi/[email protected].2)(@emnapi/[email protected].2)(@rsbuild/[email protected]([email protected]))(@rspack/[email protected].5(@swc/[email protected]))([email protected])
|
||||
'@rsdoctor/graph': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/sdk': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))([email protected])
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/utils': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/core': 1.6.5(@emnapi/[email protected].3)(@emnapi/[email protected].3)(@rsbuild/[email protected]([email protected]))(@rspack/[email protected].4(@swc/[email protected]))([email protected])
|
||||
'@rsdoctor/graph': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@rsdoctor/sdk': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))([email protected])
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@rsdoctor/utils': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
optionalDependencies:
|
||||
'@rspack/core': 2.3.5(@swc/[email protected])
|
||||
'@rspack/core': 2.3.4(@swc/[email protected])
|
||||
transitivePeerDependencies:
|
||||
- '@emnapi/core'
|
||||
- '@emnapi/runtime'
|
||||
@@ -11388,12 +11372,12 @@ snapshots:
|
||||
- utf-8-validate
|
||||
- webpack
|
||||
|
||||
'@rsdoctor/[email protected](@rspack/[email protected].5(@swc/[email protected]))([email protected])':
|
||||
'@rsdoctor/[email protected](@rspack/[email protected].4(@swc/[email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@rsdoctor/client': 1.6.5
|
||||
'@rsdoctor/graph': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/utils': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/graph': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@rsdoctor/utils': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
launch-editor: 2.14.2
|
||||
safer-buffer: 2.1.2
|
||||
socket.io: 4.8.1([email protected])
|
||||
@@ -11405,19 +11389,19 @@ snapshots:
|
||||
- utf-8-validate
|
||||
- webpack
|
||||
|
||||
'@rsdoctor/[email protected](@rspack/[email protected].5(@swc/[email protected]))':
|
||||
'@rsdoctor/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
|
||||
dependencies:
|
||||
'@types/connect': 3.4.38
|
||||
'@types/estree': 1.0.5
|
||||
'@types/tapable': 2.3.0
|
||||
source-map: 0.7.6
|
||||
optionalDependencies:
|
||||
'@rspack/core': 2.3.5(@swc/[email protected])
|
||||
'@rspack/core': 2.3.4(@swc/[email protected])
|
||||
|
||||
'@rsdoctor/[email protected](@rspack/[email protected].5(@swc/[email protected]))':
|
||||
'@rsdoctor/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.26.2
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rsdoctor/types': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
|
||||
'@types/estree': 1.0.5
|
||||
acorn: 8.18.0
|
||||
acorn-import-attributes: 1.9.5([email protected])
|
||||
@@ -11446,83 +11430,83 @@ snapshots:
|
||||
- '@swc-next/parser-binding-wasm'
|
||||
- core-js
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
dependencies:
|
||||
'@emnapi/core': 2.0.0-beta.4
|
||||
'@emnapi/runtime': 2.0.0-beta.4
|
||||
'@napi-rs/wasm-runtime': 1.2.7(@emnapi/[email protected].4)(@emnapi/[email protected].4)
|
||||
'@emnapi/core': 2.0.0-beta.3
|
||||
'@emnapi/runtime': 2.0.0-beta.3
|
||||
'@napi-rs/wasm-runtime': 1.2.7(@emnapi/[email protected].3)(@emnapi/[email protected].3)
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected].5':
|
||||
'@rspack/[email protected].4':
|
||||
optionalDependencies:
|
||||
'@rspack/binding-darwin-arm64': 2.3.5
|
||||
'@rspack/binding-darwin-x64': 2.3.5
|
||||
'@rspack/binding-linux-arm64-gnu': 2.3.5
|
||||
'@rspack/binding-linux-arm64-musl': 2.3.5
|
||||
'@rspack/binding-linux-ppc64-gnu': 2.3.5
|
||||
'@rspack/binding-linux-riscv64-gnu': 2.3.5
|
||||
'@rspack/binding-linux-riscv64-musl': 2.3.5
|
||||
'@rspack/binding-linux-s390x-gnu': 2.3.5
|
||||
'@rspack/binding-linux-x64-gnu': 2.3.5
|
||||
'@rspack/binding-linux-x64-musl': 2.3.5
|
||||
'@rspack/binding-wasm32-wasi': 2.3.5
|
||||
'@rspack/binding-win32-arm64-msvc': 2.3.5
|
||||
'@rspack/binding-win32-ia32-msvc': 2.3.5
|
||||
'@rspack/binding-win32-x64-msvc': 2.3.5
|
||||
'@rspack/binding-darwin-arm64': 2.3.4
|
||||
'@rspack/binding-darwin-x64': 2.3.4
|
||||
'@rspack/binding-linux-arm64-gnu': 2.3.4
|
||||
'@rspack/binding-linux-arm64-musl': 2.3.4
|
||||
'@rspack/binding-linux-ppc64-gnu': 2.3.4
|
||||
'@rspack/binding-linux-riscv64-gnu': 2.3.4
|
||||
'@rspack/binding-linux-riscv64-musl': 2.3.4
|
||||
'@rspack/binding-linux-s390x-gnu': 2.3.4
|
||||
'@rspack/binding-linux-x64-gnu': 2.3.4
|
||||
'@rspack/binding-linux-x64-musl': 2.3.4
|
||||
'@rspack/binding-wasm32-wasi': 2.3.4
|
||||
'@rspack/binding-win32-arm64-msvc': 2.3.4
|
||||
'@rspack/binding-win32-ia32-msvc': 2.3.4
|
||||
'@rspack/binding-win32-x64-msvc': 2.3.4
|
||||
|
||||
'@rspack/[email protected].5(@swc/[email protected])':
|
||||
'@rspack/[email protected].4(@swc/[email protected])':
|
||||
dependencies:
|
||||
'@rspack/binding': 2.3.5
|
||||
'@rspack/binding': 2.3.4
|
||||
optionalDependencies:
|
||||
'@swc/helpers': 0.5.24
|
||||
|
||||
'@rspack/[email protected](@rspack/[email protected].5(@swc/[email protected]))':
|
||||
'@rspack/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
|
||||
optionalDependencies:
|
||||
'@rspack/core': 2.3.5(@swc/[email protected])
|
||||
'@rspack/core': 2.3.4(@swc/[email protected])
|
||||
|
||||
'@rspack/[email protected](@rspack/[email protected].5(@swc/[email protected]))':
|
||||
'@rspack/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
|
||||
dependencies:
|
||||
'@rspack/core': 2.3.5(@swc/[email protected])
|
||||
'@rspack/dev-middleware': 2.0.6(@rspack/[email protected].5(@swc/[email protected]))
|
||||
'@rspack/core': 2.3.4(@swc/[email protected])
|
||||
'@rspack/dev-middleware': 2.0.6(@rspack/[email protected].4(@swc/[email protected]))
|
||||
|
||||
'@rspack/[email protected]': {}
|
||||
|
||||
@@ -11544,9 +11528,9 @@ snapshots:
|
||||
'@rspack/[email protected]':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected](@emnapi/[email protected].2)(@emnapi/[email protected].2)':
|
||||
'@rspack/[email protected](@emnapi/[email protected].3)(@emnapi/[email protected].3)':
|
||||
dependencies:
|
||||
'@napi-rs/wasm-runtime': 1.2.7(@emnapi/[email protected].2)(@emnapi/[email protected].2)
|
||||
'@napi-rs/wasm-runtime': 1.2.7(@emnapi/[email protected].3)(@emnapi/[email protected].3)
|
||||
transitivePeerDependencies:
|
||||
- '@emnapi/core'
|
||||
- '@emnapi/runtime'
|
||||
@@ -11561,7 +11545,7 @@ snapshots:
|
||||
'@rspack/[email protected]':
|
||||
optional: true
|
||||
|
||||
'@rspack/[email protected](@emnapi/[email protected].2)(@emnapi/[email protected].2)':
|
||||
'@rspack/[email protected](@emnapi/[email protected].3)(@emnapi/[email protected].3)':
|
||||
optionalDependencies:
|
||||
'@rspack/resolver-binding-darwin-arm64': 0.2.8
|
||||
'@rspack/resolver-binding-darwin-x64': 0.2.8
|
||||
@@ -11569,7 +11553,7 @@ snapshots:
|
||||
'@rspack/resolver-binding-linux-arm64-musl': 0.2.8
|
||||
'@rspack/resolver-binding-linux-x64-gnu': 0.2.8
|
||||
'@rspack/resolver-binding-linux-x64-musl': 0.2.8
|
||||
'@rspack/resolver-binding-wasm32-wasi': 0.2.8(@emnapi/[email protected].2)(@emnapi/[email protected].2)
|
||||
'@rspack/resolver-binding-wasm32-wasi': 0.2.8(@emnapi/[email protected].3)(@emnapi/[email protected].3)
|
||||
'@rspack/resolver-binding-win32-arm64-msvc': 0.2.8
|
||||
'@rspack/resolver-binding-win32-ia32-msvc': 0.2.8
|
||||
'@rspack/resolver-binding-win32-x64-msvc': 0.2.8
|
||||
@@ -12623,12 +12607,12 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected](@babel/[email protected])(@rspack/[email protected].5(@swc/[email protected])):
|
||||
[email protected](@babel/[email protected])(@rspack/[email protected].4(@swc/[email protected])):
|
||||
dependencies:
|
||||
'@babel/core': 8.1.4
|
||||
find-up: 5.0.0
|
||||
optionalDependencies:
|
||||
'@rspack/core': 2.3.5(@swc/[email protected])
|
||||
'@rspack/core': 2.3.4(@swc/[email protected])
|
||||
|
||||
[email protected](@babel/[email protected]([email protected]))([email protected]):
|
||||
dependencies:
|
||||
@@ -13088,7 +13072,7 @@ snapshots:
|
||||
'@cropper/elements': 2.3.1
|
||||
'@cropper/utils': 2.3.1
|
||||
|
||||
cross-spawn@7.1.2:
|
||||
cross-spawn@7.0.6:
|
||||
dependencies:
|
||||
path-key: 3.1.1
|
||||
shebang-command: 2.0.0
|
||||
@@ -13794,7 +13778,7 @@ snapshots:
|
||||
'@humanwhocodes/retry': 0.4.3
|
||||
'@types/estree': 1.0.9
|
||||
ajv: 6.15.0
|
||||
cross-spawn: 7.1.2
|
||||
cross-spawn: 7.0.6
|
||||
debug: 4.4.3([email protected])
|
||||
escape-string-regexp: 4.0.0
|
||||
eslint-scope: 9.1.2
|
||||
@@ -13992,7 +13976,7 @@ snapshots:
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
cross-spawn: 7.1.2
|
||||
cross-spawn: 7.0.6
|
||||
signal-exit: 4.1.0
|
||||
|
||||
[email protected]:
|
||||
@@ -15089,8 +15073,6 @@ snapshots:
|
||||
stylis: 4.4.0
|
||||
ts-dedent: 2.3.0
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
braces: 3.0.3
|
||||
@@ -15996,11 +15978,11 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected](@rspack/[email protected].5(@swc/[email protected])):
|
||||
[email protected](@rspack/[email protected].4(@swc/[email protected])):
|
||||
dependencies:
|
||||
'@rspack/lite-tapable': 1.1.5
|
||||
optionalDependencies:
|
||||
'@rspack/core': 2.3.5(@swc/[email protected])
|
||||
'@rspack/core': 2.3.4(@swc/[email protected])
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
@@ -16993,14 +16975,14 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected](@rspack/[email protected].5(@swc/[email protected])):
|
||||
[email protected](@rspack/[email protected].4(@swc/[email protected])):
|
||||
dependencies:
|
||||
ansis: 3.17.0
|
||||
consola: 3.4.2
|
||||
pretty-time: 1.1.0
|
||||
std-env: 3.10.0
|
||||
optionalDependencies:
|
||||
'@rspack/core': 2.3.5(@swc/[email protected])
|
||||
'@rspack/core': 2.3.4(@swc/[email protected])
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
|
||||
@@ -103,12 +103,6 @@
|
||||
"matchDepTypes": ["peerDependencies"],
|
||||
"rangeStrategy": "widen"
|
||||
},
|
||||
{
|
||||
"description": "Keep semver ranges for dependencies of the published components package, so consumers can share one copy with other libraries",
|
||||
"matchFileNames": ["packages/components/package.json"],
|
||||
"matchDepTypes": ["dependencies"],
|
||||
"rangeStrategy": "bump"
|
||||
},
|
||||
{
|
||||
"description": "Group all Python version updates from home-assistant/core",
|
||||
"matchDepNames": ["python"],
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
/** Loads an image, resolves with undefined when it can't be loaded. */
|
||||
export const loadImage = (
|
||||
url: string,
|
||||
crossOrigin?: "anonymous" | "use-credentials"
|
||||
): Promise<HTMLImageElement | undefined> =>
|
||||
export const loadImage = (url: string): Promise<HTMLImageElement | undefined> =>
|
||||
new Promise((resolve) => {
|
||||
const image = new Image();
|
||||
if (crossOrigin) {
|
||||
image.crossOrigin = crossOrigin;
|
||||
}
|
||||
image.onload = () => resolve(image);
|
||||
image.onerror = () => resolve(undefined);
|
||||
image.src = url;
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { html } from "lit";
|
||||
import { isMac } from "../../util/is_mac";
|
||||
|
||||
export const renderMoveShortcutHint = (
|
||||
moveUpLabel: string,
|
||||
moveDownLabel: string
|
||||
) => html`
|
||||
${moveUpLabel} <span dir="ltr">(${isMac ? "⌥" : "Alt"}+↑)</span>
|
||||
<br />
|
||||
${moveDownLabel} <span dir="ltr">(${isMac ? "⌥" : "Alt"}+↓)</span>
|
||||
`;
|
||||
@@ -87,7 +87,7 @@ export class HaButtonToggleGroup extends LitElement {
|
||||
--mdc-icon-size: var(--button-toggle-icon-size, 20px);
|
||||
}
|
||||
|
||||
:host([no-wrap]) wa-button-group::part(button-group) {
|
||||
:host([no-wrap]) wa-button-group::part(base) {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ export class HaButtonToggleGroup extends LitElement {
|
||||
}
|
||||
|
||||
:host([full-width]) wa-button-group,
|
||||
:host([full-width]) wa-button-group::part(button-group) {
|
||||
:host([full-width]) wa-button-group::part(base) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import memoizeOne from "memoize-one";
|
||||
import { consumeLocalize } from "../common/decorators/consume-context-entry";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { stopPropagation } from "../common/dom/stop_propagation";
|
||||
import { renderMoveShortcutHint } from "../common/keyboard/render-move-shortcut-hint";
|
||||
import { orderCompare } from "../common/string/compare";
|
||||
import type { LocalizeFunc } from "../common/translations/localize";
|
||||
import { afterNextRender } from "../common/util/render-status";
|
||||
@@ -20,7 +19,6 @@ import "./ha-icon-button";
|
||||
import "./ha-icon-next";
|
||||
import "./ha-sortable";
|
||||
import "./ha-svg-icon";
|
||||
import "./ha-tooltip";
|
||||
import "./item/ha-list-item-button";
|
||||
import "./list/ha-list-base";
|
||||
|
||||
@@ -115,7 +113,6 @@ export class HaItemDisplayEditor extends LitElement {
|
||||
} = item;
|
||||
return html`
|
||||
<ha-list-item-button
|
||||
id="move-item-row-${idx}"
|
||||
@click=${
|
||||
this.showNavigationButton ? this._navigate : undefined
|
||||
}
|
||||
@@ -131,11 +128,6 @@ export class HaItemDisplayEditor extends LitElement {
|
||||
: undefined
|
||||
}
|
||||
.idx=${idx}
|
||||
aria-keyshortcuts=${ifDefined(
|
||||
isVisible && !disableSorting
|
||||
? "Alt+ArrowUp Alt+ArrowDown"
|
||||
: undefined
|
||||
)}
|
||||
>
|
||||
<span slot="headline">${label}</span>
|
||||
${
|
||||
@@ -211,26 +203,10 @@ export class HaItemDisplayEditor extends LitElement {
|
||||
? this._dragHandleKeydown
|
||||
: undefined
|
||||
}
|
||||
id="move-item-${idx}"
|
||||
class="handle"
|
||||
.path=${mdiDragHorizontalVariant}
|
||||
slot="end"
|
||||
></ha-svg-icon>
|
||||
<ha-tooltip
|
||||
slot="end"
|
||||
trigger="focus"
|
||||
association="description"
|
||||
for=${
|
||||
this.showNavigationButton
|
||||
? `move-item-${idx}`
|
||||
: `move-item-row-${idx}`
|
||||
}
|
||||
>
|
||||
${renderMoveShortcutHint(
|
||||
this._localize("ui.common.move_up"),
|
||||
this._localize("ui.common.move_down")
|
||||
)}
|
||||
</ha-tooltip>
|
||||
`
|
||||
: html`<ha-svg-icon slot="end"></ha-svg-icon>`
|
||||
}
|
||||
@@ -433,9 +409,6 @@ export class HaItemDisplayEditor extends LitElement {
|
||||
/* Keep the handle above the row's hit area so dragging can start */
|
||||
z-index: 1;
|
||||
}
|
||||
ha-tooltip {
|
||||
position: absolute;
|
||||
}
|
||||
.separator {
|
||||
width: 1px;
|
||||
background-color: var(--divider-color);
|
||||
|
||||
@@ -81,11 +81,36 @@ export class HaSelectSelector extends LitElement {
|
||||
}
|
||||
|
||||
protected render() {
|
||||
const options = this._getOptions(
|
||||
this.selector,
|
||||
this.localizeValue,
|
||||
this._i18n
|
||||
);
|
||||
const options = this._getOptions(this.selector);
|
||||
|
||||
const translationKey = this.selector.select?.translation_key;
|
||||
|
||||
if (this.localizeValue && translationKey) {
|
||||
options.forEach((option) => {
|
||||
const localizedLabel = this.localizeValue!(
|
||||
`${translationKey}.options.${option.value}`
|
||||
);
|
||||
if (localizedLabel) {
|
||||
option.label = localizedLabel;
|
||||
}
|
||||
const localizedDescription = this.localizeValue!(
|
||||
`${translationKey}.options_description.${option.value}`
|
||||
);
|
||||
if (localizedDescription) {
|
||||
option.description = localizedDescription;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.selector.select?.sort) {
|
||||
options.sort((a, b) =>
|
||||
caseInsensitiveStringCompare(
|
||||
a.label,
|
||||
b.label,
|
||||
this._i18n.locale.language
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!this.selector.select?.multiple &&
|
||||
@@ -300,45 +325,12 @@ export class HaSelectSelector extends LitElement {
|
||||
}
|
||||
|
||||
private _getOptions = memoizeOne(
|
||||
(
|
||||
selector: SelectSelector,
|
||||
localizeValue: ((key: string) => string) | undefined,
|
||||
i18n: HomeAssistantInternationalization
|
||||
) => {
|
||||
const translationKey = selector.select?.translation_key;
|
||||
|
||||
const options = (selector.select?.options ?? []).map((option) => {
|
||||
const baseOption =
|
||||
typeof option === "object"
|
||||
? { ...option, label: option.label ?? option.value }
|
||||
: { value: String(option), label: option };
|
||||
|
||||
if (!localizeValue || !translationKey) {
|
||||
return baseOption;
|
||||
}
|
||||
|
||||
const localizedLabel = localizeValue(
|
||||
`${translationKey}.options.${baseOption.value}`
|
||||
);
|
||||
const localizedDescription = localizeValue(
|
||||
`${translationKey}.options_description.${baseOption.value}`
|
||||
);
|
||||
|
||||
return {
|
||||
...baseOption,
|
||||
label: localizedLabel || baseOption.label,
|
||||
description: localizedDescription || baseOption.description,
|
||||
};
|
||||
});
|
||||
|
||||
if (selector.select?.sort) {
|
||||
options.sort((a, b) =>
|
||||
caseInsensitiveStringCompare(a.label, b.label, i18n.locale.language)
|
||||
);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
(selector: SelectSelector) =>
|
||||
selector.select?.options?.map((option) =>
|
||||
typeof option === "object"
|
||||
? { ...option, label: option.label ?? option.value }
|
||||
: { value: String(option), label: option }
|
||||
) || []
|
||||
);
|
||||
|
||||
private _getItems = memoizeOne(
|
||||
@@ -478,12 +470,7 @@ export class HaSelectSelector extends LitElement {
|
||||
}
|
||||
|
||||
// Look the pick up in the current options: the open list can be older.
|
||||
const options = this._getOptions(
|
||||
this.selector,
|
||||
this.localizeValue,
|
||||
this._i18n
|
||||
);
|
||||
const option = findPickerOption(options, id);
|
||||
const option = findPickerOption(this._getOptions(this.selector), id);
|
||||
|
||||
if (
|
||||
!option ||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import type { UiColorExtraOption, UiColorSelector } from "../../data/selector";
|
||||
import type { UiColorSelector } from "../../data/selector";
|
||||
import "../ha-color-picker";
|
||||
|
||||
@customElement("ha-selector-ui_color")
|
||||
@@ -17,28 +16,6 @@ export class HaSelectorUiColor extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
@property({ attribute: false })
|
||||
public localizeValue?: (key: string) => string;
|
||||
|
||||
private _extraOptions = memoizeOne(
|
||||
(
|
||||
selector: UiColorSelector,
|
||||
localizeValue?: (key: string) => string
|
||||
): UiColorExtraOption[] | undefined => {
|
||||
const translationKey = selector.ui_color?.translation_key;
|
||||
return selector.ui_color?.extra_options?.map((option) => {
|
||||
const localizedLabel =
|
||||
translationKey && localizeValue
|
||||
? localizeValue(`${translationKey}.options.${option.value}`)
|
||||
: undefined;
|
||||
return {
|
||||
...option,
|
||||
label: localizedLabel || option.label || option.value,
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
<ha-color-picker
|
||||
@@ -49,7 +26,7 @@ export class HaSelectorUiColor extends LitElement {
|
||||
.includeNone=${this.selector.ui_color?.include_none}
|
||||
.includeState=${this.selector.ui_color?.include_state}
|
||||
.defaultColor=${this.selector.ui_color?.default_color}
|
||||
.extraOptions=${this._extraOptions(this.selector, this.localizeValue)}
|
||||
.extraOptions=${this.selector.ui_color?.extra_options}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-color-picker>
|
||||
`;
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
mdiMenuOpen,
|
||||
} from "@mdi/js";
|
||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import type { PropertyDeclaration, PropertyValues } from "lit";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
@@ -28,7 +28,8 @@ import {
|
||||
import type { PersistentNotification } from "../data/persistent_notification";
|
||||
import { subscribeNotifications } from "../data/persistent_notification";
|
||||
import { subscribeRepairsIssueRegistry } from "../data/repairs";
|
||||
import { countInstallableUpdates } from "../data/update";
|
||||
import type { UpdateEntity } from "../data/update";
|
||||
import { updateCanInstall } from "../data/update";
|
||||
import { showEditSidebarDialog } from "../dialogs/sidebar/show-dialog-edit-sidebar";
|
||||
import { ScrollableFadeMixin } from "../mixins/scrollable-fade-mixin";
|
||||
import { SubscribeMixin } from "../mixins/subscribe-mixin";
|
||||
@@ -222,34 +223,8 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
|
||||
];
|
||||
}
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
if (this.hass) {
|
||||
this._calculateCounts();
|
||||
}
|
||||
}
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._calculateCounts.cancel();
|
||||
}
|
||||
|
||||
public override requestUpdate(
|
||||
name?: PropertyKey,
|
||||
oldValue?: unknown,
|
||||
options?: PropertyDeclaration
|
||||
) {
|
||||
if (name === "hass" && this.hass && this.isConnected) {
|
||||
const oldHass = oldValue as HomeAssistant | undefined;
|
||||
if (
|
||||
!oldHass ||
|
||||
this.hass.states !== oldHass.states ||
|
||||
this.hass.entities !== oldHass.entities
|
||||
) {
|
||||
this._calculateCounts();
|
||||
}
|
||||
}
|
||||
super.requestUpdate(name, oldValue, options);
|
||||
}
|
||||
|
||||
protected render() {
|
||||
@@ -331,6 +306,7 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
|
||||
hass.user !== oldHass.user ||
|
||||
hass.localize !== oldHass.localize ||
|
||||
hass.locale !== oldHass.locale ||
|
||||
hass.states !== oldHass.states ||
|
||||
hass.userData !== oldHass.userData ||
|
||||
hass.systemData !== oldHass.systemData ||
|
||||
hass.connected !== oldHass.connected
|
||||
@@ -372,16 +348,24 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
|
||||
) {
|
||||
this._subscribePersistentNotifications();
|
||||
}
|
||||
|
||||
this._calculateCounts();
|
||||
}
|
||||
|
||||
private _calculateCounts = throttle(() => {
|
||||
if (!this.hass?.states) {
|
||||
return;
|
||||
let updateCount = 0;
|
||||
|
||||
for (const entityId of Object.keys(this.hass.states)) {
|
||||
if (
|
||||
entityId.startsWith("update.") &&
|
||||
!this.hass.entities[entityId]?.hidden &&
|
||||
updateCanInstall(this.hass.states[entityId] as UpdateEntity)
|
||||
) {
|
||||
updateCount++;
|
||||
}
|
||||
}
|
||||
this._updatesCount = countInstallableUpdates(
|
||||
this.hass.states,
|
||||
this.hass.entities
|
||||
);
|
||||
|
||||
this._updatesCount = updateCount;
|
||||
}, 5000);
|
||||
|
||||
private _renderHeader() {
|
||||
|
||||
@@ -20,10 +20,6 @@ import "./ha-media-browser-thumbnail";
|
||||
*
|
||||
* @csspart start - The graphic container.
|
||||
*
|
||||
* @cssprop --ha-media-browser-list-item-background - Background of the row.
|
||||
* Lets a theme keep rows readable over an image panel background, like the
|
||||
* cards of the grid view. Defaults to `transparent`.
|
||||
*
|
||||
* @attr {string} thumbnail - URL of the thumbnail. Shown inside the graphic.
|
||||
*/
|
||||
@customElement("ha-media-player-browse-list-item")
|
||||
@@ -59,7 +55,6 @@ export class HaMediaPlayerBrowseListItem extends HaListItemButton {
|
||||
css`
|
||||
:host {
|
||||
direction: var(--direction);
|
||||
background: var(--ha-media-browser-list-item-background, transparent);
|
||||
--ha-row-item-padding-block: 0;
|
||||
--ha-row-item-min-height: 48px;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ export interface AreaRegistryEntry extends RegistryEntry {
|
||||
icon: string | null;
|
||||
labels: string[];
|
||||
name: string;
|
||||
occupancy_entity_id: string | null;
|
||||
picture: string | null;
|
||||
temperature_entity_id: string | null;
|
||||
}
|
||||
@@ -35,7 +34,6 @@ export interface AreaRegistryEntryMutableParams {
|
||||
icon?: string | null;
|
||||
labels?: string[];
|
||||
name: string;
|
||||
occupancy_entity_id?: string | null;
|
||||
picture?: string | null;
|
||||
temperature_entity_id?: string | null;
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ export interface WindowWithPreloads extends Window {
|
||||
llConfProm?: Promise<LovelaceRawConfig>;
|
||||
llResProm?: Promise<LovelaceResource[]>;
|
||||
recorderInfoProm?: Promise<RecorderInfo>;
|
||||
entityStateThrottleMs?: () => number;
|
||||
}
|
||||
@@ -683,17 +683,12 @@ export interface UiColorExtraOption {
|
||||
display_color?: string;
|
||||
}
|
||||
|
||||
export type UiColorSelectorExtraOption = Omit<UiColorExtraOption, "label"> & {
|
||||
label?: string;
|
||||
};
|
||||
|
||||
export interface UiColorSelector {
|
||||
ui_color: {
|
||||
default_color?: string;
|
||||
include_none?: boolean;
|
||||
include_state?: boolean;
|
||||
extra_options?: readonly UiColorSelectorExtraOption[];
|
||||
translation_key?: string;
|
||||
extra_options?: UiColorExtraOption[];
|
||||
} | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CallWS, HomeAssistant } from "../../types";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import type { AddonRole, AddonStage } from "../hassio/addon";
|
||||
import { supervisorApiCall } from "./common";
|
||||
import type { SupervisorArch } from "./supervisor";
|
||||
@@ -56,14 +56,8 @@ export interface SupervisorStore {
|
||||
}
|
||||
|
||||
export const fetchSupervisorStore = async (
|
||||
callWS: CallWS
|
||||
): Promise<SupervisorStore> =>
|
||||
callWS<SupervisorStore>({
|
||||
type: "supervisor/api",
|
||||
endpoint: "/store",
|
||||
method: "get",
|
||||
timeout: null,
|
||||
});
|
||||
hass: HomeAssistant
|
||||
): Promise<SupervisorStore> => supervisorApiCall(hass, "/store");
|
||||
|
||||
export const fetchStoreRepositories = async (
|
||||
hass: HomeAssistant
|
||||
|
||||
+3
-8
@@ -158,14 +158,9 @@ const findUpdateEntityIds = memoizeOne((entityIds: string[]) =>
|
||||
entityIds.filter((entityId) => computeDomain(entityId) === "update")
|
||||
);
|
||||
|
||||
export const countInstallableUpdates = (
|
||||
states: HassEntityStates,
|
||||
entities?: HomeAssistant["entities"]
|
||||
): number =>
|
||||
findUpdateEntityIds(getEntityIds(states)).filter(
|
||||
(entityId) =>
|
||||
!entities?.[entityId]?.hidden &&
|
||||
updateCanInstall(states[entityId] as UpdateEntity)
|
||||
export const countInstallableUpdates = (states: HassEntityStates): number =>
|
||||
findUpdateEntityIds(getEntityIds(states)).filter((entityId) =>
|
||||
updateCanInstall(states[entityId] as UpdateEntity)
|
||||
).length;
|
||||
|
||||
export const filterUpdateEntitiesParameterized = (
|
||||
|
||||
@@ -177,7 +177,10 @@ window.hassConnection.then(({ conn }) => {
|
||||
const noop = () => {
|
||||
// do nothing
|
||||
};
|
||||
subscribeEntityStates(conn, noop);
|
||||
const preloadWindow = window as WindowWithPreloads;
|
||||
subscribeEntityStates(conn, noop, {
|
||||
throttleMs: () => preloadWindow.entityStateThrottleMs?.() ?? 0,
|
||||
});
|
||||
subscribeEntityRegistryDisplay(conn, noop);
|
||||
subscribeDeviceRegistry(conn, noop);
|
||||
subscribeAreaRegistry(conn, noop);
|
||||
@@ -189,7 +192,6 @@ window.hassConnection.then(({ conn }) => {
|
||||
subscribeUser(conn, noop);
|
||||
subscribeRepairsIssueRegistry(conn, noop);
|
||||
|
||||
const preloadWindow = window as WindowWithPreloads;
|
||||
preloadWindow.recorderInfoProm = getRecorderInfo(conn);
|
||||
|
||||
// "/" opens the default panel, which is not known yet, so only preload the
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
export interface FeaturedApp {
|
||||
slug: string;
|
||||
// Center in percent of the empty state
|
||||
x: number;
|
||||
y: number;
|
||||
size: number;
|
||||
tilt: number;
|
||||
// How far the app drifts around its center, varied so no two move alike
|
||||
dx: number;
|
||||
dy: number;
|
||||
// Beside the text, so only shown on wide screens
|
||||
side?: boolean;
|
||||
}
|
||||
|
||||
// Popular apps from the repositories the Supervisor adds by default, each
|
||||
// with its own place around the empty state. Ordered so that apps fading in
|
||||
// one after another land far apart.
|
||||
export const FEATURED_APPS: FeaturedApp[] = [
|
||||
{
|
||||
slug: "5c53de3b_esphome",
|
||||
x: 14,
|
||||
y: 18,
|
||||
size: 64,
|
||||
tilt: -6,
|
||||
dx: 16,
|
||||
dy: -12,
|
||||
},
|
||||
{
|
||||
slug: "core_mosquitto",
|
||||
x: 84,
|
||||
y: 62,
|
||||
size: 60,
|
||||
tilt: 5,
|
||||
dx: -21,
|
||||
dy: 19,
|
||||
side: true,
|
||||
},
|
||||
{
|
||||
slug: "core_speech-to-phrase",
|
||||
x: 46,
|
||||
y: 10,
|
||||
size: 48,
|
||||
tilt: 4,
|
||||
dx: 18,
|
||||
dy: 17,
|
||||
},
|
||||
{
|
||||
slug: "d5369777_music_assistant",
|
||||
x: 20,
|
||||
y: 80,
|
||||
size: 56,
|
||||
tilt: 7,
|
||||
dx: -20,
|
||||
dy: -15,
|
||||
},
|
||||
{
|
||||
slug: "core_configurator",
|
||||
x: 78,
|
||||
y: 20,
|
||||
size: 52,
|
||||
tilt: -4,
|
||||
dx: 17,
|
||||
dy: 13,
|
||||
},
|
||||
{
|
||||
slug: "core_matter_server",
|
||||
x: 8,
|
||||
y: 50,
|
||||
size: 48,
|
||||
tilt: 3,
|
||||
dx: -22,
|
||||
dy: 20,
|
||||
side: true,
|
||||
},
|
||||
{
|
||||
slug: "core_openthread_border_router",
|
||||
x: 62,
|
||||
y: 88,
|
||||
size: 56,
|
||||
tilt: -5,
|
||||
dx: 19,
|
||||
dy: -18,
|
||||
},
|
||||
{
|
||||
slug: "core_samba",
|
||||
x: 30,
|
||||
y: 24,
|
||||
size: 44,
|
||||
tilt: 6,
|
||||
dx: -16,
|
||||
dy: 16,
|
||||
side: true,
|
||||
},
|
||||
{
|
||||
slug: "a0d7b954_vscode",
|
||||
x: 92,
|
||||
y: 36,
|
||||
size: 44,
|
||||
tilt: -7,
|
||||
dx: 22,
|
||||
dy: 14,
|
||||
side: true,
|
||||
},
|
||||
{
|
||||
slug: "a0d7b954_adguard",
|
||||
x: 40,
|
||||
y: 86,
|
||||
size: 48,
|
||||
tilt: -3,
|
||||
dx: -18,
|
||||
dy: -12,
|
||||
},
|
||||
{ slug: "core_mariadb", x: 66, y: 8, size: 44, tilt: 8, dx: 15, dy: 19 },
|
||||
{ slug: "core_ssh", x: 86, y: 82, size: 48, tilt: 4, dx: -17, dy: 13 },
|
||||
];
|
||||
|
||||
// Matches the media query in the styles that hides the slots beside the text
|
||||
export const SCATTER_NARROW_QUERY = "(max-width: 600px)";
|
||||
|
||||
// Minimum time between two apps fading in, so cached icons still cascade
|
||||
export const SCATTER_REVEAL_INTERVAL = 400;
|
||||
|
||||
// Apps that load together and show without waiting for each other
|
||||
export const SCATTER_INSTANT_COUNT = 2;
|
||||
@@ -1,328 +0,0 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiOpenInNew, mdiPuzzle, mdiStorePlus } from "@mdi/js";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import { consume } from "../../../../common/decorators/consume";
|
||||
import { loadImage } from "../../../../common/dom/load-image";
|
||||
import { isExternalHassUrl } from "../../../../common/url/hass-url";
|
||||
import { waitForMs } from "../../../../common/util/wait";
|
||||
import "../../../../components/ha-app-icon";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-svg-icon";
|
||||
import {
|
||||
apiContext,
|
||||
configContext,
|
||||
internationalizationContext,
|
||||
} from "../../../../data/context";
|
||||
import { supervisorUrl } from "../../../../data/hassio/common";
|
||||
import type { StoreAddon } from "../../../../data/supervisor/store";
|
||||
import { fetchSupervisorStore } from "../../../../data/supervisor/store";
|
||||
import { documentationUrl } from "../../../../util/documentation-url";
|
||||
import type { FeaturedApp } from "../common/empty-state";
|
||||
import {
|
||||
FEATURED_APPS,
|
||||
SCATTER_INSTANT_COUNT,
|
||||
SCATTER_NARROW_QUERY,
|
||||
SCATTER_REVEAL_INTERVAL,
|
||||
} from "../common/empty-state";
|
||||
|
||||
/**
|
||||
* @element supervisor-apps-empty-state
|
||||
*
|
||||
* @summary Empty state of the installed apps page, with popular apps from the
|
||||
* store fading in one after another around it.
|
||||
*/
|
||||
@customElement("supervisor-apps-empty-state")
|
||||
export class SupervisorAppsEmptyState extends LitElement {
|
||||
@state()
|
||||
@consume({ context: internationalizationContext, subscribe: true })
|
||||
private _i18n!: ContextType<typeof internationalizationContext>;
|
||||
|
||||
@state()
|
||||
@consume({ context: configContext, subscribe: true })
|
||||
private _config!: ContextType<typeof configContext>;
|
||||
|
||||
@consume({ context: apiContext, subscribe: true })
|
||||
private _api!: ContextType<typeof apiContext>;
|
||||
|
||||
@state() private _loadedIcons: ReadonlySet<string> = new Set();
|
||||
|
||||
private _storeAppsLoad?: Promise<StoreAddon[]>;
|
||||
|
||||
private _revealingIcons = false;
|
||||
|
||||
public connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
// Continue with the icons that didn't show before the page was left
|
||||
if (this.hasUpdated) {
|
||||
this._loadStoreApps();
|
||||
}
|
||||
}
|
||||
|
||||
protected firstUpdated(): void {
|
||||
this._loadStoreApps();
|
||||
}
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
<div class="scatter" aria-hidden="true">
|
||||
${FEATURED_APPS.map((app, index) => {
|
||||
if (!this._loadedIcons.has(app.slug)) {
|
||||
return nothing;
|
||||
}
|
||||
return html`
|
||||
<div
|
||||
class=${classMap({ bubble: true, side: Boolean(app.side) })}
|
||||
style=${styleMap({
|
||||
"--x": `${app.x}%`,
|
||||
"--y": `${app.y}%`,
|
||||
"--size": `${app.size}px`,
|
||||
"--tilt": `${app.tilt}deg`,
|
||||
"--index": String(index),
|
||||
"--dx": `${app.dx}px`,
|
||||
"--dy": `${app.dy}px`,
|
||||
})}
|
||||
>
|
||||
<ha-app-icon .slug=${app.slug} has-icon></ha-app-icon>
|
||||
</div>
|
||||
`;
|
||||
})}
|
||||
</div>
|
||||
<div class="content">
|
||||
<ha-svg-icon class="icon" .path=${mdiPuzzle}></ha-svg-icon>
|
||||
<h2>
|
||||
${this._i18n.localize("ui.panel.config.apps.installed.empty_header")}
|
||||
</h2>
|
||||
<p>
|
||||
${this._i18n.localize("ui.panel.config.apps.installed.empty_text")}
|
||||
</p>
|
||||
<ha-button size="l" href="/config/apps/available">
|
||||
<ha-svg-icon slot="start" .path=${mdiStorePlus}></ha-svg-icon>
|
||||
${this._i18n.localize("ui.panel.config.apps.installed.add_app")}
|
||||
</ha-button>
|
||||
<ha-button
|
||||
class="learn-more"
|
||||
appearance="plain"
|
||||
href=${documentationUrl(this._config, "/apps/")}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
size="s"
|
||||
>
|
||||
${this._i18n.localize("ui.panel.config.common.learn_more")}
|
||||
<ha-svg-icon slot="end" .path=${mdiOpenInNew}></ha-svg-icon>
|
||||
</ha-button>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
private async _loadStoreApps(): Promise<void> {
|
||||
// Reconnects while the store loads share its request
|
||||
this._storeAppsLoad ??= this._fetchStoreApps();
|
||||
this._revealIcons(await this._storeAppsLoad);
|
||||
}
|
||||
|
||||
private async _fetchStoreApps(): Promise<StoreAddon[]> {
|
||||
try {
|
||||
return (await fetchSupervisorStore(this._api.callWS)).addons;
|
||||
} catch (_err: unknown) {
|
||||
// The apps are decoration only
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private async _revealIcons(storeApps: StoreAddon[]): Promise<void> {
|
||||
// The store can answer after the page was left
|
||||
if (this._revealingIcons || !this.isConnected) {
|
||||
return;
|
||||
}
|
||||
this._revealingIcons = true;
|
||||
try {
|
||||
// Same CORS mode as ha-app-icon, so its image comes from the cache
|
||||
const crossOrigin = isExternalHassUrl() ? undefined : "anonymous";
|
||||
const load = (app: FeaturedApp) =>
|
||||
loadImage(supervisorUrl(`addons/${app.slug}/icon`), crossOrigin);
|
||||
const reveal = (app: FeaturedApp) => {
|
||||
this._loadedIcons = new Set([...this._loadedIcons, app.slug]);
|
||||
};
|
||||
const available = new Set(
|
||||
storeApps
|
||||
.filter((app) => app.available && app.icon)
|
||||
.map((app) => app.slug)
|
||||
);
|
||||
const featured = FEATURED_APPS.filter((app) => available.has(app.slug));
|
||||
const pending = featured.filter(
|
||||
(app) => !this._loadedIcons.has(app.slug)
|
||||
);
|
||||
// The first apps show right away, so the page doesn't look empty
|
||||
const instant = pending.filter(
|
||||
(app) => featured.indexOf(app) < SCATTER_INSTANT_COUNT
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
instant.map(async (app) => {
|
||||
if ((await load(app)) && this.isConnected) {
|
||||
reveal(app);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// The rest one after another, with a pause between two that show
|
||||
let lastReveal = performance.now();
|
||||
for (const app of pending) {
|
||||
if (instant.includes(app)) {
|
||||
continue;
|
||||
}
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
if (!(await load(app))) {
|
||||
continue;
|
||||
}
|
||||
if (!app.side || !matchMedia(SCATTER_NARROW_QUERY).matches) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await waitForMs(
|
||||
Math.max(
|
||||
0,
|
||||
lastReveal + SCATTER_REVEAL_INTERVAL - performance.now()
|
||||
)
|
||||
);
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
lastReveal = performance.now();
|
||||
}
|
||||
reveal(app);
|
||||
}
|
||||
} finally {
|
||||
this._revealingIcons = false;
|
||||
}
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
:host {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
min-height: 100%;
|
||||
padding: var(--ha-space-4);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.scatter {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
direction: ltr;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.bubble {
|
||||
position: absolute;
|
||||
left: var(--x);
|
||||
top: var(--y);
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
width: var(--size);
|
||||
height: var(--size);
|
||||
margin: calc(var(--size) / -2);
|
||||
padding: calc(var(--size) / 6);
|
||||
border-radius: var(--ha-border-radius-xl);
|
||||
background-color: var(--card-background-color);
|
||||
box-shadow: var(--ha-box-shadow-s);
|
||||
opacity: 0.7;
|
||||
transform: rotate(var(--tilt));
|
||||
animation:
|
||||
appear calc(3 * var(--ha-animation-duration-slow)) ease-out backwards,
|
||||
drift calc(16s + var(--index) * 0.9s) ease-in-out
|
||||
calc(var(--index) * -2.3s) infinite;
|
||||
}
|
||||
|
||||
ha-app-icon {
|
||||
--ha-app-icon-size: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
max-width: 500px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.icon {
|
||||
--mdc-icon-size: 80px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-block: var(--ha-space-5);
|
||||
font-family: var(--ha-font-family-heading);
|
||||
font-size: var(--ha-font-size-3xl);
|
||||
font-weight: var(--ha-font-weight-normal);
|
||||
line-height: var(--ha-line-height-condensed);
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 var(--ha-space-6);
|
||||
}
|
||||
|
||||
.learn-more {
|
||||
margin-top: var(--ha-space-3);
|
||||
}
|
||||
|
||||
@keyframes appear {
|
||||
from {
|
||||
opacity: 0;
|
||||
scale: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes drift {
|
||||
0%,
|
||||
100% {
|
||||
transform: translate(0, 0) rotate(var(--tilt));
|
||||
}
|
||||
25% {
|
||||
transform: translate(var(--dx), calc(-1 * var(--dy)))
|
||||
rotate(calc(var(--tilt) + 4deg));
|
||||
}
|
||||
50% {
|
||||
transform: translate(calc(-0.4 * var(--dx)), var(--dy))
|
||||
rotate(calc(var(--tilt) - 3deg));
|
||||
}
|
||||
75% {
|
||||
transform: translate(calc(-1 * var(--dx)), calc(-0.3 * var(--dy)))
|
||||
rotate(var(--tilt));
|
||||
}
|
||||
}
|
||||
|
||||
/* Same width as SCATTER_NARROW_QUERY */
|
||||
@media (max-width: 600px) {
|
||||
.bubble {
|
||||
scale: 0.8;
|
||||
}
|
||||
.bubble.side {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.bubble {
|
||||
animation: appear var(--ha-animation-duration-slow) backwards;
|
||||
}
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"supervisor-apps-empty-state": SupervisorAppsEmptyState;
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ class HaConfigAppDashboard extends LitElement {
|
||||
slug: string,
|
||||
repositoryUrl: string
|
||||
): Promise<void> {
|
||||
const storeInfo = await fetchSupervisorStore(this.hass.callWS);
|
||||
const storeInfo = await fetchSupervisorStore(this.hass);
|
||||
if (storeInfo.repositories.some((repo) => repo.source === repositoryUrl)) {
|
||||
// Repository is already installed, addon just doesn't exist
|
||||
return;
|
||||
|
||||
@@ -281,7 +281,7 @@ export class HaConfigAppsAvailable extends LitElement {
|
||||
try {
|
||||
const [addonInfo, store] = await Promise.all([
|
||||
addon ?? fetchHassioAddonsInfo(this.hass),
|
||||
fetchSupervisorStore(this.hass.callWS),
|
||||
fetchSupervisorStore(this.hass),
|
||||
]);
|
||||
|
||||
this._addon = addonInfo;
|
||||
@@ -304,7 +304,7 @@ export class HaConfigAppsAvailable extends LitElement {
|
||||
if (collection === "addon") {
|
||||
this._addon = await fetchHassioAddonsInfo(this.hass);
|
||||
} else if (collection === "store") {
|
||||
this._store = await fetchSupervisorStore(this.hass.callWS);
|
||||
this._store = await fetchSupervisorStore(this.hass);
|
||||
}
|
||||
} catch (_err: any) {
|
||||
// Silently fail on refresh errors
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
mdiRefresh,
|
||||
mdiStorePlus,
|
||||
} from "@mdi/js";
|
||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { navigate } from "../../../common/navigate";
|
||||
@@ -84,17 +84,6 @@ export class HaConfigAppsInstalled extends LitElement {
|
||||
});
|
||||
}
|
||||
|
||||
protected willUpdate(changedProps: PropertyValues): void {
|
||||
super.willUpdate(changedProps);
|
||||
// Only needed without installed apps, so it isn't part of the page
|
||||
if (
|
||||
changedProps.has("_addonInfo") &&
|
||||
this._addonInfo?.addons.length === 0
|
||||
) {
|
||||
import("./components/supervisor-apps-empty-state");
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (this._error) {
|
||||
return html`
|
||||
@@ -114,7 +103,6 @@ export class HaConfigAppsInstalled extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
const hasApps = this._addonInfo.addons.length > 0;
|
||||
const addons = this._getAddons(this._addonInfo.addons, this._filter);
|
||||
|
||||
return html`
|
||||
@@ -134,90 +122,85 @@ export class HaConfigAppsInstalled extends LitElement {
|
||||
"ui.panel.config.apps.store.check_updates"
|
||||
)}
|
||||
></ha-icon-button>
|
||||
${
|
||||
hasApps
|
||||
? html`
|
||||
<div class="search">
|
||||
<ha-input-search
|
||||
appearance="outlined"
|
||||
.value=${this._filter}
|
||||
.placeholder=${this.hass.localize(
|
||||
"ui.panel.config.apps.installed.search",
|
||||
{ number: this._addonInfo.addons.length }
|
||||
)}
|
||||
@input=${this._handleSearchChange}
|
||||
>
|
||||
</ha-input-search>
|
||||
</div>
|
||||
${
|
||||
addons.length === 0
|
||||
? html`<p class="no-results">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.apps.installed.no_results"
|
||||
)}
|
||||
</p>`
|
||||
: html`<div class="content">
|
||||
${addons.map((addon) => this._renderApp(addon))}
|
||||
</div>`
|
||||
}
|
||||
`
|
||||
: html`<supervisor-apps-empty-state></supervisor-apps-empty-state>`
|
||||
}
|
||||
${
|
||||
hasApps
|
||||
? html`<ha-button
|
||||
class="fab"
|
||||
size="l"
|
||||
href="/config/apps/available"
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiStorePlus}></ha-svg-icon>
|
||||
${this.hass.localize("ui.panel.config.apps.installed.add_app")}
|
||||
</ha-button>`
|
||||
: nothing
|
||||
}
|
||||
</hass-subpage>
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderApp(addon: HassioAddonInfo) {
|
||||
return html`
|
||||
<ha-card
|
||||
role="button"
|
||||
tabindex="0"
|
||||
outlined
|
||||
.addon=${addon}
|
||||
@click=${this._addonTapped}
|
||||
aria-label=${getAppDisplayName(addon.name, addon.stage)}
|
||||
>
|
||||
<div class="card-content">
|
||||
<supervisor-apps-card-content
|
||||
.hass=${this.hass}
|
||||
.title=${addon.name}
|
||||
.stage=${addon.stage}
|
||||
.description=${addon.description}
|
||||
available
|
||||
.tags=${this._getAppTags(addon)}
|
||||
.state=${addon.state}
|
||||
.operation=${this._operations[addon.slug]}
|
||||
.icon=${addon.update_available ? mdiArrowUpBoldCircle : mdiPuzzle}
|
||||
.iconTitle=${
|
||||
addon.state !== "started"
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.apps.installed.app_stopped"
|
||||
)
|
||||
: addon.update_available
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.apps.installed.app_update_available"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.config.apps.installed.app_running"
|
||||
)
|
||||
}
|
||||
.appSlug=${addon.slug}
|
||||
.hasAppIcon=${addon.icon}
|
||||
></supervisor-apps-card-content>
|
||||
<div class="search">
|
||||
<ha-input-search
|
||||
appearance="outlined"
|
||||
.value=${this._filter}
|
||||
.placeholder=${this.hass.localize(
|
||||
"ui.panel.config.apps.installed.search",
|
||||
{ number: this._addonInfo.addons.length }
|
||||
)}
|
||||
@input=${this._handleSearchChange}
|
||||
>
|
||||
</ha-input-search>
|
||||
</div>
|
||||
</ha-card>
|
||||
<div class="content">
|
||||
${
|
||||
addons.length === 0
|
||||
? html`
|
||||
<ha-card outlined>
|
||||
<div class="card-content">
|
||||
<button class="link" @click=${this._openStore}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.apps.installed.no_apps"
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</ha-card>
|
||||
`
|
||||
: addons.map(
|
||||
(addon) => html`
|
||||
<ha-card
|
||||
role="button"
|
||||
tabindex="0"
|
||||
outlined
|
||||
.addon=${addon}
|
||||
@click=${this._addonTapped}
|
||||
aria-label=${getAppDisplayName(addon.name, addon.stage)}
|
||||
>
|
||||
<div class="card-content">
|
||||
<supervisor-apps-card-content
|
||||
.hass=${this.hass}
|
||||
.title=${addon.name}
|
||||
.stage=${addon.stage}
|
||||
.description=${addon.description}
|
||||
available
|
||||
.tags=${this._getAppTags(addon)}
|
||||
.state=${addon.state}
|
||||
.operation=${this._operations[addon.slug]}
|
||||
.icon=${
|
||||
addon.update_available
|
||||
? mdiArrowUpBoldCircle
|
||||
: mdiPuzzle
|
||||
}
|
||||
.iconTitle=${
|
||||
addon.state !== "started"
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.apps.installed.app_stopped"
|
||||
)
|
||||
: addon.update_available
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.apps.installed.app_update_available"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.config.apps.installed.app_running"
|
||||
)
|
||||
}
|
||||
.appSlug=${addon.slug}
|
||||
.hasAppIcon=${addon.icon}
|
||||
></supervisor-apps-card-content>
|
||||
</div>
|
||||
</ha-card>
|
||||
`
|
||||
)
|
||||
}
|
||||
</div>
|
||||
|
||||
<ha-button size="l" href="/config/apps/available">
|
||||
<ha-svg-icon slot="start" .path=${mdiStorePlus}></ha-svg-icon>
|
||||
${this.hass.localize("ui.panel.config.apps.installed.add_app")}
|
||||
</ha-button>
|
||||
</hass-subpage>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -362,6 +345,10 @@ export class HaConfigAppsInstalled extends LitElement {
|
||||
navigate(`/config/app/${addon.slug}/info`);
|
||||
}
|
||||
|
||||
private _openStore(): void {
|
||||
navigate("/config/apps/available");
|
||||
}
|
||||
|
||||
private _getAppTags(addon: HassioAddonInfo): AppTag[] {
|
||||
const labels: AppTag[] = [];
|
||||
|
||||
@@ -439,13 +426,18 @@ export class HaConfigAppsInstalled extends LitElement {
|
||||
padding: var(--ha-space-4) var(--ha-space-4) var(--ha-space-2);
|
||||
}
|
||||
|
||||
.no-results {
|
||||
margin: var(--ha-space-8) var(--ha-space-4);
|
||||
text-align: center;
|
||||
color: var(--secondary-text-color);
|
||||
button.link {
|
||||
color: var(--primary-color);
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
ha-button.fab {
|
||||
ha-button[size="l"] {
|
||||
position: fixed;
|
||||
right: calc(var(--ha-space-4) + var(--safe-area-inset-right));
|
||||
bottom: calc(var(--ha-space-4) + var(--safe-area-inset-bottom));
|
||||
|
||||
@@ -3,7 +3,6 @@ import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { getEntityAreaId } from "../../../common/entity/context/get_entity_context";
|
||||
import type { HASSDomTargetEvent } from "../../../common/dom/fire_event";
|
||||
import { DirtyStateProviderMixin } from "../../../mixins/dirty-state-provider-mixin";
|
||||
import "../../../components/entity/ha-entity-picker";
|
||||
@@ -60,9 +59,6 @@ const cropOptions: CropOptions = {
|
||||
const SENSOR_DOMAINS = ["sensor"];
|
||||
const TEMPERATURE_DEVICE_CLASSES = [SENSOR_DEVICE_CLASS_TEMPERATURE];
|
||||
const HUMIDITY_DEVICE_CLASSES = [SENSOR_DEVICE_CLASS_HUMIDITY];
|
||||
const BINARY_SENSOR_DOMAINS = ["binary_sensor"];
|
||||
// Core accepts only these device classes for an area's occupancy entity.
|
||||
const OCCUPANCY_DEVICE_CLASSES = ["motion", "occupancy"];
|
||||
|
||||
interface AreaFormState {
|
||||
name: string;
|
||||
@@ -73,7 +69,6 @@ interface AreaFormState {
|
||||
floor: string | null;
|
||||
temperatureEntity: string | null;
|
||||
humidityEntity: string | null;
|
||||
occupancyEntity: string | null;
|
||||
}
|
||||
|
||||
@customElement("dialog-area-registry-detail")
|
||||
@@ -99,8 +94,6 @@ class DialogAreaDetail
|
||||
|
||||
@state() private _humidityEntity!: string | null;
|
||||
|
||||
@state() private _occupancyEntity!: string | null;
|
||||
|
||||
@state() private _error?: string;
|
||||
|
||||
@state() private _params?: AreaRegistryDetailDialogParams;
|
||||
@@ -133,7 +126,6 @@ class DialogAreaDetail
|
||||
this._floor = this._params.entry.floor_id;
|
||||
this._temperatureEntity = this._params.entry.temperature_entity_id;
|
||||
this._humidityEntity = this._params.entry.humidity_entity_id;
|
||||
this._occupancyEntity = this._params.entry.occupancy_entity_id;
|
||||
} else {
|
||||
this._name = this._params.suggestedName || "";
|
||||
this._aliases = [];
|
||||
@@ -143,7 +135,6 @@ class DialogAreaDetail
|
||||
this._floor = null;
|
||||
this._temperatureEntity = null;
|
||||
this._humidityEntity = null;
|
||||
this._occupancyEntity = null;
|
||||
}
|
||||
this._iconFollowsName = !this._params.entry;
|
||||
this._open = true;
|
||||
@@ -161,7 +152,6 @@ class DialogAreaDetail
|
||||
floor: this._floor,
|
||||
temperatureEntity: this._temperatureEntity,
|
||||
humidityEntity: this._humidityEntity,
|
||||
occupancyEntity: this._occupancyEntity,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -325,20 +315,6 @@ class DialogAreaDetail
|
||||
.entityFilter=${this._areaEntityFilter}
|
||||
@value-changed=${this._sensorChanged}
|
||||
></ha-entity-picker>
|
||||
|
||||
<ha-entity-picker
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.config.areas.editor.occupancy_entity"
|
||||
)}
|
||||
.helper=${this.hass.localize(
|
||||
"ui.panel.config.areas.editor.occupancy_entity_description"
|
||||
)}
|
||||
.value=${this._occupancyEntity}
|
||||
.includeDomains=${BINARY_SENSOR_DOMAINS}
|
||||
.includeDeviceClasses=${OCCUPANCY_DEVICE_CLASSES}
|
||||
.entityFilter=${this._areaEntityFilter}
|
||||
@value-changed=${this._occupancyEntityChanged}
|
||||
></ha-entity-picker>
|
||||
</div>
|
||||
</ha-expansion-panel>
|
||||
`;
|
||||
@@ -497,14 +473,21 @@ class DialogAreaDetail
|
||||
return this._name.trim() !== "";
|
||||
}
|
||||
|
||||
// The entity's own area takes precedence over its device's area, so a
|
||||
// sensor assigned to another area isn't offered here.
|
||||
private _areaEntityFilter = (stateObj: HassEntityState): boolean =>
|
||||
getEntityAreaId(
|
||||
stateObj.entity_id,
|
||||
this.hass.entities,
|
||||
this.hass.devices
|
||||
) === this._params!.entry!.area_id;
|
||||
private _areaEntityFilter = (stateObj: HassEntityState): boolean => {
|
||||
const entityReg = this.hass.entities[stateObj.entity_id];
|
||||
if (!entityReg) {
|
||||
return false;
|
||||
}
|
||||
const areaId = this._params!.entry!.area_id;
|
||||
if (entityReg.area_id === areaId) {
|
||||
return true;
|
||||
}
|
||||
if (!entityReg.device_id) {
|
||||
return false;
|
||||
}
|
||||
const deviceReg = this.hass.devices[entityReg.device_id];
|
||||
return deviceReg && deviceReg.area_id === areaId;
|
||||
};
|
||||
|
||||
private _nameChanged(ev: InputEvent & HASSDomTargetEvent<HaInput>) {
|
||||
this._error = undefined;
|
||||
@@ -553,11 +536,6 @@ class DialogAreaDetail
|
||||
this._updateDirtyState(this._currentState());
|
||||
}
|
||||
|
||||
private _occupancyEntityChanged(ev: ValueChangedEvent<string>): void {
|
||||
this._occupancyEntity = ev.detail.value || null;
|
||||
this._updateDirtyState(this._currentState());
|
||||
}
|
||||
|
||||
private async _updateEntry() {
|
||||
const create = !this._params!.entry;
|
||||
this._submitting = true;
|
||||
@@ -571,7 +549,6 @@ class DialogAreaDetail
|
||||
aliases: this._aliases,
|
||||
temperature_entity_id: this._temperatureEntity,
|
||||
humidity_entity_id: this._humidityEntity,
|
||||
occupancy_entity_id: this._occupancyEntity,
|
||||
};
|
||||
if (create) {
|
||||
await this._params!.createEntry!(values);
|
||||
|
||||
@@ -5,14 +5,11 @@ import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, queryAll } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import { renderMoveShortcutHint } from "../../../../common/keyboard/render-move-shortcut-hint";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { stopPropagation } from "../../../../common/dom/stop_propagation";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-sortable";
|
||||
import "../../../../components/ha-svg-icon";
|
||||
import "../../../../components/ha-tooltip";
|
||||
import {
|
||||
ACTION_BUILDING_BLOCKS,
|
||||
getAutomationActionType,
|
||||
@@ -103,8 +100,6 @@ export default class HaAutomationAction extends AutomationSortableListMixin<Acti
|
||||
? html`
|
||||
<div
|
||||
tabindex="0"
|
||||
id="move-row-${idx}"
|
||||
aria-keyshortcuts=${ifDefined(this.optionsInSidebar ? "Alt+ArrowUp Alt+ArrowDown" : undefined)}
|
||||
class="handle ${
|
||||
this.rowSortSelected === idx ? "active" : ""
|
||||
}"
|
||||
@@ -116,20 +111,6 @@ export default class HaAutomationAction extends AutomationSortableListMixin<Acti
|
||||
<ha-svg-icon
|
||||
.path=${mdiDragHorizontalVariant}
|
||||
></ha-svg-icon>
|
||||
${
|
||||
this.optionsInSidebar
|
||||
? html`<ha-tooltip
|
||||
trigger="focus"
|
||||
association="description"
|
||||
for="move-row-${idx}"
|
||||
>
|
||||
${renderMoveShortcutHint(
|
||||
this.hass.localize("ui.common.move_up"),
|
||||
this.hass.localize("ui.common.move_down")
|
||||
)}
|
||||
</ha-tooltip>`
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
`
|
||||
: nothing
|
||||
|
||||
@@ -5,15 +5,12 @@ import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, queryAll, state } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import { renderMoveShortcutHint } from "../../../../common/keyboard/render-move-shortcut-hint";
|
||||
import { consume } from "../../../../common/decorators/consume";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { stopPropagation } from "../../../../common/dom/stop_propagation";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-sortable";
|
||||
import "../../../../components/ha-svg-icon";
|
||||
import "../../../../components/ha-tooltip";
|
||||
import type { Condition } from "../../../../data/automation";
|
||||
import type { ConditionDescriptions } from "../../../../data/condition";
|
||||
import { CONDITION_BUILDING_BLOCKS } from "../../../../data/condition";
|
||||
@@ -216,8 +213,6 @@ export default class HaAutomationCondition extends AutomationSortableListMixin<C
|
||||
? html`
|
||||
<div
|
||||
tabindex="0"
|
||||
id="move-row-${idx}"
|
||||
aria-keyshortcuts=${ifDefined(this.optionsInSidebar ? "Alt+ArrowUp Alt+ArrowDown" : undefined)}
|
||||
class="handle ${
|
||||
this.rowSortSelected === idx ? "active" : ""
|
||||
}"
|
||||
@@ -229,20 +224,6 @@ export default class HaAutomationCondition extends AutomationSortableListMixin<C
|
||||
<ha-svg-icon
|
||||
.path=${mdiDragHorizontalVariant}
|
||||
></ha-svg-icon>
|
||||
${
|
||||
this.optionsInSidebar
|
||||
? html`<ha-tooltip
|
||||
trigger="focus"
|
||||
association="description"
|
||||
for="move-row-${idx}"
|
||||
>
|
||||
${renderMoveShortcutHint(
|
||||
this.hass.localize("ui.common.move_up"),
|
||||
this.hass.localize("ui.common.move_down")
|
||||
)}
|
||||
</ha-tooltip>`
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
`
|
||||
: nothing
|
||||
|
||||
@@ -3,14 +3,11 @@ import type { PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, queryAll } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import { renderMoveShortcutHint } from "../../../../common/keyboard/render-move-shortcut-hint";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { stopPropagation } from "../../../../common/dom/stop_propagation";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-sortable";
|
||||
import "../../../../components/ha-svg-icon";
|
||||
import "../../../../components/ha-tooltip";
|
||||
import type { Option } from "../../../../data/script";
|
||||
import { AutomationSortableListMixin } from "../ha-automation-sortable-list-mixin";
|
||||
import { automationRowsStyles } from "../styles";
|
||||
@@ -77,8 +74,6 @@ export default class HaAutomationOption extends AutomationSortableListMixin<Opti
|
||||
? html`
|
||||
<div
|
||||
tabindex="0"
|
||||
id="move-row-${idx}"
|
||||
aria-keyshortcuts=${ifDefined(this.optionsInSidebar ? "Alt+ArrowUp Alt+ArrowDown" : undefined)}
|
||||
class="handle ${
|
||||
this.rowSortSelected === idx ? "active" : ""
|
||||
}"
|
||||
@@ -90,20 +85,6 @@ export default class HaAutomationOption extends AutomationSortableListMixin<Opti
|
||||
<ha-svg-icon
|
||||
.path=${mdiDragHorizontalVariant}
|
||||
></ha-svg-icon>
|
||||
${
|
||||
this.optionsInSidebar
|
||||
? html`<ha-tooltip
|
||||
trigger="focus"
|
||||
association="description"
|
||||
for="move-row-${idx}"
|
||||
>
|
||||
${renderMoveShortcutHint(
|
||||
this.hass.localize("ui.common.move_up"),
|
||||
this.hass.localize("ui.common.move_down")
|
||||
)}
|
||||
</ha-tooltip>`
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
`
|
||||
: nothing
|
||||
|
||||
@@ -5,8 +5,6 @@ import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import { renderMoveShortcutHint } from "../../../../common/keyboard/render-move-shortcut-hint";
|
||||
import { consume } from "../../../../common/decorators/consume";
|
||||
import { ensureArray } from "../../../../common/array/ensure-array";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
@@ -14,7 +12,6 @@ import { stopPropagation } from "../../../../common/dom/stop_propagation";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-sortable";
|
||||
import "../../../../components/ha-svg-icon";
|
||||
import "../../../../components/ha-tooltip";
|
||||
import type { Trigger } from "../../../../data/automation";
|
||||
import { triggerDescriptionsContext } from "../../../../data/context";
|
||||
import type { TriggerDescriptions } from "../../../../data/trigger";
|
||||
@@ -111,8 +108,6 @@ export default class HaAutomationTrigger extends AutomationSortableListMixin<Tri
|
||||
? html`
|
||||
<div
|
||||
tabindex="0"
|
||||
id="move-row-${idx}"
|
||||
aria-keyshortcuts=${ifDefined(this.optionsInSidebar ? "Alt+ArrowUp Alt+ArrowDown" : undefined)}
|
||||
class="handle ${
|
||||
this.rowSortSelected === idx ? "active" : ""
|
||||
}"
|
||||
@@ -124,20 +119,6 @@ export default class HaAutomationTrigger extends AutomationSortableListMixin<Tri
|
||||
<ha-svg-icon
|
||||
.path=${mdiDragHorizontalVariant}
|
||||
></ha-svg-icon>
|
||||
${
|
||||
this.optionsInSidebar
|
||||
? html`<ha-tooltip
|
||||
trigger="focus"
|
||||
association="description"
|
||||
for="move-row-${idx}"
|
||||
>
|
||||
${renderMoveShortcutHint(
|
||||
this.hass.localize("ui.common.move_up"),
|
||||
this.hass.localize("ui.common.move_down")
|
||||
)}
|
||||
</ha-tooltip>`
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
`
|
||||
: nothing
|
||||
|
||||
@@ -734,15 +734,14 @@ export class HaConfigEntities extends LitElement {
|
||||
const hidden = !!entry.hidden_by;
|
||||
const disabled = !!entry.disabled_by;
|
||||
const readonly = entry.readonly;
|
||||
// An empty state, like that of a cleared text helper, is a valid one.
|
||||
// Entities without a state (disabled ones) are neither available nor
|
||||
// unavailable, so the Unavailable filter only lists entities that are
|
||||
// enabled but not working, matching the Status column.
|
||||
// Entities without a state (disabled ones) count as unavailable too,
|
||||
// so the Available and Unavailable filters are exact opposites. An
|
||||
// empty state, like that of a cleared text helper, is a valid one.
|
||||
const available = !!entity && entity.state !== UNAVAILABLE;
|
||||
|
||||
if (!(
|
||||
(showAvailable && available) ||
|
||||
(showUnavailable && unavailable) ||
|
||||
(showUnavailable && !available) ||
|
||||
(showRestored && restored) ||
|
||||
(showVisible && !hidden) ||
|
||||
(showHidden && hidden) ||
|
||||
|
||||
@@ -3,8 +3,6 @@ import type { CSSResultGroup } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import { renderMoveShortcutHint } from "../../../../common/keyboard/render-move-shortcut-hint";
|
||||
import { consumeLocalize } from "../../../../common/decorators/consume-context-entry";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
@@ -14,7 +12,6 @@ import "../../../../components/ha-icon-button";
|
||||
import "../../../../components/ha-icon-picker";
|
||||
import "../../../../components/ha-sortable";
|
||||
import "../../../../components/ha-svg-icon";
|
||||
import "../../../../components/ha-tooltip";
|
||||
import "../../../../components/input/ha-input";
|
||||
import "../../../../components/item/ha-list-item-base";
|
||||
import "../../../../components/list/ha-list-base";
|
||||
@@ -146,37 +143,17 @@ class HaInputSelectForm extends LitElement {
|
||||
(option) => option,
|
||||
(option, index) => html`
|
||||
<ha-list-item-base
|
||||
id="move-option-${index}"
|
||||
class="option"
|
||||
interactive
|
||||
.headline=${option}
|
||||
.index=${index}
|
||||
@keydown=${this._optionKeydown}
|
||||
aria-keyshortcuts=${ifDefined(
|
||||
!this.disabled
|
||||
? "Alt+ArrowUp Alt+ArrowDown"
|
||||
: undefined
|
||||
)}
|
||||
>
|
||||
<ha-svg-icon
|
||||
slot="start"
|
||||
class="handle"
|
||||
.path=${mdiDragHorizontalVariant}
|
||||
></ha-svg-icon>
|
||||
<ha-tooltip
|
||||
trigger="focus"
|
||||
association="description"
|
||||
slot="start"
|
||||
for=${ifDefined(
|
||||
!this.disabled ? `move-option-${index}` : undefined
|
||||
)}
|
||||
.disabled=${this.disabled}
|
||||
>
|
||||
${renderMoveShortcutHint(
|
||||
this._localize("ui.common.move_up"),
|
||||
this._localize("ui.common.move_down")
|
||||
)}
|
||||
</ha-tooltip>
|
||||
<ha-icon-button
|
||||
slot="end"
|
||||
.index=${index}
|
||||
|
||||
@@ -230,7 +230,7 @@ class HuiEnergyCarbonGaugeCard extends LitElement implements LovelaceCard {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
|
||||
ha-tooltip::part(tooltip__popup) {
|
||||
ha-tooltip::part(base__popup) {
|
||||
margin-top: 4px;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -195,7 +195,7 @@ class HuiEnergyGridGaugeCard extends LitElement implements LovelaceCard {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
|
||||
ha-tooltip::part(tooltip__popup) {
|
||||
ha-tooltip::part(base__popup) {
|
||||
margin-top: 4px;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -194,7 +194,7 @@ class HuiEnergySelfSufficiencyGaugeCard
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
|
||||
ha-tooltip::part(tooltip__popup) {
|
||||
ha-tooltip::part(base__popup) {
|
||||
margin-top: 4px;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -327,11 +327,7 @@ export class HuiDialogEditBadge
|
||||
: "ui.panel.lovelace.editor.edit_badge.show_visual_editor"
|
||||
)}
|
||||
</ha-button>
|
||||
<ha-tooltip
|
||||
slot="secondaryAction"
|
||||
for="toggle-editor-mode"
|
||||
association="description"
|
||||
>
|
||||
<ha-tooltip slot="secondaryAction" for="toggle-editor-mode">
|
||||
${ctrlOrCmdLabel(this._i18n.localize)}+Shift+Y
|
||||
</ha-tooltip>
|
||||
`
|
||||
|
||||
@@ -348,11 +348,7 @@ export class HuiDialogEditCard
|
||||
: "ui.panel.lovelace.editor.edit_card.show_visual_editor"
|
||||
)}
|
||||
</ha-button>
|
||||
<ha-tooltip
|
||||
slot="secondaryAction"
|
||||
for="toggle-editor-mode"
|
||||
association="description"
|
||||
>
|
||||
<ha-tooltip slot="secondaryAction" for="toggle-editor-mode">
|
||||
${ctrlOrCmdLabel(this._i18n.localize)}+Shift+Y
|
||||
</ha-tooltip>
|
||||
`
|
||||
|
||||
@@ -11,7 +11,6 @@ import type {
|
||||
HASSDomTargetEvent,
|
||||
} from "../../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { renderMoveShortcutHint } from "../../../../common/keyboard/render-move-shortcut-hint";
|
||||
import { nextRender } from "../../../../common/util/render-status";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-dropdown";
|
||||
@@ -19,7 +18,6 @@ import type { HaDropdownSelectEvent } from "../../../../components/ha-dropdown";
|
||||
import "../../../../components/ha-dropdown-item";
|
||||
import "../../../../components/ha-sortable";
|
||||
import "../../../../components/ha-svg-icon";
|
||||
import "../../../../components/ha-tooltip";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import { ICON_CONDITION } from "../../common/icon-condition";
|
||||
import type {
|
||||
@@ -238,8 +236,6 @@ export class HaCardConditionsEditor extends LitElement {
|
||||
return html`
|
||||
<div
|
||||
slot="drag-handle"
|
||||
id="move-condition-${idx}"
|
||||
aria-keyshortcuts="Alt+ArrowUp Alt+ArrowDown"
|
||||
class="handle ${this._rowSortSelected === idx ? "active" : ""}"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@@ -250,16 +246,6 @@ export class HaCardConditionsEditor extends LitElement {
|
||||
@keydown=${this._handleDragKeydown}
|
||||
>
|
||||
<ha-svg-icon .path=${mdiDragHorizontalVariant}></ha-svg-icon>
|
||||
<ha-tooltip
|
||||
trigger="focus"
|
||||
association="description"
|
||||
for="move-condition-${idx}"
|
||||
>
|
||||
${renderMoveShortcutHint(
|
||||
this.hass.localize("ui.common.move_up"),
|
||||
this.hass.localize("ui.common.move_down")
|
||||
)}
|
||||
</ha-tooltip>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -52,21 +52,22 @@ const iconSchema = {
|
||||
context: { icon_entity: "entity" },
|
||||
} as const satisfies HaFormSchema;
|
||||
|
||||
export const alertCardContentSchema = {
|
||||
name: "content",
|
||||
type: "expandable",
|
||||
flatten: true,
|
||||
iconPath: mdiTextShort,
|
||||
schema: [
|
||||
nameSchema,
|
||||
{
|
||||
name: "",
|
||||
type: "grid",
|
||||
schema: [iconSchema, { name: "hide_state", selector: { boolean: {} } }],
|
||||
},
|
||||
contentLayoutSchema,
|
||||
],
|
||||
} as const satisfies HaFormSchema;
|
||||
export const alertCardContentSchema = (localize: LocalizeFunc) =>
|
||||
({
|
||||
name: "content",
|
||||
type: "expandable",
|
||||
flatten: true,
|
||||
iconPath: mdiTextShort,
|
||||
schema: [
|
||||
nameSchema,
|
||||
{
|
||||
name: "",
|
||||
type: "grid",
|
||||
schema: [iconSchema, { name: "hide_state", selector: { boolean: {} } }],
|
||||
},
|
||||
contentLayoutSchema(localize),
|
||||
],
|
||||
}) as const satisfies HaFormSchema;
|
||||
|
||||
export const alertBadgeContentSchema = (localize: LocalizeFunc) =>
|
||||
({
|
||||
|
||||
@@ -27,7 +27,29 @@ const colorSchema = {
|
||||
},
|
||||
} as const satisfies HaFormSchema;
|
||||
|
||||
export const contentLayoutSchema = {
|
||||
export const contentLayoutSchema = (localize: LocalizeFunc) =>
|
||||
({
|
||||
name: "content_layout",
|
||||
required: true,
|
||||
selector: {
|
||||
select: {
|
||||
mode: "box",
|
||||
options: ["horizontal", "vertical"].map((value) => ({
|
||||
label: localize(
|
||||
`ui.panel.lovelace.editor.card.tile.content_layout_options.${value}`
|
||||
),
|
||||
value,
|
||||
image: {
|
||||
src: `/static/images/form/tile_content_layout_${value}.svg`,
|
||||
src_dark: `/static/images/form/tile_content_layout_${value}_dark.svg`,
|
||||
flip_rtl: true,
|
||||
},
|
||||
})),
|
||||
},
|
||||
},
|
||||
}) as const satisfies HaFormSchema;
|
||||
|
||||
const tileContentLayoutSchema = {
|
||||
name: "content_layout",
|
||||
required: true,
|
||||
selector: {
|
||||
@@ -122,7 +144,7 @@ export const tileContentSchema = (showTimeFormat: boolean) =>
|
||||
ui_time_format: {},
|
||||
},
|
||||
},
|
||||
contentLayoutSchema,
|
||||
tileContentLayoutSchema,
|
||||
],
|
||||
}) as const satisfies HaFormSchema;
|
||||
|
||||
|
||||
@@ -6,11 +6,13 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { ALERT_DOMAINS } from "../../../../common/entity/alert_active";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { HaFormSchema } from "../../../../components/ha-form/types";
|
||||
import type {
|
||||
HaFormSchema,
|
||||
SchemaUnion,
|
||||
} from "../../../../components/ha-form/types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import type { AlertCardConfig } from "../../cards/types";
|
||||
import type { LovelaceCardEditor } from "../../types";
|
||||
import { editorTranslations } from "../editor-translations";
|
||||
import { actionConfigStruct } from "../structs/action-struct";
|
||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||
import { entityNameStruct } from "../structs/entity-name-struct";
|
||||
@@ -38,17 +40,6 @@ const cardConfigStruct = assign(
|
||||
})
|
||||
);
|
||||
|
||||
const SCHEMA = [
|
||||
{
|
||||
name: "entity",
|
||||
required: true,
|
||||
selector: { entity: { filter: { domain: ALERT_DOMAINS } } },
|
||||
},
|
||||
alertSchema(),
|
||||
alertCardContentSchema,
|
||||
entityInteractionsSchema(),
|
||||
] as const satisfies readonly HaFormSchema[];
|
||||
|
||||
@customElement("hui-alert-card-editor")
|
||||
export class HuiAlertCardEditor
|
||||
extends LitElement
|
||||
@@ -63,8 +54,18 @@ export class HuiAlertCardEditor
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
private _translations = memoizeOne((localize: LocalizeFunc) =>
|
||||
editorTranslations(localize, "ui.panel.lovelace.editor.card.alert")
|
||||
private _schema = memoizeOne(
|
||||
(localize: LocalizeFunc) =>
|
||||
[
|
||||
{
|
||||
name: "entity",
|
||||
required: true,
|
||||
selector: { entity: { filter: { domain: ALERT_DOMAINS } } },
|
||||
},
|
||||
alertSchema(),
|
||||
alertCardContentSchema(localize),
|
||||
entityInteractionsSchema(),
|
||||
] as const satisfies readonly HaFormSchema[]
|
||||
);
|
||||
|
||||
protected render() {
|
||||
@@ -72,16 +73,13 @@ export class HuiAlertCardEditor
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const translations = this._translations(this.hass.localize);
|
||||
|
||||
return html`
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${tileContentFormData(this._config)}
|
||||
.schema=${SCHEMA}
|
||||
.computeLabel=${translations.computeLabel}
|
||||
.computeHelper=${translations.computeHelper}
|
||||
.localizeValue=${translations.localizeValue}
|
||||
.schema=${this._schema(this.hass.localize)}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
.computeHelper=${this._computeHelperCallback}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-form>
|
||||
`;
|
||||
@@ -94,6 +92,48 @@ export class HuiAlertCardEditor
|
||||
|
||||
fireEvent(this, "config-changed", { config });
|
||||
}
|
||||
|
||||
private _computeLabelCallback = (
|
||||
schema: SchemaUnion<ReturnType<typeof this._schema>>
|
||||
) => {
|
||||
switch (schema.name) {
|
||||
case "pulse":
|
||||
case "alert_color":
|
||||
case "clear_color":
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.alert.${schema.name}`
|
||||
);
|
||||
case "alert":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.alert.alert_section"
|
||||
);
|
||||
case "hide_state":
|
||||
case "content_layout":
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.tile.${schema.name}`
|
||||
);
|
||||
default:
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
private _computeHelperCallback = (
|
||||
schema: SchemaUnion<ReturnType<typeof this._schema>>
|
||||
) => {
|
||||
if (
|
||||
schema.name === "pulse" ||
|
||||
schema.name === "alert_color" ||
|
||||
schema.name === "clear_color"
|
||||
) {
|
||||
return this.hass?.localize(
|
||||
`ui.panel.lovelace.editor.card.alert.${schema.name}_helper`
|
||||
);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -24,7 +24,10 @@ import { getEntityIds } from "../../../../common/entity/get_entity_ids";
|
||||
import { caseInsensitiveStringCompare } from "../../../../common/string/compare";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { HaFormSchema } from "../../../../components/ha-form/types";
|
||||
import type {
|
||||
HaFormSchema,
|
||||
SchemaUnion,
|
||||
} from "../../../../components/ha-form/types";
|
||||
import {
|
||||
internationalizationContext,
|
||||
registriesContext,
|
||||
@@ -46,12 +49,11 @@ import {
|
||||
SUM_DEVICE_CLASSES,
|
||||
type AreaCardFeatureContext,
|
||||
} from "../../cards/hui-area-card";
|
||||
import type { AreaCardConfig } from "../../cards/types";
|
||||
import type { AreaCardConfig, AreaCardDisplayType } from "../../cards/types";
|
||||
import type { LovelaceCardEditor } from "../../types";
|
||||
import { actionConfigStruct } from "../structs/action-struct";
|
||||
import { ACTION_RELATED_CONTEXT } from "../../components/hui-action-editor";
|
||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||
import { editorTranslations } from "../editor-translations";
|
||||
import type { EditDetailElementEvent, EditSubElementEvent } from "../types";
|
||||
import { configElementStyle } from "./config-elements-style";
|
||||
import { getSupportedFeaturesType } from "./hui-card-features-editor";
|
||||
@@ -107,7 +109,8 @@ export class HuiAreaCardEditor
|
||||
|
||||
private _schema = memoizeOne(
|
||||
(
|
||||
camera: boolean,
|
||||
localize: LocalizeFunc,
|
||||
displayType: AreaCardDisplayType,
|
||||
binaryClasses: SelectOption[],
|
||||
sensorClasses: SelectOption[]
|
||||
) =>
|
||||
@@ -130,35 +133,57 @@ export class HuiAreaCardEditor
|
||||
required: true,
|
||||
selector: {
|
||||
select: {
|
||||
translation_key: "display_type",
|
||||
options: ["compact", "icon", "picture", "camera"],
|
||||
mode: "dropdown",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "content_layout",
|
||||
required: true,
|
||||
visible: { field: "display_type", value: "compact" },
|
||||
selector: {
|
||||
select: {
|
||||
mode: "dropdown",
|
||||
translation_key: "content_layout",
|
||||
options: ["horizontal", "vertical"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "camera_view",
|
||||
visible: { field: "display_type", value: "camera" },
|
||||
selector: {
|
||||
select: {
|
||||
translation_key: "camera_view",
|
||||
options: ["auto", "live"],
|
||||
options: ["compact", "icon", "picture", "camera"].map(
|
||||
(value) => ({
|
||||
value,
|
||||
label: localize(
|
||||
`ui.panel.lovelace.editor.card.area.display_type_options.${value}`
|
||||
),
|
||||
})
|
||||
),
|
||||
mode: "dropdown",
|
||||
},
|
||||
},
|
||||
},
|
||||
...(displayType === "compact"
|
||||
? ([
|
||||
{
|
||||
name: "content_layout",
|
||||
required: true,
|
||||
selector: {
|
||||
select: {
|
||||
mode: "dropdown",
|
||||
options: ["horizontal", "vertical"].map(
|
||||
(value) => ({
|
||||
label: localize(
|
||||
`ui.panel.lovelace.editor.card.area.content_layout_options.${value}`
|
||||
),
|
||||
value,
|
||||
})
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
] as const satisfies readonly HaFormSchema[])
|
||||
: []),
|
||||
...(displayType === "camera"
|
||||
? ([
|
||||
{
|
||||
name: "camera_view",
|
||||
selector: {
|
||||
select: {
|
||||
options: ["auto", "live"].map((value) => ({
|
||||
value,
|
||||
label: localize(
|
||||
`ui.panel.lovelace.editor.card.generic.camera_view_options.${value}`
|
||||
),
|
||||
})),
|
||||
mode: "dropdown",
|
||||
},
|
||||
},
|
||||
},
|
||||
] as const satisfies readonly HaFormSchema[])
|
||||
: []),
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -201,32 +226,35 @@ export class HuiAreaCardEditor
|
||||
},
|
||||
context: ACTION_RELATED_CONTEXT,
|
||||
},
|
||||
{
|
||||
name: "image_tap_action",
|
||||
visible: {
|
||||
field: "display_type",
|
||||
operator: "not_eq",
|
||||
value: "compact",
|
||||
},
|
||||
selector: {
|
||||
ui_action: {
|
||||
default_action: camera ? "more-info" : "none",
|
||||
actions: camera
|
||||
? ["more-info", "navigate", "url", "perform-action", "none"]
|
||||
: ["navigate", "url", "perform-action", "none"],
|
||||
},
|
||||
},
|
||||
context: ACTION_RELATED_CONTEXT,
|
||||
},
|
||||
...(displayType !== "compact"
|
||||
? ([
|
||||
{
|
||||
name: "image_tap_action",
|
||||
selector: {
|
||||
ui_action: {
|
||||
default_action:
|
||||
displayType === "camera" ? "more-info" : "none",
|
||||
actions:
|
||||
displayType === "camera"
|
||||
? [
|
||||
"more-info",
|
||||
"navigate",
|
||||
"url",
|
||||
"perform-action",
|
||||
"none",
|
||||
]
|
||||
: ["navigate", "url", "perform-action", "none"],
|
||||
},
|
||||
},
|
||||
context: ACTION_RELATED_CONTEXT,
|
||||
},
|
||||
] as const satisfies readonly HaFormSchema[])
|
||||
: []),
|
||||
],
|
||||
},
|
||||
] as const satisfies readonly HaFormSchema[]
|
||||
);
|
||||
|
||||
private _translations = memoizeOne((localize: LocalizeFunc) =>
|
||||
editorTranslations(localize, "ui.panel.lovelace.editor.card.area")
|
||||
);
|
||||
|
||||
private _binaryClassesForArea = memoizeOne(
|
||||
(
|
||||
states: HassEntityStates,
|
||||
@@ -385,7 +413,7 @@ export class HuiAreaCardEditor
|
||||
}
|
||||
|
||||
private _featuresSchema = memoizeOne(
|
||||
(vertical: boolean) =>
|
||||
(localize: LocalizeFunc, vertical: boolean) =>
|
||||
[
|
||||
{
|
||||
name: "features_position",
|
||||
@@ -393,8 +421,13 @@ export class HuiAreaCardEditor
|
||||
selector: {
|
||||
select: {
|
||||
mode: "box",
|
||||
translation_key: "features_position",
|
||||
options: ["bottom", "inline"].map((value) => ({
|
||||
label: localize(
|
||||
`ui.panel.lovelace.editor.card.tile.features_position_options.${value}`
|
||||
),
|
||||
description: localize(
|
||||
`ui.panel.lovelace.editor.card.tile.features_position_options.${value}_description`
|
||||
),
|
||||
value,
|
||||
image: {
|
||||
src: `/static/images/form/tile_features_position_${value}.svg`,
|
||||
@@ -462,16 +495,15 @@ export class HuiAreaCardEditor
|
||||
(this._config.show_camera ? "camera" : "picture");
|
||||
|
||||
const schema = this._schema(
|
||||
displayType === "camera",
|
||||
localize,
|
||||
displayType,
|
||||
binarySelectOptions,
|
||||
sensorSelectOptions
|
||||
);
|
||||
|
||||
const vertical = this._config.vertical && displayType === "compact";
|
||||
|
||||
const featuresSchema = this._featuresSchema(Boolean(vertical));
|
||||
|
||||
const translations = this._translations(localize);
|
||||
const featuresSchema = this._featuresSchema(localize, Boolean(vertical));
|
||||
|
||||
const data = {
|
||||
camera_view: "auto",
|
||||
@@ -504,9 +536,8 @@ export class HuiAreaCardEditor
|
||||
.hass=${this.hass}
|
||||
.data=${data}
|
||||
.schema=${schema}
|
||||
.computeLabel=${translations.computeLabel}
|
||||
.computeHelper=${translations.computeHelper}
|
||||
.localizeValue=${translations.localizeValue}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
.computeHelper=${this._computeHelperCallback}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-form>
|
||||
<ha-expansion-panel outlined>
|
||||
@@ -522,9 +553,7 @@ export class HuiAreaCardEditor
|
||||
class="features-form"
|
||||
.data=${data}
|
||||
.schema=${featuresSchema}
|
||||
.computeLabel=${translations.computeLabel}
|
||||
.computeHelper=${translations.computeHelper}
|
||||
.localizeValue=${translations.localizeValue}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-form>
|
||||
`
|
||||
@@ -622,6 +651,54 @@ export class HuiAreaCardEditor
|
||||
});
|
||||
}
|
||||
|
||||
private _computeHelperCallback = (
|
||||
schema:
|
||||
| SchemaUnion<ReturnType<typeof this._schema>>
|
||||
| SchemaUnion<ReturnType<typeof this._featuresSchema>>
|
||||
): string | undefined => {
|
||||
switch (schema.name) {
|
||||
case "alert_classes":
|
||||
if (this._config?.display_type === "compact") {
|
||||
return this._i18n.localize(
|
||||
`ui.panel.lovelace.editor.card.area.alert_classes_helper`
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
private _computeLabelCallback = (
|
||||
schema:
|
||||
| SchemaUnion<ReturnType<typeof this._schema>>
|
||||
| SchemaUnion<ReturnType<typeof this._featuresSchema>>
|
||||
) => {
|
||||
switch (schema.name) {
|
||||
case "area":
|
||||
return this._i18n.localize("ui.panel.lovelace.editor.card.area.name");
|
||||
case "name":
|
||||
case "camera_view":
|
||||
case "content":
|
||||
case "interactions":
|
||||
case "tap_action":
|
||||
return this._i18n.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
);
|
||||
case "image_tap_action":
|
||||
return this._i18n.localize(
|
||||
`ui.panel.lovelace.editor.card.area.${schema.name}`
|
||||
);
|
||||
case "features_position":
|
||||
return this._i18n.localize(
|
||||
`ui.panel.lovelace.editor.card.tile.${schema.name}`
|
||||
);
|
||||
}
|
||||
return this._i18n.localize(
|
||||
`ui.panel.lovelace.editor.card.area.${schema.name}`
|
||||
);
|
||||
};
|
||||
|
||||
static get styles() {
|
||||
return [
|
||||
configElementStyle,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@@ -12,14 +11,9 @@ import {
|
||||
string,
|
||||
union,
|
||||
} from "superstruct";
|
||||
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 { computeDomain } from "../../../../common/entity/compute_domain";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||
import type { HaEntityPickerEntityFilterFunc } from "../../../../data/entity/entity";
|
||||
@@ -84,12 +78,6 @@ export class HuiDistributionCardEditor
|
||||
|
||||
@state() private _configEntities?: EntityConfig[];
|
||||
|
||||
@state() @consumeLocalize() private _localize!: LocalizeFunc;
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["_configEntities", "0", "entity"] })
|
||||
private _firstEntityStateObj?: HassEntityState;
|
||||
|
||||
public setConfig(config: DistributionCardConfig): void {
|
||||
assert(config, cardConfigStruct);
|
||||
this._config = config;
|
||||
@@ -101,14 +89,23 @@ export class HuiDistributionCardEditor
|
||||
private _entityFilter = memoizeOne(
|
||||
(
|
||||
entities: EntityConfig[] | undefined,
|
||||
targetDeviceClass: string | undefined
|
||||
hass: HomeAssistant
|
||||
): HaEntityPickerEntityFilterFunc | undefined => {
|
||||
// No filtering if no entities yet, or the first entity has no state
|
||||
if (!entities || entities.length === 0 || !targetDeviceClass) {
|
||||
// No filtering if no entities yet
|
||||
if (!entities || entities.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Get the domain and device_class of the first entity
|
||||
const firstEntityState = hass.states[entities[0].entity];
|
||||
if (!firstEntityState) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const targetDomain = computeDomain(entities[0].entity);
|
||||
// Default to "none" if no device_class (Home Assistant pattern)
|
||||
const targetDeviceClass =
|
||||
firstEntityState.attributes.device_class || "none";
|
||||
|
||||
// Create set of already selected entity IDs for fast lookup
|
||||
const selectedEntityIds = new Set(entities.map((e) => e.entity));
|
||||
@@ -146,16 +143,11 @@ export class HuiDistributionCardEditor
|
||||
}
|
||||
|
||||
const schema = this._schema();
|
||||
// Default to "none" if no device_class (Home Assistant pattern)
|
||||
const entityFilter = this._entityFilter(
|
||||
this._configEntities,
|
||||
this._firstEntityStateObj
|
||||
? this._firstEntityStateObj.attributes.device_class || "none"
|
||||
: undefined
|
||||
);
|
||||
const entityFilter = this._entityFilter(this._configEntities, this.hass);
|
||||
|
||||
return html`
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${this._config}
|
||||
.schema=${schema}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
@@ -215,13 +207,13 @@ export class HuiDistributionCardEditor
|
||||
) => {
|
||||
switch (schema.name) {
|
||||
case "title":
|
||||
return `${this._localize(
|
||||
return `${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.title"
|
||||
)} (${this._localize(
|
||||
)} (${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.config.optional"
|
||||
)})`;
|
||||
case "expand_legend":
|
||||
return this._localize(
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.expand_legend"
|
||||
);
|
||||
default:
|
||||
|
||||
@@ -18,11 +18,9 @@ import {
|
||||
type,
|
||||
union,
|
||||
} from "superstruct";
|
||||
import { consumeLocalize } from "../../../../common/decorators/consume-context-entry";
|
||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { customType } from "../../../../common/structs/is-custom-type";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import "../../../../components/ha-card";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||
@@ -226,8 +224,6 @@ export class HuiEntitiesCardEditor
|
||||
|
||||
@state() private _subElementEditorConfig?: SubElementEditorConfig;
|
||||
|
||||
@state() @consumeLocalize() private _localize!: LocalizeFunc;
|
||||
|
||||
public setConfig(config: EntitiesCardConfig): void {
|
||||
const migratedConfig = migrateEntitiesCardConfig(config);
|
||||
assert(migratedConfig, cardConfigStruct);
|
||||
@@ -270,6 +266,7 @@ export class HuiEntitiesCardEditor
|
||||
return html`
|
||||
<div class="card-config">
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${data}
|
||||
.schema=${SCHEMA}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
@@ -317,17 +314,17 @@ export class HuiEntitiesCardEditor
|
||||
switch (schema.name) {
|
||||
case "title":
|
||||
case "theme":
|
||||
return `${this._localize(
|
||||
return `${this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
)} (${this._localize(
|
||||
)} (${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.config.optional"
|
||||
)})`;
|
||||
case "show_header_toggle":
|
||||
return this._localize(
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.entities.show_header_toggle"
|
||||
);
|
||||
default:
|
||||
return this._localize(
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
);
|
||||
}
|
||||
@@ -335,7 +332,7 @@ export class HuiEntitiesCardEditor
|
||||
|
||||
private _valueChanged(ev: CustomEvent): void {
|
||||
ev.stopPropagation();
|
||||
if (!this._config) {
|
||||
if (!this._config || !this.hass) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -377,7 +374,7 @@ export class HuiEntitiesCardEditor
|
||||
|
||||
private _handleSubElementChanged(ev: CustomEvent): void {
|
||||
ev.stopPropagation();
|
||||
if (!this._config) {
|
||||
if (!this._config || !this.hass) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ import {
|
||||
} from "superstruct";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||
import { NON_NUMERIC_ATTRIBUTES } from "../../../../data/entity/entity_attributes";
|
||||
import type { UiColorExtraOption } from "../../../../data/selector";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import {
|
||||
@@ -29,7 +31,6 @@ import {
|
||||
supportedActions,
|
||||
} from "../../components/hui-action-editor";
|
||||
import type { LovelaceCardEditor } from "../../types";
|
||||
import { editorTranslations } from "../editor-translations";
|
||||
import { actionConfigStruct } from "../structs/action-struct";
|
||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||
import { entityNameStruct } from "../structs/entity-name-struct";
|
||||
@@ -73,160 +74,6 @@ const cardConfigStruct = assign(
|
||||
})
|
||||
);
|
||||
|
||||
const SCHEMA = [
|
||||
{
|
||||
name: "entity",
|
||||
selector: {
|
||||
entity: {
|
||||
domain: ["counter", "input_number", "number", "sensor"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "attribute",
|
||||
selector: {
|
||||
attribute: {
|
||||
hide_attributes: NON_NUMERIC_ATTRIBUTES,
|
||||
},
|
||||
},
|
||||
context: { filter_entity: "entity" },
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
selector: {
|
||||
entity_name: {},
|
||||
},
|
||||
context: { entity: "entity" },
|
||||
},
|
||||
{ name: "unit", selector: { text: {} } },
|
||||
{ name: "theme", selector: { theme: {} } },
|
||||
{
|
||||
name: "",
|
||||
type: "grid",
|
||||
schema: [
|
||||
{
|
||||
name: "min",
|
||||
default: DEFAULT_MIN,
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
{
|
||||
name: "max",
|
||||
default: DEFAULT_MAX,
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "",
|
||||
type: "grid",
|
||||
schema: [
|
||||
{ name: "needle", selector: { boolean: {} } },
|
||||
{
|
||||
name: "color_mode",
|
||||
required: true,
|
||||
selector: {
|
||||
select: {
|
||||
mode: "dropdown",
|
||||
translation_key: "color_mode",
|
||||
options: ["color", "severity", "segments"],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "color",
|
||||
visible: { field: "color_mode", value: "color" },
|
||||
selector: {
|
||||
ui_color: {
|
||||
default_color: "default",
|
||||
translation_key: "color",
|
||||
extra_options: [
|
||||
{ value: "default", display_color: severityMap.normal },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "segments",
|
||||
visible: { field: "color_mode", value: "segments" },
|
||||
selector: {
|
||||
object: {
|
||||
multiple: true,
|
||||
reorder: false,
|
||||
translation_key: "segments",
|
||||
fields: {
|
||||
from: {
|
||||
required: true,
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
color: {
|
||||
required: true,
|
||||
selector: { ui_color: {} },
|
||||
},
|
||||
label: {
|
||||
selector: { text: {} },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "severity",
|
||||
type: "grid",
|
||||
visible: { field: "color_mode", value: "severity" },
|
||||
schema: [
|
||||
{
|
||||
name: "green",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
{
|
||||
name: "yellow",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
{
|
||||
name: "red",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "interactions",
|
||||
type: "expandable",
|
||||
flatten: true,
|
||||
iconPath: mdiGestureTap,
|
||||
schema: [
|
||||
{
|
||||
name: "tap_action",
|
||||
selector: {
|
||||
ui_action: {
|
||||
actions: TAP_ACTIONS,
|
||||
default_action: "more-info",
|
||||
},
|
||||
},
|
||||
context: ACTION_RELATED_CONTEXT,
|
||||
},
|
||||
{
|
||||
name: "",
|
||||
type: "optional_actions",
|
||||
flatten: true,
|
||||
schema: (["hold_action", "double_tap_action"] as const).map(
|
||||
(action) => ({
|
||||
name: action,
|
||||
selector: {
|
||||
ui_action: {
|
||||
actions: TAP_ACTIONS,
|
||||
default_action: "none" as const,
|
||||
},
|
||||
},
|
||||
context: ACTION_RELATED_CONTEXT,
|
||||
})
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const;
|
||||
|
||||
@customElement("hui-gauge-card-editor")
|
||||
export class HuiGaugeCardEditor
|
||||
extends LitElement
|
||||
@@ -241,8 +88,180 @@ export class HuiGaugeCardEditor
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
private _translations = memoizeOne((localize: LocalizeFunc) =>
|
||||
editorTranslations(localize, "ui.panel.lovelace.editor.card.gauge")
|
||||
private _schema = memoizeOne(
|
||||
(localize: LocalizeFunc) =>
|
||||
[
|
||||
{
|
||||
name: "entity",
|
||||
selector: {
|
||||
entity: {
|
||||
domain: ["counter", "input_number", "number", "sensor"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "attribute",
|
||||
selector: {
|
||||
attribute: {
|
||||
hide_attributes: NON_NUMERIC_ATTRIBUTES,
|
||||
},
|
||||
},
|
||||
context: { filter_entity: "entity" },
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
selector: {
|
||||
entity_name: {},
|
||||
},
|
||||
context: { entity: "entity" },
|
||||
},
|
||||
{ name: "unit", selector: { text: {} } },
|
||||
{ name: "theme", selector: { theme: {} } },
|
||||
{
|
||||
name: "",
|
||||
type: "grid",
|
||||
schema: [
|
||||
{
|
||||
name: "min",
|
||||
default: DEFAULT_MIN,
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
{
|
||||
name: "max",
|
||||
default: DEFAULT_MAX,
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "",
|
||||
type: "grid",
|
||||
schema: [
|
||||
{ name: "needle", selector: { boolean: {} } },
|
||||
{
|
||||
name: "color_mode",
|
||||
required: true,
|
||||
selector: {
|
||||
select: {
|
||||
mode: "dropdown",
|
||||
options: (["color", "severity", "segments"] as const).map(
|
||||
(mode) => ({
|
||||
value: mode,
|
||||
label: localize(
|
||||
`ui.panel.lovelace.editor.card.gauge.color_mode_options.${mode}`
|
||||
),
|
||||
})
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "color",
|
||||
visible: { field: "color_mode", value: "color" },
|
||||
selector: {
|
||||
ui_color: {
|
||||
default_color: "default",
|
||||
extra_options: [
|
||||
{
|
||||
value: "default",
|
||||
label: localize(
|
||||
"ui.panel.lovelace.editor.card.gauge.color_default"
|
||||
),
|
||||
display_color: severityMap.normal,
|
||||
},
|
||||
] as UiColorExtraOption[],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "segments",
|
||||
visible: { field: "color_mode", value: "segments" },
|
||||
selector: {
|
||||
object: {
|
||||
multiple: true,
|
||||
reorder: false,
|
||||
fields: {
|
||||
from: {
|
||||
label: localize(
|
||||
"ui.panel.lovelace.editor.card.gauge.segment.from"
|
||||
),
|
||||
required: true,
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
color: {
|
||||
label: localize(
|
||||
"ui.panel.lovelace.editor.card.generic.color"
|
||||
),
|
||||
required: true,
|
||||
selector: { ui_color: {} },
|
||||
},
|
||||
label: {
|
||||
label: localize(
|
||||
"ui.panel.lovelace.editor.card.gauge.segment.label"
|
||||
),
|
||||
selector: { text: {} },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "severity",
|
||||
type: "grid",
|
||||
visible: { field: "color_mode", value: "severity" },
|
||||
schema: [
|
||||
{
|
||||
name: "green",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
{
|
||||
name: "yellow",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
{
|
||||
name: "red",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "interactions",
|
||||
type: "expandable",
|
||||
flatten: true,
|
||||
iconPath: mdiGestureTap,
|
||||
schema: [
|
||||
{
|
||||
name: "tap_action",
|
||||
selector: {
|
||||
ui_action: {
|
||||
actions: TAP_ACTIONS,
|
||||
default_action: "more-info",
|
||||
},
|
||||
},
|
||||
context: ACTION_RELATED_CONTEXT,
|
||||
},
|
||||
{
|
||||
name: "",
|
||||
type: "optional_actions",
|
||||
flatten: true,
|
||||
schema: (["hold_action", "double_tap_action"] as const).map(
|
||||
(action) => ({
|
||||
name: action,
|
||||
selector: {
|
||||
ui_action: {
|
||||
actions: TAP_ACTIONS,
|
||||
default_action: "none" as const,
|
||||
},
|
||||
},
|
||||
context: ACTION_RELATED_CONTEXT,
|
||||
})
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const
|
||||
);
|
||||
|
||||
protected render() {
|
||||
@@ -250,7 +269,7 @@ export class HuiGaugeCardEditor
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const translations = this._translations(this.hass.localize);
|
||||
const schema = this._schema(this.hass.localize);
|
||||
const data = {
|
||||
color_mode: this._colorMode(this._config!),
|
||||
...this._config,
|
||||
@@ -261,10 +280,8 @@ export class HuiGaugeCardEditor
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${data}
|
||||
.schema=${SCHEMA}
|
||||
.computeLabel=${translations.computeLabel}
|
||||
.computeHelper=${translations.computeHelper}
|
||||
.localizeValue=${translations.localizeValue}
|
||||
.schema=${schema}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-form>
|
||||
`;
|
||||
@@ -319,6 +336,78 @@ export class HuiGaugeCardEditor
|
||||
|
||||
fireEvent(this, "config-changed", { config });
|
||||
}
|
||||
|
||||
private _computeLabelCallback = (
|
||||
schema: SchemaUnion<ReturnType<typeof this._schema>>
|
||||
) => {
|
||||
switch (schema.name) {
|
||||
case "name":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.name"
|
||||
);
|
||||
case "entity":
|
||||
return `${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.entity"
|
||||
)} (${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.config.required"
|
||||
)})`;
|
||||
case "max":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.maximum"
|
||||
);
|
||||
case "min":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.minimum"
|
||||
);
|
||||
case "color_mode":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.gauge.color_mode"
|
||||
);
|
||||
case "color":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.color"
|
||||
);
|
||||
case "segments":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.gauge.segments"
|
||||
);
|
||||
case "needle":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.gauge.needle_gauge"
|
||||
);
|
||||
case "theme":
|
||||
return `${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.theme"
|
||||
)} (${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.config.optional"
|
||||
)})`;
|
||||
case "unit":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.unit"
|
||||
);
|
||||
case "interactions":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.interactions"
|
||||
);
|
||||
case "tap_action":
|
||||
case "hold_action":
|
||||
case "double_tap_action":
|
||||
return `${this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
)} (${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.config.optional"
|
||||
)})`;
|
||||
case "attribute":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.attribute"
|
||||
);
|
||||
default:
|
||||
// "green" | "yellow" | "red"
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.gauge.severity.${schema.name}`
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import {
|
||||
@@ -13,12 +12,7 @@ import {
|
||||
union,
|
||||
} from "superstruct";
|
||||
import memoizeOne from "memoize-one";
|
||||
import {
|
||||
consumeEntityState,
|
||||
consumeLocalize,
|
||||
} from "../../../../common/decorators/consume-context-entry";
|
||||
import { computeDomain } from "../../../../common/entity/compute_domain";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
@@ -100,14 +94,6 @@ export class HuiGlanceCardEditor
|
||||
|
||||
@state() private _configEntities?: ConfigEntity[];
|
||||
|
||||
@state() @consumeLocalize() private _localize!: LocalizeFunc;
|
||||
|
||||
@state()
|
||||
@consumeEntityState({
|
||||
entityIdPath: ["_subElementEditorConfig", "elementConfig", "entity"],
|
||||
})
|
||||
private _subElementStateObj?: HassEntityState;
|
||||
|
||||
public setConfig(config: GlanceCardConfig): void {
|
||||
const migratedConfig = migrateGlanceCardConfig(config);
|
||||
assert(migratedConfig, cardConfigStruct);
|
||||
@@ -202,7 +188,7 @@ export class HuiGlanceCardEditor
|
||||
TIMESTAMP_STATE_DOMAINS.has(domain) ||
|
||||
(domain === "sensor" &&
|
||||
SENSOR_TIMESTAMP_DEVICE_CLASSES.includes(
|
||||
this._subElementStateObj?.attributes.device_class
|
||||
this.hass.states[entity]?.attributes.device_class
|
||||
));
|
||||
return html`
|
||||
<hui-sub-element-editor
|
||||
@@ -225,6 +211,7 @@ export class HuiGlanceCardEditor
|
||||
|
||||
return html`
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${data}
|
||||
.schema=${SCHEMA}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
@@ -284,17 +271,17 @@ export class HuiGlanceCardEditor
|
||||
private _computeLabelCallback = (schema: SchemaUnion<typeof SCHEMA>) => {
|
||||
switch (schema.name) {
|
||||
case "theme":
|
||||
return `${this._localize(
|
||||
return `${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.generic.theme"
|
||||
)} (${this._localize(
|
||||
)} (${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.config.optional"
|
||||
)})`;
|
||||
case "columns":
|
||||
return this._localize(
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.glance.${schema.name}`
|
||||
);
|
||||
default:
|
||||
return this._localize(
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,7 @@ import {
|
||||
union,
|
||||
} from "superstruct";
|
||||
import { ContextProvider } from "@lit/context";
|
||||
import type {
|
||||
HassEntityState,
|
||||
HassEntityStates,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { consume } from "../../../../common/decorators/consume";
|
||||
import { consumeLocalize } from "../../../../common/decorators/consume-context-entry";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { computeDomain } from "../../../../common/entity/compute_domain";
|
||||
@@ -43,7 +38,6 @@ import {
|
||||
MAP_STYLES,
|
||||
} from "../../../../common/map/map-styles";
|
||||
import { MAP_CARD_MARKER_LABEL_MODES } from "../../../../components/map/ha-map";
|
||||
import { statesContext } from "../../../../data/context";
|
||||
import type { SelectSelector } from "../../../../data/selector";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import { THEME_MODES } from "../../../../types";
|
||||
@@ -132,11 +126,6 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
|
||||
@state() private _subElementEditorConfig?: SubElementEditorConfig;
|
||||
|
||||
@state() @consumeLocalize() private _localize!: LocalizeFunc;
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states?: HassEntityStates | null;
|
||||
|
||||
private _shouldDisableOptions = (entityId: string) =>
|
||||
computeDomain(entityId) === "zone";
|
||||
|
||||
@@ -338,16 +327,15 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
|
||||
protected firstUpdated(changedProperties: PropertyValues<this>) {
|
||||
super.firstUpdated(changedProperties);
|
||||
const states = this._states;
|
||||
this._locationEntities = !states
|
||||
this._locationEntities = !this.hass
|
||||
? []
|
||||
: Object.keys(states).filter((entity_id) =>
|
||||
getEntityLocation(states[entity_id], states)
|
||||
: Object.keys(this.hass!.states).filter((entity_id) =>
|
||||
getEntityLocation(this.hass!.states[entity_id], this.hass!.states)
|
||||
);
|
||||
}
|
||||
|
||||
private _entityHasLocation = (stateObj: HassEntityState) =>
|
||||
!!getEntityLocation(stateObj, this._states ?? {});
|
||||
!!getEntityLocation(stateObj, this.hass!.states);
|
||||
|
||||
protected render() {
|
||||
if (!this.hass || !this._config) {
|
||||
@@ -363,7 +351,7 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
.hass=${this.hass}
|
||||
.config=${this._subElementEditorConfig}
|
||||
.form=${this._subForm(
|
||||
this._localize,
|
||||
this.hass.localize,
|
||||
entityId,
|
||||
this._locationEntities
|
||||
)}
|
||||
@@ -379,8 +367,9 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
: [];
|
||||
return html`
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${this._formData(this._config)}
|
||||
.schema=${this._schema(this._localize)}
|
||||
.schema=${this._schema(this.hass.localize)}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
.computeHelper=${this._computeHelperCallback}
|
||||
@value-changed=${this._valueChanged}
|
||||
@@ -397,19 +386,19 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
></hui-entity-editor>
|
||||
|
||||
<h3>
|
||||
${this._localize(
|
||||
${this.hass.localize(
|
||||
"ui.panel.lovelace.editor.card.map.geo_location_sources"
|
||||
)}
|
||||
</h3>
|
||||
|
||||
<ha-selector-select
|
||||
.label=${this._localize("ui.panel.lovelace.editor.card.map.source")}
|
||||
.label=${this.hass.localize("ui.panel.lovelace.editor.card.map.source")}
|
||||
.required=${false}
|
||||
.value=${this._geo_location_sources}
|
||||
@value-changed=${this._geoSourcesChanged}
|
||||
.selector=${this._selectSchema(
|
||||
this._possibleGeoSources,
|
||||
this._localize
|
||||
this.hass.localize
|
||||
)}
|
||||
></ha-selector-select>
|
||||
${this.renderConditions()}
|
||||
@@ -419,9 +408,13 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
renderConditions() {
|
||||
const conditions = this._config?.conditions ?? [];
|
||||
return html`
|
||||
<h3>${this._localize("ui.panel.lovelace.editor.card.map.conditions")}</h3>
|
||||
<h3>
|
||||
${this.hass!.localize("ui.panel.lovelace.editor.card.map.conditions")}
|
||||
</h3>
|
||||
<p class="intro">
|
||||
${this._localize("ui.panel.lovelace.editor.card.map.conditions_helper")}
|
||||
${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.map.conditions_helper"
|
||||
)}
|
||||
</p>
|
||||
<ha-card-conditions-editor
|
||||
.hass=${this.hass!}
|
||||
@@ -518,7 +511,7 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
}
|
||||
|
||||
private _geoSourcesChanged(ev: ValueChangedEvent<any>): void {
|
||||
if (!this._config) {
|
||||
if (!this._config || !this.hass) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -572,9 +565,9 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
);
|
||||
}
|
||||
|
||||
if (this._states && !this._possibleGeoSources) {
|
||||
if (this.hass && !this._possibleGeoSources) {
|
||||
const sources: Record<string, string> = {};
|
||||
Object.entries(this._states).forEach(([entity_id, stateObj]) => {
|
||||
Object.entries(this.hass.states).forEach(([entity_id, stateObj]) => {
|
||||
const domain = computeDomain(entity_id);
|
||||
if (domain === "geo_location" && stateObj.attributes.source) {
|
||||
sources[stateObj.attributes.source] = stateObj.attributes.attribution;
|
||||
@@ -603,11 +596,11 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
case "show_zone_radius":
|
||||
case "cluster":
|
||||
case "show_all":
|
||||
return this._localize(
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.map.${schema.name}`
|
||||
);
|
||||
default:
|
||||
return this._localize(
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
);
|
||||
}
|
||||
@@ -624,7 +617,7 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
||||
case "show_zone_radius":
|
||||
case "cluster":
|
||||
case "show_all":
|
||||
return this._localize(
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.map.${schema.name}_helper`
|
||||
);
|
||||
default:
|
||||
|
||||
@@ -16,11 +16,10 @@ import { consumeLocalize } from "../../../../common/decorators/consume-context-e
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { HaFormSchema } from "../../../../components/ha-form/types";
|
||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||
import { DEFAULT_HOURS_TO_SHOW } from "../../cards/hui-sensor-card";
|
||||
import type { SensorCardConfig } from "../../cards/types";
|
||||
import type { LovelaceCardEditor } from "../../types";
|
||||
import { editorTranslations } from "../editor-translations";
|
||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||
import { entityNameStruct } from "../structs/entity-name-struct";
|
||||
import { configElementStyle } from "./config-elements-style";
|
||||
@@ -46,76 +45,6 @@ const cardConfigStruct = assign(
|
||||
})
|
||||
);
|
||||
|
||||
const SCHEMA = [
|
||||
{
|
||||
name: "entity",
|
||||
selector: {
|
||||
entity: { domain: ["counter", "input_number", "number", "sensor"] },
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
selector: {
|
||||
entity_name: {},
|
||||
},
|
||||
context: { entity: "entity" },
|
||||
},
|
||||
{
|
||||
type: "grid",
|
||||
name: "",
|
||||
schema: [
|
||||
{
|
||||
name: "icon",
|
||||
selector: {
|
||||
icon: {},
|
||||
},
|
||||
context: {
|
||||
icon_entity: "entity",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "color",
|
||||
selector: {
|
||||
ui_color: {
|
||||
include_state: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "graph",
|
||||
selector: {
|
||||
select: {
|
||||
translation_key: "graph",
|
||||
options: ["none", "line"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{ name: "unit", selector: { text: {} } },
|
||||
{ name: "detail", selector: { boolean: {} } },
|
||||
{ name: "theme", selector: { theme: {} } },
|
||||
{
|
||||
name: "hours_to_show",
|
||||
default: DEFAULT_HOURS_TO_SHOW,
|
||||
selector: { number: { min: 1, mode: "box" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "grid",
|
||||
name: "limits",
|
||||
schema: [
|
||||
{
|
||||
name: "min",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
{
|
||||
name: "max",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const satisfies readonly HaFormSchema[];
|
||||
|
||||
@customElement("hui-sensor-card-editor")
|
||||
export class HuiSensorCardEditor
|
||||
extends LitElement
|
||||
@@ -131,8 +60,81 @@ export class HuiSensorCardEditor
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
private _translations = memoizeOne((localize: LocalizeFunc) =>
|
||||
editorTranslations(localize, "ui.panel.lovelace.editor.card.sensor")
|
||||
private _schema = memoizeOne(
|
||||
(localize: LocalizeFunc) =>
|
||||
[
|
||||
{
|
||||
name: "entity",
|
||||
selector: {
|
||||
entity: { domain: ["counter", "input_number", "number", "sensor"] },
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
selector: {
|
||||
entity_name: {},
|
||||
},
|
||||
context: { entity: "entity" },
|
||||
},
|
||||
{
|
||||
type: "grid",
|
||||
name: "",
|
||||
schema: [
|
||||
{
|
||||
name: "icon",
|
||||
selector: {
|
||||
icon: {},
|
||||
},
|
||||
context: {
|
||||
icon_entity: "entity",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "color",
|
||||
selector: {
|
||||
ui_color: {
|
||||
include_state: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "graph",
|
||||
selector: {
|
||||
select: {
|
||||
options: ["none", "line"].map((value) => ({
|
||||
value,
|
||||
label: localize(
|
||||
`ui.panel.lovelace.editor.card.sensor.graph_options.${value}`
|
||||
),
|
||||
})),
|
||||
},
|
||||
},
|
||||
},
|
||||
{ name: "unit", selector: { text: {} } },
|
||||
{ name: "detail", selector: { boolean: {} } },
|
||||
{ name: "theme", selector: { theme: {} } },
|
||||
{
|
||||
name: "hours_to_show",
|
||||
default: DEFAULT_HOURS_TO_SHOW,
|
||||
selector: { number: { min: 1, mode: "box" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "grid",
|
||||
name: "limits",
|
||||
schema: [
|
||||
{
|
||||
name: "min",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
{
|
||||
name: "max",
|
||||
selector: { number: { mode: "box", step: "any" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const
|
||||
);
|
||||
|
||||
protected render() {
|
||||
@@ -146,26 +148,65 @@ export class HuiSensorCardEditor
|
||||
detail: this._config!.detail === 2,
|
||||
};
|
||||
|
||||
const translations = this._translations(this._localize);
|
||||
|
||||
return html`
|
||||
<ha-form
|
||||
.data=${data}
|
||||
.schema=${SCHEMA}
|
||||
.computeLabel=${translations.computeLabel}
|
||||
.computeHelper=${translations.computeHelper}
|
||||
.localizeValue=${translations.localizeValue}
|
||||
.schema=${this._schema(this._localize)}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
.computeHelper=${this._computeHelperCallback}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-form>
|
||||
`;
|
||||
}
|
||||
|
||||
private _computeHelperCallback = (
|
||||
schema: SchemaUnion<ReturnType<typeof this._schema>>
|
||||
) => {
|
||||
switch (schema.name) {
|
||||
case "color":
|
||||
return this._localize(
|
||||
`ui.panel.lovelace.editor.card.tile.${schema.name}_helper`
|
||||
);
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
private _valueChanged(ev: CustomEvent): void {
|
||||
const config = ev.detail.value;
|
||||
config.detail = config.detail ? 2 : 1;
|
||||
fireEvent(this, "config-changed", { config });
|
||||
}
|
||||
|
||||
private _computeLabelCallback = (
|
||||
schema: SchemaUnion<ReturnType<typeof this._schema>>
|
||||
) => {
|
||||
switch (schema.name) {
|
||||
case "theme":
|
||||
return `${this._localize(
|
||||
"ui.panel.lovelace.editor.card.generic.theme"
|
||||
)} (${this._localize(
|
||||
"ui.panel.lovelace.editor.card.config.optional"
|
||||
)})`;
|
||||
case "detail":
|
||||
return this._localize(
|
||||
"ui.panel.lovelace.editor.card.sensor.show_more_detail"
|
||||
);
|
||||
case "graph":
|
||||
return this._localize(
|
||||
"ui.panel.lovelace.editor.card.sensor.graph_type"
|
||||
);
|
||||
case "min":
|
||||
return this._localize("ui.panel.lovelace.editor.card.sensor.limit_min");
|
||||
case "max":
|
||||
return this._localize("ui.panel.lovelace.editor.card.sensor.limit_max");
|
||||
default:
|
||||
return this._localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return configElementStyle;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import { getShortcutCardDefaults } from "../../cards/hui-shortcut-card-defaults"
|
||||
import type { ShortcutCardConfig } from "../../cards/types";
|
||||
import type { UiAction } from "../../components/hui-action-editor";
|
||||
import type { LovelaceCardEditor } from "../../types";
|
||||
import { editorTranslations } from "../editor-translations";
|
||||
import { actionConfigStruct } from "../structs/action-struct";
|
||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||
import { configElementStyle } from "./config-elements-style";
|
||||
@@ -74,7 +73,7 @@ export class HuiShortcutCardEditor
|
||||
}
|
||||
|
||||
private _schema = memoizeOne(
|
||||
(label: string, icon?: string) =>
|
||||
(localize: LocalizeFunc, label: string, icon?: string) =>
|
||||
[
|
||||
{
|
||||
name: "tap_action",
|
||||
@@ -134,8 +133,10 @@ export class HuiShortcutCardEditor
|
||||
selector: {
|
||||
select: {
|
||||
mode: "box",
|
||||
translation_key: "content_layout",
|
||||
options: ["horizontal", "vertical"].map((value) => ({
|
||||
label: localize(
|
||||
`ui.panel.lovelace.editor.card.tile.content_layout_options.${value}`
|
||||
),
|
||||
value,
|
||||
image: {
|
||||
src: `/static/images/form/tile_content_layout_${value}.svg`,
|
||||
@@ -181,10 +182,6 @@ export class HuiShortcutCardEditor
|
||||
] as const satisfies readonly HaFormSchema[]
|
||||
);
|
||||
|
||||
private _translations = memoizeOne((localize: LocalizeFunc) =>
|
||||
editorTranslations(localize, "ui.panel.lovelace.editor.card.shortcut")
|
||||
);
|
||||
|
||||
protected render() {
|
||||
if (!this.hass || !this._config) {
|
||||
return nothing;
|
||||
@@ -197,8 +194,6 @@ export class HuiShortcutCardEditor
|
||||
this._serviceInfo.info
|
||||
);
|
||||
|
||||
const translations = this._translations(this.hass.localize);
|
||||
|
||||
const data = {
|
||||
...this._config,
|
||||
content_layout: this._config.vertical ? "vertical" : "horizontal",
|
||||
@@ -208,10 +203,12 @@ export class HuiShortcutCardEditor
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${data}
|
||||
.schema=${this._schema(defaults.label, defaults.icon)}
|
||||
.computeLabel=${translations.computeLabel}
|
||||
.computeHelper=${translations.computeHelper}
|
||||
.localizeValue=${translations.localizeValue}
|
||||
.schema=${this._schema(
|
||||
this.hass.localize,
|
||||
defaults.label,
|
||||
defaults.icon
|
||||
)}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-form>
|
||||
`;
|
||||
@@ -235,6 +232,25 @@ export class HuiShortcutCardEditor
|
||||
fireEvent(this, "config-changed", { config });
|
||||
}
|
||||
|
||||
private _computeLabelCallback = (schema: HaFormSchema) => {
|
||||
switch (schema.name) {
|
||||
case "label":
|
||||
case "content_layout":
|
||||
case "additional_interactions":
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.shortcut.${schema.name}`
|
||||
);
|
||||
case "description":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.shortcut.card_description"
|
||||
);
|
||||
default:
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
static styles = configElementStyle;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,9 @@ import {
|
||||
optional,
|
||||
string,
|
||||
} from "superstruct";
|
||||
import { consumeLocalize } from "../../../../common/decorators/consume-context-entry";
|
||||
import { storage } from "../../../../common/decorators/storage";
|
||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import type {
|
||||
HaFormSchema,
|
||||
SchemaUnion,
|
||||
@@ -87,8 +85,6 @@ export class HuiStackCardEditor
|
||||
|
||||
@state() protected _guiModeAvailable? = true;
|
||||
|
||||
@state() @consumeLocalize() private _localize!: LocalizeFunc;
|
||||
|
||||
protected _keys = new Map<string, string>();
|
||||
|
||||
protected _schema: readonly HaFormSchema[] = SCHEMA;
|
||||
@@ -120,6 +116,7 @@ export class HuiStackCardEditor
|
||||
|
||||
return html`
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${this.formData()}
|
||||
.schema=${this._schema}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
@@ -142,7 +139,9 @@ export class HuiStackCardEditor
|
||||
<ha-icon-button
|
||||
@click=${this._handleAddCard}
|
||||
.path=${mdiPlus}
|
||||
.label=${this._localize("ui.panel.lovelace.editor.edit_card.add")}
|
||||
.label=${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.edit_card.add"
|
||||
)}
|
||||
></ha-icon-button>
|
||||
</div>
|
||||
|
||||
@@ -155,7 +154,7 @@ export class HuiStackCardEditor
|
||||
class="gui-mode-button"
|
||||
@click=${this._toggleMode}
|
||||
.disabled=${!this._guiModeAvailable}
|
||||
.label=${this._localize(
|
||||
.label=${this.hass!.localize(
|
||||
isGuiMode
|
||||
? "ui.panel.lovelace.editor.edit_card.show_code_editor"
|
||||
: "ui.panel.lovelace.editor.edit_card.show_visual_editor"
|
||||
@@ -165,7 +164,7 @@ export class HuiStackCardEditor
|
||||
|
||||
<ha-icon-button-arrow-prev
|
||||
.disabled=${selected === 0}
|
||||
.label=${this._localize(
|
||||
.label=${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.edit_card.move_before"
|
||||
)}
|
||||
@click=${this._handleMove}
|
||||
@@ -173,7 +172,7 @@ export class HuiStackCardEditor
|
||||
></ha-icon-button-arrow-prev>
|
||||
|
||||
<ha-icon-button-arrow-next
|
||||
.label=${this._localize(
|
||||
.label=${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.edit_card.move_after"
|
||||
)}
|
||||
.disabled=${selected === numcards - 1}
|
||||
@@ -182,7 +181,7 @@ export class HuiStackCardEditor
|
||||
></ha-icon-button-arrow-next>
|
||||
|
||||
<ha-icon-button
|
||||
.label=${this._localize(
|
||||
.label=${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.edit_card.copy"
|
||||
)}
|
||||
.path=${mdiContentCopy}
|
||||
@@ -190,7 +189,7 @@ export class HuiStackCardEditor
|
||||
></ha-icon-button>
|
||||
|
||||
<ha-icon-button
|
||||
.label=${this._localize(
|
||||
.label=${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.edit_card.cut"
|
||||
)}
|
||||
.path=${mdiContentCut}
|
||||
@@ -198,7 +197,7 @@ export class HuiStackCardEditor
|
||||
></ha-icon-button>
|
||||
|
||||
<ha-icon-button
|
||||
.label=${this._localize(
|
||||
.label=${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.edit_card.delete"
|
||||
)}
|
||||
.path=${mdiDelete}
|
||||
@@ -331,7 +330,7 @@ export class HuiStackCardEditor
|
||||
}
|
||||
|
||||
protected _computeLabelCallback = (schema: SchemaUnion<typeof SCHEMA>) =>
|
||||
this._localize(
|
||||
this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.${this._config!.type}.${schema.name}`
|
||||
);
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ export class HuiTileCardEditor
|
||||
);
|
||||
|
||||
private _translations = memoizeOne((localize: LocalizeFunc) =>
|
||||
editorTranslations(localize, "ui.panel.lovelace.editor.card.tile")
|
||||
editorTranslations(localize, "ui.panel.lovelace.editor.card.tile.editor")
|
||||
);
|
||||
|
||||
private _hasCompatibleFeatures = memoizeOne(
|
||||
|
||||
@@ -2,10 +2,8 @@ import { mdiCodeBraces, mdiListBoxOutline } from "@mdi/js";
|
||||
import type { TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
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-icon-button";
|
||||
import "../../../components/ha-icon-button-prev";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
@@ -33,8 +31,6 @@ export class HuiSubElementEditor extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public form?: LovelaceConfigForm;
|
||||
|
||||
@state() @consumeLocalize() private _localize!: LocalizeFunc;
|
||||
|
||||
@state() private _guiModeAvailable = true;
|
||||
|
||||
@state() private _guiMode = true;
|
||||
@@ -51,22 +47,22 @@ export class HuiSubElementEditor extends LitElement {
|
||||
<div class="header">
|
||||
<div class="back-title">
|
||||
<ha-icon-button-prev
|
||||
.label=${this._localize("ui.common.back")}
|
||||
.label=${this.hass!.localize("ui.common.back")}
|
||||
@click=${this._goBack}
|
||||
></ha-icon-button-prev>
|
||||
<span slot="title">
|
||||
${
|
||||
this.config?.type === "element"
|
||||
? this._localize(
|
||||
? this.hass.localize(
|
||||
`ui.panel.lovelace.editor.sub-element-editor.types.element_type`,
|
||||
{
|
||||
type:
|
||||
this._localize(
|
||||
this.hass.localize(
|
||||
`ui.panel.lovelace.editor.card.picture-elements.element_types.${elementType}`
|
||||
) || elementType,
|
||||
}
|
||||
)
|
||||
: this._localize(
|
||||
: this.hass.localize(
|
||||
`ui.panel.lovelace.editor.sub-element-editor.types.${this.config?.type}`
|
||||
)
|
||||
}
|
||||
@@ -76,7 +72,7 @@ export class HuiSubElementEditor extends LitElement {
|
||||
class="gui-mode-button"
|
||||
@click=${this._toggleMode}
|
||||
.disabled=${!this._guiModeAvailable}
|
||||
.label=${this._localize(
|
||||
.label=${this.hass!.localize(
|
||||
this._guiMode
|
||||
? "ui.panel.lovelace.editor.edit_card.show_code_editor"
|
||||
: "ui.panel.lovelace.editor.edit_card.show_visual_editor"
|
||||
|
||||
@@ -434,11 +434,7 @@ export class HuiDialogEditSection
|
||||
: "ui.panel.lovelace.editor.edit_card.show_code_editor"
|
||||
)}
|
||||
</ha-button>
|
||||
<ha-tooltip
|
||||
slot="secondaryAction"
|
||||
for="toggle-editor-mode"
|
||||
association="description"
|
||||
>
|
||||
<ha-tooltip slot="secondaryAction" for="toggle-editor-mode">
|
||||
${ctrlOrCmdLabel(this.hass.localize)}+Shift+Y
|
||||
</ha-tooltip>
|
||||
<ha-button
|
||||
|
||||
@@ -32,7 +32,6 @@ import { UndoRedoController } from "../../common/controllers/undo-redo-controlle
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import type { HASSDomEvent } from "../../common/dom/fire_event";
|
||||
import { ctrlOrCmdLabel } from "../../common/keyboard/ctrl-or-cmd";
|
||||
import { renderMoveShortcutHint } from "../../common/keyboard/render-move-shortcut-hint";
|
||||
import type { NavigateOptions } from "../../common/navigate";
|
||||
import { goBack, navigate, replaceCurrentUrl } from "../../common/navigate";
|
||||
import type { LocalizeKeys } from "../../common/translations/localize";
|
||||
@@ -529,7 +528,6 @@ class HUIRoot extends KeyboardShortcutMixin(LitElement) {
|
||||
`;
|
||||
return html`
|
||||
<ha-tab-group-tab
|
||||
id="move-view-${index}"
|
||||
slot="nav"
|
||||
panel=${index}
|
||||
.active=${current}
|
||||
@@ -554,20 +552,6 @@ class HUIRoot extends KeyboardShortcutMixin(LitElement) {
|
||||
class="edit-icon view handle"
|
||||
.path=${mdiDragHorizontalVariant}
|
||||
></ha-svg-icon>
|
||||
<ha-tooltip
|
||||
trigger="focus"
|
||||
association="description"
|
||||
for="move-view-${index}"
|
||||
>
|
||||
${renderMoveShortcutHint(
|
||||
this.hass.localize(
|
||||
`ui.panel.lovelace.editor.edit_view.${rtl ? "move_right" : "move_left"}`
|
||||
),
|
||||
this.hass.localize(
|
||||
`ui.panel.lovelace.editor.edit_view.${rtl ? "move_left" : "move_right"}`
|
||||
)
|
||||
)}
|
||||
</ha-tooltip>
|
||||
<ha-icon-button
|
||||
.label=${this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.edit_view.${rtl ? "move_right" : "move_left"}`
|
||||
|
||||
@@ -87,39 +87,32 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
|
||||
|
||||
private _sidebarScrollTop = 0;
|
||||
|
||||
private _measuredColumns?: number;
|
||||
private _columnsController = new ResizeController(this, {
|
||||
callback: (entries) => {
|
||||
const totalWidth = entries[0]?.contentRect.width;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
new ResizeController(this, {
|
||||
skipInitial: true,
|
||||
callback: (entries) => {
|
||||
const totalWidth = entries[0]?.contentRect.width;
|
||||
if (!totalWidth) return 1;
|
||||
|
||||
if (totalWidth) {
|
||||
this._measuredColumns = this._computeColumnCount(totalWidth);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
const style = getComputedStyle(this);
|
||||
const wrapper = this.shadowRoot!.querySelector(".wrapper")!;
|
||||
const wrapperStyle = getComputedStyle(wrapper);
|
||||
const container = this.shadowRoot!.querySelector(".container")!;
|
||||
const containerStyle = getComputedStyle(container);
|
||||
|
||||
private _computeColumnCount(totalWidth: number): number {
|
||||
const style = getComputedStyle(this);
|
||||
const minColumnWidth = parsePx(
|
||||
style.getPropertyValue("--column-min-width")
|
||||
);
|
||||
const columnGap = parsePx(style.columnGap);
|
||||
const paddingLeft = parsePx(wrapperStyle.paddingLeft);
|
||||
const paddingRight = parsePx(wrapperStyle.paddingRight);
|
||||
const padding = paddingLeft + paddingRight;
|
||||
const minColumnWidth = parsePx(
|
||||
style.getPropertyValue("--column-min-width")
|
||||
);
|
||||
const columnGap = parsePx(containerStyle.columnGap);
|
||||
|
||||
if (!totalWidth || !minColumnWidth || Number.isNaN(columnGap)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// The wrapper's side padding is one column gap on each side
|
||||
const columns = Math.floor(
|
||||
(totalWidth - columnGap) / (minColumnWidth + columnGap)
|
||||
);
|
||||
return Math.max(columns, 1);
|
||||
}
|
||||
const columns = Math.floor(
|
||||
(totalWidth - padding + columnGap) / (minColumnWidth + columnGap)
|
||||
);
|
||||
return Math.max(columns, 1);
|
||||
},
|
||||
});
|
||||
|
||||
public setConfig(config: LovelaceViewConfig): void {
|
||||
this._config = config;
|
||||
@@ -159,7 +152,6 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
|
||||
|
||||
disconnectedCallback(): void {
|
||||
super.disconnectedCallback();
|
||||
this._measuredColumns = undefined;
|
||||
this.removeEventListener(
|
||||
"section-visibility-changed",
|
||||
this._sectionVisibilityChanged
|
||||
@@ -183,10 +175,11 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
|
||||
// The column count is clamped here instead of in the resize callback, so
|
||||
// that it follows the config of the view the element is currently used for
|
||||
const maxColumns = this._config?.max_columns ?? DEFAULT_MAX_COLUMNS;
|
||||
const availableColumns =
|
||||
this._measuredColumns ??
|
||||
(this.isConnected ? this._computeColumnCount(this.clientWidth) : 1);
|
||||
const maxColumnCount = clamp(availableColumns, 1, maxColumns);
|
||||
const maxColumnCount = clamp(
|
||||
this._columnsController.value ?? 1,
|
||||
1,
|
||||
maxColumns
|
||||
);
|
||||
|
||||
if (maxColumnCount !== this._maxColumns) {
|
||||
this._maxColumns = maxColumnCount;
|
||||
@@ -559,7 +552,6 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
|
||||
--column-min-width: var(--ha-view-sections-column-min-width, 320px);
|
||||
--narrow-column-gap: var(--ha-view-sections-narrow-column-gap, 8px);
|
||||
--top-margin: var(--ha-view-sections-extra-top-margin, 80px);
|
||||
column-gap: var(--column-gap);
|
||||
display: block;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ import {
|
||||
callService,
|
||||
ERR_CONNECTION_LOST,
|
||||
ERR_INVALID_AUTH,
|
||||
flushEntityStates,
|
||||
subscribeConfig,
|
||||
subscribeEntityStates,
|
||||
subscribeServices,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { whenDocumentVisible } from "../common/dom/when-document-visible";
|
||||
import { computeEntityNameDisplayWithoutContext } from "../common/entity/compute_entity_name_display";
|
||||
import { promiseTimeout } from "../common/util/promise-timeout";
|
||||
import type { AreaRegistryEntry } from "../data/area/area_registry";
|
||||
@@ -40,6 +42,7 @@ import {
|
||||
} from "../common/util/preserve-unchanged-record";
|
||||
import type { FloorRegistryEntry } from "../data/floor_registry";
|
||||
import { subscribeFloorRegistry } from "../data/ws-floor_registry";
|
||||
import type { WindowWithPreloads } from "../data/preloads";
|
||||
import { subscribePanels } from "../data/ws-panels";
|
||||
import { translationMetadata } from "../resources/translations-metadata";
|
||||
import type {
|
||||
@@ -58,6 +61,7 @@ import { fetchWithAuth } from "../util/fetch-with-auth";
|
||||
import { getState } from "../util/ha-pref-storage";
|
||||
import hassCallApi, { hassCallApiRaw } from "../util/hass-call-api";
|
||||
import { callWS, setDebugConnection } from "../util/websocket";
|
||||
import { EntityStateThrottler } from "./entity-state-throttler";
|
||||
import type { HassBaseEl } from "./hass-base-mixin";
|
||||
|
||||
export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
||||
@@ -66,6 +70,25 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
||||
class extends superClass {
|
||||
private __backendPingInterval?: ReturnType<typeof setInterval>;
|
||||
|
||||
private __stateThrottler?: EntityStateThrottler;
|
||||
|
||||
private __cleanupStateThrottle?: () => void;
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
if (this.hass?.connection && !this.__stateThrottler) {
|
||||
this._setupStateThrottle(this.hass.connection);
|
||||
if (!document.hidden) {
|
||||
flushEntityStates(this.hass.connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this.__cleanupStateThrottle?.();
|
||||
}
|
||||
|
||||
protected initializeHass(auth: Auth, conn: Connection) {
|
||||
const language = getLocalLanguage();
|
||||
|
||||
@@ -129,6 +152,7 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
||||
);
|
||||
}
|
||||
try {
|
||||
this.__stateThrottler?.markUserAction();
|
||||
const response = (await callService(
|
||||
conn,
|
||||
domain,
|
||||
@@ -273,7 +297,21 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
||||
}
|
||||
});
|
||||
|
||||
subscribeEntityStates(conn, (states) => this._updateHass({ states }));
|
||||
const getThrottleMs = this._setupStateThrottle(conn);
|
||||
|
||||
subscribeEntityStates(
|
||||
conn,
|
||||
(states) => {
|
||||
if (this.__stateThrottler) {
|
||||
this.__stateThrottler.measureUpdate(() =>
|
||||
this._updateHass({ states })
|
||||
);
|
||||
} else {
|
||||
this._updateHass({ states });
|
||||
}
|
||||
},
|
||||
"_ent" in conn ? undefined : { throttleMs: getThrottleMs }
|
||||
);
|
||||
// A refetch returns new objects for every entry. Putting the unchanged
|
||||
// previous ones back into the store's list keeps one copy, shared with
|
||||
// `hass`.
|
||||
@@ -412,6 +450,53 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
||||
this._startBackendPing();
|
||||
}
|
||||
|
||||
private _setupStateThrottle(conn: Connection): () => number {
|
||||
this.__cleanupStateThrottle?.();
|
||||
const throttler = new EntityStateThrottler(
|
||||
() => this.hass?.suspendWhenHidden !== false
|
||||
);
|
||||
this.__stateThrottler = throttler;
|
||||
const getThrottleMs = () => this.__stateThrottler?.getThrottleMs() ?? 0;
|
||||
const preloadWindow = window as WindowWithPreloads;
|
||||
preloadWindow.entityStateThrottleMs = getThrottleMs;
|
||||
|
||||
let cancelVisibleCheck: (() => void) | undefined;
|
||||
const onVisibilityChange = () => {
|
||||
if (document.hidden) {
|
||||
throttler.onHidden();
|
||||
cancelVisibleCheck ??= whenDocumentVisible(() => {
|
||||
cancelVisibleCheck = undefined;
|
||||
throttler.onVisible();
|
||||
flushEntityStates(conn);
|
||||
});
|
||||
} else {
|
||||
cancelVisibleCheck?.();
|
||||
cancelVisibleCheck = undefined;
|
||||
throttler.onVisible();
|
||||
flushEntityStates(conn);
|
||||
}
|
||||
};
|
||||
document.addEventListener("visibilitychange", onVisibilityChange);
|
||||
if (document.hidden) {
|
||||
onVisibilityChange();
|
||||
}
|
||||
this.__cleanupStateThrottle = () => {
|
||||
document.removeEventListener("visibilitychange", onVisibilityChange);
|
||||
cancelVisibleCheck?.();
|
||||
cancelVisibleCheck = undefined;
|
||||
throttler.destroy();
|
||||
if (preloadWindow.entityStateThrottleMs === getThrottleMs) {
|
||||
preloadWindow.entityStateThrottleMs = undefined;
|
||||
}
|
||||
if (this.__stateThrottler === throttler) {
|
||||
this.__stateThrottler = undefined;
|
||||
}
|
||||
this.__cleanupStateThrottle = undefined;
|
||||
};
|
||||
|
||||
return getThrottleMs;
|
||||
}
|
||||
|
||||
protected hassReconnected() {
|
||||
super.hassReconnected();
|
||||
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
const TARGET_DUTY_CYCLE = 0.12;
|
||||
const MIN_INTERVAL_MS = 16;
|
||||
const MAX_INTERVAL_MS = 1000;
|
||||
const EMA_ALPHA = 0.25;
|
||||
const MAX_SAMPLE_MS = 200;
|
||||
const USER_ACTION_WINDOW_MS = 2000;
|
||||
|
||||
const closeChannel = (channel?: MessageChannel) => {
|
||||
if (!channel) {
|
||||
return;
|
||||
}
|
||||
channel.port1.onmessage = null;
|
||||
channel.port2.onmessage = null;
|
||||
channel.port1.close();
|
||||
channel.port2.close();
|
||||
};
|
||||
|
||||
export class EntityStateThrottler {
|
||||
private _emaCostMs = 0;
|
||||
|
||||
private _hasSample = false;
|
||||
|
||||
private _throttleMs = 0;
|
||||
|
||||
private _seenInitial = false;
|
||||
|
||||
private _skipNextMeasure = false;
|
||||
|
||||
private _fastPathUntil = -Infinity;
|
||||
|
||||
private _probeInFlight = false;
|
||||
|
||||
private _probeToken = 0;
|
||||
|
||||
private _rafId?: number;
|
||||
|
||||
private _mcA?: MessageChannel;
|
||||
|
||||
private _mcB?: MessageChannel;
|
||||
|
||||
private _destroyed = false;
|
||||
|
||||
private _shouldPauseWhenHidden: () => boolean;
|
||||
|
||||
constructor(shouldPauseWhenHidden: () => boolean = () => true) {
|
||||
this._shouldPauseWhenHidden = shouldPauseWhenHidden;
|
||||
}
|
||||
|
||||
public getThrottleMs(): number {
|
||||
if (document.hidden && this._shouldPauseWhenHidden()) {
|
||||
return Infinity;
|
||||
}
|
||||
if (performance.now() < this._fastPathUntil) {
|
||||
return 0;
|
||||
}
|
||||
return this._throttleMs;
|
||||
}
|
||||
|
||||
public markUserAction(): void {
|
||||
this._fastPathUntil = performance.now() + USER_ACTION_WINDOW_MS;
|
||||
}
|
||||
|
||||
public onHidden(): void {
|
||||
this._cancelProbe();
|
||||
}
|
||||
|
||||
public onVisible(): void {
|
||||
this._skipNextMeasure = true;
|
||||
}
|
||||
|
||||
public recordSample(sampleMs: number): void {
|
||||
const clamped = Math.min(MAX_SAMPLE_MS, Math.max(0, sampleMs));
|
||||
this._emaCostMs = this._hasSample
|
||||
? EMA_ALPHA * clamped + (1 - EMA_ALPHA) * this._emaCostMs
|
||||
: clamped;
|
||||
this._hasSample = true;
|
||||
const raw = this._emaCostMs / TARGET_DUTY_CYCLE;
|
||||
this._throttleMs =
|
||||
raw < MIN_INTERVAL_MS ? 0 : Math.min(MAX_INTERVAL_MS, Math.round(raw));
|
||||
}
|
||||
|
||||
public measureUpdate(run: () => void): void {
|
||||
if (!this._seenInitial) {
|
||||
this._seenInitial = true;
|
||||
run();
|
||||
return;
|
||||
}
|
||||
if (this._skipNextMeasure) {
|
||||
this._skipNextMeasure = false;
|
||||
run();
|
||||
return;
|
||||
}
|
||||
if (this._destroyed || this._probeInFlight || document.hidden) {
|
||||
run();
|
||||
return;
|
||||
}
|
||||
|
||||
const t0 = performance.now();
|
||||
run();
|
||||
if (!this._destroyed && !document.hidden) {
|
||||
this._startProbe(t0);
|
||||
}
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
if (this._destroyed) {
|
||||
return;
|
||||
}
|
||||
this._destroyed = true;
|
||||
this._cancelProbe();
|
||||
closeChannel(this._mcA);
|
||||
closeChannel(this._mcB);
|
||||
this._mcA = undefined;
|
||||
this._mcB = undefined;
|
||||
}
|
||||
|
||||
private _cancelProbe(): void {
|
||||
this._probeToken++;
|
||||
this._probeInFlight = false;
|
||||
if (this._rafId !== undefined) {
|
||||
cancelAnimationFrame(this._rafId);
|
||||
this._rafId = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
private _startProbe(t0: number): void {
|
||||
if (typeof MessageChannel !== "function") {
|
||||
this.recordSample(performance.now() - t0);
|
||||
return;
|
||||
}
|
||||
|
||||
this._probeInFlight = true;
|
||||
const token = ++this._probeToken;
|
||||
this._mcA ??= new MessageChannel();
|
||||
|
||||
this._mcA.port1.onmessage = (ev: MessageEvent) => {
|
||||
if (ev.data !== token) {
|
||||
return;
|
||||
}
|
||||
if (this._destroyed || token !== this._probeToken || document.hidden) {
|
||||
if (token === this._probeToken) {
|
||||
this._probeInFlight = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const jsMs = Math.max(0, performance.now() - t0);
|
||||
if (typeof requestAnimationFrame !== "function") {
|
||||
this._probeInFlight = false;
|
||||
this.recordSample(jsMs);
|
||||
return;
|
||||
}
|
||||
|
||||
let rafFired = false;
|
||||
const id = requestAnimationFrame(() => {
|
||||
rafFired = true;
|
||||
this._rafId = undefined;
|
||||
if (this._destroyed || token !== this._probeToken || document.hidden) {
|
||||
if (token === this._probeToken) {
|
||||
this._probeInFlight = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const tRaf = performance.now();
|
||||
this._mcB ??= new MessageChannel();
|
||||
this._mcB.port1.onmessage = (ev2: MessageEvent) => {
|
||||
if (ev2.data !== token) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this._destroyed ||
|
||||
token !== this._probeToken ||
|
||||
document.hidden
|
||||
) {
|
||||
if (token === this._probeToken) {
|
||||
this._probeInFlight = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
this._probeInFlight = false;
|
||||
this.recordSample(jsMs + Math.max(0, performance.now() - tRaf));
|
||||
};
|
||||
this._mcB.port2.postMessage(token);
|
||||
});
|
||||
if (!rafFired) {
|
||||
this._rafId = id;
|
||||
}
|
||||
};
|
||||
|
||||
this._mcA.port2.postMessage(token);
|
||||
}
|
||||
}
|
||||
+52
-250
@@ -482,8 +482,6 @@
|
||||
"and": "and",
|
||||
"continue": "Continue",
|
||||
"previous": "Previous",
|
||||
"move_up": "Move up",
|
||||
"move_down": "Move down",
|
||||
"loading": "Loading",
|
||||
"refresh": "Refresh",
|
||||
"cancel": "Cancel",
|
||||
@@ -3465,9 +3463,7 @@
|
||||
},
|
||||
"installed": {
|
||||
"search": "Search {number} {number, plural,\n one {app}\n other {apps}\n}",
|
||||
"empty_header": "Install your first app",
|
||||
"empty_text": "Apps run extra software alongside Home Assistant, like a file editor, an MQTT broker, or a media server. Find the ones that fit your home in the app store.",
|
||||
"no_results": "No apps match your search",
|
||||
"no_apps": "You don't have any apps installed yet. Click here to browse available apps.",
|
||||
"add_app": "Install app",
|
||||
"app_stopped": "App is stopped",
|
||||
"app_update_available": "Update available",
|
||||
@@ -3841,8 +3837,6 @@
|
||||
"temperature_entity_description": "Sensor that represents the area temperature.",
|
||||
"humidity_entity": "Humidity sensor",
|
||||
"humidity_entity_description": "Sensor that represents the area humidity.",
|
||||
"occupancy_entity": "Occupancy sensor",
|
||||
"occupancy_entity_description": "Motion or occupancy sensor that shows whether the area is in use.",
|
||||
"related_entities_section": "Related sensors"
|
||||
},
|
||||
"delete": {
|
||||
@@ -6131,8 +6125,8 @@
|
||||
"alias": "Name",
|
||||
"automation_alias": "Automation name",
|
||||
"automation_settings": "Automation settings",
|
||||
"move_up": "[%key:ui::common::move_up%]",
|
||||
"move_down": "[%key:ui::common::move_down%]",
|
||||
"move_up": "Move up",
|
||||
"move_down": "Move down",
|
||||
"collapse_all": "Collapse all",
|
||||
"expand_all": "Expand all",
|
||||
"description": {
|
||||
@@ -11505,44 +11499,7 @@
|
||||
"clear_color_helper": "Used when the entity isn't in an alert state. The background doesn't pulse.",
|
||||
"pulse": "Pulse",
|
||||
"pulse_helper": "Animates the colored background while the entity is in an alert state. When reduced motion is on, the background stays tinted instead.",
|
||||
"alert_section": "Alert",
|
||||
"sections": {
|
||||
"alert": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::alert::alert_section%]"
|
||||
},
|
||||
"content": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::content%]"
|
||||
},
|
||||
"interactions": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::interactions%]"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"entity": "[%key:ui::panel::lovelace::editor::card::generic::entity%]",
|
||||
"clear_color": "[%key:ui::panel::lovelace::editor::card::alert::clear_color%]",
|
||||
"alert_color": "[%key:ui::panel::lovelace::editor::card::alert::alert_color%]",
|
||||
"pulse": "[%key:ui::panel::lovelace::editor::card::alert::pulse%]",
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::name%]",
|
||||
"icon": "[%key:ui::panel::lovelace::editor::card::generic::icon%]",
|
||||
"hide_state": "[%key:ui::panel::lovelace::editor::card::tile::hide_state%]",
|
||||
"content_layout": "[%key:ui::panel::lovelace::editor::card::tile::content_layout%]",
|
||||
"tap_action": "[%key:ui::panel::lovelace::editor::card::generic::tap_action%]",
|
||||
"hold_action": "[%key:ui::panel::lovelace::editor::card::generic::hold_action%]",
|
||||
"double_tap_action": "[%key:ui::panel::lovelace::editor::card::generic::double_tap_action%]"
|
||||
},
|
||||
"data_description": {
|
||||
"clear_color": "[%key:ui::panel::lovelace::editor::card::alert::clear_color_helper%]",
|
||||
"alert_color": "[%key:ui::panel::lovelace::editor::card::alert::alert_color_helper%]",
|
||||
"pulse": "[%key:ui::panel::lovelace::editor::card::alert::pulse_helper%]"
|
||||
},
|
||||
"selector": {
|
||||
"content_layout": {
|
||||
"options": {
|
||||
"horizontal": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::horizontal%]",
|
||||
"vertical": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::vertical%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
"alert_section": "Alert"
|
||||
},
|
||||
"area": {
|
||||
"name": "Area",
|
||||
@@ -11565,63 +11522,7 @@
|
||||
"picture": "Area picture",
|
||||
"camera": "Camera feed"
|
||||
},
|
||||
"image_tap_action": "Image tap behavior",
|
||||
"sections": {
|
||||
"content": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::content%]"
|
||||
},
|
||||
"interactions": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::interactions%]"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"area": "[%key:ui::panel::lovelace::editor::card::area::name%]",
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::name%]",
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::tile::color%]",
|
||||
"display_type": "[%key:ui::panel::lovelace::editor::card::area::display_type%]",
|
||||
"content_layout": "[%key:ui::panel::lovelace::editor::card::tile::content_layout%]",
|
||||
"camera_view": "[%key:ui::panel::lovelace::editor::card::generic::camera_view%]",
|
||||
"alert_classes": "[%key:ui::panel::lovelace::editor::card::area::alert_classes%]",
|
||||
"sensor_classes": "[%key:ui::panel::lovelace::editor::card::area::sensor_classes%]",
|
||||
"tap_action": "[%key:ui::panel::lovelace::editor::card::generic::tap_action%]",
|
||||
"image_tap_action": "[%key:ui::panel::lovelace::editor::card::area::image_tap_action%]",
|
||||
"features_position": "[%key:ui::panel::lovelace::editor::card::tile::features_position%]"
|
||||
},
|
||||
"data_description": {
|
||||
"alert_classes": "[%key:ui::panel::lovelace::editor::card::area::alert_classes_helper%]"
|
||||
},
|
||||
"selector": {
|
||||
"display_type": {
|
||||
"options": {
|
||||
"compact": "[%key:ui::panel::lovelace::editor::card::area::display_type_options::compact%]",
|
||||
"icon": "[%key:ui::panel::lovelace::editor::card::area::display_type_options::icon%]",
|
||||
"picture": "[%key:ui::panel::lovelace::editor::card::area::display_type_options::picture%]",
|
||||
"camera": "[%key:ui::panel::lovelace::editor::card::area::display_type_options::camera%]"
|
||||
}
|
||||
},
|
||||
"content_layout": {
|
||||
"options": {
|
||||
"horizontal": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::horizontal%]",
|
||||
"vertical": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::vertical%]"
|
||||
}
|
||||
},
|
||||
"camera_view": {
|
||||
"options": {
|
||||
"auto": "[%key:ui::panel::lovelace::editor::card::generic::camera_view_options::auto%]",
|
||||
"live": "[%key:ui::panel::lovelace::editor::card::generic::camera_view_options::live%]"
|
||||
}
|
||||
},
|
||||
"features_position": {
|
||||
"options": {
|
||||
"bottom": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::bottom%]",
|
||||
"inline": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::inline%]"
|
||||
},
|
||||
"options_description": {
|
||||
"bottom": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::bottom_description%]",
|
||||
"inline": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::inline_description%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
"image_tap_action": "Image tap behavior"
|
||||
},
|
||||
"calendar": {
|
||||
"name": "Calendar",
|
||||
@@ -11741,58 +11642,7 @@
|
||||
"red": "Red",
|
||||
"yellow": "Yellow"
|
||||
},
|
||||
"description": "This card is a basic card that allows visually seeing sensor data.",
|
||||
"sections": {
|
||||
"interactions": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::interactions%]"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"entity": "[%key:ui::panel::lovelace::editor::card::generic::entity%]",
|
||||
"attribute": "[%key:ui::panel::lovelace::editor::card::generic::attribute%]",
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::name%]",
|
||||
"unit": "[%key:ui::panel::lovelace::editor::card::generic::unit%]",
|
||||
"theme": "[%key:ui::panel::lovelace::editor::card::generic::theme%]",
|
||||
"min": "[%key:ui::panel::lovelace::editor::card::generic::minimum%]",
|
||||
"max": "[%key:ui::panel::lovelace::editor::card::generic::maximum%]",
|
||||
"needle": "[%key:ui::panel::lovelace::editor::card::gauge::needle_gauge%]",
|
||||
"color_mode": "[%key:ui::panel::lovelace::editor::card::gauge::color_mode%]",
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::tile::color%]",
|
||||
"segments": "[%key:ui::panel::lovelace::editor::card::gauge::segments%]",
|
||||
"green": "[%key:ui::panel::lovelace::editor::card::gauge::severity::green%]",
|
||||
"yellow": "[%key:ui::panel::lovelace::editor::card::gauge::severity::yellow%]",
|
||||
"red": "[%key:ui::panel::lovelace::editor::card::gauge::severity::red%]",
|
||||
"tap_action": "[%key:ui::panel::lovelace::editor::card::generic::tap_action%]",
|
||||
"hold_action": "[%key:ui::panel::lovelace::editor::card::generic::hold_action%]",
|
||||
"double_tap_action": "[%key:ui::panel::lovelace::editor::card::generic::double_tap_action%]"
|
||||
},
|
||||
"selector": {
|
||||
"color_mode": {
|
||||
"options": {
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::gauge::color_mode_options::color%]",
|
||||
"severity": "[%key:ui::panel::lovelace::editor::card::gauge::color_mode_options::severity%]",
|
||||
"segments": "[%key:ui::panel::lovelace::editor::card::gauge::color_mode_options::segments%]"
|
||||
}
|
||||
},
|
||||
"color": {
|
||||
"options": {
|
||||
"default": "[%key:ui::panel::lovelace::editor::card::gauge::color_default%]"
|
||||
}
|
||||
},
|
||||
"segments": {
|
||||
"fields": {
|
||||
"from": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::gauge::segment::from%]"
|
||||
},
|
||||
"color": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::tile::color%]"
|
||||
},
|
||||
"label": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::gauge::segment::label%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"description": "This card is a basic card that allows visually seeing sensor data."
|
||||
},
|
||||
"glance": {
|
||||
"name": "Glance",
|
||||
@@ -12169,33 +12019,7 @@
|
||||
"card_description": "Description",
|
||||
"text": "Text",
|
||||
"content_layout": "[%key:ui::panel::lovelace::editor::card::tile::content_layout%]",
|
||||
"additional_interactions": "Additional interactions",
|
||||
"sections": {
|
||||
"content": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::content%]"
|
||||
},
|
||||
"additional_interactions": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::shortcut::additional_interactions%]"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"tap_action": "[%key:ui::panel::lovelace::editor::card::generic::tap_action%]",
|
||||
"label": "[%key:ui::panel::lovelace::editor::card::shortcut::label%]",
|
||||
"description": "[%key:ui::panel::lovelace::editor::card::shortcut::card_description%]",
|
||||
"icon": "[%key:ui::panel::lovelace::editor::card::generic::icon%]",
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::tile::color%]",
|
||||
"content_layout": "[%key:ui::panel::lovelace::editor::card::tile::content_layout%]",
|
||||
"hold_action": "[%key:ui::panel::lovelace::editor::card::generic::hold_action%]",
|
||||
"double_tap_action": "[%key:ui::panel::lovelace::editor::card::generic::double_tap_action%]"
|
||||
},
|
||||
"selector": {
|
||||
"content_layout": {
|
||||
"options": {
|
||||
"horizontal": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::horizontal%]",
|
||||
"vertical": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::vertical%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
"additional_interactions": "Additional interactions"
|
||||
},
|
||||
"map": {
|
||||
"name": "Map",
|
||||
@@ -12435,31 +12259,7 @@
|
||||
},
|
||||
"description": "This card gives you a quick overview of a sensor's state with an optional graph to visualize change over time.",
|
||||
"limit_min": "Minimum value",
|
||||
"limit_max": "Maximum value",
|
||||
"data": {
|
||||
"entity": "[%key:ui::panel::lovelace::editor::card::generic::entity%]",
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::name%]",
|
||||
"icon": "[%key:ui::panel::lovelace::editor::card::generic::icon%]",
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::tile::color%]",
|
||||
"graph": "[%key:ui::panel::lovelace::editor::card::sensor::graph_type%]",
|
||||
"unit": "[%key:ui::panel::lovelace::editor::card::generic::unit%]",
|
||||
"detail": "[%key:ui::panel::lovelace::editor::card::sensor::show_more_detail%]",
|
||||
"theme": "[%key:ui::panel::lovelace::editor::card::generic::theme%]",
|
||||
"hours_to_show": "[%key:ui::panel::lovelace::editor::card::generic::hours_to_show%]",
|
||||
"min": "[%key:ui::panel::lovelace::editor::card::sensor::limit_min%]",
|
||||
"max": "[%key:ui::panel::lovelace::editor::card::sensor::limit_max%]"
|
||||
},
|
||||
"data_description": {
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::tile::color_helper%]"
|
||||
},
|
||||
"selector": {
|
||||
"graph": {
|
||||
"options": {
|
||||
"none": "[%key:ui::panel::lovelace::editor::card::sensor::graph_options::none%]",
|
||||
"line": "[%key:ui::panel::lovelace::editor::card::sensor::graph_options::line%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
"limit_max": "Maximum value"
|
||||
},
|
||||
"timer-list": {
|
||||
"name": "Timer list",
|
||||
@@ -12520,51 +12320,53 @@
|
||||
"horizontal": "Horizontal",
|
||||
"vertical": "Vertical"
|
||||
},
|
||||
"sections": {
|
||||
"content": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::content%]"
|
||||
},
|
||||
"interactions": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::interactions%]"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"entity": "[%key:ui::panel::lovelace::editor::card::generic::entity%]",
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::name%]",
|
||||
"icon": "[%key:ui::panel::lovelace::editor::card::generic::icon%]",
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::tile::color%]",
|
||||
"show_entity_picture": "[%key:ui::panel::lovelace::editor::card::tile::show_entity_picture%]",
|
||||
"hide_state": "[%key:ui::panel::lovelace::editor::card::tile::hide_state%]",
|
||||
"state_content": "[%key:ui::panel::lovelace::editor::card::tile::state_content%]",
|
||||
"time_format": "[%key:ui::panel::lovelace::editor::card::generic::time_format%]",
|
||||
"content_layout": "[%key:ui::panel::lovelace::editor::card::tile::content_layout%]",
|
||||
"tap_action": "[%key:ui::panel::lovelace::editor::card::generic::tap_action%]",
|
||||
"icon_tap_action": "[%key:ui::panel::lovelace::editor::card::tile::icon_tap_action%]",
|
||||
"hold_action": "[%key:ui::panel::lovelace::editor::card::generic::hold_action%]",
|
||||
"icon_hold_action": "[%key:ui::panel::lovelace::editor::card::tile::icon_hold_action%]",
|
||||
"double_tap_action": "[%key:ui::panel::lovelace::editor::card::generic::double_tap_action%]",
|
||||
"icon_double_tap_action": "[%key:ui::panel::lovelace::editor::card::tile::icon_double_tap_action%]",
|
||||
"features_position": "[%key:ui::panel::lovelace::editor::card::tile::features_position%]"
|
||||
},
|
||||
"data_description": {
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::tile::color_helper%]",
|
||||
"features_position": "[%key:ui::panel::lovelace::editor::card::tile::features_position_helper_vertical%]"
|
||||
},
|
||||
"selector": {
|
||||
"content_layout": {
|
||||
"options": {
|
||||
"horizontal": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::horizontal%]",
|
||||
"vertical": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::vertical%]"
|
||||
"editor": {
|
||||
"sections": {
|
||||
"content": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::content%]"
|
||||
},
|
||||
"interactions": {
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::interactions%]"
|
||||
}
|
||||
},
|
||||
"features_position": {
|
||||
"options": {
|
||||
"bottom": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::bottom%]",
|
||||
"inline": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::inline%]"
|
||||
"data": {
|
||||
"entity": "[%key:ui::panel::lovelace::editor::card::generic::entity%]",
|
||||
"name": "[%key:ui::panel::lovelace::editor::card::generic::name%]",
|
||||
"icon": "[%key:ui::panel::lovelace::editor::card::generic::icon%]",
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::tile::color%]",
|
||||
"show_entity_picture": "[%key:ui::panel::lovelace::editor::card::tile::show_entity_picture%]",
|
||||
"hide_state": "[%key:ui::panel::lovelace::editor::card::tile::hide_state%]",
|
||||
"state_content": "[%key:ui::panel::lovelace::editor::card::tile::state_content%]",
|
||||
"time_format": "[%key:ui::panel::lovelace::editor::card::generic::time_format%]",
|
||||
"content_layout": "[%key:ui::panel::lovelace::editor::card::tile::content_layout%]",
|
||||
"tap_action": "[%key:ui::panel::lovelace::editor::card::generic::tap_action%]",
|
||||
"icon_tap_action": "[%key:ui::panel::lovelace::editor::card::tile::icon_tap_action%]",
|
||||
"hold_action": "[%key:ui::panel::lovelace::editor::card::generic::hold_action%]",
|
||||
"icon_hold_action": "[%key:ui::panel::lovelace::editor::card::tile::icon_hold_action%]",
|
||||
"double_tap_action": "[%key:ui::panel::lovelace::editor::card::generic::double_tap_action%]",
|
||||
"icon_double_tap_action": "[%key:ui::panel::lovelace::editor::card::tile::icon_double_tap_action%]",
|
||||
"features_position": "[%key:ui::panel::lovelace::editor::card::tile::features_position%]"
|
||||
},
|
||||
"data_description": {
|
||||
"color": "[%key:ui::panel::lovelace::editor::card::tile::color_helper%]",
|
||||
"features_position": "[%key:ui::panel::lovelace::editor::card::tile::features_position_helper_vertical%]"
|
||||
},
|
||||
"selector": {
|
||||
"content_layout": {
|
||||
"options": {
|
||||
"horizontal": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::horizontal%]",
|
||||
"vertical": "[%key:ui::panel::lovelace::editor::card::tile::content_layout_options::vertical%]"
|
||||
}
|
||||
},
|
||||
"options_description": {
|
||||
"bottom": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::bottom_description%]",
|
||||
"inline": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::inline_description%]"
|
||||
"features_position": {
|
||||
"options": {
|
||||
"bottom": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::bottom%]",
|
||||
"inline": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::inline%]"
|
||||
},
|
||||
"options_description": {
|
||||
"bottom": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::bottom_description%]",
|
||||
"inline": "[%key:ui::panel::lovelace::editor::card::tile::features_position_options::inline_description%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@ export const mockArea = (
|
||||
created_at: 0,
|
||||
modified_at: 0,
|
||||
humidity_entity_id: null,
|
||||
occupancy_entity_id: null,
|
||||
temperature_entity_id: null,
|
||||
icon: null,
|
||||
labels: [],
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
getEntityAreaId,
|
||||
getEntityContext,
|
||||
} from "../../../../src/common/entity/context/get_entity_context";
|
||||
import { getEntityContext } from "../../../../src/common/entity/context/get_entity_context";
|
||||
import type { HomeAssistant } from "../../../../src/types";
|
||||
import {
|
||||
mockArea,
|
||||
@@ -265,61 +262,3 @@ describe("getEntityContext", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("getEntityAreaId", () => {
|
||||
const devices = {
|
||||
device_1: mockDevice({ id: "device_1", area_id: "living_room" }),
|
||||
device_2: mockDevice({
|
||||
id: "device_2",
|
||||
area_id: null,
|
||||
parent_device_id: "device_1",
|
||||
}),
|
||||
} as unknown as HomeAssistant["devices"];
|
||||
|
||||
it("prefers the entity's own area over its device's area", () => {
|
||||
const entities = {
|
||||
"binary_sensor.motion": mockEntity({
|
||||
entity_id: "binary_sensor.motion",
|
||||
device_id: "device_1",
|
||||
area_id: "bedroom",
|
||||
}),
|
||||
} as unknown as HomeAssistant["entities"];
|
||||
|
||||
expect(getEntityAreaId("binary_sensor.motion", entities, devices)).toBe(
|
||||
"bedroom"
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to the device's area, then its parent device's", () => {
|
||||
const entities = {
|
||||
"binary_sensor.motion": mockEntity({
|
||||
entity_id: "binary_sensor.motion",
|
||||
device_id: "device_1",
|
||||
}),
|
||||
"binary_sensor.child": mockEntity({
|
||||
entity_id: "binary_sensor.child",
|
||||
device_id: "device_2",
|
||||
}),
|
||||
} as unknown as HomeAssistant["entities"];
|
||||
|
||||
expect(getEntityAreaId("binary_sensor.motion", entities, devices)).toBe(
|
||||
"living_room"
|
||||
);
|
||||
expect(getEntityAreaId("binary_sensor.child", entities, devices)).toBe(
|
||||
"living_room"
|
||||
);
|
||||
});
|
||||
|
||||
it("returns undefined for an unknown entity or one without an area", () => {
|
||||
const entities = {
|
||||
"binary_sensor.motion": mockEntity({ entity_id: "binary_sensor.motion" }),
|
||||
} as unknown as HomeAssistant["entities"];
|
||||
|
||||
expect(getEntityAreaId("binary_sensor.missing", entities, devices)).toBe(
|
||||
undefined
|
||||
);
|
||||
expect(getEntityAreaId("binary_sensor.motion", entities, devices)).toBe(
|
||||
undefined
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
checkForEntityUpdates,
|
||||
countInstallableUpdates,
|
||||
UpdateEntityFeature,
|
||||
} from "../../src/data/update";
|
||||
import { checkForEntityUpdates } from "../../src/data/update";
|
||||
import { showAlertDialog } from "../../src/dialogs/generic/show-dialog-box";
|
||||
import type { HomeAssistant } from "../../src/types";
|
||||
import { createMockEntityState, createMockHass } from "../fixtures/hass";
|
||||
@@ -56,26 +52,3 @@ describe("checkForEntityUpdates", () => {
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe("countInstallableUpdates", () => {
|
||||
it("counts installable update entities and skips hidden ones when registry is provided", () => {
|
||||
const states = {
|
||||
"update.installable": createMockEntityState("update.installable", "on", {
|
||||
supported_features: UpdateEntityFeature.INSTALL,
|
||||
}),
|
||||
"update.hidden": createMockEntityState("update.hidden", "on", {
|
||||
supported_features: UpdateEntityFeature.INSTALL,
|
||||
}),
|
||||
"update.up_to_date": createMockEntityState("update.up_to_date", "off", {
|
||||
supported_features: UpdateEntityFeature.INSTALL,
|
||||
}),
|
||||
"sensor.other": createMockEntityState("sensor.other", "on"),
|
||||
};
|
||||
const entities = {
|
||||
"update.hidden": { entity_id: "update.hidden", hidden: true, labels: [] },
|
||||
} as unknown as HomeAssistant["entities"];
|
||||
|
||||
expect(countInstallableUpdates(states)).toBe(2);
|
||||
expect(countInstallableUpdates(states, entities)).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -81,7 +81,6 @@ const area = (id: string, overrides: Record<string, unknown> = {}) =>
|
||||
picture: null,
|
||||
temperature_entity_id: null,
|
||||
humidity_entity_id: null,
|
||||
occupancy_entity_id: null,
|
||||
created_at: 0,
|
||||
modified_at: 0,
|
||||
...overrides,
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { EntityStateThrottler } from "../../src/state/entity-state-throttler";
|
||||
|
||||
const setHidden = (hidden: boolean) => {
|
||||
Object.defineProperty(document, "hidden", {
|
||||
configurable: true,
|
||||
value: hidden,
|
||||
});
|
||||
};
|
||||
|
||||
describe("EntityStateThrottler", () => {
|
||||
afterEach(() => {
|
||||
setHidden(false);
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("keeps fast devices unthrottled and scales slow devices within [16, 1000] ms", () => {
|
||||
const throttler = new EntityStateThrottler();
|
||||
expect(throttler.getThrottleMs()).toBe(0);
|
||||
|
||||
// 1.5 ms / 0.12 = 12.5 ms (< 16 ms deadband) -> stays 0
|
||||
throttler.recordSample(1.5);
|
||||
expect(throttler.getThrottleMs()).toBe(0);
|
||||
|
||||
// First slow sample updates EMA: 0.25 * 30 + 0.75 * 1.5 = 8.625 -> 72 ms
|
||||
throttler.recordSample(30);
|
||||
expect(throttler.getThrottleMs()).toBe(72);
|
||||
|
||||
// Large spike is winsorized at 200 ms and capped at 1000 ms
|
||||
const slow = new EntityStateThrottler();
|
||||
slow.recordSample(500);
|
||||
expect(slow.getThrottleMs()).toBe(1000);
|
||||
});
|
||||
|
||||
it("returns Infinity while hidden and skips measuring resume flushes", () => {
|
||||
let now = 1000;
|
||||
vi.spyOn(performance, "now").mockImplementation(() => now);
|
||||
vi.stubGlobal("MessageChannel", undefined);
|
||||
|
||||
const throttler = new EntityStateThrottler();
|
||||
// Initial snapshot render is not measured
|
||||
throttler.measureUpdate(() => {
|
||||
now += 150;
|
||||
});
|
||||
expect(throttler.getThrottleMs()).toBe(0);
|
||||
|
||||
// Hide then resume
|
||||
setHidden(true);
|
||||
expect(throttler.getThrottleMs()).toBe(Infinity);
|
||||
throttler.onHidden();
|
||||
|
||||
// Respect opt-out when background suspension is disabled
|
||||
const noSuspend = new EntityStateThrottler(() => false);
|
||||
noSuspend.recordSample(24);
|
||||
expect(noSuspend.getThrottleMs()).toBe(200);
|
||||
|
||||
setHidden(false);
|
||||
throttler.onVisible();
|
||||
// Resume flush should not pollute EMA
|
||||
throttler.measureUpdate(() => {
|
||||
now += 120;
|
||||
});
|
||||
expect(throttler.getThrottleMs()).toBe(0);
|
||||
|
||||
// Next normal update is measured
|
||||
throttler.measureUpdate(() => {
|
||||
now += 24;
|
||||
});
|
||||
expect(throttler.getThrottleMs()).toBe(200);
|
||||
});
|
||||
|
||||
it("bypasses throttle during the user-action window", () => {
|
||||
let now = 1000;
|
||||
vi.spyOn(performance, "now").mockImplementation(() => now);
|
||||
|
||||
const throttler = new EntityStateThrottler();
|
||||
throttler.recordSample(36);
|
||||
expect(throttler.getThrottleMs()).toBe(300);
|
||||
|
||||
throttler.markUserAction();
|
||||
expect(throttler.getThrottleMs()).toBe(0);
|
||||
|
||||
now += 1999;
|
||||
expect(throttler.getThrottleMs()).toBe(0);
|
||||
|
||||
now += 1;
|
||||
expect(throttler.getThrottleMs()).toBe(300);
|
||||
});
|
||||
|
||||
it("measures JS + paint cost via split MessageChannel + rAF probe", () => {
|
||||
let now = 100;
|
||||
vi.spyOn(performance, "now").mockImplementation(() => now);
|
||||
|
||||
const portCallbacks: (() => void)[] = [];
|
||||
class FakeMessageChannel {
|
||||
port1: {
|
||||
onmessage: ((ev: { data: unknown }) => void) | null;
|
||||
close: ReturnType<typeof vi.fn>;
|
||||
} = {
|
||||
onmessage: null,
|
||||
close: vi.fn(),
|
||||
};
|
||||
|
||||
port2 = {
|
||||
postMessage: (data: unknown) => {
|
||||
portCallbacks.push(() => this.port1.onmessage?.({ data }));
|
||||
},
|
||||
close: vi.fn(),
|
||||
};
|
||||
}
|
||||
|
||||
let rafCb: FrameRequestCallback | undefined;
|
||||
vi.stubGlobal("MessageChannel", FakeMessageChannel);
|
||||
vi.stubGlobal(
|
||||
"requestAnimationFrame",
|
||||
vi.fn((cb: FrameRequestCallback) => {
|
||||
rafCb = cb;
|
||||
return 1;
|
||||
})
|
||||
);
|
||||
vi.stubGlobal("cancelAnimationFrame", vi.fn());
|
||||
|
||||
const throttler = new EntityStateThrottler();
|
||||
throttler.measureUpdate(() => undefined); // skip initial
|
||||
|
||||
throttler.measureUpdate(() => {
|
||||
now += 10; // sync + Lit microtask work = 10 ms
|
||||
});
|
||||
// mcA fires after microtasks
|
||||
now += 2; // +2 ms microtasks -> jsMs = 12
|
||||
portCallbacks.shift()!();
|
||||
|
||||
// Waiting for vsync (8 ms idle wait — should NOT be counted!)
|
||||
now += 8;
|
||||
rafCb!(now);
|
||||
|
||||
// Paint takes 6 ms before mcB fires -> total = 12 + 6 = 18 ms -> 18 / 0.12 = 150 ms
|
||||
now += 6;
|
||||
portCallbacks.shift()!();
|
||||
expect(throttler.getThrottleMs()).toBe(150);
|
||||
|
||||
throttler.destroy();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user