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 | |
|---|---|---|---|
|
|
fd87f0fd2d |
No files matched your search
@@ -62,7 +62,7 @@ Use entity-scoped helpers when the component watches an entity ID held on the ho
|
||||
|
||||
```ts
|
||||
@state() @consumeEntityState({ entityIdPath: ["_config", "entity"] })
|
||||
private _stateObj?: HassEntityState;
|
||||
private _stateObj?: HassEntity;
|
||||
|
||||
@state() @consumeEntityRegistryEntry({ entityIdPath: ["_config", "entity"] })
|
||||
private _entity?: EntityRegistryDisplayEntry;
|
||||
@@ -75,7 +75,7 @@ Use `consumeEntityStates` when the host property contains one or more entity IDs
|
||||
|
||||
```ts
|
||||
@state() @consumeEntityStates({ entityIdPath: ["_config", "entities"] })
|
||||
private _stateObjs?: Record<string, HassEntityState>;
|
||||
private _stateObjs?: Record<string, HassEntity>;
|
||||
```
|
||||
|
||||
For a single field from a grouped context, pair `@consume` with `@transform`:
|
||||
|
||||
@@ -20,9 +20,8 @@ runs:
|
||||
steps:
|
||||
- name: Build ${{ inputs.target }}
|
||||
shell: bash
|
||||
run: ./node_modules/.bin/gulp "$TARGET"
|
||||
run: ./node_modules/.bin/gulp ${{ inputs.target }}
|
||||
env:
|
||||
TARGET: ${{ inputs.target }}
|
||||
GITHUB_TOKEN: ${{ inputs.github-token }}
|
||||
IS_TEST: ${{ inputs.is-test }}
|
||||
RSPACK_CACHE: ${{ inputs.rspack-cache }}
|
||||
@@ -40,22 +40,3 @@ jobs:
|
||||
curl -sSfL "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" \
|
||||
| tar -xz actionlint
|
||||
./actionlint -color
|
||||
|
||||
zizmor:
|
||||
name: Check workflow security
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# renovate: datasource=github-releases depName=zizmorcore/zizmor
|
||||
ZIZMOR_VERSION: 1.33.1
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run zizmor
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
curl -sSfL "https://github.com/zizmorcore/zizmor/releases/download/v${ZIZMOR_VERSION}/zizmor-x86_64-unknown-linux-gnu.tar.gz" \
|
||||
| tar -xz zizmor
|
||||
./zizmor --format=github .
|
||||
@@ -47,6 +47,4 @@ jobs:
|
||||
site-id: ${{ secrets.NETLIFY_GALLERY_SITE_ID }}
|
||||
|
||||
- name: Generate summary
|
||||
env:
|
||||
NETLIFY_URL: ${{ steps.deploy.outputs.netlify_url }}
|
||||
run: echo "$NETLIFY_URL" >> "$GITHUB_STEP_SUMMARY"
|
||||
run: echo "${{ steps.deploy.outputs.netlify_url }}" >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -2,8 +2,6 @@ name: "Pull Request Labeler"
|
||||
|
||||
on: pull_request_target # zizmor: ignore[dangerous-triggers] -- safe: checks out base repo scripts only and reads PR files through the API, never PR head code
|
||||
|
||||
permissions: {}
|
||||
|
||||
# Runs one at a time per pull request, so an older run can't undo a newer one
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
@@ -15,7 +13,6 @@ jobs:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Apply labels
|
||||
id: labeler
|
||||
|
||||
@@ -20,7 +20,6 @@ jobs:
|
||||
check:
|
||||
name: Check pull request follows contribution standards
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
pull-requests: write # To label and comment on pull requests
|
||||
steps:
|
||||
|
||||
@@ -28,10 +28,18 @@ AI can be a helpful tool for writing code and documentation. However, due to the
|
||||
|
||||
All contributions must be reviewed and understood by the contributor before submission. You should be able to explain every change in a pull request you submit. Pull requests that appear to be unreviewed AI output will be closed without review.
|
||||
|
||||
## Design contributions
|
||||
|
||||
AI can be a helpful tool to explore ideas and build mockups and prototypes. But AI tends to give the most common answer, not the one that fits Home Assistant and its users. So we require a human who brings the point of view and owns the design decisions.
|
||||
|
||||
You should be able to explain the problem your design solves and why you made your choices. If a mockup or prototype was mostly generated with AI, say so when you share it. Check your work against the [design guidelines](https://contributors.home-assistant.io/design/), as AI tools often make up components, colors, or spacing that don't exist in Home Assistant. Design proposals that look like unreviewed AI output may be closed or hidden.
|
||||
|
||||
## Our use of AI
|
||||
|
||||
Some of our projects use AI tools to assist with code reviews, issue triaging, reporting, and other project management tasks. These tools may leave comments on pull requests or issues. As with any automated tooling, these comments are not always correct.
|
||||
|
||||
We also use AI to help keep the design system, the Figma kit, and the code in sync. The design decisions behind them are made by people.
|
||||
|
||||
If an AI tool leaves a comment on your contribution, treat it as you would any other review comment. If you believe it is incorrect, say so; a brief explanation is sufficient. Maintainers always have the final say. If in doubt, ask a maintainer.
|
||||
|
||||
## Enforcement
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ContextProvider, provide } from "@lit/context";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
@@ -317,6 +317,6 @@ declare global {
|
||||
"ha-embed-provider": HaEmbedProvider;
|
||||
}
|
||||
interface HASSDomEvents {
|
||||
"states-changed": { states: HassEntityStates };
|
||||
"states-changed": { states: HassEntities };
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HistoryStates } from "../../../src/data/history";
|
||||
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import { driftedValue, hashFraction } from "./drift";
|
||||
|
||||
const generateStateHistory = (
|
||||
state: HassEntityState,
|
||||
state: HassEntity,
|
||||
deltas,
|
||||
start_date: Date,
|
||||
end_date: Date
|
||||
@@ -50,7 +50,7 @@ const NUMBER_POINTS = 96;
|
||||
// An on/off entity, such as a light, switches a few times over the range, at
|
||||
// times picked from its entity ID, and ends in its state
|
||||
const generateOnOffHistory = (
|
||||
state: HassEntityState,
|
||||
state: HassEntity,
|
||||
start: Date,
|
||||
end: Date
|
||||
): HistoryStates[string] => {
|
||||
@@ -78,7 +78,7 @@ const generateOnOffHistory = (
|
||||
// A number drifts around its state over the range, the same on every load,
|
||||
// with as many decimals as its state, and ends in its state
|
||||
const generateNumberHistory = (
|
||||
state: HassEntityState,
|
||||
state: HassEntity,
|
||||
value: number,
|
||||
start: Date,
|
||||
end: Date
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
startOfWeek,
|
||||
startOfYear,
|
||||
} from "date-fns";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HaDurationData } from "../../../src/components/ha-duration-input";
|
||||
import type {
|
||||
Statistic,
|
||||
@@ -416,14 +416,14 @@ const derivedBatteryFlows: Record<string, { source: string; share: number }> = {
|
||||
},
|
||||
};
|
||||
|
||||
const hasSum = (stateObj: HassEntityState | undefined): boolean =>
|
||||
const hasSum = (stateObj: HassEntity | undefined): boolean =>
|
||||
stateObj?.attributes.state_class === "total" ||
|
||||
stateObj?.attributes.state_class === "total_increasing";
|
||||
|
||||
// Like Core, statistics are given in the unit asked for, such as power in kW
|
||||
// for the energy dashboard while the demo's power sensors are in W
|
||||
const unitFactor = (
|
||||
stateObj: HassEntityState | undefined,
|
||||
stateObj: HassEntity | undefined,
|
||||
units?: StatisticsUnitConfiguration
|
||||
): number => {
|
||||
const unit = stateObj?.attributes.unit_of_measurement;
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
HassEntityState,
|
||||
HassEntityStateAttributeBase,
|
||||
HassEntity,
|
||||
HassEntityAttributeBase,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
@@ -94,7 +94,7 @@ const BINARY_SENSOR_DEVICE_CLASSES = [
|
||||
"window",
|
||||
];
|
||||
|
||||
const ENTITIES: HassEntityState[] = [
|
||||
const ENTITIES: HassEntity[] = [
|
||||
// Alarm control panel
|
||||
createEntity("alarm_control_panel.disarmed", "disarmed"),
|
||||
createEntity("alarm_control_panel.armed_home", "armed_home"),
|
||||
@@ -305,8 +305,8 @@ function createEntity(
|
||||
entity_id: string,
|
||||
state: string,
|
||||
device_class?: string,
|
||||
attributes?: HassEntityStateAttributeBase | HassEntityState["attributes"]
|
||||
): HassEntityState {
|
||||
attributes?: HassEntityAttributeBase | HassEntity["attributes"]
|
||||
): HassEntity {
|
||||
return {
|
||||
entity_id,
|
||||
state,
|
||||
@@ -325,14 +325,14 @@ function createEntity(
|
||||
}
|
||||
|
||||
interface EntityRowData {
|
||||
stateObj: HassEntityState;
|
||||
stateObj: HassEntity;
|
||||
entity_id: string;
|
||||
state: string;
|
||||
device_class?: string;
|
||||
domain: string;
|
||||
}
|
||||
|
||||
function createRowData(stateObj: HassEntityState): EntityRowData {
|
||||
function createRowData(stateObj: HassEntity): EntityRowData {
|
||||
return {
|
||||
stateObj,
|
||||
entity_id: stateObj.entity_id,
|
||||
|
||||
+4
-4
@@ -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",
|
||||
@@ -109,7 +109,7 @@
|
||||
"lit": "3.3.3",
|
||||
"lit-html": "3.3.3",
|
||||
"maplibre-gl": "6.20.0",
|
||||
"marked": "18.4.0",
|
||||
"marked": "18.3.0",
|
||||
"marked-footnote": "1.4.0",
|
||||
"marked-gfm-heading-id": "4.1.4",
|
||||
"memoize-one": "7.0.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",
|
||||
@@ -212,7 +212,7 @@
|
||||
"rspack-manifest-plugin": "5.2.2",
|
||||
"serve": "14.2.8",
|
||||
"sinon": "22.1.0",
|
||||
"tar": "8.0.4",
|
||||
"tar": "8.0.3",
|
||||
"terser-webpack-plugin": "5.6.1",
|
||||
"ts-lit-plugin": "2.0.2",
|
||||
"typescript": "6.0.3",
|
||||
|
||||
@@ -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
+148
-166
@@ -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
|
||||
@@ -407,14 +407,14 @@ importers:
|
||||
specifier: 6.20.0
|
||||
version: 6.20.0
|
||||
marked:
|
||||
specifier: 18.4.0
|
||||
version: 18.4.0
|
||||
specifier: 18.3.0
|
||||
version: 18.3.0
|
||||
marked-footnote:
|
||||
specifier: 1.4.0
|
||||
version: 1.4.0(marked@18.4.0)
|
||||
version: 1.4.0(marked@18.3.0)
|
||||
marked-gfm-heading-id:
|
||||
specifier: 4.1.4
|
||||
version: 4.1.4(marked@18.4.0)
|
||||
version: 4.1.4(marked@18.3.0)
|
||||
memoize-one:
|
||||
specifier: 7.0.0
|
||||
version: 7.0.0
|
||||
@@ -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])
|
||||
@@ -711,8 +711,8 @@ importers:
|
||||
specifier: 22.1.0
|
||||
version: 22.1.0
|
||||
tar:
|
||||
specifier: 8.0.4
|
||||
version: 8.0.4
|
||||
specifier: 8.0.3
|
||||
version: 8.0.3
|
||||
terser-webpack-plugin:
|
||||
specifier: 5.6.1
|
||||
version: 5.6.1([email protected])([email protected])([email protected])([email protected])([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]:
|
||||
@@ -6579,8 +6575,8 @@ packages:
|
||||
engines: {node: '>= 20'}
|
||||
hasBin: true
|
||||
|
||||
marked@18.4.0:
|
||||
resolution: {integrity: sha512-evbvoaiBPFO2lk2kSkIbrwjPMuX/HjKyefPdZbtwccsJWY91xlLF/SzB5hRsAOwStztmKC09i+IGsUcTYMt//A==}
|
||||
marked@18.3.0:
|
||||
resolution: {integrity: sha512-ed8zmPXlBb3UfGXN5iHMQyMhFpdqLgoV5umUXx/Q1R+FW3q8VpqpyoKUwlENL9appo2UMvNLURDVaT3AMOryGA==}
|
||||
engines: {node: '>= 20'}
|
||||
hasBin: true
|
||||
|
||||
@@ -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'}
|
||||
@@ -7809,8 +7801,8 @@ packages:
|
||||
resolution: {integrity: sha512-to/OxuCk5DeVONcjjODT7aeoRq5NIPPlfPc0tNML+wLlnf6u5BcJz97Uukv3pT3jzorkFhUevylkAiBr+ZmV2w==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
[email protected].4:
|
||||
resolution: {integrity: sha512-efl2GHJOnqAV5jVrxbM8T3KrLyCAdcwtqF7tJOEJAe1S8rUJSkGrPu6nSZLJP6/KE7U2hDpMcktnKLx3iPwcZQ==}
|
||||
[email protected].3:
|
||||
resolution: {integrity: sha512-S+Gnl5H2+dD5DF7h4e6BOftgFcCqPv3rDRXCvhPLPeX7o2hnQ/aCax5bjdzRBb886xvBGR1vs+wHComyXbnRhQ==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
[email protected]:
|
||||
@@ -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]:
|
||||
@@ -15036,20 +15020,20 @@ snapshots:
|
||||
- react
|
||||
- use-sync-external-store
|
||||
|
||||
[email protected](marked@18.4.0):
|
||||
[email protected](marked@18.3.0):
|
||||
dependencies:
|
||||
marked: 18.4.0
|
||||
marked: 18.3.0
|
||||
|
||||
[email protected](marked@18.4.0):
|
||||
[email protected](marked@18.3.0):
|
||||
dependencies:
|
||||
github-slugger: 2.0.0
|
||||
marked: 18.4.0
|
||||
marked: 18.3.0
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
marked@18.4.0: {}
|
||||
marked@18.3.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:
|
||||
@@ -16476,7 +16458,7 @@ snapshots:
|
||||
minizlib: 3.1.0
|
||||
yallist: 5.0.0
|
||||
|
||||
[email protected].4: {}
|
||||
[email protected].3: {}
|
||||
|
||||
[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]: {}
|
||||
|
||||
|
||||
@@ -62,15 +62,6 @@
|
||||
"datasourceTemplate": "github-releases",
|
||||
"extractVersionTemplate": "^v(?<version>.+)$"
|
||||
},
|
||||
{
|
||||
"description": "Keep zizmor used in CI up to date",
|
||||
"customType": "regex",
|
||||
"managerFilePatterns": ["/^\\.github/workflows/actionlint\\.yaml$/"],
|
||||
"matchStrings": ["ZIZMOR_VERSION: (?<currentValue>\\S+)"],
|
||||
"depNameTemplate": "zizmorcore/zizmor",
|
||||
"datasourceTemplate": "github-releases",
|
||||
"extractVersionTemplate": "^v(?<version>.+)$"
|
||||
},
|
||||
{
|
||||
"description": "Keep gh-actions-lock in CI and Renovate's lockfile generator on the same version",
|
||||
"customType": "regex",
|
||||
@@ -103,12 +94,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,7 +1,7 @@
|
||||
import type { ReactiveControllerHost } from "@lit/reactive-element/reactive-controller";
|
||||
import type {
|
||||
Connection,
|
||||
HassEntityStates,
|
||||
HassEntities,
|
||||
UnsubscribeFunc,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { subscribeCondition } from "../../data/automation";
|
||||
@@ -393,7 +393,7 @@ export class ConditionEvaluator {
|
||||
*/
|
||||
export class ConditionEvaluatorController extends ContextController {
|
||||
@consumeContext({ context: statesContext, subscribe: true })
|
||||
private _states?: HassEntityStates | null;
|
||||
private _states?: HassEntities | null;
|
||||
|
||||
@consumeContext({ context: configContext, subscribe: true })
|
||||
private _hassConfig?: HomeAssistantConfig | null;
|
||||
|
||||
@@ -2,7 +2,7 @@ import type {
|
||||
ReactiveController,
|
||||
ReactiveControllerHost,
|
||||
} from "@lit/reactive-element/reactive-controller";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { timerTimeRemaining } from "../../data/timer";
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ export class TimerRemainingTimeController implements ReactiveController {
|
||||
|
||||
private _host: ReactiveControllerHost;
|
||||
|
||||
private _stateObj?: HassEntityState;
|
||||
private _stateObj?: HassEntity;
|
||||
|
||||
private _interval?: number;
|
||||
|
||||
@@ -26,7 +26,7 @@ export class TimerRemainingTimeController implements ReactiveController {
|
||||
host.addController(this);
|
||||
}
|
||||
|
||||
public setStateObj(stateObj: HassEntityState | undefined): void {
|
||||
public setStateObj(stateObj: HassEntity | undefined): void {
|
||||
this._stateObj = stateObj;
|
||||
this._startInterval();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import type { Context } from "@lit/context";
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import type {
|
||||
HomeAssistant,
|
||||
HomeAssistantInternationalization,
|
||||
@@ -31,9 +28,9 @@ const resolveAtPath = (host: unknown, path: readonly string[]) => {
|
||||
return cur;
|
||||
};
|
||||
|
||||
/** Reuse `previous` when every entry still references the same `HassEntityState`. */
|
||||
/** Reuse `previous` when every entry still references the same `HassEntity`. */
|
||||
export const preserveUnchangedEntityStatesRecord = <
|
||||
T extends Record<string, HassEntityState | undefined>,
|
||||
T extends Record<string, HassEntity | undefined>,
|
||||
>(
|
||||
previous: T | undefined,
|
||||
next: T
|
||||
@@ -83,7 +80,7 @@ const composeDecorator = <T, V>(
|
||||
};
|
||||
|
||||
/**
|
||||
* Consumes `statesContext` and narrows it to the `HassEntityState` for the entity
|
||||
* Consumes `statesContext` and narrows it to the `HassEntity` for the entity
|
||||
* ID found at `entityIdPath` on the host (e.g. `["_config", "entity"]`).
|
||||
*
|
||||
* The first path segment is watched on the host — changes to it re-run the
|
||||
@@ -91,7 +88,7 @@ const composeDecorator = <T, V>(
|
||||
* nullish values.
|
||||
*/
|
||||
export const consumeEntityState = (config: ConsumeEntryConfig) =>
|
||||
composeDecorator<HassEntityStates, HassEntityState>(
|
||||
composeDecorator<HassEntities, HassEntity>(
|
||||
statesContext,
|
||||
config.entityIdPath[0],
|
||||
function (states) {
|
||||
@@ -109,10 +106,10 @@ export const consumeEntityState = (config: ConsumeEntryConfig) =>
|
||||
*/
|
||||
export const consumeEntityStates = (config: ConsumeEntryConfig) => {
|
||||
const watchKey = config.entityIdPath[0];
|
||||
const buildRecord = function (this: unknown, states: HassEntityStates) {
|
||||
const buildRecord = function (this: unknown, states: HassEntities) {
|
||||
const ids = ensureArray(resolveAtPath(this, config.entityIdPath));
|
||||
if (!ids || !states) return undefined;
|
||||
const result: Record<string, HassEntityState> = {};
|
||||
const result: Record<string, HassEntity> = {};
|
||||
for (const id of ids) {
|
||||
if (typeof id !== "string") continue;
|
||||
const state = states[id];
|
||||
@@ -124,22 +121,22 @@ export const consumeEntityStates = (config: ConsumeEntryConfig) => {
|
||||
return (proto: unknown, propertyKey: string) => {
|
||||
const key = String(propertyKey);
|
||||
const transformDec = transform<
|
||||
HassEntityStates,
|
||||
Record<string, HassEntityState> | undefined
|
||||
HassEntities,
|
||||
Record<string, HassEntity> | undefined
|
||||
>({
|
||||
transformer: function (this: unknown, states: HassEntityStates) {
|
||||
transformer: function (this: unknown, states: HassEntities) {
|
||||
const next = buildRecord.call(this, states);
|
||||
if (next === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const previous = (this as Record<string, unknown>)[
|
||||
`__transform_${key}`
|
||||
] as Record<string, HassEntityState> | undefined;
|
||||
] as Record<string, HassEntity> | undefined;
|
||||
return preserveUnchangedEntityStatesRecord(previous, next);
|
||||
},
|
||||
watch: watchKey ? [watchKey] : [],
|
||||
});
|
||||
const consumeDec = subscribeContext<HassEntityStates>(statesContext);
|
||||
const consumeDec = subscribeContext<HassEntities>(statesContext);
|
||||
transformDec(proto as never, propertyKey);
|
||||
consumeDec(proto as never, propertyKey);
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { getShadowRootHost } from "./get-shadow-root-host";
|
||||
|
||||
/** The element and its ancestors, crossing shadow root boundaries. */
|
||||
export const composedAncestors = (element: Element | null): Element[] => {
|
||||
const ancestors: Element[] = [];
|
||||
let current = element;
|
||||
while (current) {
|
||||
ancestors.push(current);
|
||||
current = current.parentElement ?? getShadowRootHost(current);
|
||||
}
|
||||
return ancestors;
|
||||
};
|
||||
@@ -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,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { computeCssColor } from "../color/compute-color";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
import { stateColorCss } from "./state_color";
|
||||
@@ -23,11 +23,11 @@ export const computeAlertActiveStates = (entityId: string): string[] => {
|
||||
}
|
||||
};
|
||||
|
||||
export const isAlertActive = (stateObj: HassEntityState): boolean =>
|
||||
export const isAlertActive = (stateObj: HassEntity): boolean =>
|
||||
computeAlertActiveStates(stateObj.entity_id).includes(stateObj.state);
|
||||
|
||||
export const computeAlertColor = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
color: string
|
||||
): string | undefined => {
|
||||
if (color === "none") {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
|
||||
export const attributeClassNames = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
attributes: string[]
|
||||
): string => {
|
||||
if (!stateObj) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
mdiBatteryAlertVariantOutline,
|
||||
mdiBatteryUnknown,
|
||||
} from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
|
||||
const BATTERY_ICONS = {
|
||||
10: "mdi:battery-10",
|
||||
@@ -51,7 +51,7 @@ const BATTERY_CHARGING_ICONS = {
|
||||
100: "mdi:battery-charging",
|
||||
};
|
||||
|
||||
export const batteryIcon = (stateObj: HassEntityState, state?: string) => {
|
||||
export const batteryIcon = (stateObj: HassEntity, state?: string) => {
|
||||
const level = state ?? stateObj.state;
|
||||
return batteryLevelIcon(level);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
HassEntities,
|
||||
HassEntity,
|
||||
HassServices,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { canToggleDomain } from "./can_toggle_domain";
|
||||
@@ -9,9 +9,9 @@ import { supportsFeature } from "./supports-feature";
|
||||
import { SPECIAL_TOGGLE_ACTIONS } from "./get_toggle_action";
|
||||
|
||||
export const canToggleState = (
|
||||
states: HassEntityStates,
|
||||
states: HassEntities,
|
||||
services: HassServices,
|
||||
stateObj: HassEntityState
|
||||
stateObj: HassEntity
|
||||
) => {
|
||||
const domain = computeStateDomain(stateObj);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassConfig, HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntity } from "home-assistant-js-websocket";
|
||||
import {
|
||||
DOMAIN_ATTRIBUTES_FORMATERS,
|
||||
DOMAIN_ATTRIBUTES_UNITS,
|
||||
@@ -25,7 +25,7 @@ import { computeStateDomain } from "./compute_state_domain";
|
||||
|
||||
export const computeAttributeValueDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"],
|
||||
@@ -47,7 +47,7 @@ export const computeAttributeValueDisplay = (
|
||||
|
||||
export const computeAttributeValueToParts = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"],
|
||||
@@ -205,7 +205,7 @@ export const computeAttributeValueToParts = (
|
||||
// effects of a light group, so use the translation of a member.
|
||||
const computeMemberAttributeValueDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
entities: HomeAssistant["entities"],
|
||||
attribute: string,
|
||||
attributeValue: string
|
||||
@@ -224,7 +224,7 @@ const computeMemberAttributeValueDisplay = (
|
||||
|
||||
export const computeAttributeNameDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
entities: HomeAssistant["entities"],
|
||||
attribute: string
|
||||
): string => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type {
|
||||
EntityRegistryDisplayEntry,
|
||||
EntityRegistryEntry,
|
||||
@@ -56,7 +56,7 @@ const computeTextOnlyName = (
|
||||
* while the real formatter is still loading.
|
||||
*/
|
||||
export const computeEntityNameDisplayWithoutContext = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
name?: string | EntityNameItem | EntityNameItem[],
|
||||
options?: EntityNameOptions
|
||||
): string => {
|
||||
@@ -125,7 +125,7 @@ export const computeEntityEntryNameParts = (
|
||||
};
|
||||
|
||||
export const computeEntityNameParts = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
registries: HomeAssistantRegistries,
|
||||
options?: EntityNamePartsOptions
|
||||
): EntityNameParts => {
|
||||
@@ -139,7 +139,7 @@ export const computeEntityNameParts = (
|
||||
};
|
||||
|
||||
export const computeDefaultEntityNameItems = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
registries: HomeAssistantRegistries
|
||||
): EntityNameItem[] => {
|
||||
const parts = computeEntityNameParts(stateObj, registries);
|
||||
@@ -147,7 +147,7 @@ export const computeDefaultEntityNameItems = (
|
||||
};
|
||||
|
||||
export const computeEntityNameDisplay = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
name: string | EntityNameItem | EntityNameItem[] | undefined,
|
||||
registries: HomeAssistantRegistries,
|
||||
options?: EntityNameOptions
|
||||
@@ -194,7 +194,7 @@ export const computeEntityNameDisplay = (
|
||||
};
|
||||
|
||||
export const computeEntitySearchLabels = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
registries: HomeAssistantRegistries
|
||||
) => {
|
||||
const parts = computeEntityNameParts(stateObj, registries, {
|
||||
@@ -221,7 +221,7 @@ export interface EntityPickerDisplayOptions extends HomeAssistantRegistries {
|
||||
|
||||
export const computeEntityPickerDisplay = (
|
||||
options: EntityPickerDisplayOptions,
|
||||
stateObj: HassEntityState
|
||||
stateObj: HassEntity
|
||||
): EntityPickerDisplay => {
|
||||
const parts = computeEntityNameParts(stateObj, options);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import type { HomeAssistantFormatters } from "../../types";
|
||||
import { unitFromParts } from "./value_parts";
|
||||
@@ -19,7 +19,7 @@ interface EntityUnitStubConfig {
|
||||
*/
|
||||
export const computeEntityUnitDisplay = (
|
||||
formatters: HomeAssistantFormatters,
|
||||
stateObj: HassEntityState | undefined,
|
||||
stateObj: HassEntity | undefined,
|
||||
config: EntityUnitStubConfig
|
||||
): string => {
|
||||
if (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { parseISO } from "date-fns";
|
||||
import type { HassConfig, HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntity } from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import type { EntityRegistryDisplayEntry } from "../../data/entity/entity_registry";
|
||||
import type { FrontendLocaleData } from "../../data/translation";
|
||||
@@ -44,7 +44,7 @@ const NUMERICAL_DOMAINS = ["counter", "input_number", "number"];
|
||||
|
||||
export const computeStateDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"],
|
||||
@@ -146,7 +146,7 @@ const computeStateToPartsFromEntityAttributes = (
|
||||
minimumFractionDigits: 2,
|
||||
// Override monetary options with number format
|
||||
...getNumberFormatOptions(
|
||||
{ state, attributes } as HassEntityState,
|
||||
{ state, attributes } as HassEntity,
|
||||
entity
|
||||
),
|
||||
});
|
||||
@@ -177,7 +177,7 @@ const computeStateToPartsFromEntityAttributes = (
|
||||
const value = formatNumber(
|
||||
state,
|
||||
locale,
|
||||
getNumberFormatOptions({ state, attributes } as HassEntityState, entity)
|
||||
getNumberFormatOptions({ state, attributes } as HassEntity, entity)
|
||||
);
|
||||
|
||||
const unit =
|
||||
@@ -298,7 +298,7 @@ const computeStateToPartsFromEntityAttributes = (
|
||||
|
||||
export const computeStateToParts = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
|
||||
export const computeStateDomain = (stateObj: HassEntityState) =>
|
||||
export const computeStateDomain = (stateObj: HassEntity) =>
|
||||
computeDomain(stateObj.entity_id);
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { computeObjectId } from "./compute_object_id";
|
||||
|
||||
export const computeStateNameFromEntityAttributes = (
|
||||
@@ -9,5 +9,5 @@ export const computeStateNameFromEntityAttributes = (
|
||||
? computeObjectId(entityId).replace(/_/g, " ")
|
||||
: (attributes.friendly_name ?? "").toString();
|
||||
|
||||
export const computeStateName = (stateObj: HassEntityState): string =>
|
||||
export const computeStateName = (stateObj: HassEntity): string =>
|
||||
computeStateNameFromEntityAttributes(stateObj.entity_id, stateObj.attributes);
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { AreaRegistryEntry } from "../../../data/area/area_registry";
|
||||
import type { DeviceRegistryEntry } from "../../../data/device/device_registry";
|
||||
import type {
|
||||
@@ -19,7 +19,7 @@ interface EntityContext {
|
||||
}
|
||||
|
||||
export const getEntityContext = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
entities: HomeAssistant["entities"],
|
||||
devices: HomeAssistant["devices"],
|
||||
areas: HomeAssistant["areas"],
|
||||
|
||||
@@ -9,9 +9,9 @@ import {
|
||||
mdiGate,
|
||||
mdiGateOpen,
|
||||
} from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
|
||||
export const computeOpenIcon = (stateObj: HassEntityState): string => {
|
||||
export const computeOpenIcon = (stateObj: HassEntity): string => {
|
||||
switch (stateObj.attributes.device_class) {
|
||||
case "door":
|
||||
return mdiDoorOpen;
|
||||
@@ -26,7 +26,7 @@ export const computeOpenIcon = (stateObj: HassEntityState): string => {
|
||||
}
|
||||
};
|
||||
|
||||
export const computeCloseIcon = (stateObj: HassEntityState): string => {
|
||||
export const computeCloseIcon = (stateObj: HassEntity): string => {
|
||||
switch (stateObj.attributes.device_class) {
|
||||
case "door":
|
||||
return mdiDoorClosed;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
|
||||
export const deviceTrackerIcon = (
|
||||
stateObj: HassEntityState,
|
||||
state?: string
|
||||
) => {
|
||||
export const deviceTrackerIcon = (stateObj: HassEntity, state?: string) => {
|
||||
const compareState = state ?? stateObj.state;
|
||||
if (stateObj?.attributes.source_type === "router") {
|
||||
return compareState === "home" ? "mdi:lan-connect" : "mdi:lan-disconnect";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import memoizeOne from "memoize-one";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import { ensureArray } from "../array/ensure-array";
|
||||
@@ -68,7 +68,7 @@ export const generateEntityFilter = (
|
||||
: undefined;
|
||||
|
||||
return (entityId: string) => {
|
||||
const stateObj = states[entityId] as HassEntityState | undefined;
|
||||
const stateObj = states[entityId] as HassEntity | undefined;
|
||||
if (!stateObj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
import { DEFAULT_VIEW_ENTITY_ID } from "../const";
|
||||
|
||||
// Return an ordered array of available views
|
||||
export const extractViews = (entities: HassEntityStates): GroupEntity[] => {
|
||||
export const extractViews = (entities: HassEntities): GroupEntity[] => {
|
||||
const views: GroupEntity[] = [];
|
||||
|
||||
Object.keys(entities).forEach((entityId) => {
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
|
||||
export interface EntityLocation {
|
||||
@@ -12,8 +9,8 @@ export interface EntityLocation {
|
||||
|
||||
export const findFirstActiveZone = (
|
||||
inZones: readonly string[],
|
||||
states: HassEntityStates
|
||||
): HassEntityState | undefined => {
|
||||
states: HassEntities
|
||||
): HassEntity | undefined => {
|
||||
for (const zoneId of inZones) {
|
||||
const zone = states[zoneId];
|
||||
if (
|
||||
@@ -29,8 +26,8 @@ export const findFirstActiveZone = (
|
||||
};
|
||||
|
||||
export const getEntityLocation = (
|
||||
stateObj: HassEntityState,
|
||||
states: HassEntityStates
|
||||
stateObj: HassEntity,
|
||||
states: HassEntities
|
||||
): EntityLocation | undefined => {
|
||||
const {
|
||||
latitude,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
|
||||
export const getGroupEntities = (
|
||||
entities: HassEntityStates,
|
||||
entities: HassEntities,
|
||||
group: GroupEntity
|
||||
) => {
|
||||
const result = {};
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import { HVAC_MODES } from "../../data/climate";
|
||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import { OPERATION_MODES } from "../../data/water_heater";
|
||||
@@ -252,7 +249,7 @@ const FIXED_DOMAIN_ATTRIBUTE_STATES = {
|
||||
};
|
||||
|
||||
export const getStatesDomain = (
|
||||
states: HassEntityStates,
|
||||
states: HassEntities,
|
||||
language: string,
|
||||
domain: string,
|
||||
attribute?: string | undefined
|
||||
@@ -411,9 +408,9 @@ export const getValueAttribute = (
|
||||
): string | undefined => DOMAIN_VALUE_ATTRIBUTES[domain]?.[optionsAttribute];
|
||||
|
||||
export const getStates = (
|
||||
states: HassEntityStates,
|
||||
states: HassEntities,
|
||||
language: string,
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
attribute: string | undefined = undefined
|
||||
): string[] => {
|
||||
const domain = computeStateDomain(stateObj);
|
||||
|
||||
@@ -3,7 +3,6 @@ import { ClimateEntityFeature } from "../../data/feature/climate_entity_feature"
|
||||
import { CoverEntityFeature } from "../../data/feature/cover_entity_feature";
|
||||
import { MediaPlayerEntityFeature } from "../../data/feature/media-player_entity_feature";
|
||||
import { SirenEntityFeature } from "../../data/feature/siren_entity_feature";
|
||||
import { ValveEntityFeature } from "../../data/feature/valve_entity_feature";
|
||||
|
||||
// These are domains which have nonstandard 'toggle' behavior.
|
||||
// Otherwise, any domain with a turn_on and turn_off service may be toggled.
|
||||
@@ -59,7 +58,6 @@ export const SPECIAL_TOGGLE_ACTIONS: Record<string, SpecialToggleAction> = {
|
||||
valve: {
|
||||
on: "open_valve",
|
||||
off: "close_valve",
|
||||
feature: [ValveEntityFeature.OPEN, ValveEntityFeature.CLOSE],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
import { getGroupEntities } from "./get_group_entities";
|
||||
@@ -6,9 +6,9 @@ import { getGroupEntities } from "./get_group_entities";
|
||||
// Return an object containing all entities that the view will show
|
||||
// including embedded groups.
|
||||
export const getViewEntities = (
|
||||
entities: HassEntityStates,
|
||||
entities: HassEntities,
|
||||
view: GroupEntity
|
||||
): HassEntityStates => {
|
||||
): HassEntities => {
|
||||
const viewEntities = {};
|
||||
|
||||
view.attributes.entity_id.forEach((entityId) => {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
import { getToggleAction } from "./get_toggle_action";
|
||||
|
||||
export const computeGroupEntitiesState = (
|
||||
states: HassEntityState[]
|
||||
): string => {
|
||||
export const computeGroupEntitiesState = (states: HassEntity[]): string => {
|
||||
if (!states.length) {
|
||||
return UNAVAILABLE;
|
||||
}
|
||||
@@ -46,7 +44,7 @@ export const computeGroupEntitiesState = (
|
||||
|
||||
export const toggleGroupEntities = (
|
||||
hass: Pick<HomeAssistant, "callService">,
|
||||
states: HassEntityState[]
|
||||
states: HassEntity[]
|
||||
) => {
|
||||
if (!states.length) {
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
|
||||
export const hasLocation = (stateObj: HassEntityState) =>
|
||||
export const hasLocation = (stateObj: HassEntity) =>
|
||||
"latitude" in stateObj.attributes && "longitude" in stateObj.attributes;
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
|
||||
// Split a collection into a list of groups and a 'rest' list of ungrouped
|
||||
// entities.
|
||||
// Returns { groups: [], ungrouped: {} }
|
||||
export const splitByGroups = (entities: HassEntityStates) => {
|
||||
export const splitByGroups = (entities: HassEntities) => {
|
||||
const groups: GroupEntity[] = [];
|
||||
const ungrouped: HassEntityStates = {};
|
||||
const ungrouped: HassEntities = {};
|
||||
|
||||
Object.keys(entities).forEach((entityId) => {
|
||||
const entity = entities[entityId];
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { OFF, UNAVAILABLE, UNKNOWN } from "../../data/entity/entity";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
import { TIMESTAMP_STATE_DOMAINS } from "../const";
|
||||
|
||||
export function stateActive(
|
||||
stateObj: HassEntityState,
|
||||
state?: string
|
||||
): boolean {
|
||||
export function stateActive(stateObj: HassEntity, state?: string): boolean {
|
||||
const domain = computeDomain(stateObj.entity_id);
|
||||
const compareState = state !== undefined ? state : stateObj?.state;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
HassEntities,
|
||||
HassEntity,
|
||||
HassServices,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE } from "../../data/entity/entity";
|
||||
@@ -9,9 +9,9 @@ import { canToggleState } from "./can_toggle_state";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
|
||||
export const stateCardType = (
|
||||
states: HassEntityStates,
|
||||
states: HassEntities,
|
||||
services: HassServices,
|
||||
stateObj: HassEntityState
|
||||
stateObj: HassEntity
|
||||
) => {
|
||||
if (stateObj.state === UNAVAILABLE) {
|
||||
return "display";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Return a color representing a state. */
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { UNAVAILABLE } from "../../data/entity/entity";
|
||||
import type { GroupEntity } from "../../data/group";
|
||||
import { computeGroupDomain } from "../../data/group";
|
||||
@@ -44,7 +44,7 @@ const STATE_COLORED_DOMAIN = new Set([
|
||||
"weather",
|
||||
]);
|
||||
|
||||
export const stateColorCss = (stateObj: HassEntityState, state?: string) => {
|
||||
export const stateColorCss = (stateObj: HassEntity, state?: string) => {
|
||||
const compareState = state !== undefined ? state : stateObj?.state;
|
||||
if (compareState === UNAVAILABLE) {
|
||||
return `var(--state-unavailable-color)`;
|
||||
@@ -60,7 +60,7 @@ export const stateColorCss = (stateObj: HassEntityState, state?: string) => {
|
||||
|
||||
export const domainStateColorProperties = (
|
||||
domain: string,
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
state?: string
|
||||
): string[] => {
|
||||
const compareState = state !== undefined ? state : stateObj.state;
|
||||
@@ -99,7 +99,7 @@ export const domainColorProperties = (
|
||||
};
|
||||
|
||||
export const stateColorProperties = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
state?: string
|
||||
): string[] | undefined => {
|
||||
const compareState = state !== undefined ? state : stateObj?.state;
|
||||
@@ -129,7 +129,7 @@ export const stateColorProperties = (
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const stateColorBrightness = (stateObj: HassEntityState): string => {
|
||||
export const stateColorBrightness = (stateObj: HassEntity): string => {
|
||||
if (
|
||||
stateObj.attributes.brightness &&
|
||||
computeDomain(stateObj.entity_id) !== "plant"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
import { updateIcon } from "./update_icon";
|
||||
import { deviceTrackerIcon } from "./device_tracker_icon";
|
||||
|
||||
export const stateIcon = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
state?: string
|
||||
): string | undefined => {
|
||||
const domain = computeStateDomain(stateObj);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
|
||||
export const supportsFeature = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
feature: number
|
||||
): boolean => supportsFeatureFromAttributes(stateObj.attributes, feature);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { UpdateEntity } from "../../data/update";
|
||||
import { updateIsInstalling } from "../../data/update";
|
||||
|
||||
export const updateIcon = (stateObj: HassEntityState, state?: string) => {
|
||||
export const updateIcon = (stateObj: HassEntity, state?: string) => {
|
||||
const compareState = state ?? stateObj.state;
|
||||
// An install can be in progress even when the state is "off", e.g. when
|
||||
// downgrading firmware. Show the installing icon regardless of state.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { html } from "lit";
|
||||
import type { HassConfig } from "home-assistant-js-websocket";
|
||||
import { getConfigEntries } from "../../data/config_entries";
|
||||
import { domainToName } from "../../data/integration";
|
||||
import { getIntegrationDescriptions } from "../../data/integrations";
|
||||
@@ -7,11 +6,7 @@ import { showConfigFlowDialog } from "../../dialogs/config-flow/show-dialog-conf
|
||||
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
|
||||
import { showMatterAddDeviceDialog } from "../../panels/config/integrations/integration-panels/matter/show-dialog-add-matter-device";
|
||||
import { showZWaveJSAddNodeDialog } from "../../panels/config/integrations/integration-panels/zwave_js/add-node/show-dialog-zwave_js-add-node";
|
||||
import type { LocalizeFunc } from "../translations/localize";
|
||||
import type {
|
||||
HomeAssistantApi,
|
||||
HomeAssistantInternationalization,
|
||||
} from "../../types";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import { documentationUrl } from "../../util/documentation-url";
|
||||
import { isComponentLoaded } from "../config/is_component_loaded";
|
||||
import { navigate } from "../navigate";
|
||||
@@ -20,20 +15,17 @@ export const PROTOCOL_INTEGRATIONS = ["zha", "zwave_js", "matter"] as const;
|
||||
|
||||
export const protocolIntegrationPicked = async (
|
||||
element: HTMLElement,
|
||||
callWS: HomeAssistantApi["callWS"],
|
||||
localize: LocalizeFunc,
|
||||
loadBackendTranslation: HomeAssistantInternationalization["loadBackendTranslation"],
|
||||
hassConfig: HassConfig,
|
||||
hass: HomeAssistant,
|
||||
domain: string,
|
||||
options?: { brand?: string; domain?: string; config_entry?: string }
|
||||
) => {
|
||||
if (options?.domain) {
|
||||
const titleLocalize = await loadBackendTranslation("title", options.domain);
|
||||
options.domain = domainToName(titleLocalize, options.domain);
|
||||
const localize = await hass.loadBackendTranslation("title", options.domain);
|
||||
options.domain = domainToName(localize, options.domain);
|
||||
}
|
||||
|
||||
if (options?.brand) {
|
||||
const integrationDescriptions = await getIntegrationDescriptions(callWS);
|
||||
const integrationDescriptions = await getIntegrationDescriptions(hass);
|
||||
options.brand =
|
||||
integrationDescriptions.core.integration[options.brand]?.name ||
|
||||
options.brand;
|
||||
@@ -43,40 +35,37 @@ export const protocolIntegrationPicked = async (
|
||||
const entries = options?.config_entry
|
||||
? undefined
|
||||
: (
|
||||
await getConfigEntries(
|
||||
{ callWS },
|
||||
{
|
||||
domain,
|
||||
}
|
||||
)
|
||||
await getConfigEntries(hass, {
|
||||
domain,
|
||||
})
|
||||
).filter((e) => !e.disabled_by);
|
||||
|
||||
if (
|
||||
!isComponentLoaded(hassConfig, "zwave_js") ||
|
||||
!isComponentLoaded(hass.config, "zwave_js") ||
|
||||
(!options?.config_entry && !entries?.length)
|
||||
) {
|
||||
// If the component isn't loaded, ask them to load the integration first
|
||||
showConfirmationDialog(element, {
|
||||
title: localize(
|
||||
title: hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
|
||||
{ integration: "Z-Wave" }
|
||||
),
|
||||
text: localize(
|
||||
text: hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee",
|
||||
{
|
||||
integration: "Z-Wave",
|
||||
brand: options?.brand || options?.domain || "Z-Wave",
|
||||
supported_hardware_link: html`<a
|
||||
href=${documentationUrl({ config: hassConfig }, "/docs/z-wave/controllers")}
|
||||
href=${documentationUrl(hass, "/docs/z-wave/controllers")}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${localize(
|
||||
>${hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.supported_hardware"
|
||||
)}</a
|
||||
>`,
|
||||
}
|
||||
),
|
||||
confirmText: localize(
|
||||
confirmText: hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.proceed"
|
||||
),
|
||||
confirm: () => {
|
||||
@@ -95,43 +84,40 @@ export const protocolIntegrationPicked = async (
|
||||
const entries = options?.config_entry
|
||||
? undefined
|
||||
: (
|
||||
await getConfigEntries(
|
||||
{ callWS },
|
||||
{
|
||||
domain,
|
||||
}
|
||||
)
|
||||
await getConfigEntries(hass, {
|
||||
domain,
|
||||
})
|
||||
).filter((e) => !e.disabled_by);
|
||||
|
||||
if (
|
||||
!isComponentLoaded(hassConfig, "zha") ||
|
||||
!isComponentLoaded(hass.config, "zha") ||
|
||||
(!options?.config_entry && !entries?.length)
|
||||
) {
|
||||
// If the component isn't loaded, ask them to load the integration first
|
||||
showConfirmationDialog(element, {
|
||||
title: localize(
|
||||
title: hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
|
||||
{ integration: "Zigbee" }
|
||||
),
|
||||
text: localize(
|
||||
text: hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee",
|
||||
{
|
||||
integration: "Zigbee",
|
||||
brand: options?.brand || options?.domain || "Zigbee",
|
||||
supported_hardware_link: html`<a
|
||||
href=${documentationUrl(
|
||||
{ config: hassConfig },
|
||||
hass,
|
||||
"/integrations/zha/#known-working-zigbee-radio-modules"
|
||||
)}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${localize(
|
||||
>${hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.supported_hardware"
|
||||
)}</a
|
||||
>`,
|
||||
}
|
||||
),
|
||||
confirmText: localize(
|
||||
confirmText: hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.proceed"
|
||||
),
|
||||
confirm: () => {
|
||||
@@ -148,39 +134,36 @@ export const protocolIntegrationPicked = async (
|
||||
const entries = options?.config_entry
|
||||
? undefined
|
||||
: (
|
||||
await getConfigEntries(
|
||||
{ callWS },
|
||||
{
|
||||
domain,
|
||||
}
|
||||
)
|
||||
await getConfigEntries(hass, {
|
||||
domain,
|
||||
})
|
||||
).filter((e) => !e.disabled_by);
|
||||
if (
|
||||
!isComponentLoaded(hassConfig, domain) ||
|
||||
!isComponentLoaded(hass.config, domain) ||
|
||||
(!options?.config_entry && !entries?.length)
|
||||
) {
|
||||
// If the component isn't loaded, ask them to load the integration first
|
||||
showConfirmationDialog(element, {
|
||||
title: localize(
|
||||
title: hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
|
||||
{ integration: "Matter" }
|
||||
),
|
||||
text: localize(
|
||||
text: hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.missing_matter",
|
||||
{
|
||||
integration: "Matter",
|
||||
brand: options?.brand || options?.domain || "Matter",
|
||||
supported_hardware_link: html`<a
|
||||
href=${documentationUrl({ config: hassConfig }, "/integrations/matter")}
|
||||
href=${documentationUrl(hass, "/integrations/matter")}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>${localize(
|
||||
>${hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.supported_hardware"
|
||||
)}</a
|
||||
>`,
|
||||
}
|
||||
),
|
||||
confirmText: localize(
|
||||
confirmText: hass.localize(
|
||||
"ui.panel.config.integrations.config_flow.proceed"
|
||||
),
|
||||
confirm: () => {
|
||||
|
||||
@@ -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>
|
||||
`;
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
closeAllDialogs,
|
||||
DIALOG_WAIT_TIMEOUT,
|
||||
updateClosedDialogSearch,
|
||||
} from "../dialogs/make-dialog-manager";
|
||||
import { fireEvent } from "./dom/fire_event";
|
||||
@@ -26,6 +25,9 @@ export interface NavigateOptions {
|
||||
keepDialogs?: boolean;
|
||||
}
|
||||
|
||||
// max time to wait for dialogs to close before navigating
|
||||
const DIALOG_WAIT_TIMEOUT = 500;
|
||||
|
||||
/**
|
||||
* State of the current history entry. Always read through this, the app writes
|
||||
* to the main window and a panel running in an iframe has its own history.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
HassEntityState,
|
||||
HassEntityStateAttributeBase,
|
||||
HassEntity,
|
||||
HassEntityAttributeBase,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { EntityRegistryDisplayEntry } from "../../data/entity/entity_registry";
|
||||
import type { FrontendLocaleData } from "../../data/translation";
|
||||
@@ -12,11 +12,11 @@ import { blankBeforeUnit } from "../translations/blank_before_unit";
|
||||
* Returns true if the entity is considered numeric based on the attributes it has
|
||||
* @param stateObj The entity state object
|
||||
*/
|
||||
export const isNumericState = (stateObj: HassEntityState): boolean =>
|
||||
export const isNumericState = (stateObj: HassEntity): boolean =>
|
||||
isNumericFromAttributes(stateObj.attributes);
|
||||
|
||||
export const isNumericFromAttributes = (
|
||||
attributes: HassEntityStateAttributeBase
|
||||
attributes: HassEntityAttributeBase
|
||||
): boolean => !!attributes.unit_of_measurement || !!attributes.state_class;
|
||||
|
||||
export const numberFormatToLocale = (
|
||||
@@ -152,7 +152,7 @@ export const formatNumberToParts = (
|
||||
* @returns An `Intl.NumberFormatOptions` object with `maximumFractionDigits` set to 0, or `undefined`
|
||||
*/
|
||||
export const getNumberFormatOptions = (
|
||||
entityState?: HassEntityState,
|
||||
entityState?: HassEntity,
|
||||
entity?: EntityRegistryDisplayEntry
|
||||
): Intl.NumberFormatOptions | undefined => {
|
||||
const precision = entity?.display_precision;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassConfig, HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntity } from "home-assistant-js-websocket";
|
||||
import type { FrontendLocaleData } from "../../data/translation";
|
||||
import type { HomeAssistant, ValuePart } from "../../types";
|
||||
import {
|
||||
@@ -9,30 +9,30 @@ import {
|
||||
import type { LocalizeFunc } from "./localize";
|
||||
|
||||
export type FormatEntityStateFunc = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
state?: string
|
||||
) => string;
|
||||
export type FormatEntityStateToPartsFunc = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
state?: string
|
||||
) => ValuePart[];
|
||||
export type FormatEntityAttributeValueFunc = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
attribute: string,
|
||||
value?: any
|
||||
) => string;
|
||||
export type FormatEntityAttributeValueToPartsFunc = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
attribute: string,
|
||||
value?: any
|
||||
) => ValuePart[];
|
||||
export type FormatEntityAttributeNameFunc = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
attribute: string
|
||||
) => string;
|
||||
|
||||
export type FormatEntityNameFunc = (
|
||||
stateObj: HassEntityState,
|
||||
stateObj: HassEntity,
|
||||
name?: string | EntityNameItem | EntityNameItem[],
|
||||
options?: EntityNameOptions
|
||||
) => string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { LineSeriesOption } from "echarts/charts";
|
||||
import type { VisualMapComponentOption } from "echarts/components";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import { getGraphColorByIndex } from "../../common/color/colors";
|
||||
import { CLIMATE_HVAC_ACTION_TO_MODE } from "../../data/climate";
|
||||
import type { LineChartEntity, LineChartState } from "../../data/history";
|
||||
@@ -21,7 +21,7 @@ export const CLIMATE_MODE_CONFIGS = [
|
||||
|
||||
export interface StateHistoryChartLineDataParams {
|
||||
localize: LocalizeFunc;
|
||||
states: HassEntityStates;
|
||||
states: HassEntities;
|
||||
data: LineChartEntity[];
|
||||
endTime: Date;
|
||||
names?: Record<string, string>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassConfig, HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntities } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -145,7 +145,7 @@ export class StateHistoryChartLine extends LitElement {
|
||||
private _entities!: HomeAssistant["entities"];
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states?: HassEntityStates;
|
||||
private _states?: HassEntities;
|
||||
|
||||
private _optionsEntityStates: Record<string, string | undefined> = {};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type {
|
||||
CustomSeriesOption,
|
||||
CustomSeriesRenderItem,
|
||||
} from "echarts/types/dist/shared";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import { hex2rgb } from "../../common/color/convert-color";
|
||||
import { luminosity } from "../../common/color/rgb";
|
||||
import type { TimelineEntity } from "../../data/history";
|
||||
@@ -10,7 +10,7 @@ import { snapFrameSize } from "./down-sample";
|
||||
import { computeTimelineColor } from "./timeline-color";
|
||||
|
||||
export interface StateHistoryChartTimelineDataParams {
|
||||
states: HassEntityStates;
|
||||
states: HassEntities;
|
||||
data: TimelineEntity[];
|
||||
startTime: Date;
|
||||
endTime: Date;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -88,7 +88,7 @@ export class StateHistoryChartTimeline extends LitElement {
|
||||
private _hassConfig!: HomeAssistantConfig;
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states?: HassEntityStates;
|
||||
private _states?: HassEntities;
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
|
||||
@@ -3,7 +3,7 @@ import type {
|
||||
LineSeriesOption,
|
||||
ZRColor,
|
||||
} from "echarts/types/dist/shared";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import { getGraphColorByIndex } from "../../common/color/colors";
|
||||
import type { LocalizeFunc } from "../../common/translations/localize";
|
||||
import type {
|
||||
@@ -30,7 +30,7 @@ export interface StatisticsChartLegendItem {
|
||||
}
|
||||
|
||||
export interface StatisticsChartDataParams {
|
||||
states: HassEntityStates;
|
||||
states: HassEntities;
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"];
|
||||
localize: LocalizeFunc;
|
||||
statisticsData: Statistics;
|
||||
|
||||
@@ -2,7 +2,7 @@ import type {
|
||||
BarSeriesOption,
|
||||
LineSeriesOption,
|
||||
} from "echarts/types/dist/shared";
|
||||
import type { HassConfig, HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassConfig, HassEntities } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -186,7 +186,7 @@ export class StatisticsChart extends LitElement {
|
||||
private _themes!: Themes;
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states!: HassEntityStates;
|
||||
private _states!: HassEntities;
|
||||
|
||||
@consume({ context: entitiesContext, subscribe: true })
|
||||
private _entities!: HomeAssistant["entities"];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { getGraphColorByIndex } from "../../common/color/colors";
|
||||
import { hex2rgb, lab2hex, rgb2lab } from "../../common/color/convert-color";
|
||||
import { labBrighten } from "../../common/color/lab";
|
||||
@@ -23,7 +23,7 @@ const DOMAIN_STATE_SHADES: Record<string, Record<string, number>> = {
|
||||
function computeTimelineStateColor(
|
||||
state: string,
|
||||
computedStyles: CSSStyleDeclaration,
|
||||
stateObj?: HassEntityState
|
||||
stateObj?: HassEntity
|
||||
): string | undefined {
|
||||
if (!stateObj || state === UNAVAILABLE) {
|
||||
return computeCssValue("--history-unavailable-color", computedStyles);
|
||||
@@ -74,7 +74,7 @@ const stateColorMap = new Map<string, string>();
|
||||
function computeTimelineEnumColor(
|
||||
state: string,
|
||||
computedStyles: CSSStyleDeclaration,
|
||||
stateObj?: HassEntityState
|
||||
stateObj?: HassEntity
|
||||
): string | undefined {
|
||||
if (!stateObj) {
|
||||
return undefined;
|
||||
@@ -111,7 +111,7 @@ function computeTimeLineGenericColor(
|
||||
export function computeTimelineColor(
|
||||
state: string,
|
||||
computedStyles: CSSStyleDeclaration,
|
||||
stateObj?: HassEntityState
|
||||
stateObj?: HassEntity
|
||||
): string {
|
||||
return (
|
||||
computeTimelineStateColor(state, computedStyles, stateObj) ||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { property, state } from "lit/decorators";
|
||||
@@ -69,13 +69,13 @@ export abstract class HaDeviceAutomationPicker<
|
||||
|
||||
@state()
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
@transform<HassEntityStates, HassEntityStates>({
|
||||
@transform<HassEntities, HassEntities>({
|
||||
transformer: function (
|
||||
this: HaDeviceAutomationPicker<DeviceAutomation>,
|
||||
states
|
||||
) {
|
||||
const registryById = entityRegistryById(this._entityReg ?? []);
|
||||
const picked: HassEntityStates = {};
|
||||
const picked: HassEntities = {};
|
||||
[...(this._automations ?? []), this.value].forEach((automation) => {
|
||||
const id = automation?.entity_id;
|
||||
const entityId = id?.includes(".")
|
||||
@@ -89,7 +89,7 @@ export abstract class HaDeviceAutomationPicker<
|
||||
},
|
||||
watch: ["_automations", "value", "_entityReg"],
|
||||
})
|
||||
private _states: HassEntityStates = {};
|
||||
private _states: HassEntities = {};
|
||||
|
||||
@state()
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
@@ -119,7 +119,7 @@ export abstract class HaDeviceAutomationPicker<
|
||||
|
||||
private _localizeDeviceAutomation: (
|
||||
localize: LocalizeFunc,
|
||||
states: HassEntityStates,
|
||||
states: HassEntities,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"],
|
||||
entityRegistry: EntityRegistryEntry[],
|
||||
automation: T
|
||||
@@ -214,7 +214,7 @@ export abstract class HaDeviceAutomationPicker<
|
||||
automations: T[] | undefined,
|
||||
localize: LocalizeFunc,
|
||||
language: string,
|
||||
states: HassEntityStates,
|
||||
states: HassEntities,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"],
|
||||
entityReg: EntityRegistryEntry[]
|
||||
) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { mdiSwapHorizontal } from "@mdi/js";
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing, type PropertyValues } from "lit";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -55,9 +55,7 @@ export type HaDevicePickerDeviceFilterFunc = (
|
||||
device: DeviceRegistryEntry
|
||||
) => boolean;
|
||||
|
||||
export type HaDevicePickerEntityFilterFunc = (
|
||||
entity: HassEntityState
|
||||
) => boolean;
|
||||
export type HaDevicePickerEntityFilterFunc = (entity: HassEntity) => boolean;
|
||||
|
||||
@customElement("ha-device-picker")
|
||||
export class HaDevicePicker extends LitElement {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { batteryLevelIcon } from "../../common/entity/battery_icon";
|
||||
@@ -6,10 +6,9 @@ import "../ha-icon";
|
||||
|
||||
@customElement("ha-battery-icon")
|
||||
export class HaBatteryIcon extends LitElement {
|
||||
@property({ attribute: false }) public batteryStateObj?: HassEntityState;
|
||||
@property({ attribute: false }) public batteryStateObj?: HassEntity;
|
||||
|
||||
@property({ attribute: false })
|
||||
public batteryChargingStateObj?: HassEntityState;
|
||||
@property({ attribute: false }) public batteryChargingStateObj?: HassEntity;
|
||||
|
||||
protected render() {
|
||||
if (!this.batteryStateObj) return nothing;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@@ -50,7 +50,7 @@ class HaEntityAttributePicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["entityId"] })
|
||||
private _stateObjs?: Record<string, HassEntityState>;
|
||||
private _stateObjs?: Record<string, HassEntity>;
|
||||
|
||||
@state()
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
@@ -64,7 +64,7 @@ class HaEntityAttributePicker extends LitElement {
|
||||
private _getItemsMemoized = memoizeOne(
|
||||
(
|
||||
entityId: string | string[] | undefined,
|
||||
stateObjs: Record<string, HassEntityState> | undefined,
|
||||
stateObjs: Record<string, HassEntity> | undefined,
|
||||
hideAttributes: string[] | undefined,
|
||||
formatEntityAttributeName: FormatEntityAttributeName
|
||||
): PickerComboBoxItem[] => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiDragHorizontalVariant, mdiPlus, mdiRestore } from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -101,7 +101,7 @@ export class HaEntityNamePicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["entityId"] })
|
||||
private _stateObj?: HassEntityState;
|
||||
private _stateObj?: HassEntity;
|
||||
|
||||
@state()
|
||||
@consume({ context: registriesContext, subscribe: true })
|
||||
@@ -423,7 +423,7 @@ export class HaEntityNamePicker extends LitElement {
|
||||
|
||||
private _defaultItems = memoizeOne(
|
||||
(
|
||||
stateObj: HassEntityState | undefined,
|
||||
stateObj: HassEntity | undefined,
|
||||
registries: ContextType<typeof registriesContext>
|
||||
): EntityNameItem[] => {
|
||||
if (!stateObj) {
|
||||
@@ -470,7 +470,7 @@ export class HaEntityNamePicker extends LitElement {
|
||||
|
||||
private _validTypes = memoizeOne(
|
||||
(
|
||||
stateObj: HassEntityState | undefined,
|
||||
stateObj: HassEntity | undefined,
|
||||
registries: ContextType<typeof registriesContext>
|
||||
) => {
|
||||
if (!stateObj) {
|
||||
@@ -497,7 +497,7 @@ export class HaEntityNamePicker extends LitElement {
|
||||
|
||||
private _getItems = memoizeOne(
|
||||
(
|
||||
stateObj: HassEntityState | undefined,
|
||||
stateObj: HassEntity | undefined,
|
||||
registries: ContextType<typeof registriesContext>,
|
||||
localize: LocalizeFunc,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiDragHorizontalVariant, mdiPlus } from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
@@ -118,7 +118,7 @@ export class HaStateContentPicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["entityId"] })
|
||||
private _stateObj?: HassEntityState;
|
||||
private _stateObj?: HassEntity;
|
||||
|
||||
@state()
|
||||
@consume({ context: registriesContext, subscribe: true })
|
||||
@@ -138,7 +138,7 @@ export class HaStateContentPicker extends LitElement {
|
||||
private _getItems = memoizeOne(
|
||||
(
|
||||
entityId: string | undefined,
|
||||
stateObj: HassEntityState | undefined,
|
||||
stateObj: HassEntity | undefined,
|
||||
allowName: boolean,
|
||||
allowContext: boolean,
|
||||
localize: LocalizeFunc,
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@@ -48,7 +45,7 @@ const keepsStatesOrder = (
|
||||
};
|
||||
|
||||
export const computeEntityStateItems = (
|
||||
states: HassEntityStates | null | undefined,
|
||||
states: HassEntities | null | undefined,
|
||||
formatters: HomeAssistantFormatters,
|
||||
language: string,
|
||||
entityId: string | string[] | undefined,
|
||||
@@ -58,11 +55,11 @@ export const computeEntityStateItems = (
|
||||
): PickerComboBoxItem[] => {
|
||||
const entityIds = entityId ? ensureArray(entityId) : [];
|
||||
|
||||
const stateObjsByState = new Map<string, HassEntityState>();
|
||||
const stateObjsByState = new Map<string, HassEntity>();
|
||||
for (const entityIdItem of entityIds) {
|
||||
const stateObj =
|
||||
states?.[entityIdItem] ||
|
||||
({ entity_id: entityIdItem, attributes: {} } as HassEntityState);
|
||||
({ entity_id: entityIdItem, attributes: {} } as HassEntity);
|
||||
const entityStates = getStates(states ?? {}, language, stateObj, attribute);
|
||||
for (const s of entityStates) {
|
||||
if (!hideStates?.includes(s) && !stateObjsByState.has(s)) {
|
||||
@@ -108,7 +105,7 @@ export const computeEntityStateItems = (
|
||||
export const computeDefaultStateLabel = (
|
||||
i18n: ContextType<typeof internationalizationContext>,
|
||||
formatters: HomeAssistantFormatters,
|
||||
stateObjs: Record<string, HassEntityState> | undefined,
|
||||
stateObjs: Record<string, HassEntity> | undefined,
|
||||
entityId: string | string[] | undefined,
|
||||
attribute: string | undefined
|
||||
): string => {
|
||||
@@ -151,7 +148,7 @@ export class HaEntityStatePicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["entityId"] })
|
||||
private _stateObjs?: Record<string, HassEntityState>;
|
||||
private _stateObjs?: Record<string, HassEntity>;
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states?: ContextType<typeof statesContext>;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type {
|
||||
HassEntityStates,
|
||||
HassEntityState,
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -56,7 +53,7 @@ export class HaEntityStatesPicker extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["entityId"] })
|
||||
private _stateObjs?: Record<string, HassEntityState>;
|
||||
private _stateObjs?: Record<string, HassEntity>;
|
||||
|
||||
@consume({ context: statesContext, subscribe: true })
|
||||
private _states?: ContextType<typeof statesContext>;
|
||||
@@ -71,7 +68,7 @@ export class HaEntityStatesPicker extends LitElement {
|
||||
|
||||
private _chipsSelector = memoizeOne(
|
||||
(
|
||||
states: HassEntityStates | null | undefined,
|
||||
states: HassEntities | null | undefined,
|
||||
formatters: HomeAssistantFormatters,
|
||||
language: string,
|
||||
entityId: string | string[] | undefined,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiFlash, mdiFlashOff } from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { LitElement, css, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -16,7 +16,7 @@ import "../ha-switch";
|
||||
import { getToggleAction } from "../../common/entity/get_toggle_action";
|
||||
import type { LocalizeFunc } from "../../common/translations/localize";
|
||||
|
||||
const isOn = (stateObj?: HassEntityState) =>
|
||||
const isOn = (stateObj?: HassEntity) =>
|
||||
stateObj !== undefined &&
|
||||
!STATES_OFF.includes(stateObj.state) &&
|
||||
stateObj.state !== UNAVAILABLE &&
|
||||
@@ -43,7 +43,7 @@ export class HaEntityToggle extends LitElement {
|
||||
@consumeLocalize()
|
||||
private _localize!: LocalizeFunc;
|
||||
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiDelete } from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
@@ -32,7 +32,7 @@ export class HaFavoriteEntityListItem extends LitElement {
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["entityId"] })
|
||||
private _stateObj?: HassEntityState;
|
||||
private _stateObj?: HassEntity;
|
||||
|
||||
@state()
|
||||
@consume({ context: registriesContext, subscribe: true })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiAlert } from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -57,7 +57,7 @@ export class HaStateLabelBadge extends LitElement {
|
||||
@consumeEntityRegistryEntry({ entityIdPath: ["state", "entity_id"] })
|
||||
private _entry?: EntityRegistryDisplayEntry;
|
||||
|
||||
@property({ attribute: false }) public state?: HassEntityState;
|
||||
@property({ attribute: false }) public state?: HassEntity;
|
||||
|
||||
@property() public name?: string;
|
||||
|
||||
@@ -170,7 +170,7 @@ export class HaStateLabelBadge extends LitElement {
|
||||
|
||||
private _computeValue(
|
||||
domain: string,
|
||||
entityState: HassEntityState,
|
||||
entityState: HassEntity,
|
||||
entry?: EntityRegistryDisplayEntry
|
||||
) {
|
||||
switch (domain) {
|
||||
@@ -203,7 +203,7 @@ export class HaStateLabelBadge extends LitElement {
|
||||
|
||||
private _computeShowIcon(
|
||||
domain: string,
|
||||
entityState: HassEntityState,
|
||||
entityState: HassEntity,
|
||||
entry?: EntityRegistryDisplayEntry
|
||||
): boolean {
|
||||
if (entityState.state === UNAVAILABLE) {
|
||||
@@ -228,7 +228,7 @@ export class HaStateLabelBadge extends LitElement {
|
||||
|
||||
private _computeLabel(
|
||||
domain: string,
|
||||
entityState: HassEntityState,
|
||||
entityState: HassEntity,
|
||||
_timerTimeRemaining = 0
|
||||
) {
|
||||
// For unavailable states or certain domains, use a special translation that is truncated to fit within the badge label
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
mdiPencil,
|
||||
mdiShape,
|
||||
} from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, nothing, type PropertyValues } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@@ -54,7 +54,7 @@ type StatisticItemType = "entity" | "external" | "no_state";
|
||||
|
||||
interface StatisticComboBoxItem extends PickerComboBoxItem {
|
||||
statistic_id?: string;
|
||||
stateObj?: HassEntityState;
|
||||
stateObj?: HassEntity;
|
||||
domainName?: string;
|
||||
type?: StatisticItemType;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiAlert } from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -30,7 +30,7 @@ import "../ha-state-icon";
|
||||
|
||||
@customElement("state-badge")
|
||||
export class StateBadge extends LitElement {
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
|
||||
@property({ attribute: false }) public overrideIcon?: string;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
@@ -14,7 +14,7 @@ import "./state-badge";
|
||||
|
||||
@customElement("state-info")
|
||||
class StateInfo extends LitElement {
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
|
||||
@property({ attribute: "in-dialog", type: Boolean }) public inDialog = false;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import Fuse from "fuse.js";
|
||||
@@ -29,7 +29,7 @@ import "./ha-state-icon";
|
||||
|
||||
export interface AreaControlPickerItem extends PickerComboBoxItem {
|
||||
type?: "domain" | "entity";
|
||||
stateObj?: HassEntityState;
|
||||
stateObj?: HassEntity;
|
||||
domain?: string;
|
||||
deviceClass?: string;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiPlus, mdiTextureBox } from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { LitElement, html, nothing } from "lit";
|
||||
import type { TemplateResult, PropertyValues } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
@@ -85,7 +85,7 @@ export class HaAreaPicker extends LitElement {
|
||||
public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||
|
||||
@property({ attribute: false })
|
||||
public entityFilter?: (entity: HassEntityState) => boolean;
|
||||
public entityFilter?: (entity: HassEntity) => boolean;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { mdiDragHorizontalVariant } from "@mdi/js";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
@@ -48,7 +48,7 @@ export class HaAreasPicker extends LitElement {
|
||||
public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||
|
||||
@property({ attribute: false })
|
||||
public entityFilter?: (entity: HassEntityState) => boolean;
|
||||
public entityFilter?: (entity: HassEntity) => boolean;
|
||||
|
||||
@property({ attribute: "picked-area-label" })
|
||||
public pickedAreaLabel?: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { initialState } from "@lit/task";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consume } from "../common/decorators/consume";
|
||||
@@ -16,7 +16,7 @@ import "./ha-svg-icon";
|
||||
|
||||
@customElement("ha-attribute-icon")
|
||||
export class HaAttributeIcon extends LitElement {
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
|
||||
@property() public attribute?: string;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { initialState } from "@lit/task";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consume } from "../common/decorators/consume";
|
||||
@@ -20,7 +20,7 @@ class HaAttributeValue extends LitElement {
|
||||
@consume({ context: formattersContext, subscribe: true })
|
||||
private _formatters?: ContextType<typeof formattersContext>;
|
||||
|
||||
@property({ attribute: false }) public stateObj?: HassEntityState;
|
||||
@property({ attribute: false }) public stateObj?: HassEntity;
|
||||
|
||||
@property() public attribute!: string;
|
||||
|
||||
|
||||
@@ -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%;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
mdiRedo,
|
||||
mdiUndo,
|
||||
} from "@mdi/js";
|
||||
import type { HassEntityStates } from "home-assistant-js-websocket";
|
||||
import type { HassEntities } from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { css, html, ReactiveElement, render } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -1096,7 +1096,7 @@ export class HaCodeEditor extends ReactiveElement {
|
||||
|
||||
private _getStates = memoizeOne(
|
||||
(
|
||||
states: HassEntityStates,
|
||||
states: HassEntities,
|
||||
formatEntityName: HomeAssistantFormatters["formatEntityName"],
|
||||
registries: HomeAssistantRegistries
|
||||
): Completion[] => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { TemplateResult } from "lit";
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -26,7 +26,7 @@ export interface EntitiesDisplayValue {
|
||||
export class HaEntitiesDisplayEditor extends LitElement {
|
||||
@state()
|
||||
@consumeEntityStates({ entityIdPath: ["entitiesIds"] })
|
||||
private _entityStates?: Record<string, HassEntityState>;
|
||||
private _entityStates?: Record<string, HassEntity>;
|
||||
|
||||
@consume({ context: entitiesContext, subscribe: true })
|
||||
@state()
|
||||
@@ -85,7 +85,7 @@ export class HaEntitiesDisplayEditor extends LitElement {
|
||||
private _items = memoizeOne(
|
||||
(
|
||||
entitiesIds: string[],
|
||||
entityStates: Record<string, HassEntityState> | undefined,
|
||||
entityStates: Record<string, HassEntity> | undefined,
|
||||
entitiesReg: ContextType<typeof entitiesContext>,
|
||||
config: ContextType<typeof configContext>,
|
||||
connection: ContextType<typeof connectionContext>,
|
||||
@@ -93,7 +93,7 @@ export class HaEntitiesDisplayEditor extends LitElement {
|
||||
): DisplayItem[] => {
|
||||
const entities = entitiesIds
|
||||
.map((entityId) => entityStates?.[entityId])
|
||||
.filter((stateObj): stateObj is HassEntityState => Boolean(stateObj));
|
||||
.filter((stateObj): stateObj is HassEntity => Boolean(stateObj));
|
||||
|
||||
return entities.map((entity) => ({
|
||||
value: entity.entity_id,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consumeEntityState } from "../common/decorators/consume-context-entry";
|
||||
@@ -10,7 +10,7 @@ import "./ha-state-icon";
|
||||
export class HaEntityIdIcon extends LitElement {
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["entityId"] })
|
||||
private stateObj?: HassEntityState;
|
||||
private stateObj?: HassEntity;
|
||||
|
||||
@property({ attribute: false }) public entityId!: string;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { HassEntityState } from "home-assistant-js-websocket";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { mdiFilterVariantRemove } from "@mdi/js";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
@@ -34,7 +34,7 @@ import type { HaListSelectableVirtualized } from "./list/ha-list-selectable-virt
|
||||
import type { HaListVirtualizedItem } from "./list/ha-list-virtualized";
|
||||
|
||||
interface EntityItem extends HaListVirtualizedItem {
|
||||
stateObj: HassEntityState;
|
||||
stateObj: HassEntity;
|
||||
name: string;
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 560 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user