mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 22:07:20 +00:00
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import {
|
|
LitElement,
|
|
property,
|
|
customElement,
|
|
PropertyValues,
|
|
TemplateResult,
|
|
html,
|
|
} from "lit-element";
|
|
import { HassEntity } from "home-assistant-js-websocket";
|
|
|
|
import "./configurator-notification-item";
|
|
import "./persistent-notification-item";
|
|
|
|
import { HomeAssistant } from "../../types";
|
|
import { PersistentNotification } from "../../data/persistent_notification";
|
|
|
|
@customElement("notification-item")
|
|
export class HuiNotificationItem extends LitElement {
|
|
@property() public hass?: HomeAssistant;
|
|
|
|
@property() public notification?: HassEntity | PersistentNotification;
|
|
|
|
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
|
if (!this.hass || !this.notification || changedProps.has("notification")) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
protected render(): TemplateResult | void {
|
|
if (!this.hass || !this.notification) {
|
|
return html``;
|
|
}
|
|
|
|
return "entity_id" in this.notification
|
|
? html`
|
|
<configurator-notification-item
|
|
.hass="${this.hass}"
|
|
.notification="${this.notification}"
|
|
></configurator-notification-item>
|
|
`
|
|
: html`
|
|
<persistent-notification-item
|
|
.hass="${this.hass}"
|
|
.notification="${this.notification}"
|
|
></persistent-notification-item>
|
|
`;
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
"notification-item": HuiNotificationItem;
|
|
}
|
|
}
|