From 12e23c119d75a3af171a1a8859da7d4bbb5eca5d Mon Sep 17 00:00:00 2001 From: selvalt7 <52136675+selvalt7@users.noreply.github.com> Date: Thu, 26 Sep 2024 23:28:53 +0200 Subject: [PATCH] Pass localizeValue to ha-form-expandable and ha-form-grid --- src/components/ha-form/ha-form-expandable.ts | 5 +++++ src/components/ha-form/ha-form-grid.ts | 5 +++++ src/components/ha-form/ha-form.ts | 1 + 3 files changed, 11 insertions(+) diff --git a/src/components/ha-form/ha-form-expandable.ts b/src/components/ha-form/ha-form-expandable.ts index 1ffa6339b568..a751a5acd244 100644 --- a/src/components/ha-form/ha-form-expandable.ts +++ b/src/components/ha-form/ha-form-expandable.ts @@ -30,6 +30,10 @@ export class HaFormExpendable extends LitElement implements HaFormElement { options?: { path?: string[] } ) => string; + @property({ attribute: false }) public localizeValue?: ( + key: string + ) => string; + private _renderDescription() { const description = this.computeHelper?.(this.schema); return description ? html`

${description}

` : nothing; @@ -86,6 +90,7 @@ export class HaFormExpendable extends LitElement implements HaFormElement { .disabled=${this.disabled} .computeLabel=${this._computeLabel} .computeHelper=${this._computeHelper} + .localizeValue=${this.localizeValue} > diff --git a/src/components/ha-form/ha-form-grid.ts b/src/components/ha-form/ha-form-grid.ts index 27c602531234..4eefedf4691c 100644 --- a/src/components/ha-form/ha-form-grid.ts +++ b/src/components/ha-form/ha-form-grid.ts @@ -35,6 +35,10 @@ export class HaFormGrid extends LitElement implements HaFormElement { schema: HaFormSchema ) => string; + @property({ attribute: false }) public localizeValue?: ( + key: string + ) => string; + public async focus() { await this.updateComplete; this.renderRoot.querySelector("ha-form")?.focus(); @@ -65,6 +69,7 @@ export class HaFormGrid extends LitElement implements HaFormElement { .disabled=${this.disabled} .computeLabel=${this.computeLabel} .computeHelper=${this.computeHelper} + .localizeValue=${this.localizeValue} > ` )} diff --git a/src/components/ha-form/ha-form.ts b/src/components/ha-form/ha-form.ts index a44067599049..b3e0e21de7ff 100644 --- a/src/components/ha-form/ha-form.ts +++ b/src/components/ha-form/ha-form.ts @@ -163,6 +163,7 @@ export class HaForm extends LitElement implements HaFormElement { localize: this.hass?.localize, computeLabel: this.computeLabel, computeHelper: this.computeHelper, + localizeValue: this.localizeValue, context: this._generateContext(item), ...this.getFormProperties(), })}