mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +00:00
Add trigger selector for blueprint (#18469)
This commit is contained in:
parent
cfa522068c
commit
e63c7e3763
56
src/components/ha-selector/ha-selector-trigger.ts
Normal file
56
src/components/ha-selector/ha-selector-trigger.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { Trigger } from "../../data/automation";
|
||||||
|
import { TriggerSelector } from "../../data/selector";
|
||||||
|
import "../../panels/config/automation/trigger/ha-automation-trigger";
|
||||||
|
import { HomeAssistant } from "../../types";
|
||||||
|
|
||||||
|
@customElement("ha-selector-trigger")
|
||||||
|
export class HaTriggerSelector extends LitElement {
|
||||||
|
@property() public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property() public selector!: TriggerSelector;
|
||||||
|
|
||||||
|
@property() public value?: Trigger;
|
||||||
|
|
||||||
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||||
|
|
||||||
|
protected render() {
|
||||||
|
return html`
|
||||||
|
${this.label ? html`<label>${this.label}</label>` : nothing}
|
||||||
|
<ha-automation-trigger
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
.triggers=${this.value || []}
|
||||||
|
.hass=${this.hass}
|
||||||
|
.nested=${this.selector.trigger?.nested}
|
||||||
|
.reOrderMode=${this.selector.trigger?.reorder_mode}
|
||||||
|
></ha-automation-trigger>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles(): CSSResultGroup {
|
||||||
|
return css`
|
||||||
|
ha-automation-trigger {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
:host([disabled]) ha-automation-trigger {
|
||||||
|
opacity: var(--light-disabled-opacity);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-selector-trigger": HaTriggerSelector;
|
||||||
|
}
|
||||||
|
}
|
@ -44,6 +44,7 @@ const LOAD_ELEMENTS = {
|
|||||||
icon: () => import("./ha-selector-icon"),
|
icon: () => import("./ha-selector-icon"),
|
||||||
media: () => import("./ha-selector-media"),
|
media: () => import("./ha-selector-media"),
|
||||||
theme: () => import("./ha-selector-theme"),
|
theme: () => import("./ha-selector-theme"),
|
||||||
|
trigger: () => import("./ha-selector-trigger"),
|
||||||
tts: () => import("./ha-selector-tts"),
|
tts: () => import("./ha-selector-tts"),
|
||||||
tts_voice: () => import("./ha-selector-tts-voice"),
|
tts_voice: () => import("./ha-selector-tts-voice"),
|
||||||
location: () => import("./ha-selector-location"),
|
location: () => import("./ha-selector-location"),
|
||||||
|
@ -49,6 +49,7 @@ export type Selector =
|
|||||||
| TemplateSelector
|
| TemplateSelector
|
||||||
| ThemeSelector
|
| ThemeSelector
|
||||||
| TimeSelector
|
| TimeSelector
|
||||||
|
| TriggerSelector
|
||||||
| TTSSelector
|
| TTSSelector
|
||||||
| TTSVoiceSelector
|
| TTSVoiceSelector
|
||||||
| UiActionSelector
|
| UiActionSelector
|
||||||
@ -373,6 +374,13 @@ export interface TimeSelector {
|
|||||||
time: {} | null;
|
time: {} | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TriggerSelector {
|
||||||
|
trigger: {
|
||||||
|
reorder_mode?: boolean;
|
||||||
|
nested?: boolean;
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface TTSSelector {
|
export interface TTSSelector {
|
||||||
tts: { language?: string } | null;
|
tts: { language?: string } | null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user