mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +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`
|
: html`
|
||||||
<paper-input
|
<paper-input
|
||||||
|
.type=${this._stringType}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
.value=${this.data}
|
.value=${this.data}
|
||||||
.required=${this.schema.required}
|
.required=${this.schema.required}
|
||||||
@ -84,6 +85,18 @@ export class HaFormString extends LitElement implements HaFormElement {
|
|||||||
{ bubbles: false }
|
{ 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 {
|
declare global {
|
||||||
|
@ -51,6 +51,7 @@ export interface HaFormFloatSchema extends HaFormBaseSchema {
|
|||||||
|
|
||||||
export interface HaFormStringSchema extends HaFormBaseSchema {
|
export interface HaFormStringSchema extends HaFormBaseSchema {
|
||||||
type: "string";
|
type: "string";
|
||||||
|
format?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HaFormBooleanSchema extends HaFormBaseSchema {
|
export interface HaFormBooleanSchema extends HaFormBaseSchema {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user