Compare commits

..
Author SHA1 Message Date
Paul Bottein 2cdd31284c Fix select labels not updating when the language changes (#56460)
* Fix select labels not updating when the language changes

* Refresh select options when translations load
2026-12-04 10:02:08 +00:00
Paul Bottein 251e7efd99 Move shortcut card editor translations to the standard structure (#56465) 2026-12-04 10:02:04 +00:00
Paul Bottein b57d2f1b4b Move sensor card editor translations to the standard structure (#56464) 2026-12-04 10:02:00 +00:00
Paul Bottein 65f0425cf8 Move area card editor translations to the standard structure (#56463) 2026-12-04 10:01:56 +00:00
Paul Bottein 3a59d8c47d Move alert card editor translations to the standard structure (#56462) 2026-12-04 10:01:51 +00:00
WendelinandClaude Opus 5.5 4bc3b0e9b0 Add hac-popover to the component library (#56348)
* Add hac-popover and a shared popup base to the component library

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Let themes set the popover's border, radius and padding

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Use a 1px border on the popover

Browsers round sub-pixel borders up to 1px anyway.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Say why the popover closed and type its trigger

The hide events carry detail.reason, so a parent can react differently to
Escape than to a click outside. The trigger takes one word: click, hover
(which still opens on click) or manual.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Hand aria-expanded to button components and document popover usage

The popover sets the ariaExpanded property instead of the attribute, so a
button component can pass it on to its inner button. Native buttons still
get the attribute. The JSDoc explains how to use the popover and that it is
not a tooltip. aria-controls and the generated id are gone, as no screen
reader relies on them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Say that the anchor hook does nothing by default

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Make the popup's open and close checks easier to read

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Use only semantic tokens in the popover

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Follow a replaced anchor and keep state when a hide is cancelled

A parent may render a new anchor with the same id; capture listeners on the
root bind it before its own events run. A cancelled hide keeps focus where
it is and keeps the popover pinned. Old browsers without min() keep the
popover within the free space.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Handle trigger changes, programmatic opens and anchor changes while open

Hover timers check the trigger when they fire. An anchor click closes a
popover opened from code. Open popups are tracked on window, so scoped
copies share one Escape order. While open, the popup rebinds to a replaced
anchor or closes when it is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Notice a removed anchor through autoUpdate instead of a MutationObserver

autoUpdate's ResizeObserver already fires when the anchor leaves the DOM,
so the reposition callback checks isConnected and rebinds or closes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep the popover working inside a closed shadow root

A press inside a closed shadow root only shows its host to the document,
so the popup decides after its own and the anchor's listeners have seen
the press. Focus inside is looked up from the popup's own root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep the popover at its anchor and hide it while the anchor is scrolled away

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Drop the undocumented base part of the popover

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-04 09:48:48 +00:00
afe3e31d9c Don't list disabled entities under the Unavailable status filter (#56438)
Claude-Session: https://claude.ai/code/session_01CDc15sh8fUNmnB9T6EqcML

Co-authored-by: stoppyz0r <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-04 09:08:45 +00:00
Petar Petrov db89abfc52 Measure initial column count in sections view before first render (#56424)
* Measure initial column count in sections view before first render

* Read column gap from custom property in sections view

* Resolve sections view column gap to pixels
2026-12-04 08:59:16 +00:00
cerealkiller57540andcerealkiller57540 1633f06297 Add a theme variable for the media browser list item background (#56456)
Co-authored-by: cerealkiller57540 <[email protected]>
2026-12-04 08:50:19 +00:00
Paul Bottein 7fec500672 Move gauge card editor translations to the standard structure (#56429) 2026-12-04 08:47:10 +00:00
WendelinandClaude Opus 5.5 237fd4341a Add an empty state to the installed apps page (#56434)
* Add an empty state to the installed apps page

Without installed apps, the page showed a search for 0 apps and a small
link card. It now shows an empty state like the automation, scene and
script pickers, with a centered Install app button and popular apps from
the store fading in one after another around it and drifting slowly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Give each featured app a fixed place and drop the fill-up

Featured apps and their places are one list now. An app missing from
the store leaves its place empty instead of being replaced by another
store app, so the list of hidden apps is no longer needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Move the apps empty state into a lazy-loaded component

The empty state, its store request and the icon reveal now live in
supervisor-apps-empty-state, which the installed apps page only loads
when no app is installed. The component reads contexts instead of hass,
so fetchSupervisorStore takes callWS now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Load the store apps with try/catch

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-04 08:39:28 +00:00
Paul Bottein 9b5ad7d6bd Move tile card editor translations up to the card level (#56428) 2026-12-04 08:36:35 +00:00
dependabot[bot] b6a6c17053 Bump cross-spawn from 7.0.6 to 7.1.2 (#56457)
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.6 to 7.1.2.
- [Release notes](https://github.com/moxystudio/node-cross-spawn/releases)
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.6...v7.1.2)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-version: 7.1.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-12-04 08:35:39 +00:00
Petar Petrov 971fe1fec6 Move typed Lovelace editor hosts to contexts (#56408)
* Move typed Lovelace editor hosts to contexts

Entities, glance, distribution, map and stack card editors and the sub-element editor read localize and states from contexts and drop the ha-form hass binding.

* Don't throw in consumeLocalize before the context has a value

ha-form consumes localize since #56402, so the gallery threw before provideHass ran.

* Move the consumeLocalize fix to its own PR

It lands separately in #56418.
2026-12-04 08:33:42 +00:00
Clément NotinandWendelin 60d1400f46 Show keyboard shortcuts for reordering items (#55747)
* Add keyboard shortcut hints for moving editor rows

* Limit move shortcut hints to dashboard condition handles

* Show keyboard reorder hints on drag handles

* Show reorder shortcut hints only when focused

* Fix reorder shortcut hints from review

* Fix reorder shortcut hints and preserve accessible names

* Use upstream tooltip description association

* Clear reorder tooltip association when disabled

* Prepare Web Awesome tooltip dependency update

* Update Web Awesome to 3.15.0-ha.0

* Fix copilot review

---------

Co-authored-by: Wendelin <[email protected]>
2026-12-04 08:33:13 +00:00
Petar Petrov f6cdf9cc5f Stop re-rendering ha-sidebar on unrelated entity state updates (#56419)
* Stop re-rendering ha-sidebar on unrelated entity state updates

* Move count updates out of shouldUpdate and test countInstallableUpdates
2026-12-04 08:29:57 +00:00
renovate[bot] 3273d6804a Update dependency @rspack/core to v2.3.5 (#56455)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-04 09:28:38 +01:00
WendelinandClaude Opus 5.5 dad8eebe51 Upgrade webawesome to 3.15.0-ha.0 (#56440)
* Upgrade webawesome to 3.15.0-ha.0

Use the new button-group and tooltip part names, and describe the editor
mode shortcut tooltips instead of labelling their buttons with them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Re-seed bundle budget for Web Awesome 3.15

Web Awesome 3.15 inlines 100 system icons instead of 61 in
library.system.js (+27.6 KiB), which wa-icon imports statically, so
every entrypoint using Web Awesome components grows. New translation
strings add another 3.3 KiB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-04 09:26:24 +01:00
Nathan Burns 86a05fb48b Add occupancy sensor to the area settings dialog (#56377)
Core stores one motion or occupancy entity per area (home-assistant/core#195471). Add the field to the area registry types and a picker for it next to the temperature and humidity sensors.
2026-12-04 09:21:31 +01:00
Lazizbek Ergashev 493579cee0 Keep pinging the backend after a reconnect (#56452) 2026-12-04 09:11:17 +01:00
Erik Montnemery 1b7932bf91 Clear the name when duplicating a YAML-only script or automation (#56454) 2026-12-04 09:08:27 +01:00
Erik Montnemery aa1d28022b Normalize script config in the YAML editor and for new scripts (#56453)
* Normalize script config in the YAML editor and for new scripts

* Normalize null YAML before accessing the config sequence
2026-12-04 08:37:53 +01:00
Erik Montnemery ed63a7a4bb Fall back to service when describing an action (#56451) 2026-12-04 08:35:12 +01:00
renovate[bot] ee8ae2a2ef Update dependency marked to v18.4.0 (#56445)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-03 18:51:52 +00:00
renovate[bot] 5b73d7bb50 Update dependency tar to v8.0.4 (#56444)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-03 18:50:29 +00:00
Matthias de BaatandClaude Opus 5.5 194356846b Revert "Add design to the AI policy" (#56439)
Revert "Add design to the AI policy (#55795)"

This reverts commit 432762a2ea.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-03 19:39:46 +01:00
Maarten Lakerveld 0f2148445b Use the entity state names from home-assistant-js-websocket (#56442)
home-assistant-js-websocket 9.9.0 renamed the state types and
subscription helpers to avoid confusion with the entity registry and
deprecated the old names: HassEntity, HassEntities, HassEntityBase,
HassEntityAttributeBase and subscribeEntities.
2026-12-03 19:38:39 +01:00
Bram KragtenandClaude Opus 5.5 0a637a0d52 Harden pull_request_target workflows and check workflows with zizmor (#56432)
Run zizmor in CI so a new privileged trigger or template injection is
caught in review, and fix the two findings it reports today. Give the
labeler an empty top-level token and cap both pull_request_target jobs
at 10 minutes.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-03 17:50:45 +02:00
WendelinandClaude Opus 5.5 c09bfad8c2 Return the focus to the opener after a dialog closes (#56426)
* Return the focus to the opener after a dialog closes

DialogMixin dialogs never returned the focus, because the manager removed
its focus listener during the same dialog-closed dispatch. A dialog opened
from another one now returns the focus to where the first one would have,
and the manager no longer takes away focus the browser already restored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Stop waiting for a stale dialog history entry after a timeout

A dialog entry left in the history with no dialog open kept the next
dialog from ever opening when nothing went back from it. Wait at most
DIALOG_WAIT_TIMEOUT, like navigate() does, then show the dialog in that
entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Say what the focus restore test expects

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-03 17:50:05 +02:00
WendelinandClaude Opus 5.5 d9f115b5c6 Move the add integration dialog to contexts and DialogMixin (#56425)
* Move the add integration dialog to contexts and DialogMixin

The add device or integration dialog and ha-domain-integrations read
from Lit contexts instead of hass. The dialog uses DialogMixin, so
the contexts are connected before it loads.

protocolIntegrationPicked and getIntegrationDescriptions take the
plain values they need instead of hass, so their callers update too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Open config flows from the add dialog's parent

The config flow keeps the element it was opened from, to show the
application credentials dialog and restart the flow later. With
DialogMixin the add dialog is gone by then, so ha-domain-integrations
now gets the dialog's saved parent and opens flows from it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-03 17:49:41 +02:00
Felipe Santos 081506950c Call each domain's own toggle action from dashboard cards (#56381)
* Use cover.toggle for the toggle action on covers

Core's cover toggle stops a moving cover, moves a part-open one away from its last move and can reach a device's own toggle (ESPHome toggle_action). The card picked open or close from the state on screen, so it could do none of that.

* Call the domain's toggle action when it has one

Core decides what toggle does: covers and valves stop while moving and
otherwise reverse their last move. Domains without a toggle action, such
as lock, button and scene, keep the on or off choice. Valves now need
open and close support to offer Toggle, as covers do.

* Keep the valve feature enum out of the entry bundles
2026-12-03 16:30:20 +01:00
560 changed files with 6206 additions and 2929 deletions

No files matched your search

+2 -2
View File
@@ -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?: HassEntity;
private _stateObj?: HassEntityState;
@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, HassEntity>;
private _stateObjs?: Record<string, HassEntityState>;
```
For a single field from a grouped context, pair `@consume` with `@transform`:
+2 -1
View File
@@ -20,8 +20,9 @@ runs:
steps:
- name: Build ${{ inputs.target }}
shell: bash
run: ./node_modules/.bin/gulp ${{ inputs.target }}
run: ./node_modules/.bin/gulp "$TARGET"
env:
TARGET: ${{ inputs.target }}
GITHUB_TOKEN: ${{ inputs.github-token }}
IS_TEST: ${{ inputs.is-test }}
RSPACK_CACHE: ${{ inputs.rspack-cache }}
+19
View File
@@ -40,3 +40,22 @@ 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 .
+3 -1
View File
@@ -47,4 +47,6 @@ jobs:
site-id: ${{ secrets.NETLIFY_GALLERY_SITE_ID }}
- name: Generate summary
run: echo "${{ steps.deploy.outputs.netlify_url }}" >> "$GITHUB_STEP_SUMMARY"
env:
NETLIFY_URL: ${{ steps.deploy.outputs.netlify_url }}
run: echo "$NETLIFY_URL" >> "$GITHUB_STEP_SUMMARY"
+3
View File
@@ -2,6 +2,8 @@ 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 }}
@@ -13,6 +15,7 @@ jobs:
contents: read
pull-requests: write
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Apply labels
id: labeler
@@ -20,6 +20,7 @@ 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:
-8
View File
@@ -28,18 +28,10 @@ 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
+8 -8
View File
@@ -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": 627654,
"core": 57901,
"authorize": 593862,
"onboarding": 709255
"app": 655843,
"core": 58038,
"authorize": 620096,
"onboarding": 753790
},
"frontend-legacy": {
"app": 724225,
"core": 163115,
"authorize": 693913,
"onboarding": 812415
"app": 755140,
"core": 146919,
"authorize": 723005,
"onboarding": 861854
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { ContextProvider, provide } from "@lit/context";
import type { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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: HassEntities };
"states-changed": { states: HassEntityStates };
}
}
+2
View File
@@ -10,6 +10,7 @@ export interface DemoArea {
picture?: string;
temperature_entity_id?: string;
humidity_entity_id?: string;
occupancy_entity_id?: string;
}
let areas: AreaRegistryEntry[] = [];
@@ -21,6 +22,7 @@ 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,
+4 -4
View File
@@ -1,10 +1,10 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity,
state: HassEntityState,
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: HassEntity,
state: HassEntityState,
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: HassEntity,
state: HassEntityState,
value: number,
start: Date,
end: Date
+3 -3
View File
@@ -15,7 +15,7 @@ import {
startOfWeek,
startOfYear,
} from "date-fns";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity | undefined): boolean =>
const hasSum = (stateObj: HassEntityState | 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: HassEntity | undefined,
stateObj: HassEntityState | undefined,
units?: StatisticsUnitConfiguration
): number => {
const unit = stateObj?.attributes.unit_of_measurement;
@@ -122,6 +122,7 @@ const AREAS: AreaRegistryEntry[] = [
labels: [],
temperature_entity_id: null,
humidity_entity_id: null,
occupancy_entity_id: null,
created_at: 0,
modified_at: 0,
},
@@ -135,6 +136,7 @@ const AREAS: AreaRegistryEntry[] = [
labels: [],
temperature_entity_id: null,
humidity_entity_id: null,
occupancy_entity_id: null,
created_at: 0,
modified_at: 0,
},
@@ -118,6 +118,7 @@ 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,
});
+7 -7
View File
@@ -1,6 +1,6 @@
import type {
HassEntity,
HassEntityAttributeBase,
HassEntityState,
HassEntityStateAttributeBase,
} 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: HassEntity[] = [
const ENTITIES: HassEntityState[] = [
// 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?: HassEntityAttributeBase | HassEntity["attributes"]
): HassEntity {
attributes?: HassEntityStateAttributeBase | HassEntityState["attributes"]
): HassEntityState {
return {
entity_id,
state,
@@ -325,14 +325,14 @@ function createEntity(
}
interface EntityRowData {
stateObj: HassEntity;
stateObj: HassEntityState;
entity_id: string;
state: string;
device_class?: string;
domain: string;
}
function createRowData(stateObj: HassEntity): EntityRowData {
function createRowData(stateObj: HassEntityState): EntityRowData {
return {
stateObj,
entity_id: stateObj.entity_id,
+4 -4
View File
@@ -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.14.0-ha.2",
"@home-assistant/webawesome": "3.15.0-ha.0",
"@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.3.0",
"marked": "18.4.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.4",
"@rspack/core": "2.3.5",
"@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.3",
"tar": "8.0.4",
"terser-webpack-plugin": "5.6.1",
"ts-lit-plugin": "2.0.2",
"typescript": "6.0.3",
+10 -2
View File
@@ -102,6 +102,12 @@ 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
@@ -131,8 +137,10 @@ src/components/card/ <hac-card> -> @home-assistant/components/card
```
Shared code lives in `src/utils/`: `registration/` for defining elements
(global and scoped) and `element/` for helpers that components use
themselves, like slot checks.
(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).
Every element has its own version in `info.ts`.
@@ -41,6 +41,9 @@ 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);
});
},
});
@@ -72,7 +75,8 @@ const distPaths = () => {
};
export default {
globs: ["src/components/**/hac-*.ts"],
// Base classes are analyzed too, so elements list the members they inherit
globs: ["src/components/**/hac-*.ts", "src/utils/popup/*.ts"],
outdir: "dist",
litelement: true,
plugins: [
+3
View File
@@ -48,6 +48,9 @@
"dev": "rslib build --watch",
"prepublishOnly": "pnpm run build"
},
"dependencies": {
"@floating-ui/dom": "^1.8.0"
},
"peerDependencies": {
"lit": "^3.3.0"
},
@@ -0,0 +1,8 @@
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 };
@@ -0,0 +1,274 @@
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>;
}
}
@@ -0,0 +1,5 @@
/** Tag name of the element. */
export const TAG_NAME = "hac-popover";
/** Version of <hac-popover>. */
export const VERSION = "0.1.0";
@@ -0,0 +1,15 @@
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,
};
@@ -0,0 +1,20 @@
/**
* 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);
}
};
@@ -0,0 +1,35 @@
/**
* 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;
};
@@ -0,0 +1,14 @@
/**
* 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);
};
@@ -0,0 +1,485 @@
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;
}
`;
}
+285
View File
@@ -0,0 +1,285 @@
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);
});
});
+166 -148
View File
@@ -269,8 +269,8 @@ importers:
specifier: 13.0.5
version: 13.0.5
'@home-assistant/webawesome':
specifier: 3.14.0-ha.2
version: 3.14.0-ha.2(@floating-ui/[email protected])(@types/[email protected])
specifier: 3.15.0-ha.0
version: 3.15.0-ha.0(@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.3.0
version: 18.3.0
specifier: 18.4.0
version: 18.4.0
marked-footnote:
specifier: 1.4.0
version: 1.4.0(marked@18.3.0)
version: 1.4.0(marked@18.4.0)
marked-gfm-heading-id:
specifier: 4.1.4
version: 4.1.4(marked@18.3.0)
version: 4.1.4(marked@18.4.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].3)(@emnapi/[email protected].3)(@rsbuild/[email protected]([email protected]))(@rspack/[email protected].4(@swc/[email protected]))([email protected])
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])
'@rspack/core':
specifier: 2.3.4
version: 2.3.4(@swc/[email protected])
specifier: 2.3.5
version: 2.3.5(@swc/[email protected])
'@rspack/dev-server':
specifier: 2.2.3
version: 2.2.3(@rspack/[email protected].4(@swc/[email protected]))
version: 2.2.3(@rspack/[email protected].5(@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].4(@swc/[email protected]))
version: 10.1.1(@babel/[email protected])(@rspack/[email protected].5(@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].4(@swc/[email protected]))
version: 5.2.2(@rspack/[email protected].5(@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.3
version: 8.0.3
specifier: 8.0.4
version: 8.0.4
terser-webpack-plugin:
specifier: 5.6.1
version: 5.6.1([email protected])([email protected])([email protected])([email protected])([email protected])
@@ -739,12 +739,16 @@ importers:
version: 1.1.3
webpackbar:
specifier: 7.0.0
version: 7.0.0(@rspack/[email protected].4(@swc/[email protected]))
version: 7.0.0(@rspack/[email protected].5(@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
@@ -1905,8 +1909,8 @@ packages:
'@emnapi/[email protected]':
resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==}
'@emnapi/[email protected].3':
resolution: {integrity: sha512-KA+gOBtbifRATmUa/Gpf5C2B2EJ0r4brHUT3XSgACeHREcuiObXH56xd+B3fFsEFbUT04VBEe6MuZiCtMp0tQg==}
'@emnapi/[email protected].4':
resolution: {integrity: sha512-AhU/vMMXtGgLCrWsL3PjZGSpCWXlGETabnyyB2pBUd6h7AMy2toffJO2T7yXOYXtw8FyD6dYK/5b3u5eRK3yhw==}
'@emnapi/[email protected]':
resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==}
@@ -1917,8 +1921,8 @@ packages:
'@emnapi/[email protected]':
resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==}
'@emnapi/[email protected].3':
resolution: {integrity: sha512-ayb/PyyLzpwRyFVxeC0uoEHu59QlB1iWGcGsOpXQcaB/Dc+uGfBmNmpCHp3HmTT0t8lSsMmg3j7+tdJW/TlHjQ==}
'@emnapi/[email protected].4':
resolution: {integrity: sha512-UKxc3beuftD67T1mPCVf0mnwRKOBsq9XrhLCDGGQKsbG9jx6osvGyjIbJm9DsucyUtFSMTV2ZxsjiuTMjEqWkA==}
'@emnapi/[email protected]':
resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}
@@ -2092,8 +2096,8 @@ packages:
resolution: {integrity: sha512-kjotm7XJrJ6v+7knhPaRgaT6q8F8K2jiafwYdNHLzmV0uGLuZY43FK6smNSHUPrhq5kX2slCUy+RGG/xGqmIKA==}
engines: {node: '>=10.13.0'}
'@home-assistant/[email protected]4.0-ha.2':
resolution: {integrity: sha512-EX1qiX5h3LAoTjuE3rgfuRlNq3Rds5tGrgDGlHoFbxhXaCSTTtuYU6tdR8vgOXKGUDi5gBDrcoNdLYKFXSrknA==}
'@home-assistant/[email protected]5.0-ha.0':
resolution: {integrity: sha512-s1L2M8oaPNfDXdG2M5afeEpEJOP3s0t2GICl8XYgL6SVLVFDNOwWLG2SysbI/Iw7VhIos/4TIbOKr8IEOdLceQ==}
engines: {node: '>=14.17.0'}
'@html-eslint/[email protected]':
@@ -3049,88 +3053,88 @@ packages:
typescript:
optional: true
'@rspack/[email protected].4':
resolution: {integrity: sha512-eBD71fbmoJKnxcHD03bukbAIOP5r7nD0Ehs+mUrUQlZ6N53EhuJsTeJ1oYdg5L4GoSeQ+KecCqME81Nm0COLrA==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-A5XnBdSoJvcYV4t2Y+XJiCF0UZ42nOKE2D0ZlegfErGhzlQG1t3hDOzskSB2fPD3z+w5QeREoclqQ0zFOZyBpw==}
cpu: [arm64]
os: [darwin]
'@rspack/[email protected].4':
resolution: {integrity: sha512-CqdfzTLPVFQCniOy/GDVWbg+rqg31qfdzbFf8NYCzdDkCQg+p15hU2HsckD/1sLsaNB8Y55EjGz4ZyGDny0cHg==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-iZrweqTIj2cM4f0ADRj6FXn9a0FOpD1Mx/++zrsbrQzmnY0c8wmfpvZ5xA5Zfcq9O6nuUBS6GnhkmoFTgviHwQ==}
cpu: [x64]
os: [darwin]
'@rspack/[email protected].4':
resolution: {integrity: sha512-T/Y1FYiSegcNc+oHuDOLRGIcc+eSdBnfbS70d51EWQj4+0TG/tlfuqFKeAIL3mnKUV5lDLaTz3vsoD0Sws5Fxw==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-aWE9V0ZhmclKsJNuO37cxUMLtXMjhLtFzrWDWC82mksUX6qM2rzOpPuye9i/c9NGqyrIH7EFQre8bskJvNHGuQ==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rspack/[email protected].4':
resolution: {integrity: sha512-WZHCzZ532UfXFXNU8XyM8jb+I6wddegbs/7IXsyw7xiPwwZX1D/M6iKFVpBYdvKcupUM8bS8Uw2REirR/cERVw==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-I8ENTXdv7Th/OHEYhL7uu3B7DA9r1oTWSifkGHJtuT1XJ0KDsxoA6ORpYz1R2qIs87l+8+5QUnRH7iWyZrnroA==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rspack/[email protected].4':
resolution: {integrity: sha512-WeizqeI6HIh7Ax9w2tlmpTtipJWxXcdgt3QqI3N9LOixymlMD5yMBMZNPqwZ6cHXT9gOQ69SvPcVgMwxsdmceQ==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-ps5do0cKf4aTBWd+LHqvwm8Gdn7J/gvzmx9pWJhAIThvzii45wJREFjGOzJNxdQl+pzKq8JFuzbShNskCN9k2w==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@rspack/[email protected].4':
resolution: {integrity: sha512-h+001Vbq8LyGwPMNkeRWidPOVKwlAbwNPskY3CjNlSw3euHkVchfhM3uo6+1h0GyTtb3rzsWqsfm1kar7m/tiQ==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-3XXIEMS4SSr1/9wIAGgPT1oj1SzhnlejAG5xeVbGJR5y6iFp/oFKYzUPqyuuzZCkWph2/hJ+Q16sa+BJn1YIkg==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@rspack/[email protected].4':
resolution: {integrity: sha512-S1rlaCnNVG5s4WZ9odLsqN3ySh5TEdNTLXWapEK8x3iQl56aLtdvqXTfbJWHWnYLJuS7M1WqnQGdJNdjy2NDsA==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-z2DbQNcLbUEY9OvUa3gahsHey+dW4acLc9d3QlyJm7TJE//rL9C/XBk4kETvCgtdhqrwBSfWrZfislBPKODjvA==}
cpu: [riscv64]
os: [linux]
libc: [musl]
'@rspack/[email protected].4':
resolution: {integrity: sha512-0SkgGrgulVMam3xel5dMNKQ+U7BEpCczhF1avGT1DzDVIbMfIOsbb32gApQNSz0E7RfAQ/Pa5eWiA9oyRq7ZMQ==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-n2UudDpzt9G2AOmycVS7uWRMcNMd2k4ubU4b4SX3FfU/uT6mfSNzuwhBhCi0RSZQAGBU0ombJ+sqw8vKXjGGbw==}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@rspack/[email protected].4':
resolution: {integrity: sha512-q7E6x3rJJ/9fJyLuRe5+KyEPi23BF/xkAU4xCM5VwLkTf+rVyOkDZfu0qOkxmILjrxllQPV+b/ojBL/ZaIeQPw==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-1sxASGJXg9luaYsFSmAQxSFbUbnMnPA5Mr94yIlLsq4q94sHUIn5YjG1XGcT+cPhUYF9fHkCsKRmQlzrN9fR8A==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rspack/[email protected].4':
resolution: {integrity: sha512-rey4Tyasui/WeMn6KfhH5xyZGOMt+Ny+GDK7nGh9TSz/cb3/bisxqGzpbu6GJK8leDmTUDD5ZdpODexytA5rzQ==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-/S4pe1wAo8CBTs0X8DNKu1ZOJ2vQcnThLBKS2CxOPiuQXI7UfAsJCEABBoa8yCrZANWh63fJ90UwLb/s245Gsw==}
cpu: [x64]
os: [linux]
libc: [musl]
'@rspack/[email protected].4':
resolution: {integrity: sha512-sDt2MSXZrIaMBa6UaEqmXEqebwpTOPAXLdo9CYJ2Fa9FJWP4TCYbn30mbvV38ZC2n5YX411DRbjck+s97CceIg==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-GQnswrv6AyBdDCcTy8dTVhD0JqnvmgewzPz6qnOYWGKxpCY99Bv6FL4jvxI1yh64Uk3ykEfbwhrPnaA8Px4KJA==}
cpu: [wasm32]
'@rspack/[email protected].4':
resolution: {integrity: sha512-24YC1YSodLAJ8VsMQJmJSHCNvHTqK9JP5hj50T50WE8lCHNsNl/rIYXO9V0VlCYT/HshE6EHHzAeKdahiEOtcw==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-XVKu3Zs5KGr+P5Seh6NtSNU0UQ1GSgSDFANQRZlT1uFZ1NpBCX+9NB8FVZB0hBBoBKI1kU4b0Cr6Df1Xx0K4nQ==}
cpu: [arm64]
os: [win32]
'@rspack/[email protected].4':
resolution: {integrity: sha512-xmUNu6kgV9lLEkRP1Zb+t6i1Z1ZMEWXmLlMalPx8tHqndz2RflNMBBx6kjB2nAPQBIZgWufwm7dVGS0HKomCmw==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-ejCqSuctPcOev2dyi0ayZyfIUY3fJdYHYvrTfSVrrGC19TspuRATXu+RLyu3xvB6TrQF3+JEF4KeG4/ZeWuXOg==}
cpu: [ia32]
os: [win32]
'@rspack/[email protected].4':
resolution: {integrity: sha512-WY+AkJqpbLtLEZiG1fE7CVJZ54y0qHeCiVmLxGBsh4OOGIDCs6v2Ub5COcPrYVzGJFGyeHUS29dV7JAs93qIHw==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-IPvkjM3xAwL1z2N4Jp/GBcZUme703uDy5vrP1IMtXJEl/EOLLfwl7cRb4sSzdeOYGDDHs5dPYDcpgP5eRSRauA==}
cpu: [x64]
os: [win32]
'@rspack/[email protected].4':
resolution: {integrity: sha512-wSOT16LVITL/IKeIiLXgN5Q5jZIDqnQ7Gmk+wzKOSZ6OHYNfEBXAKhSJuYtCBq8ovJuGl8cJjdqatAlHE5XKIA==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-W3x7zw5d/mIH9WhWt4pO9RKYURoqgdUxeLSV5IhDCajnhXdRr7R59u5S2j5ZXzSk3eMGUC0PenfKIIdW7t0ufQ==}
'@rspack/[email protected].4':
resolution: {integrity: sha512-T8HGkIjPVDlGlIN8st/ICe8Gfixq8te75g/8crSdNSf8F+6884sBcKNky0CRdfPxao1C5SXV+Vjv1XJTjyu83w==}
'@rspack/[email protected].5':
resolution: {integrity: sha512-4TG6zGTemEU/FU7bymDgeFOO7CRdd7ucn0CmXo+3cG6EhYmY5+hpAFYBRgxDbDuL4Bwo/s5GsgUvZuI7rLqVbQ==}
engines: {node: ^20.19.0 || >=22.12.0}
peerDependencies:
'@module-federation/runtime-tools': ^0.24.1 || ^2.0.0
@@ -4816,8 +4820,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-bgy+iHRFjsBxBCriXkTuFuHRJGSGZISuqDGhDQG7gLK0F7qOzhH06bdXzGf4b0bZSQ+mApakybiW9xvKnS9dbg==}
cross-spawn@7.0.6:
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
cross-spawn@7.1.2:
resolution: {integrity: sha512-8BPK2r+sKWC8sDinRwLwrFMq2lXTBBwzYYEB9LiCznfMurOi4FOvQflq3XOLGG+HPdMSVpe+k/s96+AtDEOgPg==}
engines: {node: '>= 8'}
[email protected]:
@@ -6575,8 +6579,8 @@ packages:
engines: {node: '>= 20'}
hasBin: true
marked@18.3.0:
resolution: {integrity: sha512-ed8zmPXlBb3UfGXN5iHMQyMhFpdqLgoV5umUXx/Q1R+FW3q8VpqpyoKUwlENL9appo2UMvNLURDVaT3AMOryGA==}
marked@18.4.0:
resolution: {integrity: sha512-evbvoaiBPFO2lk2kSkIbrwjPMuX/HjKyefPdZbtwccsJWY91xlLF/SzB5hRsAOwStztmKC09i+IGsUcTYMt//A==}
engines: {node: '>= 20'}
hasBin: true
@@ -6607,6 +6611,10 @@ 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'}
@@ -7801,8 +7809,8 @@ packages:
resolution: {integrity: sha512-to/OxuCk5DeVONcjjODT7aeoRq5NIPPlfPc0tNML+wLlnf6u5BcJz97Uukv3pT3jzorkFhUevylkAiBr+ZmV2w==}
engines: {node: '>=18'}
[email protected].3:
resolution: {integrity: sha512-S+Gnl5H2+dD5DF7h4e6BOftgFcCqPv3rDRXCvhPLPeX7o2hnQ/aCax5bjdzRBb886xvBGR1vs+wHComyXbnRhQ==}
[email protected].4:
resolution: {integrity: sha512-efl2GHJOnqAV5jVrxbM8T3KrLyCAdcwtqF7tJOEJAe1S8rUJSkGrPu6nSZLJP6/KE7U2hDpMcktnKLx3iPwcZQ==}
engines: {node: '>=22'}
[email protected]:
@@ -10119,7 +10127,7 @@ snapshots:
tslib: 2.9.1
optional: true
'@emnapi/[email protected].3':
'@emnapi/[email protected].4':
dependencies:
'@emnapi/wasi-threads': 2.2.0
tslib: 2.9.1
@@ -10140,7 +10148,7 @@ snapshots:
tslib: 2.9.1
optional: true
'@emnapi/[email protected].3':
'@emnapi/[email protected].4':
dependencies:
tslib: 2.9.1
optional: true
@@ -10331,7 +10339,7 @@ snapshots:
dependencies:
is-negated-glob: 1.0.0
'@home-assistant/[email protected]4.0-ha.2(@floating-ui/[email protected])(@types/[email protected])':
'@home-assistant/[email protected]5.0-ha.0(@floating-ui/[email protected])(@types/[email protected])':
dependencies:
'@ctrl/tinycolor': 4.1.0
'@floating-ui/dom': 1.8.0
@@ -10345,6 +10353,7 @@ 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'
@@ -10701,10 +10710,17 @@ snapshots:
'@tybys/wasm-util': 0.10.3
optional: true
'@napi-rs/[email protected](@emnapi/[email protected].3)(@emnapi/[email protected].3)':
'@napi-rs/[email protected](@emnapi/[email protected].2)(@emnapi/[email protected].2)':
dependencies:
'@emnapi/core': 2.0.0-beta.3
'@emnapi/runtime': 2.0.0-beta.3
'@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
'@tybys/wasm-util': 0.10.3
optional: true
@@ -11299,7 +11315,7 @@ snapshots:
'@rsbuild/[email protected]([email protected])':
dependencies:
'@rspack/core': 2.3.4(@swc/[email protected])
'@rspack/core': 2.3.5(@swc/[email protected])
'@swc/helpers': 0.5.24
optionalDependencies:
core-js: 3.51.0
@@ -11318,14 +11334,14 @@ snapshots:
'@rsdoctor/[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])':
'@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])':
dependencies:
'@rsbuild/plugin-check-syntax': 1.6.1(@rsbuild/[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]))
'@rspack/resolver': 0.2.8(@emnapi/[email protected].3)(@emnapi/[email protected].3)
'@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)
browserslist-load-config: 1.0.3
enhanced-resolve: 5.26.0
es-toolkit: 1.50.0
@@ -11343,10 +11359,10 @@ snapshots:
- utf-8-validate
- webpack
'@rsdoctor/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
'@rsdoctor/[email protected](@rspack/[email protected].5(@swc/[email protected]))':
dependencies:
'@rsdoctor/types': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
'@rsdoctor/utils': 1.6.5(@rspack/[email protected].4(@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]))
es-toolkit: 1.50.0
path-browserify: 1.0.1
source-map: 0.7.6
@@ -11354,15 +11370,15 @@ snapshots:
- '@rspack/core'
- webpack
'@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])':
'@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])':
dependencies:
'@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]))
'@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]))
optionalDependencies:
'@rspack/core': 2.3.4(@swc/[email protected])
'@rspack/core': 2.3.5(@swc/[email protected])
transitivePeerDependencies:
- '@emnapi/core'
- '@emnapi/runtime'
@@ -11372,12 +11388,12 @@ snapshots:
- utf-8-validate
- webpack
'@rsdoctor/[email protected](@rspack/[email protected].4(@swc/[email protected]))([email protected])':
'@rsdoctor/[email protected](@rspack/[email protected].5(@swc/[email protected]))([email protected])':
dependencies:
'@rsdoctor/client': 1.6.5
'@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]))
'@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]))
launch-editor: 2.14.2
safer-buffer: 2.1.2
socket.io: 4.8.1([email protected])
@@ -11389,19 +11405,19 @@ snapshots:
- utf-8-validate
- webpack
'@rsdoctor/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
'@rsdoctor/[email protected](@rspack/[email protected].5(@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.4(@swc/[email protected])
'@rspack/core': 2.3.5(@swc/[email protected])
'@rsdoctor/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
'@rsdoctor/[email protected](@rspack/[email protected].5(@swc/[email protected]))':
dependencies:
'@babel/code-frame': 7.26.2
'@rsdoctor/types': 1.6.5(@rspack/[email protected].4(@swc/[email protected]))
'@rsdoctor/types': 1.6.5(@rspack/[email protected].5(@swc/[email protected]))
'@types/estree': 1.0.5
acorn: 8.18.0
acorn-import-attributes: 1.9.5([email protected])
@@ -11430,83 +11446,83 @@ snapshots:
- '@swc-next/parser-binding-wasm'
- core-js
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
dependencies:
'@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)
'@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)
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optional: true
'@rspack/[email protected].4':
'@rspack/[email protected].5':
optionalDependencies:
'@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/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/[email protected].4(@swc/[email protected])':
'@rspack/[email protected].5(@swc/[email protected])':
dependencies:
'@rspack/binding': 2.3.4
'@rspack/binding': 2.3.5
optionalDependencies:
'@swc/helpers': 0.5.24
'@rspack/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
'@rspack/[email protected](@rspack/[email protected].5(@swc/[email protected]))':
optionalDependencies:
'@rspack/core': 2.3.4(@swc/[email protected])
'@rspack/core': 2.3.5(@swc/[email protected])
'@rspack/[email protected](@rspack/[email protected].4(@swc/[email protected]))':
'@rspack/[email protected](@rspack/[email protected].5(@swc/[email protected]))':
dependencies:
'@rspack/core': 2.3.4(@swc/[email protected])
'@rspack/dev-middleware': 2.0.6(@rspack/[email protected].4(@swc/[email protected]))
'@rspack/core': 2.3.5(@swc/[email protected])
'@rspack/dev-middleware': 2.0.6(@rspack/[email protected].5(@swc/[email protected]))
'@rspack/[email protected]': {}
@@ -11528,9 +11544,9 @@ snapshots:
'@rspack/[email protected]':
optional: true
'@rspack/[email protected](@emnapi/[email protected].3)(@emnapi/[email protected].3)':
'@rspack/[email protected](@emnapi/[email protected].2)(@emnapi/[email protected].2)':
dependencies:
'@napi-rs/wasm-runtime': 1.2.7(@emnapi/[email protected].3)(@emnapi/[email protected].3)
'@napi-rs/wasm-runtime': 1.2.7(@emnapi/[email protected].2)(@emnapi/[email protected].2)
transitivePeerDependencies:
- '@emnapi/core'
- '@emnapi/runtime'
@@ -11545,7 +11561,7 @@ snapshots:
'@rspack/[email protected]':
optional: true
'@rspack/[email protected](@emnapi/[email protected].3)(@emnapi/[email protected].3)':
'@rspack/[email protected](@emnapi/[email protected].2)(@emnapi/[email protected].2)':
optionalDependencies:
'@rspack/resolver-binding-darwin-arm64': 0.2.8
'@rspack/resolver-binding-darwin-x64': 0.2.8
@@ -11553,7 +11569,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].3)(@emnapi/[email protected].3)
'@rspack/resolver-binding-wasm32-wasi': 0.2.8(@emnapi/[email protected].2)(@emnapi/[email protected].2)
'@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
@@ -12607,12 +12623,12 @@ snapshots:
[email protected]: {}
[email protected](@babel/[email protected])(@rspack/[email protected].4(@swc/[email protected])):
[email protected](@babel/[email protected])(@rspack/[email protected].5(@swc/[email protected])):
dependencies:
'@babel/core': 8.1.4
find-up: 5.0.0
optionalDependencies:
'@rspack/core': 2.3.4(@swc/[email protected])
'@rspack/core': 2.3.5(@swc/[email protected])
[email protected](@babel/[email protected]([email protected]))([email protected]):
dependencies:
@@ -13072,7 +13088,7 @@ snapshots:
'@cropper/elements': 2.3.1
'@cropper/utils': 2.3.1
cross-spawn@7.0.6:
cross-spawn@7.1.2:
dependencies:
path-key: 3.1.1
shebang-command: 2.0.0
@@ -13778,7 +13794,7 @@ snapshots:
'@humanwhocodes/retry': 0.4.3
'@types/estree': 1.0.9
ajv: 6.15.0
cross-spawn: 7.0.6
cross-spawn: 7.1.2
debug: 4.4.3([email protected])
escape-string-regexp: 4.0.0
eslint-scope: 9.1.2
@@ -13976,7 +13992,7 @@ snapshots:
[email protected]:
dependencies:
cross-spawn: 7.0.6
cross-spawn: 7.1.2
signal-exit: 4.1.0
[email protected]:
@@ -15020,20 +15036,20 @@ snapshots:
- react
- use-sync-external-store
[email protected](marked@18.3.0):
[email protected](marked@18.4.0):
dependencies:
marked: 18.3.0
marked: 18.4.0
[email protected](marked@18.3.0):
[email protected](marked@18.4.0):
dependencies:
github-slugger: 2.0.0
marked: 18.3.0
marked: 18.4.0
[email protected]: {}
[email protected]: {}
marked@18.3.0: {}
marked@18.4.0: {}
[email protected]: {}
@@ -15073,6 +15089,8 @@ snapshots:
stylis: 4.4.0
ts-dedent: 2.3.0
[email protected]: {}
[email protected]:
dependencies:
braces: 3.0.3
@@ -15978,11 +15996,11 @@ snapshots:
[email protected]: {}
[email protected](@rspack/[email protected].4(@swc/[email protected])):
[email protected](@rspack/[email protected].5(@swc/[email protected])):
dependencies:
'@rspack/lite-tapable': 1.1.5
optionalDependencies:
'@rspack/core': 2.3.4(@swc/[email protected])
'@rspack/core': 2.3.5(@swc/[email protected])
[email protected]:
dependencies:
@@ -16458,7 +16476,7 @@ snapshots:
minizlib: 3.1.0
yallist: 5.0.0
[email protected].3: {}
[email protected].4: {}
[email protected]:
dependencies:
@@ -16975,14 +16993,14 @@ snapshots:
[email protected]: {}
[email protected](@rspack/[email protected].4(@swc/[email protected])):
[email protected](@rspack/[email protected].5(@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.4(@swc/[email protected])
'@rspack/core': 2.3.5(@swc/[email protected])
[email protected]: {}
+15
View File
@@ -62,6 +62,15 @@
"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",
@@ -94,6 +103,12 @@
"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,
HassEntities,
HassEntityStates,
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?: HassEntities | null;
private _states?: HassEntityStates | 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 { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } from "home-assistant-js-websocket";
import { timerTimeRemaining } from "../../data/timer";
/**
@@ -17,7 +17,7 @@ export class TimerRemainingTimeController implements ReactiveController {
private _host: ReactiveControllerHost;
private _stateObj?: HassEntity;
private _stateObj?: HassEntityState;
private _interval?: number;
@@ -26,7 +26,7 @@ export class TimerRemainingTimeController implements ReactiveController {
host.addController(this);
}
public setStateObj(stateObj: HassEntity | undefined): void {
public setStateObj(stateObj: HassEntityState | undefined): void {
this._stateObj = stateObj;
this._startInterval();
}
+15 -12
View File
@@ -1,5 +1,8 @@
import type { Context } from "@lit/context";
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
import type {
HassEntityStates,
HassEntityState,
} from "home-assistant-js-websocket";
import type {
HomeAssistant,
HomeAssistantInternationalization,
@@ -28,9 +31,9 @@ const resolveAtPath = (host: unknown, path: readonly string[]) => {
return cur;
};
/** Reuse `previous` when every entry still references the same `HassEntity`. */
/** Reuse `previous` when every entry still references the same `HassEntityState`. */
export const preserveUnchangedEntityStatesRecord = <
T extends Record<string, HassEntity | undefined>,
T extends Record<string, HassEntityState | undefined>,
>(
previous: T | undefined,
next: T
@@ -80,7 +83,7 @@ const composeDecorator = <T, V>(
};
/**
* Consumes `statesContext` and narrows it to the `HassEntity` for the entity
* Consumes `statesContext` and narrows it to the `HassEntityState` 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
@@ -88,7 +91,7 @@ const composeDecorator = <T, V>(
* nullish values.
*/
export const consumeEntityState = (config: ConsumeEntryConfig) =>
composeDecorator<HassEntities, HassEntity>(
composeDecorator<HassEntityStates, HassEntityState>(
statesContext,
config.entityIdPath[0],
function (states) {
@@ -106,10 +109,10 @@ export const consumeEntityState = (config: ConsumeEntryConfig) =>
*/
export const consumeEntityStates = (config: ConsumeEntryConfig) => {
const watchKey = config.entityIdPath[0];
const buildRecord = function (this: unknown, states: HassEntities) {
const buildRecord = function (this: unknown, states: HassEntityStates) {
const ids = ensureArray(resolveAtPath(this, config.entityIdPath));
if (!ids || !states) return undefined;
const result: Record<string, HassEntity> = {};
const result: Record<string, HassEntityState> = {};
for (const id of ids) {
if (typeof id !== "string") continue;
const state = states[id];
@@ -121,22 +124,22 @@ export const consumeEntityStates = (config: ConsumeEntryConfig) => {
return (proto: unknown, propertyKey: string) => {
const key = String(propertyKey);
const transformDec = transform<
HassEntities,
Record<string, HassEntity> | undefined
HassEntityStates,
Record<string, HassEntityState> | undefined
>({
transformer: function (this: unknown, states: HassEntities) {
transformer: function (this: unknown, states: HassEntityStates) {
const next = buildRecord.call(this, states);
if (next === undefined) {
return undefined;
}
const previous = (this as Record<string, unknown>)[
`__transform_${key}`
] as Record<string, HassEntity> | undefined;
] as Record<string, HassEntityState> | undefined;
return preserveUnchangedEntityStatesRecord(previous, next);
},
watch: watchKey ? [watchKey] : [],
});
const consumeDec = subscribeContext<HassEntities>(statesContext);
const consumeDec = subscribeContext<HassEntityStates>(statesContext);
transformDec(proto as never, propertyKey);
consumeDec(proto as never, propertyKey);
};
+12
View File
@@ -0,0 +1,12 @@
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;
};
+7 -1
View File
@@ -1,7 +1,13 @@
/** Loads an image, resolves with undefined when it can't be loaded. */
export const loadImage = (url: string): Promise<HTMLImageElement | undefined> =>
export const loadImage = (
url: string,
crossOrigin?: "anonymous" | "use-credentials"
): 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;
+3 -3
View File
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity): boolean =>
export const isAlertActive = (stateObj: HassEntityState): boolean =>
computeAlertActiveStates(stateObj.entity_id).includes(stateObj.state);
export const computeAlertColor = (
stateObj: HassEntity,
stateObj: HassEntityState,
color: string
): string | undefined => {
if (color === "none") {
+2 -2
View File
@@ -1,7 +1,7 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } from "home-assistant-js-websocket";
export const attributeClassNames = (
stateObj: HassEntity,
stateObj: HassEntityState,
attributes: string[]
): string => {
if (!stateObj) {
+2 -2
View File
@@ -12,7 +12,7 @@ import {
mdiBatteryAlertVariantOutline,
mdiBatteryUnknown,
} from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity, state?: string) => {
export const batteryIcon = (stateObj: HassEntityState, state?: string) => {
const level = state ?? stateObj.state;
return batteryLevelIcon(level);
};
+4 -4
View File
@@ -1,6 +1,6 @@
import type {
HassEntities,
HassEntity,
HassEntityStates,
HassEntityState,
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: HassEntities,
states: HassEntityStates,
services: HassServices,
stateObj: HassEntity
stateObj: HassEntityState
) => {
const domain = computeStateDomain(stateObj);
@@ -1,4 +1,4 @@
import type { HassConfig, HassEntity } from "home-assistant-js-websocket";
import type { HassConfig, HassEntityState } 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: HassEntity,
stateObj: HassEntityState,
locale: FrontendLocaleData,
config: HassConfig,
entities: HomeAssistant["entities"],
@@ -47,7 +47,7 @@ export const computeAttributeValueDisplay = (
export const computeAttributeValueToParts = (
localize: LocalizeFunc,
stateObj: HassEntity,
stateObj: HassEntityState,
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: HassEntity,
stateObj: HassEntityState,
entities: HomeAssistant["entities"],
attribute: string,
attributeValue: string
@@ -224,7 +224,7 @@ const computeMemberAttributeValueDisplay = (
export const computeAttributeNameDisplay = (
localize: LocalizeFunc,
stateObj: HassEntity,
stateObj: HassEntityState,
entities: HomeAssistant["entities"],
attribute: string
): string => {
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity,
stateObj: HassEntityState,
name?: string | EntityNameItem | EntityNameItem[],
options?: EntityNameOptions
): string => {
@@ -125,7 +125,7 @@ export const computeEntityEntryNameParts = (
};
export const computeEntityNameParts = (
stateObj: HassEntity,
stateObj: HassEntityState,
registries: HomeAssistantRegistries,
options?: EntityNamePartsOptions
): EntityNameParts => {
@@ -139,7 +139,7 @@ export const computeEntityNameParts = (
};
export const computeDefaultEntityNameItems = (
stateObj: HassEntity,
stateObj: HassEntityState,
registries: HomeAssistantRegistries
): EntityNameItem[] => {
const parts = computeEntityNameParts(stateObj, registries);
@@ -147,7 +147,7 @@ export const computeDefaultEntityNameItems = (
};
export const computeEntityNameDisplay = (
stateObj: HassEntity,
stateObj: HassEntityState,
name: string | EntityNameItem | EntityNameItem[] | undefined,
registries: HomeAssistantRegistries,
options?: EntityNameOptions
@@ -194,7 +194,7 @@ export const computeEntityNameDisplay = (
};
export const computeEntitySearchLabels = (
stateObj: HassEntity,
stateObj: HassEntityState,
registries: HomeAssistantRegistries
) => {
const parts = computeEntityNameParts(stateObj, registries, {
@@ -221,7 +221,7 @@ export interface EntityPickerDisplayOptions extends HomeAssistantRegistries {
export const computeEntityPickerDisplay = (
options: EntityPickerDisplayOptions,
stateObj: HassEntity
stateObj: HassEntityState
): EntityPickerDisplay => {
const parts = computeEntityNameParts(stateObj, options);
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity | undefined,
stateObj: HassEntityState | undefined,
config: EntityUnitStubConfig
): string => {
if (
+5 -5
View File
@@ -1,5 +1,5 @@
import { parseISO } from "date-fns";
import type { HassConfig, HassEntity } from "home-assistant-js-websocket";
import type { HassConfig, HassEntityState } 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: HassEntity,
stateObj: HassEntityState,
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 HassEntity,
{ state, attributes } as HassEntityState,
entity
),
});
@@ -177,7 +177,7 @@ const computeStateToPartsFromEntityAttributes = (
const value = formatNumber(
state,
locale,
getNumberFormatOptions({ state, attributes } as HassEntity, entity)
getNumberFormatOptions({ state, attributes } as HassEntityState, entity)
);
const unit =
@@ -298,7 +298,7 @@ const computeStateToPartsFromEntityAttributes = (
export const computeStateToParts = (
localize: LocalizeFunc,
stateObj: HassEntity,
stateObj: HassEntityState,
locale: FrontendLocaleData,
config: HassConfig,
entities: HomeAssistant["entities"],
+2 -2
View File
@@ -1,5 +1,5 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } from "home-assistant-js-websocket";
import { computeDomain } from "./compute_domain";
export const computeStateDomain = (stateObj: HassEntity) =>
export const computeStateDomain = (stateObj: HassEntityState) =>
computeDomain(stateObj.entity_id);
+2 -2
View File
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity): string =>
export const computeStateName = (stateObj: HassEntityState): string =>
computeStateNameFromEntityAttributes(stateObj.entity_id, stateObj.attributes);
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity,
stateObj: HassEntityState,
entities: HomeAssistant["entities"],
devices: HomeAssistant["devices"],
areas: HomeAssistant["areas"],
+3 -3
View File
@@ -9,9 +9,9 @@ import {
mdiGate,
mdiGateOpen,
} from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } from "home-assistant-js-websocket";
export const computeOpenIcon = (stateObj: HassEntity): string => {
export const computeOpenIcon = (stateObj: HassEntityState): string => {
switch (stateObj.attributes.device_class) {
case "door":
return mdiDoorOpen;
@@ -26,7 +26,7 @@ export const computeOpenIcon = (stateObj: HassEntity): string => {
}
};
export const computeCloseIcon = (stateObj: HassEntity): string => {
export const computeCloseIcon = (stateObj: HassEntityState): string => {
switch (stateObj.attributes.device_class) {
case "door":
return mdiDoorClosed;
+5 -2
View File
@@ -1,6 +1,9 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } from "home-assistant-js-websocket";
export const deviceTrackerIcon = (stateObj: HassEntity, state?: string) => {
export const deviceTrackerIcon = (
stateObj: HassEntityState,
state?: string
) => {
const compareState = state ?? stateObj.state;
if (stateObj?.attributes.source_type === "router") {
return compareState === "home" ? "mdi:lan-connect" : "mdi:lan-disconnect";
+2 -2
View File
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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 HassEntity | undefined;
const stateObj = states[entityId] as HassEntityState | undefined;
if (!stateObj) {
return false;
}
+2 -2
View File
@@ -1,9 +1,9 @@
import type { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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: HassEntities): GroupEntity[] => {
export const extractViews = (entities: HassEntityStates): GroupEntity[] => {
const views: GroupEntity[] = [];
Object.keys(entities).forEach((entityId) => {
+8 -5
View File
@@ -1,4 +1,7 @@
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
import type {
HassEntityStates,
HassEntityState,
} from "home-assistant-js-websocket";
import { computeStateDomain } from "./compute_state_domain";
export interface EntityLocation {
@@ -9,8 +12,8 @@ export interface EntityLocation {
export const findFirstActiveZone = (
inZones: readonly string[],
states: HassEntities
): HassEntity | undefined => {
states: HassEntityStates
): HassEntityState | undefined => {
for (const zoneId of inZones) {
const zone = states[zoneId];
if (
@@ -26,8 +29,8 @@ export const findFirstActiveZone = (
};
export const getEntityLocation = (
stateObj: HassEntity,
states: HassEntities
stateObj: HassEntityState,
states: HassEntityStates
): EntityLocation | undefined => {
const {
latitude,
+2 -2
View File
@@ -1,8 +1,8 @@
import type { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } from "home-assistant-js-websocket";
import type { GroupEntity } from "../../data/group";
export const getGroupEntities = (
entities: HassEntities,
entities: HassEntityStates,
group: GroupEntity
) => {
const result = {};
+7 -4
View File
@@ -1,4 +1,7 @@
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
import type {
HassEntityStates,
HassEntityState,
} 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";
@@ -249,7 +252,7 @@ const FIXED_DOMAIN_ATTRIBUTE_STATES = {
};
export const getStatesDomain = (
states: HassEntities,
states: HassEntityStates,
language: string,
domain: string,
attribute?: string | undefined
@@ -408,9 +411,9 @@ export const getValueAttribute = (
): string | undefined => DOMAIN_VALUE_ATTRIBUTES[domain]?.[optionsAttribute];
export const getStates = (
states: HassEntities,
states: HassEntityStates,
language: string,
stateObj: HassEntity,
stateObj: HassEntityState,
attribute: string | undefined = undefined
): string[] => {
const domain = computeStateDomain(stateObj);
+2
View File
@@ -3,6 +3,7 @@ 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.
@@ -58,6 +59,7 @@ export const SPECIAL_TOGGLE_ACTIONS: Record<string, SpecialToggleAction> = {
valve: {
on: "open_valve",
off: "close_valve",
feature: [ValveEntityFeature.OPEN, ValveEntityFeature.CLOSE],
},
};
+3 -3
View File
@@ -1,4 +1,4 @@
import type { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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: HassEntities,
entities: HassEntityStates,
view: GroupEntity
): HassEntities => {
): HassEntityStates => {
const viewEntities = {};
view.attributes.entity_id.forEach((entityId) => {
+5 -3
View File
@@ -1,10 +1,12 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity[]): string => {
export const computeGroupEntitiesState = (
states: HassEntityState[]
): string => {
if (!states.length) {
return UNAVAILABLE;
}
@@ -44,7 +46,7 @@ export const computeGroupEntitiesState = (states: HassEntity[]): string => {
export const toggleGroupEntities = (
hass: Pick<HomeAssistant, "callService">,
states: HassEntity[]
states: HassEntityState[]
) => {
if (!states.length) {
return;
+2 -2
View File
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } from "home-assistant-js-websocket";
export const hasLocation = (stateObj: HassEntity) =>
export const hasLocation = (stateObj: HassEntityState) =>
"latitude" in stateObj.attributes && "longitude" in stateObj.attributes;
+3 -3
View File
@@ -1,13 +1,13 @@
import type { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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: HassEntities) => {
export const splitByGroups = (entities: HassEntityStates) => {
const groups: GroupEntity[] = [];
const ungrouped: HassEntities = {};
const ungrouped: HassEntityStates = {};
Object.keys(entities).forEach((entityId) => {
const entity = entities[entityId];
+5 -2
View File
@@ -1,9 +1,12 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity, state?: string): boolean {
export function stateActive(
stateObj: HassEntityState,
state?: string
): boolean {
const domain = computeDomain(stateObj.entity_id);
const compareState = state !== undefined ? state : stateObj?.state;
+4 -4
View File
@@ -1,6 +1,6 @@
import type {
HassEntities,
HassEntity,
HassEntityStates,
HassEntityState,
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: HassEntities,
states: HassEntityStates,
services: HassServices,
stateObj: HassEntity
stateObj: HassEntityState
) => {
if (stateObj.state === UNAVAILABLE) {
return "display";
+5 -5
View File
@@ -1,5 +1,5 @@
/** Return a color representing a state. */
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity, state?: string) => {
export const stateColorCss = (stateObj: HassEntityState, 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: HassEntity, state?: string) => {
export const domainStateColorProperties = (
domain: string,
stateObj: HassEntity,
stateObj: HassEntityState,
state?: string
): string[] => {
const compareState = state !== undefined ? state : stateObj.state;
@@ -99,7 +99,7 @@ export const domainColorProperties = (
};
export const stateColorProperties = (
stateObj: HassEntity,
stateObj: HassEntityState,
state?: string
): string[] | undefined => {
const compareState = state !== undefined ? state : stateObj?.state;
@@ -129,7 +129,7 @@ export const stateColorProperties = (
return undefined;
};
export const stateColorBrightness = (stateObj: HassEntity): string => {
export const stateColorBrightness = (stateObj: HassEntityState): string => {
if (
stateObj.attributes.brightness &&
computeDomain(stateObj.entity_id) !== "plant"
+2 -2
View File
@@ -1,10 +1,10 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity,
stateObj: HassEntityState,
state?: string
): string | undefined => {
const domain = computeStateDomain(stateObj);
+2 -2
View File
@@ -1,7 +1,7 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } from "home-assistant-js-websocket";
export const supportsFeature = (
stateObj: HassEntity,
stateObj: HassEntityState,
feature: number
): boolean => supportsFeatureFromAttributes(stateObj.attributes, feature);
+2 -2
View File
@@ -1,8 +1,8 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } from "home-assistant-js-websocket";
import type { UpdateEntity } from "../../data/update";
import { updateIsInstalling } from "../../data/update";
export const updateIcon = (stateObj: HassEntity, state?: string) => {
export const updateIcon = (stateObj: HassEntityState, 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,4 +1,5 @@
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";
@@ -6,7 +7,11 @@ 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 { HomeAssistant } from "../../types";
import type { LocalizeFunc } from "../translations/localize";
import type {
HomeAssistantApi,
HomeAssistantInternationalization,
} from "../../types";
import { documentationUrl } from "../../util/documentation-url";
import { isComponentLoaded } from "../config/is_component_loaded";
import { navigate } from "../navigate";
@@ -15,17 +20,20 @@ export const PROTOCOL_INTEGRATIONS = ["zha", "zwave_js", "matter"] as const;
export const protocolIntegrationPicked = async (
element: HTMLElement,
hass: HomeAssistant,
callWS: HomeAssistantApi["callWS"],
localize: LocalizeFunc,
loadBackendTranslation: HomeAssistantInternationalization["loadBackendTranslation"],
hassConfig: HassConfig,
domain: string,
options?: { brand?: string; domain?: string; config_entry?: string }
) => {
if (options?.domain) {
const localize = await hass.loadBackendTranslation("title", options.domain);
options.domain = domainToName(localize, options.domain);
const titleLocalize = await loadBackendTranslation("title", options.domain);
options.domain = domainToName(titleLocalize, options.domain);
}
if (options?.brand) {
const integrationDescriptions = await getIntegrationDescriptions(hass);
const integrationDescriptions = await getIntegrationDescriptions(callWS);
options.brand =
integrationDescriptions.core.integration[options.brand]?.name ||
options.brand;
@@ -35,37 +43,40 @@ export const protocolIntegrationPicked = async (
const entries = options?.config_entry
? undefined
: (
await getConfigEntries(hass, {
domain,
})
await getConfigEntries(
{ callWS },
{
domain,
}
)
).filter((e) => !e.disabled_by);
if (
!isComponentLoaded(hass.config, "zwave_js") ||
!isComponentLoaded(hassConfig, "zwave_js") ||
(!options?.config_entry && !entries?.length)
) {
// If the component isn't loaded, ask them to load the integration first
showConfirmationDialog(element, {
title: hass.localize(
title: localize(
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
{ integration: "Z-Wave" }
),
text: hass.localize(
text: 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(hass, "/docs/z-wave/controllers")}
href=${documentationUrl({ config: hassConfig }, "/docs/z-wave/controllers")}
target="_blank"
rel="noreferrer"
>${hass.localize(
>${localize(
"ui.panel.config.integrations.config_flow.supported_hardware"
)}</a
>`,
}
),
confirmText: hass.localize(
confirmText: localize(
"ui.panel.config.integrations.config_flow.proceed"
),
confirm: () => {
@@ -84,40 +95,43 @@ export const protocolIntegrationPicked = async (
const entries = options?.config_entry
? undefined
: (
await getConfigEntries(hass, {
domain,
})
await getConfigEntries(
{ callWS },
{
domain,
}
)
).filter((e) => !e.disabled_by);
if (
!isComponentLoaded(hass.config, "zha") ||
!isComponentLoaded(hassConfig, "zha") ||
(!options?.config_entry && !entries?.length)
) {
// If the component isn't loaded, ask them to load the integration first
showConfirmationDialog(element, {
title: hass.localize(
title: localize(
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
{ integration: "Zigbee" }
),
text: hass.localize(
text: 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(
hass,
{ config: hassConfig },
"/integrations/zha/#known-working-zigbee-radio-modules"
)}
target="_blank"
rel="noreferrer"
>${hass.localize(
>${localize(
"ui.panel.config.integrations.config_flow.supported_hardware"
)}</a
>`,
}
),
confirmText: hass.localize(
confirmText: localize(
"ui.panel.config.integrations.config_flow.proceed"
),
confirm: () => {
@@ -134,36 +148,39 @@ export const protocolIntegrationPicked = async (
const entries = options?.config_entry
? undefined
: (
await getConfigEntries(hass, {
domain,
})
await getConfigEntries(
{ callWS },
{
domain,
}
)
).filter((e) => !e.disabled_by);
if (
!isComponentLoaded(hass.config, domain) ||
!isComponentLoaded(hassConfig, domain) ||
(!options?.config_entry && !entries?.length)
) {
// If the component isn't loaded, ask them to load the integration first
showConfirmationDialog(element, {
title: hass.localize(
title: localize(
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
{ integration: "Matter" }
),
text: hass.localize(
text: localize(
"ui.panel.config.integrations.config_flow.missing_matter",
{
integration: "Matter",
brand: options?.brand || options?.domain || "Matter",
supported_hardware_link: html`<a
href=${documentationUrl(hass, "/integrations/matter")}
href=${documentationUrl({ config: hassConfig }, "/integrations/matter")}
target="_blank"
rel="noreferrer"
>${hass.localize(
>${localize(
"ui.panel.config.integrations.config_flow.supported_hardware"
)}</a
>`,
}
),
confirmText: hass.localize(
confirmText: localize(
"ui.panel.config.integrations.config_flow.proceed"
),
confirm: () => {
@@ -0,0 +1,11 @@
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 -3
View File
@@ -1,5 +1,6 @@
import {
closeAllDialogs,
DIALOG_WAIT_TIMEOUT,
updateClosedDialogSearch,
} from "../dialogs/make-dialog-manager";
import { fireEvent } from "./dom/fire_event";
@@ -25,9 +26,6 @@ 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.
+5 -5
View File
@@ -1,6 +1,6 @@
import type {
HassEntity,
HassEntityAttributeBase,
HassEntityState,
HassEntityStateAttributeBase,
} 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: HassEntity): boolean =>
export const isNumericState = (stateObj: HassEntityState): boolean =>
isNumericFromAttributes(stateObj.attributes);
export const isNumericFromAttributes = (
attributes: HassEntityAttributeBase
attributes: HassEntityStateAttributeBase
): 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?: HassEntity,
entityState?: HassEntityState,
entity?: EntityRegistryDisplayEntry
): Intl.NumberFormatOptions | undefined => {
const precision = entity?.display_precision;
+7 -7
View File
@@ -1,4 +1,4 @@
import type { HassConfig, HassEntity } from "home-assistant-js-websocket";
import type { HassConfig, HassEntityState } 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: HassEntity,
stateObj: HassEntityState,
state?: string
) => string;
export type FormatEntityStateToPartsFunc = (
stateObj: HassEntity,
stateObj: HassEntityState,
state?: string
) => ValuePart[];
export type FormatEntityAttributeValueFunc = (
stateObj: HassEntity,
stateObj: HassEntityState,
attribute: string,
value?: any
) => string;
export type FormatEntityAttributeValueToPartsFunc = (
stateObj: HassEntity,
stateObj: HassEntityState,
attribute: string,
value?: any
) => ValuePart[];
export type FormatEntityAttributeNameFunc = (
stateObj: HassEntity,
stateObj: HassEntityState,
attribute: string
) => string;
export type FormatEntityNameFunc = (
stateObj: HassEntity,
stateObj: HassEntityState,
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 { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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: HassEntities;
states: HassEntityStates;
data: LineChartEntity[];
endTime: Date;
names?: Record<string, string>;
@@ -1,4 +1,4 @@
import type { HassConfig, HassEntities } from "home-assistant-js-websocket";
import type { HassConfig, HassEntityStates } 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?: HassEntities;
private _states?: HassEntityStates;
private _optionsEntityStates: Record<string, string | undefined> = {};
@@ -2,7 +2,7 @@ import type {
CustomSeriesOption,
CustomSeriesRenderItem,
} from "echarts/types/dist/shared";
import type { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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: HassEntities;
states: HassEntityStates;
data: TimelineEntity[];
startTime: Date;
endTime: Date;
@@ -1,4 +1,4 @@
import type { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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?: HassEntities;
private _states?: HassEntityStates;
protected render() {
return html`
@@ -3,7 +3,7 @@ import type {
LineSeriesOption,
ZRColor,
} from "echarts/types/dist/shared";
import type { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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: HassEntities;
states: HassEntityStates;
formatEntityName: HomeAssistantFormatters["formatEntityName"];
localize: LocalizeFunc;
statisticsData: Statistics;
+2 -2
View File
@@ -2,7 +2,7 @@ import type {
BarSeriesOption,
LineSeriesOption,
} from "echarts/types/dist/shared";
import type { HassConfig, HassEntities } from "home-assistant-js-websocket";
import type { HassConfig, HassEntityStates } 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!: HassEntities;
private _states!: HassEntityStates;
@consume({ context: entitiesContext, subscribe: true })
private _entities!: HomeAssistant["entities"];
+4 -4
View File
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity
stateObj?: HassEntityState
): 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?: HassEntity
stateObj?: HassEntityState
): string | undefined {
if (!stateObj) {
return undefined;
@@ -111,7 +111,7 @@ function computeTimeLineGenericColor(
export function computeTimelineColor(
state: string,
computedStyles: CSSStyleDeclaration,
stateObj?: HassEntity
stateObj?: HassEntityState
): 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 { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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<HassEntities, HassEntities>({
@transform<HassEntityStates, HassEntityStates>({
transformer: function (
this: HaDeviceAutomationPicker<DeviceAutomation>,
states
) {
const registryById = entityRegistryById(this._entityReg ?? []);
const picked: HassEntities = {};
const picked: HassEntityStates = {};
[...(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: HassEntities = {};
private _states: HassEntityStates = {};
@state()
@consume({ context: formattersContext, subscribe: true })
@@ -119,7 +119,7 @@ export abstract class HaDeviceAutomationPicker<
private _localizeDeviceAutomation: (
localize: LocalizeFunc,
states: HassEntities,
states: HassEntityStates,
formatEntityName: HomeAssistantFormatters["formatEntityName"],
entityRegistry: EntityRegistryEntry[],
automation: T
@@ -214,7 +214,7 @@ export abstract class HaDeviceAutomationPicker<
automations: T[] | undefined,
localize: LocalizeFunc,
language: string,
states: HassEntities,
states: HassEntityStates,
formatEntityName: HomeAssistantFormatters["formatEntityName"],
entityReg: EntityRegistryEntry[]
) => {
+4 -2
View File
@@ -1,6 +1,6 @@
import { mdiSwapHorizontal } from "@mdi/js";
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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,7 +55,9 @@ export type HaDevicePickerDeviceFilterFunc = (
device: DeviceRegistryEntry
) => boolean;
export type HaDevicePickerEntityFilterFunc = (entity: HassEntity) => boolean;
export type HaDevicePickerEntityFilterFunc = (
entity: HassEntityState
) => boolean;
@customElement("ha-device-picker")
export class HaDevicePicker extends LitElement {
+4 -3
View File
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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,9 +6,10 @@ import "../ha-icon";
@customElement("ha-battery-icon")
export class HaBatteryIcon extends LitElement {
@property({ attribute: false }) public batteryStateObj?: HassEntity;
@property({ attribute: false }) public batteryStateObj?: HassEntityState;
@property({ attribute: false }) public batteryChargingStateObj?: HassEntity;
@property({ attribute: false })
public batteryChargingStateObj?: HassEntityState;
protected render() {
if (!this.batteryStateObj) return nothing;
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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, HassEntity>;
private _stateObjs?: Record<string, HassEntityState>;
@state()
@consume({ context: formattersContext, subscribe: true })
@@ -64,7 +64,7 @@ class HaEntityAttributePicker extends LitElement {
private _getItemsMemoized = memoizeOne(
(
entityId: string | string[] | undefined,
stateObjs: Record<string, HassEntity> | undefined,
stateObjs: Record<string, HassEntityState> | 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 { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
private _stateObj?: HassEntityState;
@state()
@consume({ context: registriesContext, subscribe: true })
@@ -423,7 +423,7 @@ export class HaEntityNamePicker extends LitElement {
private _defaultItems = memoizeOne(
(
stateObj: HassEntity | undefined,
stateObj: HassEntityState | undefined,
registries: ContextType<typeof registriesContext>
): EntityNameItem[] => {
if (!stateObj) {
@@ -470,7 +470,7 @@ export class HaEntityNamePicker extends LitElement {
private _validTypes = memoizeOne(
(
stateObj: HassEntity | undefined,
stateObj: HassEntityState | undefined,
registries: ContextType<typeof registriesContext>
) => {
if (!stateObj) {
@@ -497,7 +497,7 @@ export class HaEntityNamePicker extends LitElement {
private _getItems = memoizeOne(
(
stateObj: HassEntity | undefined,
stateObj: HassEntityState | 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 { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
private _stateObj?: HassEntityState;
@state()
@consume({ context: registriesContext, subscribe: true })
@@ -138,7 +138,7 @@ export class HaStateContentPicker extends LitElement {
private _getItems = memoizeOne(
(
entityId: string | undefined,
stateObj: HassEntity | undefined,
stateObj: HassEntityState | undefined,
allowName: boolean,
allowContext: boolean,
localize: LocalizeFunc,
@@ -1,5 +1,8 @@
import type { ContextType } from "@lit/context";
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
import type {
HassEntityStates,
HassEntityState,
} from "home-assistant-js-websocket";
import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
@@ -45,7 +48,7 @@ const keepsStatesOrder = (
};
export const computeEntityStateItems = (
states: HassEntities | null | undefined,
states: HassEntityStates | null | undefined,
formatters: HomeAssistantFormatters,
language: string,
entityId: string | string[] | undefined,
@@ -55,11 +58,11 @@ export const computeEntityStateItems = (
): PickerComboBoxItem[] => {
const entityIds = entityId ? ensureArray(entityId) : [];
const stateObjsByState = new Map<string, HassEntity>();
const stateObjsByState = new Map<string, HassEntityState>();
for (const entityIdItem of entityIds) {
const stateObj =
states?.[entityIdItem] ||
({ entity_id: entityIdItem, attributes: {} } as HassEntity);
({ entity_id: entityIdItem, attributes: {} } as HassEntityState);
const entityStates = getStates(states ?? {}, language, stateObj, attribute);
for (const s of entityStates) {
if (!hideStates?.includes(s) && !stateObjsByState.has(s)) {
@@ -105,7 +108,7 @@ export const computeEntityStateItems = (
export const computeDefaultStateLabel = (
i18n: ContextType<typeof internationalizationContext>,
formatters: HomeAssistantFormatters,
stateObjs: Record<string, HassEntity> | undefined,
stateObjs: Record<string, HassEntityState> | undefined,
entityId: string | string[] | undefined,
attribute: string | undefined
): string => {
@@ -148,7 +151,7 @@ export class HaEntityStatePicker extends LitElement {
@state()
@consumeEntityStates({ entityIdPath: ["entityId"] })
private _stateObjs?: Record<string, HassEntity>;
private _stateObjs?: Record<string, HassEntityState>;
@consume({ context: statesContext, subscribe: true })
private _states?: ContextType<typeof statesContext>;
@@ -1,5 +1,8 @@
import type { ContextType } from "@lit/context";
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
import type {
HassEntityStates,
HassEntityState,
} from "home-assistant-js-websocket";
import type { PropertyValues } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
@@ -53,7 +56,7 @@ export class HaEntityStatesPicker extends LitElement {
@state()
@consumeEntityStates({ entityIdPath: ["entityId"] })
private _stateObjs?: Record<string, HassEntity>;
private _stateObjs?: Record<string, HassEntityState>;
@consume({ context: statesContext, subscribe: true })
private _states?: ContextType<typeof statesContext>;
@@ -68,7 +71,7 @@ export class HaEntityStatesPicker extends LitElement {
private _chipsSelector = memoizeOne(
(
states: HassEntities | null | undefined,
states: HassEntityStates | null | undefined,
formatters: HomeAssistantFormatters,
language: string,
entityId: string | string[] | undefined,
+3 -3
View File
@@ -1,6 +1,6 @@
import type { ContextType } from "@lit/context";
import { mdiFlash, mdiFlashOff } from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity) =>
const isOn = (stateObj?: HassEntityState) =>
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?: HassEntity;
@property({ attribute: false }) public stateObj?: HassEntityState;
@property() public label?: string;
@@ -1,6 +1,6 @@
import type { ContextType } from "@lit/context";
import { mdiDelete } from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
private _stateObj?: HassEntityState;
@state()
@consume({ context: registriesContext, subscribe: true })
@@ -1,6 +1,6 @@
import type { ContextType } from "@lit/context";
import { mdiAlert } from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
@property({ attribute: false }) public state?: HassEntityState;
@property() public name?: string;
@@ -170,7 +170,7 @@ export class HaStateLabelBadge extends LitElement {
private _computeValue(
domain: string,
entityState: HassEntity,
entityState: HassEntityState,
entry?: EntityRegistryDisplayEntry
) {
switch (domain) {
@@ -203,7 +203,7 @@ export class HaStateLabelBadge extends LitElement {
private _computeShowIcon(
domain: string,
entityState: HassEntity,
entityState: HassEntityState,
entry?: EntityRegistryDisplayEntry
): boolean {
if (entityState.state === UNAVAILABLE) {
@@ -228,7 +228,7 @@ export class HaStateLabelBadge extends LitElement {
private _computeLabel(
domain: string,
entityState: HassEntity,
entityState: HassEntityState,
_timerTimeRemaining = 0
) {
// For unavailable states or certain domains, use a special translation that is truncated to fit within the badge label
+2 -2
View File
@@ -6,7 +6,7 @@ import {
mdiPencil,
mdiShape,
} from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
stateObj?: HassEntityState;
domainName?: string;
type?: StatisticItemType;
}
+2 -2
View File
@@ -1,6 +1,6 @@
import type { ContextType } from "@lit/context";
import { mdiAlert } from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
@property({ attribute: false }) public stateObj?: HassEntityState;
@property({ attribute: false }) public overrideIcon?: string;
+2 -2
View File
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
@property({ attribute: false }) public stateObj?: HassEntityState;
@property({ attribute: "in-dialog", type: Boolean }) public inDialog = false;
+2 -2
View File
@@ -1,5 +1,5 @@
import type { ContextType } from "@lit/context";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
stateObj?: HassEntityState;
domain?: string;
deviceClass?: string;
}
+2 -2
View File
@@ -1,6 +1,6 @@
import type { ContextType } from "@lit/context";
import { mdiPlus, mdiTextureBox } from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity) => boolean;
public entityFilter?: (entity: HassEntityState) => boolean;
@property({ type: Boolean }) public disabled = false;
+2 -2
View File
@@ -1,5 +1,5 @@
import { mdiDragHorizontalVariant } from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity) => boolean;
public entityFilter?: (entity: HassEntityState) => boolean;
@property({ attribute: "picked-area-label" })
public pickedAreaLabel?: string;
+2 -2
View File
@@ -1,6 +1,6 @@
import type { ContextType } from "@lit/context";
import { initialState } from "@lit/task";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
@property({ attribute: false }) public stateObj?: HassEntityState;
@property() public attribute?: string;
+2 -2
View File
@@ -1,6 +1,6 @@
import type { ContextType } from "@lit/context";
import { initialState } from "@lit/task";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
@property({ attribute: false }) public stateObj?: HassEntityState;
@property() public attribute!: string;
+2 -2
View File
@@ -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(base) {
:host([no-wrap]) wa-button-group::part(button-group) {
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(base) {
:host([full-width]) wa-button-group::part(button-group) {
width: 100%;
}
+2 -2
View File
@@ -22,7 +22,7 @@ import {
mdiRedo,
mdiUndo,
} from "@mdi/js";
import type { HassEntities } from "home-assistant-js-websocket";
import type { HassEntityStates } 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: HassEntities,
states: HassEntityStates,
formatEntityName: HomeAssistantFormatters["formatEntityName"],
registries: HomeAssistantRegistries
): Completion[] => {
+4 -4
View File
@@ -1,5 +1,5 @@
import type { ContextType } from "@lit/context";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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, HassEntity>;
private _entityStates?: Record<string, HassEntityState>;
@consume({ context: entitiesContext, subscribe: true })
@state()
@@ -85,7 +85,7 @@ export class HaEntitiesDisplayEditor extends LitElement {
private _items = memoizeOne(
(
entitiesIds: string[],
entityStates: Record<string, HassEntity> | undefined,
entityStates: Record<string, HassEntityState> | 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 HassEntity => Boolean(stateObj));
.filter((stateObj): stateObj is HassEntityState => Boolean(stateObj));
return entities.map((entity) => ({
value: entity.entity_id,
+2 -2
View File
@@ -1,4 +1,4 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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?: HassEntity;
private stateObj?: HassEntityState;
@property({ attribute: false }) public entityId!: string;
+2 -2
View File
@@ -1,5 +1,5 @@
import type { ContextType } from "@lit/context";
import type { HassEntity } from "home-assistant-js-websocket";
import type { HassEntityState } 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: HassEntity;
stateObj: HassEntityState;
name: string;
}
Loaded 100 of 560 files, more files were not shown because too many files have changed in this diff. Show more