mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Add condition selector for blueprint (#17278)
This commit is contained in:
parent
e2ec3b63ce
commit
efc8ed5c94
48
src/components/ha-selector/ha-selector-condition.ts
Normal file
48
src/components/ha-selector/ha-selector-condition.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { css, CSSResultGroup, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { Condition } from "../../data/automation";
|
||||
import { ConditionSelector } from "../../data/selector";
|
||||
import "../../panels/config/automation/condition/ha-automation-condition";
|
||||
import { HomeAssistant } from "../../types";
|
||||
|
||||
@customElement("ha-selector-condition")
|
||||
export class HaConditionSelector extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public selector!: ConditionSelector;
|
||||
|
||||
@property() public value?: Condition;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||
|
||||
protected render() {
|
||||
return html`
|
||||
<ha-automation-condition
|
||||
.disabled=${this.disabled}
|
||||
.conditions=${this.value || []}
|
||||
.hass=${this.hass}
|
||||
></ha-automation-condition>
|
||||
`;
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
ha-automation-condition {
|
||||
display: block;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
:host([disabled]) ha-automation-condition {
|
||||
opacity: var(--light-disabled-opacity);
|
||||
pointer-events: none;
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-selector-condition": HaConditionSelector;
|
||||
}
|
||||
}
|
@ -3,9 +3,9 @@ import { customElement, property } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { dynamicElement } from "../../common/dom/dynamic-element-directive";
|
||||
import {
|
||||
Selector,
|
||||
handleLegacyEntitySelector,
|
||||
handleLegacyDeviceSelector,
|
||||
handleLegacyEntitySelector,
|
||||
Selector,
|
||||
} from "../../data/selector";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
|
||||
@ -17,6 +17,7 @@ const LOAD_ELEMENTS = {
|
||||
assist_pipeline: () => import("./ha-selector-assist-pipeline"),
|
||||
boolean: () => import("./ha-selector-boolean"),
|
||||
color_rgb: () => import("./ha-selector-color-rgb"),
|
||||
condition: () => import("./ha-selector-condition"),
|
||||
config_entry: () => import("./ha-selector-config-entry"),
|
||||
conversation_agent: () => import("./ha-selector-conversation-agent"),
|
||||
constant: () => import("./ha-selector-constant"),
|
||||
|
@ -19,6 +19,7 @@ export type Selector =
|
||||
| BooleanSelector
|
||||
| ColorRGBSelector
|
||||
| ColorTempSelector
|
||||
| ConditionSelector
|
||||
| ConversationAgentSelector
|
||||
| ConfigEntrySelector
|
||||
| ConstantSelector
|
||||
@ -96,6 +97,11 @@ export interface ColorTempSelector {
|
||||
} | null;
|
||||
}
|
||||
|
||||
export interface ConditionSelector {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
condition: {} | null;
|
||||
}
|
||||
|
||||
export interface ConversationAgentSelector {
|
||||
conversation_agent: { language?: string } | null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user