mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +00:00
Support email and url form input types (#4186)
* Support email and url form input types * Lint * Lint * Add types
This commit is contained in:
parent
920ee741f3
commit
1e217e8d2f
@ -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 {
|
||||
|
@ -51,6 +51,7 @@ export interface HaFormFloatSchema extends HaFormBaseSchema {
|
||||
|
||||
export interface HaFormStringSchema extends HaFormBaseSchema {
|
||||
type: "string";
|
||||
format?: string;
|
||||
}
|
||||
|
||||
export interface HaFormBooleanSchema extends HaFormBaseSchema {
|
||||
|
Loading…
x
Reference in New Issue
Block a user