import { LitElement, CSSResult, css } from "lit"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators"; import PFForm from "@patternfly/patternfly/components/Form/form.css"; import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css"; import { ErrorDetail } from "@goauthentik/api"; @customElement("ak-form-element") export class FormElement extends LitElement { static get styles(): CSSResult[] { return [ PFForm, PFFormControl, css` slot { display: flex; flex-direction: row; align-items: center; justify-content: space-around; } `, ]; } @property() label?: string; @property({ type: Boolean }) required = false; @property({ attribute: false }) errors?: ErrorDetail[]; updated(): void { this.querySelectorAll("input[autofocus]").forEach((input) => { input.focus(); }); } render(): TemplateResult { return html`
${(this.errors || []).map((error) => { return html`

${error.string}

`; })}
`; } }