mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-31 21:17:47 +00:00
Password manager?
This commit is contained in:
parent
1eac9fa1cd
commit
bd316a36a0
@ -37,6 +37,24 @@ export class HaFormString extends LitElement implements HaFormElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected firstUpdated(): void {
|
||||
if (this.schema.name.includes("password")) {
|
||||
const stepInput = document.createElement("input");
|
||||
stepInput.setAttribute("type", "password");
|
||||
stepInput.setAttribute("name", "password");
|
||||
stepInput.setAttribute("autocomplete", "on");
|
||||
stepInput.onkeyup = (ev) => this._externalValueChanged(ev, this);
|
||||
document.documentElement.appendChild(stepInput);
|
||||
} else if (this.schema.name.includes("username")) {
|
||||
const stepInput = document.createElement("input");
|
||||
stepInput.setAttribute("type", "text");
|
||||
stepInput.setAttribute("name", "username");
|
||||
stepInput.setAttribute("autocomplete", "on");
|
||||
stepInput.onkeyup = (ev) => this._externalValueChanged(ev, this);
|
||||
document.documentElement.appendChild(stepInput);
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return this.schema.name.includes("password")
|
||||
? html`
|
||||
@ -81,11 +99,21 @@ export class HaFormString extends LitElement implements HaFormElement {
|
||||
if (this.data === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
fireEvent(this, "value-changed", {
|
||||
value,
|
||||
});
|
||||
}
|
||||
|
||||
private _externalValueChanged(ev: Event, el): void {
|
||||
const value = (ev.target as PaperInputElement).value;
|
||||
if (this.data === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
el.shadowRoot!.querySelector("paper-input").value = value;
|
||||
}
|
||||
|
||||
private get _stringType(): string {
|
||||
if (this.schema.format) {
|
||||
if (["email", "url"].includes(this.schema.format)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user