1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<script>
import { GlFormInput, GlButton, GlTooltipDirective } from '@gitlab/ui';
import { SHOW_PASSWORD, HIDE_PASSWORD } from '../constants';
export default {
name: 'PasswordInput',
components: {
GlFormInput,
GlButton,
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
title: {
type: String,
required: false,
default: null,
},
id: {
type: String,
required: false,
default: null,
},
minimumPasswordLength: {
type: String,
required: false,
default: null,
},
testid: {
type: String,
required: false,
default: null,
},
autocomplete: {
type: String,
required: false,
default: 'current-password',
},
name: {
type: String,
required: true,
},
},
data() {
return {
isMasked: true,
};
},
computed: {
type() {
return this.isMasked ? 'password' : 'text';
},
toggleVisibilityLabel() {
return this.isMasked ? SHOW_PASSWORD : HIDE_PASSWORD;
},
toggleVisibilityIcon() {
return this.isMasked ? 'eye' : 'eye-slash';
},
},
methods: {
handleToggleVisibilityButtonClick() {
this.isMasked = !this.isMasked;
},
},
};
</script>
<template>
<div class="gl-field-error-anchor input-icon-wrapper">
<gl-form-input
:id="id"
class="js-password-complexity-validation gl-pr-8!"
required
:autocomplete="autocomplete"
:name="name"
:minlength="minimumPasswordLength"
:data-testid="testid"
:title="title"
:type="type"
/>
<gl-button
v-gl-tooltip="toggleVisibilityLabel"
class="input-icon-right gl-right-0!"
category="tertiary"
:aria-label="toggleVisibilityLabel"
:icon="toggleVisibilityIcon"
@click="handleToggleVisibilityButtonClick"
/>
</div>
</template>
|