Password manager?

This commit is contained in:
Zack Arnett 2020-08-10 15:15:21 -05:00
parent 1eac9fa1cd
commit bd316a36a0

View File

@ -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)) {