web: Improve form input validation and visibility. (#12812)

This commit is contained in:
Teffen Ellis
2025-02-14 02:11:35 +01:00
committed by GitHub
parent 49cc70eb96
commit 46a968d1dd
44 changed files with 268 additions and 79 deletions

View File

@ -45,6 +45,9 @@ export class HorizontalLightComponent<T> extends AKElement {
@property({ attribute: false })
value?: T;
@property({ type: String })
inputHint = "";
renderControl() {
throw new Error("Must be implemented in a subclass");
}
@ -69,7 +72,7 @@ export class HorizontalLightComponent<T> extends AKElement {
.errorMessages=${this.errorMessages}
?invalid=${this.invalid}
>
${this.renderControl()}
${this.renderControl()}
${this.renderHelp()}
</ak-form-element-horizontal> `;
}

View File

@ -1,5 +1,6 @@
import { html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import { ifDefined } from "lit/directives/if-defined.js";
import { HorizontalLightComponent } from "./HorizontalLightComponent";
@ -14,11 +15,18 @@ export class AkTextInput extends HorizontalLightComponent<string> {
this.value = (ev.target as HTMLInputElement).value;
};
const code = this.inputHint === "code";
return html` <input
type="text"
@input=${setValue}
value=${ifDefined(this.value)}
class="pf-c-form-control"
class="${classMap({
"pf-c-form-control": true,
"pf-m-monospace": code,
})}"
autocomplete=${ifDefined(code ? "off" : undefined)}
spellcheck=${ifDefined(code ? "false" : undefined)}
?required=${this.required}
/>`;
}