mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 18:06:36 +00:00
Fix password field in ha-form (#8400)
This commit is contained in:
parent
d54a129605
commit
d93d2b5945
@ -1,6 +1,9 @@
|
|||||||
|
import { mdiEye, mdiEyeOff } from "@mdi/js";
|
||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-input/paper-input";
|
||||||
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||||
import {
|
import {
|
||||||
|
css,
|
||||||
|
CSSResult,
|
||||||
customElement,
|
customElement,
|
||||||
html,
|
html,
|
||||||
internalProperty,
|
internalProperty,
|
||||||
@ -10,12 +13,13 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import "../ha-icon-button";
|
import "../ha-svg-icon";
|
||||||
import type {
|
import type {
|
||||||
HaFormElement,
|
HaFormElement,
|
||||||
HaFormStringData,
|
HaFormStringData,
|
||||||
HaFormStringSchema,
|
HaFormStringSchema,
|
||||||
} from "./ha-form";
|
} from "./ha-form";
|
||||||
|
import "@material/mwc-icon-button/mwc-icon-button";
|
||||||
|
|
||||||
@customElement("ha-form-string")
|
@customElement("ha-form-string")
|
||||||
export class HaFormString extends LitElement implements HaFormElement {
|
export class HaFormString extends LitElement implements HaFormElement {
|
||||||
@ -48,16 +52,17 @@ export class HaFormString extends LitElement implements HaFormElement {
|
|||||||
.autoValidate=${this.schema.required}
|
.autoValidate=${this.schema.required}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
>
|
>
|
||||||
<ha-icon-button
|
<mwc-icon-button
|
||||||
toggles
|
toggles
|
||||||
slot="suffix"
|
slot="suffix"
|
||||||
.icon=${this._unmaskedPassword ? "hass:eye-off" : "hass:eye"}
|
|
||||||
id="iconButton"
|
id="iconButton"
|
||||||
title="Click to toggle between masked and clear password"
|
title="Click to toggle between masked and clear password"
|
||||||
@click=${this._toggleUnmaskedPassword}
|
@click=${this._toggleUnmaskedPassword}
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
>
|
><ha-svg-icon
|
||||||
</ha-icon-button>
|
.path=${this._unmaskedPassword ? mdiEyeOff : mdiEye}
|
||||||
|
></ha-svg-icon>
|
||||||
|
</mwc-icon-button>
|
||||||
</paper-input>
|
</paper-input>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
@ -98,6 +103,15 @@ export class HaFormString extends LitElement implements HaFormElement {
|
|||||||
}
|
}
|
||||||
return "text";
|
return "text";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get styles(): CSSResult {
|
||||||
|
return css`
|
||||||
|
mwc-icon-button {
|
||||||
|
--mdc-icon-button-size: 24px;
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user