From 224df896a153e6d8c27787522c9d0f8ac0656a8c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 24 Mar 2022 17:50:38 -0700 Subject: [PATCH] Allow rendering helper text from strings.json (#12119) * Allow rendering helper text from strings.json * Persistent helpers * Update src/components/ha-base-time-input.ts Co-authored-by: Zack Barett * Update src/components/ha-base-time-input.ts Co-authored-by: Zack Barett --- src/components/ha-base-time-input.ts | 13 +++++++++++++ src/components/ha-duration-input.ts | 3 +++ src/components/ha-form/ha-form-string.ts | 4 ++++ src/components/ha-selector/ha-selector-duration.ts | 3 +++ src/components/ha-selector/ha-selector-number.ts | 4 ++++ src/components/ha-selector/ha-selector-text.ts | 6 ++++++ src/dialogs/config-flow/dialog-data-entry-flow.ts | 2 -- src/dialogs/config-flow/show-dialog-config-flow.ts | 6 ++++++ .../config-flow/show-dialog-data-entry-flow.ts | 6 ++++++ src/dialogs/config-flow/show-dialog-options-flow.ts | 6 ++++++ src/dialogs/config-flow/step-flow-form.ts | 4 ++++ 11 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/components/ha-base-time-input.ts b/src/components/ha-base-time-input.ts index 64b12f18e2..4c1f1d7ff4 100644 --- a/src/components/ha-base-time-input.ts +++ b/src/components/ha-base-time-input.ts @@ -21,6 +21,11 @@ export class HaBaseTimeInput extends LitElement { */ @property() label?: string; + /** + * Helper for the input + */ + @property() helper?: string; + /** * auto validate time inputs */ @@ -207,6 +212,7 @@ export class HaBaseTimeInput extends LitElement { PM `} + ${this.helper ? html`
${this.helper}
` : ""} `; } @@ -303,6 +309,13 @@ export class HaBaseTimeInput extends LitElement { color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87)); padding-left: 4px; } + + .helper { + color: var(--mdc-text-field-label-ink-color, rgba(0, 0, 0, 0.6)); + font-size: 0.75rem; + padding-left: 16px; + padding-right: 16px; + } `; } diff --git a/src/components/ha-duration-input.ts b/src/components/ha-duration-input.ts index 9ac4e72e2f..b862059b35 100644 --- a/src/components/ha-duration-input.ts +++ b/src/components/ha-duration-input.ts @@ -17,6 +17,8 @@ class HaDurationInput extends LitElement { @property() public label?: string; + @property() public helper?: string; + @property({ type: Boolean }) public required?: boolean; @property({ type: Boolean }) public enableMillisecond?: boolean; @@ -35,6 +37,7 @@ class HaDurationInput extends LitElement { return html` @@ -166,6 +167,9 @@ class StepFlowForm extends LitElement { private _labelCallback = (field: HaFormSchema): string => this.flowConfig.renderShowFormStepFieldLabel(this.hass, this.step, field); + private _helperCallback = (field: HaFormSchema): string => + this.flowConfig.renderShowFormStepFieldHelper(this.hass, this.step, field); + private _errorCallback = (error: string) => this.flowConfig.renderShowFormStepFieldError(this.hass, this.step, error);