@dile/ui 3.1.1 → 3.2.1
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.
|
@@ -1,9 +1,67 @@
|
|
|
1
|
-
import { LitElement, html } from 'lit';
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { DileInput } from '../../input/index.js';
|
|
3
|
+
import '@dile/iconlib/lucide-icons/eye.js';
|
|
4
|
+
import '@dile/iconlib/lucide-icons/eye-off.js';
|
|
3
5
|
|
|
4
6
|
export class DilePassword extends DileInput {
|
|
5
7
|
|
|
8
|
+
static get properties() {
|
|
9
|
+
return {
|
|
10
|
+
...super.properties,
|
|
11
|
+
/** Enable show/hide password toggle */
|
|
12
|
+
showPasswordToggle: { type: Boolean },
|
|
13
|
+
/** Current password visibility state */
|
|
14
|
+
passwordVisible: { type: Boolean },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static get styles() {
|
|
19
|
+
return [
|
|
20
|
+
...super.styles,
|
|
21
|
+
css`
|
|
22
|
+
.password-toggle-btn {
|
|
23
|
+
background: none;
|
|
24
|
+
border: none;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
padding: var(--dile-password-toggle-padding, var(--dile-input-padding, 5px));
|
|
27
|
+
margin: var(--dile-password-toggle-margin, 0 5px);
|
|
28
|
+
color: var(--dile-password-toggle-color, var(--dile-input-color, #303030));
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
width: var(--dile-password-toggle-width, 32px);
|
|
33
|
+
height: var(--dile-password-toggle-height, 32px);
|
|
34
|
+
border-radius: var(--dile-password-toggle-border-radius, var(--dile-input-border-radius, 5px));
|
|
35
|
+
transition: var(--dile-password-toggle-transition, background-color 0.2s);
|
|
36
|
+
}
|
|
37
|
+
.password-toggle-btn:hover {
|
|
38
|
+
background-color: var(--dile-password-toggle-hover-bg, rgba(0, 0, 0, 0.05));
|
|
39
|
+
}
|
|
40
|
+
.password-toggle-btn:active {
|
|
41
|
+
background-color: var(--dile-password-toggle-active-bg, rgba(0, 0, 0, 0.1));
|
|
42
|
+
}
|
|
43
|
+
.password-toggle-btn:disabled {
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
opacity: 0.5;
|
|
46
|
+
}
|
|
47
|
+
.password-toggle-btn dile-lucide-icon-eye,
|
|
48
|
+
.password-toggle-btn dile-lucide-icon-eye-off {
|
|
49
|
+
--dile-icon-color: var(--dile-password-toggle-color, var(--dile-input-color, #303030));
|
|
50
|
+
--dile-icon-size: var(--dile-password-toggle-icon-size, 20px);
|
|
51
|
+
}
|
|
52
|
+
`
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
constructor() {
|
|
57
|
+
super();
|
|
58
|
+
this.showPasswordToggle = false;
|
|
59
|
+
this.passwordVisible = false;
|
|
60
|
+
}
|
|
61
|
+
|
|
6
62
|
render() {
|
|
63
|
+
const inputType = this.passwordVisible ? 'text' : 'password';
|
|
64
|
+
|
|
7
65
|
return html`
|
|
8
66
|
<div>
|
|
9
67
|
${this.label
|
|
@@ -12,7 +70,7 @@ export class DilePassword extends DileInput {
|
|
|
12
70
|
}
|
|
13
71
|
<section class="for-input">
|
|
14
72
|
<input
|
|
15
|
-
type="
|
|
73
|
+
type="${inputType}"
|
|
16
74
|
id="textField"
|
|
17
75
|
name="${this.name}"
|
|
18
76
|
placeholder="${this.placeholder}"
|
|
@@ -22,6 +80,21 @@ export class DilePassword extends DileInput {
|
|
|
22
80
|
.value="${this.value}"
|
|
23
81
|
class="${ this.errored ? 'errored' : '' }"
|
|
24
82
|
>
|
|
83
|
+
${this.showPasswordToggle
|
|
84
|
+
? html`<button
|
|
85
|
+
class="password-toggle-btn"
|
|
86
|
+
type="button"
|
|
87
|
+
@click="${this._togglePasswordVisibility}"
|
|
88
|
+
?disabled="${this.disabled}"
|
|
89
|
+
aria-label="${this.passwordVisible ? 'Hide password' : 'Show password'}"
|
|
90
|
+
>
|
|
91
|
+
${this.passwordVisible
|
|
92
|
+
? html`<dile-lucide-icon-eye></dile-lucide-icon-eye>`
|
|
93
|
+
: html`<dile-lucide-icon-eye-off></dile-lucide-icon-eye-off>`
|
|
94
|
+
}
|
|
95
|
+
</button>`
|
|
96
|
+
: ''
|
|
97
|
+
}
|
|
25
98
|
</section>
|
|
26
99
|
${this.message
|
|
27
100
|
? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
@@ -31,4 +104,15 @@ export class DilePassword extends DileInput {
|
|
|
31
104
|
`;
|
|
32
105
|
}
|
|
33
106
|
|
|
107
|
+
_togglePasswordVisibility() {
|
|
108
|
+
this.passwordVisible = !this.passwordVisible;
|
|
109
|
+
this.dispatchEvent(new CustomEvent('password-visibility-changed', {
|
|
110
|
+
bubbles: true,
|
|
111
|
+
composed: true,
|
|
112
|
+
detail: {
|
|
113
|
+
visible: this.passwordVisible,
|
|
114
|
+
}
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
|
|
34
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "UI Core components from dile-components.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "d2ea4a1b93655d34f8e5113726283f2a311370cc"
|
|
31
31
|
}
|