@vaadin/password-field 22.0.0-alpha9 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# @vaadin/password-field
|
|
2
2
|
|
|
3
|
-
An extension of
|
|
3
|
+
An extension of [`<vaadin-text-field>`](https://www.npmjs.com/package/@vaadin/text-field) component for entering passwords.
|
|
4
4
|
|
|
5
|
-
[Live Demo ↗](https://vaadin.com/docs/latest/ds/components/password-field)
|
|
5
|
+
[Documentation + Live Demo ↗](https://vaadin.com/docs/latest/ds/components/password-field)
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@vaadin/password-field)
|
|
8
|
+
[](https://discord.gg/PHmkCKC)
|
|
6
9
|
|
|
7
10
|
```html
|
|
8
11
|
<vaadin-password-field label="Password"></vaadin-password-field>
|
|
@@ -13,7 +16,7 @@ An extension of `vaadin-text-field` component for entering passwords.
|
|
|
13
16
|
Install the component:
|
|
14
17
|
|
|
15
18
|
```sh
|
|
16
|
-
npm i @vaadin/password-field
|
|
19
|
+
npm i @vaadin/password-field
|
|
17
20
|
```
|
|
18
21
|
|
|
19
22
|
Once installed, import the component in your application:
|
|
@@ -24,9 +27,8 @@ import '@vaadin/password-field';
|
|
|
24
27
|
|
|
25
28
|
## Themes
|
|
26
29
|
|
|
27
|
-
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes),
|
|
28
|
-
|
|
29
|
-
of the package uses Lumo theme.
|
|
30
|
+
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
|
|
31
|
+
The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/password-field/vaadin-password-field.js) of the package uses Lumo theme.
|
|
30
32
|
|
|
31
33
|
To use the Material theme, import the component from the `theme/material` folder:
|
|
32
34
|
|
|
@@ -46,9 +48,13 @@ Finally, you can import the un-themed component from the `src` folder to get a m
|
|
|
46
48
|
import '@vaadin/password-field/src/vaadin-password-field.js';
|
|
47
49
|
```
|
|
48
50
|
|
|
51
|
+
## Contributing
|
|
52
|
+
|
|
53
|
+
Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
|
|
54
|
+
|
|
49
55
|
## License
|
|
50
56
|
|
|
51
57
|
Apache License 2.0
|
|
52
58
|
|
|
53
|
-
Vaadin collects development time
|
|
59
|
+
Vaadin collects usage statistics at development time to improve this product.
|
|
54
60
|
For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/password-field",
|
|
3
|
-
"version": "22.0.0
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@polymer/polymer": "^3.0.0",
|
|
35
|
-
"@vaadin/text-field": "22.0.0
|
|
36
|
-
"@vaadin/vaadin-lumo-styles": "22.0.0
|
|
37
|
-
"@vaadin/vaadin-material-styles": "22.0.0
|
|
35
|
+
"@vaadin/text-field": "^22.0.0",
|
|
36
|
+
"@vaadin/vaadin-lumo-styles": "^22.0.0",
|
|
37
|
+
"@vaadin/vaadin-material-styles": "^22.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@esm-bundle/chai": "^4.3.4",
|
|
41
|
-
"@vaadin/testing-helpers": "^0.3.
|
|
41
|
+
"@vaadin/testing-helpers": "^0.3.2",
|
|
42
42
|
"sinon": "^9.2.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "b668e9b1a975227fbe34beb70d1cd5b03dce2348"
|
|
45
45
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { SlotStylesMixin } from '@vaadin/field-base/src/slot-styles-mixin.js';
|
|
6
7
|
import { TextField } from '@vaadin/text-field/src/vaadin-text-field.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -32,19 +33,20 @@ export interface PasswordFieldEventMap extends HTMLElementEventMap, PasswordFiel
|
|
|
32
33
|
*
|
|
33
34
|
* ### Styling
|
|
34
35
|
*
|
|
36
|
+
* `<vaadin-password-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
35
37
|
* See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
|
|
36
38
|
*
|
|
37
|
-
* In addition to `<vaadin-text-field>` parts,
|
|
39
|
+
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
38
40
|
*
|
|
39
41
|
* Part name | Description
|
|
40
42
|
* ----------------|----------------------------------------------------
|
|
41
43
|
* `reveal-button` | The eye icon which toggles the password visibility
|
|
42
44
|
*
|
|
43
|
-
* In addition to `<vaadin-text-field>` state attributes,
|
|
45
|
+
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
44
46
|
*
|
|
45
|
-
* Attribute | Description
|
|
46
|
-
*
|
|
47
|
-
* `password-visible` | Set when the password is visible
|
|
47
|
+
* Attribute | Description
|
|
48
|
+
* -------------------|---------------------------------
|
|
49
|
+
* `password-visible` | Set when the password is visible
|
|
48
50
|
*
|
|
49
51
|
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
50
52
|
*
|
|
@@ -53,7 +55,7 @@ export interface PasswordFieldEventMap extends HTMLElementEventMap, PasswordFiel
|
|
|
53
55
|
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
54
56
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
55
57
|
*/
|
|
56
|
-
declare class PasswordField extends TextField {
|
|
58
|
+
declare class PasswordField extends SlotStylesMixin(TextField) {
|
|
57
59
|
/**
|
|
58
60
|
* Set to true to hide the eye icon which toggles the password visibility.
|
|
59
61
|
* @attr {boolean} reveal-button-hidden
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
|
7
|
+
import { SlotStylesMixin } from '@vaadin/field-base/src/slot-styles-mixin.js';
|
|
7
8
|
import { TextField } from '@vaadin/text-field/src/vaadin-text-field.js';
|
|
8
9
|
|
|
9
10
|
const ownTemplate = html`
|
|
@@ -23,19 +24,20 @@ let memoizedTemplate;
|
|
|
23
24
|
*
|
|
24
25
|
* ### Styling
|
|
25
26
|
*
|
|
27
|
+
* `<vaadin-password-field>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
26
28
|
* See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
|
|
27
29
|
*
|
|
28
|
-
* In addition to `<vaadin-text-field>` parts,
|
|
30
|
+
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
29
31
|
*
|
|
30
32
|
* Part name | Description
|
|
31
33
|
* ----------------|----------------------------------------------------
|
|
32
34
|
* `reveal-button` | The eye icon which toggles the password visibility
|
|
33
35
|
*
|
|
34
|
-
* In addition to `<vaadin-text-field>` state attributes,
|
|
36
|
+
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
35
37
|
*
|
|
36
|
-
* Attribute | Description
|
|
37
|
-
*
|
|
38
|
-
* `password-visible` | Set when the password is visible
|
|
38
|
+
* Attribute | Description
|
|
39
|
+
* -------------------|---------------------------------
|
|
40
|
+
* `password-visible` | Set when the password is visible
|
|
39
41
|
*
|
|
40
42
|
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
41
43
|
*
|
|
@@ -45,8 +47,9 @@ let memoizedTemplate;
|
|
|
45
47
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
46
48
|
*
|
|
47
49
|
* @extends TextField
|
|
50
|
+
* @mixes SlotStylesMixin
|
|
48
51
|
*/
|
|
49
|
-
export class PasswordField extends TextField {
|
|
52
|
+
export class PasswordField extends SlotStylesMixin(TextField) {
|
|
50
53
|
static get is() {
|
|
51
54
|
return 'vaadin-password-field';
|
|
52
55
|
}
|
|
@@ -124,12 +127,24 @@ export class PasswordField extends TextField {
|
|
|
124
127
|
reveal: () => {
|
|
125
128
|
const btn = document.createElement('button');
|
|
126
129
|
btn.setAttribute('type', 'button');
|
|
127
|
-
btn.
|
|
130
|
+
btn.disabled = this.disabled;
|
|
128
131
|
return btn;
|
|
129
132
|
}
|
|
130
133
|
};
|
|
131
134
|
}
|
|
132
135
|
|
|
136
|
+
/** @protected */
|
|
137
|
+
get slotStyles() {
|
|
138
|
+
const tag = this.localName;
|
|
139
|
+
return [
|
|
140
|
+
`
|
|
141
|
+
${tag} [slot="input"]::-ms-reveal {
|
|
142
|
+
display: none;
|
|
143
|
+
}
|
|
144
|
+
`
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
|
|
133
148
|
/** @protected */
|
|
134
149
|
get _revealNode() {
|
|
135
150
|
return this._getDirectSlotChild('reveal');
|
|
@@ -203,7 +218,12 @@ export class PasswordField extends TextField {
|
|
|
203
218
|
);
|
|
204
219
|
}
|
|
205
220
|
|
|
206
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Override method inherited from `FocusMixin` to toggle password visibility.
|
|
223
|
+
* @param {boolean} focused
|
|
224
|
+
* @protected
|
|
225
|
+
* @override
|
|
226
|
+
*/
|
|
207
227
|
_setFocused(focused) {
|
|
208
228
|
super._setFocused(focused);
|
|
209
229
|
|
|
@@ -212,7 +232,7 @@ export class PasswordField extends TextField {
|
|
|
212
232
|
} else {
|
|
213
233
|
const isButtonFocused = this.getRootNode().activeElement === this._revealNode;
|
|
214
234
|
// Remove focus-ring from the field when the reveal button gets focused
|
|
215
|
-
this.toggleAttribute('focus-ring', !isButtonFocused);
|
|
235
|
+
this.toggleAttribute('focus-ring', this._keyboardActive && !isButtonFocused);
|
|
216
236
|
}
|
|
217
237
|
}
|
|
218
238
|
|
|
@@ -281,6 +301,20 @@ export class PasswordField extends TextField {
|
|
|
281
301
|
|
|
282
302
|
this._updateToggleState(passwordVisible);
|
|
283
303
|
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Override method inherited from `DisabledMixin` to synchronize the reveal button
|
|
307
|
+
* disabled state with the password field disabled state.
|
|
308
|
+
* @param {boolean} disabled
|
|
309
|
+
* @protected
|
|
310
|
+
*/
|
|
311
|
+
_disabledChanged(disabled) {
|
|
312
|
+
super._disabledChanged(disabled);
|
|
313
|
+
|
|
314
|
+
if (this._revealNode) {
|
|
315
|
+
this._revealNode.disabled = disabled;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
284
318
|
}
|
|
285
319
|
|
|
286
320
|
customElements.define(PasswordField.is, PasswordField);
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
7
6
|
import '@vaadin/vaadin-lumo-styles/font-icons.js';
|
|
8
7
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
9
8
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
10
9
|
import { inputFieldShared } from '@vaadin/vaadin-lumo-styles/mixins/input-field-shared.js';
|
|
10
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
11
|
|
|
12
12
|
const passwordField = css`
|
|
13
13
|
[part='reveal-button']::before {
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
7
6
|
import '@vaadin/vaadin-material-styles/color.js';
|
|
8
7
|
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
9
8
|
import { inputFieldShared } from '@vaadin/vaadin-material-styles/mixins/input-field-shared.js';
|
|
9
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
10
|
|
|
11
11
|
const passwordField = css`
|
|
12
12
|
[part='reveal-button']::before {
|