Support email and url form input types (#4186)

* Support email and url form input types

* Lint

* Lint

* Add types
This commit is contained in:
Ville Skyttä 2019-11-18 19:03:19 +02:00 committed by Bram Kragten
parent 920ee741f3
commit 1e217e8d2f
2 changed files with 14 additions and 0 deletions

View File

@ -56,6 +56,7 @@ export class HaFormString extends LitElement implements HaFormElement {
`
: html`
<paper-input
.type=${this._stringType}
.label=${this.label}
.value=${this.data}
.required=${this.schema.required}
@ -84,6 +85,18 @@ export class HaFormString extends LitElement implements HaFormElement {
{ bubbles: false }
);
}
private _stringType() {
if (this.schema.format) {
if (["email", "url"].includes(this.schema.format)) {
return this.schema.format;
}
if (this.schema.format === "fqdnurl") {
return "url";
}
}
return "text";
}
}
declare global {

View File

@ -51,6 +51,7 @@ export interface HaFormFloatSchema extends HaFormBaseSchema {
export interface HaFormStringSchema extends HaFormBaseSchema {
type: "string";
format?: string;
}
export interface HaFormBooleanSchema extends HaFormBaseSchema {