[HOMEASSIST-4] panel_custom element wrapper and HA types in packages/ui #4

Merged
chris merged 8 commits from feature/HOMEASSIST-4 into main 2026-10-03 16:37:58 -06:00
Owner

Ticket

HOMEASSIST-4 Dashboards: panel_custom element wrapper and HA types in packages/ui

Summary

  • definePanel(name, Component, { styles }) in @ha-dashboards/ui/panel: shadow root + injected CSS string, React mount, hass/narrow/route/panel forwarded via context; render waits for hass and panel, coalesced into one root.render, deferred unmount so same-task detach/reattach keeps the tree.
  • useHass(), useEntity(id), usePanel() hooks; HA types extended (user, language, PanelRoute, PanelInfo, PanelProps).
  • ha-map migrated onto the wrapper as ha-map-panel (the Lovelace card ha-map-card is replaced, per decision); build:card now emits ha-map-panel.js.
  • Constructor sets no attributes (Chromium rejects them from document.createElement); host sizing is :host CSS.
  • Not in this PR: the live panel_custom entry in HA config and the deploy-script cleanup of the old ha-map-card.js (HOMEASSIST-6); real-browser/HA verification is deferred to that ticket since happy-dom does not enforce the createElement attribute rule.
  • Tests: ui 63 pass, map 8 pass; typecheck/lint/format/builds green.

🤖 Generated with Claude Code

## Ticket [HOMEASSIST-4](http://192.168.2.100:7123/home/browse/HOMEASSIST-4/) Dashboards: panel_custom element wrapper and HA types in packages/ui ## Summary - `definePanel(name, Component, { styles })` in `@ha-dashboards/ui/panel`: shadow root + injected CSS string, React mount, hass/narrow/route/panel forwarded via context; render waits for hass and panel, coalesced into one root.render, deferred unmount so same-task detach/reattach keeps the tree. - `useHass()`, `useEntity(id)`, `usePanel()` hooks; HA types extended (`user`, `language`, `PanelRoute`, `PanelInfo`, `PanelProps`). - ha-map migrated onto the wrapper as `ha-map-panel` (the Lovelace card `ha-map-card` is replaced, per decision); build:card now emits `ha-map-panel.js`. - Constructor sets no attributes (Chromium rejects them from `document.createElement`); host sizing is `:host` CSS. - Not in this PR: the live `panel_custom` entry in HA config and the deploy-script cleanup of the old `ha-map-card.js` (HOMEASSIST-6); real-browser/HA verification is deferred to that ticket since happy-dom does not enforce the createElement attribute rule. - Tests: ui 63 pass, map 8 pass; typecheck/lint/format/builds green. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
@ -62,0 +63,4 @@
callService,
user: { id: 'dev-user', name: 'Dev', is_admin: true },
language: 'en',
};
Author
Owner

Are dev-user and Dev significant? Do I need to create an account with HA to use these or something? Unclear what they're for.

Are `dev-user` and `Dev` significant? Do I need to create an account with HA to use these or something? Unclear what they're for.
chris marked this conversation as resolved
@ -62,0 +63,4 @@
callService,
user: { id: 'dev-user', name: 'Dev', is_admin: true },
language: 'en',
};
Author
Owner

Re: "Are dev-user and Dev significant?"

No. They are placeholder values and don't correspond to any Home Assistant account; you don't need to create anything. HomeAssistant.user is a required field on the type (packages/ui/src/types/hass.ts), so the dev harness has to supply some value to typecheck. Nothing in the map panel reads it. In production the real hass object from HA carries the logged-in user, and this harness (dev-only, bun run dev) never ships.

I can add a short comment in DevHarness.tsx saying so if that would help.

--Claude

Re: "Are `dev-user` and `Dev` significant?" No. They are placeholder values and don't correspond to any Home Assistant account; you don't need to create anything. `HomeAssistant.user` is a required field on the type (`packages/ui/src/types/hass.ts`), so the dev harness has to supply some value to typecheck. Nothing in the map panel reads it. In production the real `hass` object from HA carries the logged-in user, and this harness (dev-only, `bun run dev`) never ships. I can add a short comment in `DevHarness.tsx` saying so if that would help. --Claude
chris marked this conversation as resolved
chris merged commit f394faca27 into main 2026-10-03 16:37:58 -06:00
chris deleted branch feature/HOMEASSIST-4 2026-10-03 16:37:58 -06:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
chris/home-assistant-dashboards!4
No description provided.