mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-12 20:40:29 +00:00
Add a placeholder hint for template selector (#27297)
Add a placeholder for template selector
This commit is contained in:
@@ -8,6 +8,7 @@ import type {
|
|||||||
import { undo, undoDepth, redo, redoDepth } from "@codemirror/commands";
|
import { undo, undoDepth, redo, redoDepth } from "@codemirror/commands";
|
||||||
import type { Extension, TransactionSpec } from "@codemirror/state";
|
import type { Extension, TransactionSpec } from "@codemirror/state";
|
||||||
import type { EditorView, KeyBinding, ViewUpdate } from "@codemirror/view";
|
import type { EditorView, KeyBinding, ViewUpdate } from "@codemirror/view";
|
||||||
|
import { placeholder } from "@codemirror/view";
|
||||||
import {
|
import {
|
||||||
mdiArrowExpand,
|
mdiArrowExpand,
|
||||||
mdiArrowCollapse,
|
mdiArrowCollapse,
|
||||||
@@ -81,6 +82,8 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
@property({ type: Boolean, attribute: "has-toolbar" })
|
@property({ type: Boolean, attribute: "has-toolbar" })
|
||||||
public hasToolbar = true;
|
public hasToolbar = true;
|
||||||
|
|
||||||
|
@property({ type: String }) public placeholder?: string;
|
||||||
|
|
||||||
@state() private _value = "";
|
@state() private _value = "";
|
||||||
|
|
||||||
@state() private _isFullscreen = false;
|
@state() private _isFullscreen = false;
|
||||||
@@ -264,6 +267,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
this._loadedCodeMirror.foldingCompartment.of(
|
this._loadedCodeMirror.foldingCompartment.of(
|
||||||
this._getFoldingExtensions()
|
this._getFoldingExtensions()
|
||||||
),
|
),
|
||||||
|
...(this.placeholder ? [placeholder(this.placeholder)] : []),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!this.readOnly) {
|
if (!this.readOnly) {
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ export class HaTemplateSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public helper?: string;
|
@property() public helper?: string;
|
||||||
|
|
||||||
|
@property() public placeholder?: any;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
@@ -55,6 +57,7 @@ export class HaTemplateSelector extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.readOnly=${this.disabled}
|
.readOnly=${this.disabled}
|
||||||
|
.placeholder=${this.placeholder || "{{ ... }}"}
|
||||||
autofocus
|
autofocus
|
||||||
autocomplete-entities
|
autocomplete-entities
|
||||||
autocomplete-icons
|
autocomplete-icons
|
||||||
|
|||||||
Reference in New Issue
Block a user