diff --git a/src/data/selector.ts b/src/data/selector.ts index f3d1d39c71..d8cb9a4e63 100644 --- a/src/data/selector.ts +++ b/src/data/selector.ts @@ -87,8 +87,8 @@ export interface TargetSelector { export interface NumberSelector { number: { - min: number; - max: number; + min?: number; + max?: number; step?: number; mode?: "box" | "slider"; unit_of_measurement?: string; diff --git a/src/panels/lovelace/editor/config-elements/hui-history-graph-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-history-graph-card-editor.ts index 9ed7e4279b..a18b13c2c1 100644 --- a/src/panels/lovelace/editor/config-elements/hui-history-graph-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-history-graph-card-editor.ts @@ -1,5 +1,5 @@ -import "@polymer/paper-input/paper-input"; -import { CSSResultGroup, html, LitElement, TemplateResult } from "lit"; +import "../../../../components/ha-form/ha-form"; +import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property, state } from "lit/decorators"; import { array, @@ -11,16 +11,15 @@ import { assign, } from "superstruct"; import { fireEvent } from "../../../../common/dom/fire_event"; -import { HomeAssistant } from "../../../../types"; -import { HistoryGraphCardConfig } from "../../cards/types"; +import type { HomeAssistant } from "../../../../types"; +import type { HistoryGraphCardConfig } from "../../cards/types"; import "../../components/hui-entity-editor"; -import { EntityConfig } from "../../entity-rows/types"; -import { LovelaceCardEditor } from "../../types"; +import type { EntityConfig } from "../../entity-rows/types"; +import type { LovelaceCardEditor } from "../../types"; import { processEditorEntities } from "../process-editor-entities"; import { entitiesConfigStruct } from "../structs/entities-struct"; -import { EditorTarget, EntitiesEditorEvent } from "../types"; -import { configElementStyle } from "./config-elements-style"; import { baseLovelaceCardConfig } from "../structs/base-card-struct"; +import type { HaFormSchema } from "../../../../components/ha-form/types"; const cardConfigStruct = assign( baseLovelaceCardConfig, @@ -32,6 +31,21 @@ const cardConfigStruct = assign( }) ); +const SCHEMA: HaFormSchema[] = [ + { name: "title", selector: { text: {} } }, + { + name: "", + type: "grid", + schema: [ + { name: "hours_to_show", selector: { number: { min: 1, mode: "box" } } }, + { + name: "refresh_interval", + selector: { number: { min: 1, mode: "box" } }, + }, + ], + }, +]; + @customElement("hui-history-graph-card-editor") export class HuiHistoryGraphCardEditor extends LitElement @@ -49,104 +63,48 @@ export class HuiHistoryGraphCardEditor this._configEntities = processEditorEntities(config.entities); } - get _title(): string { - return this._config!.title || ""; - } - - get _hours_to_show(): number { - return this._config!.hours_to_show || 24; - } - - get _refresh_interval(): number { - return this._config!.refresh_interval || 0; - } - protected render(): TemplateResult { if (!this.hass || !this._config) { return html``; } return html` -