Accessibility for Password

pull/2760/head
Tuğçe Küçükoğlu 2022-07-04 16:51:59 +03:00
parent c636777200
commit 96177cbc60
1 changed files with 19 additions and 22 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div :class="containerClass" :id="id" :style="style"> <div :class="containerClass" v-bind="passwordProps">
<PInputText ref="input" :id="inputId" :class="inputFieldClass" :style="inputStyle" :type="inputType" :value="modelValue" @input="onInput" @focus="onFocus" @blur="onBlur" @keyup="onKeyUp" v-bind="$attrs" /> <PInputText ref="input" :type="inputType" :value="modelValue" @input="onInput" @focus="onFocus" @blur="onBlur" @keyup="onKeyUp" v-bind="inputProps" />
<i v-if="toggleMask" :class="toggleIconClass" @click="onMaskToggle" /> <i v-if="toggleMask" :class="toggleIconClass" @click="onMaskToggle" />
<Portal :appendTo="appendTo"> <Portal :appendTo="appendTo">
<transition name="p-connected-overlay" @enter="onOverlayEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave"> <transition name="p-connected-overlay" @enter="onOverlayEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave">
@ -27,18 +27,9 @@ import Portal from 'primevue/portal';
export default { export default {
name: 'Password', name: 'Password',
emits: ['update:modelValue'], emits: ['update:modelValue', 'change', 'focus', 'blur'],
inheritAttrs: false,
props: { props: {
modelValue: String, modelValue: String,
id: {
type: String,
default: null
},
inputId: {
type: String,
default: null
},
promptLabel: { promptLabel: {
type: String, type: String,
default: null default: null
@ -83,11 +74,13 @@ export default {
type: String, type: String,
default: 'pi pi-eye' default: 'pi pi-eye'
}, },
inputClass: null, panelClass: String,
inputStyle: null, disabled: {
style: null, type: Boolean,
class: String, default: false
panelClass: String },
passwordProps: null,
inputProps: null
}, },
data() { data() {
return { return {
@ -159,17 +152,21 @@ export default {
onInput(event) { onInput(event) {
this.$emit('update:modelValue', event.target.value) this.$emit('update:modelValue', event.target.value)
}, },
onFocus() { onFocus(event) {
this.focused = true; this.focused = true;
if (this.feedback) { if (this.feedback) {
this.overlayVisible = true; this.overlayVisible = true;
} }
this.$emit('focus', event);
}, },
onBlur() { onBlur(event) {
this.focused = false; this.focused = false;
if (this.feedback) { if (this.feedback) {
this.overlayVisible = false; this.overlayVisible = false;
} }
this.$emit('blur', event);
}, },
onKeyUp(event) { onKeyUp(event) {
if (this.feedback) { if (this.feedback) {
@ -269,15 +266,15 @@ export default {
}, },
computed: { computed: {
containerClass() { containerClass() {
return ['p-password p-component p-inputwrapper', this.class, { return ['p-password p-component p-inputwrapper', {
'p-inputwrapper-filled': this.filled, 'p-inputwrapper-filled': this.filled,
'p-inputwrapper-focus': this.focused, 'p-inputwrapper-focus': this.focused,
'p-input-icon-right': this.toggleMask 'p-input-icon-right': this.toggleMask
}]; }];
}, },
inputFieldClass() { inputFieldClass() {
return ['p-password-input', this.inputClass, { return ['p-password-input', {
'p-disabled': this.$attrs.disabled 'p-disabled': this.disabled
}]; }];
}, },
panelStyleClass() { panelStyleClass() {