2021-03-31 15:22:55 +00:00
|
|
|
<template>
|
|
|
|
<q-input v-model="password" v-bind="attrs" :label="label" :type="type">
|
|
|
|
<template #append><q-icon :name="name" class="cursor-pointer" @click="toggle" /></template
|
|
|
|
></q-input>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { computed, defineComponent, ref } from 'vue';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'PasswordInput',
|
|
|
|
props: {
|
|
|
|
modelValue: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
emits: {
|
|
|
|
'update:modelValue': (value: string) => !!value,
|
|
|
|
},
|
|
|
|
setup(props, { emit, attrs }) {
|
|
|
|
const isPassword = ref(true);
|
|
|
|
const type = computed(() => (isPassword.value ? 'password' : 'text'));
|
2021-04-03 11:24:19 +00:00
|
|
|
const name = computed(() => (isPassword.value ? 'mdi-eye-off' : 'mdi-eye'));
|
2021-03-31 15:22:55 +00:00
|
|
|
const password = computed({
|
|
|
|
get: () => props.modelValue,
|
|
|
|
set: (value: string) => emit('update:modelValue', value),
|
|
|
|
});
|
|
|
|
function toggle() {
|
|
|
|
isPassword.value = !isPassword.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
attrs,
|
|
|
|
isPassword,
|
|
|
|
name,
|
|
|
|
password,
|
|
|
|
toggle,
|
|
|
|
type,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2021-12-05 23:40:50 +00:00
|
|
|
</script>
|