Add preview for template (#17699)

This commit is contained in:
Bram Kragten
2023-08-30 12:56:53 +02:00
committed by GitHub
parent 034ce56da5
commit d350c35c4e
3 changed files with 148 additions and 1 deletions

View File

@@ -70,7 +70,7 @@ class StepFlowForm extends LitElement {
></ha-form>
</div>
${step.preview
? html`<div class="preview">
? html`<div class="preview" @set-flow-errors=${this._setError}>
<h3>
${this.hass.localize(
"ui.panel.config.integrations.config_flow.preview"
@@ -107,6 +107,10 @@ class StepFlowForm extends LitElement {
`;
}
private _setError(ev: CustomEvent) {
this.step = { ...this.step, errors: ev.detail };
}
protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
setTimeout(() => this.shadowRoot!.querySelector("ha-form")!.focus(), 0);
@@ -253,6 +257,9 @@ class StepFlowForm extends LitElement {
}
declare global {
interface HASSDomEvents {
"set-flow-errors": { errors: DataEntryFlowStepForm["errors"] };
}
interface HTMLElementTagNameMap {
"step-flow-form": StepFlowForm;
}