uptime-kuma/src/components/HiddenInput.vue

80 lines
1.7 KiB
Vue
Raw Normal View History

2021-09-07 00:24:02 +00:00
<template>
<div class="input-group mb-3">
2021-09-07 08:46:42 +00:00
<input
ref="input"
2021-09-07 08:46:42 +00:00
v-model="model"
:type="visibility"
class="form-control"
:placeholder="placeholder"
:maxlength="maxlength"
:autocomplete="autocomplete"
:required="required"
:readonly="readonly"
2021-09-07 08:46:42 +00:00
>
2021-09-07 00:24:02 +00:00
<a v-if="visibility == 'password'" class="btn btn-outline-primary" @click="showInput()">
<font-awesome-icon icon="eye" />
</a>
<a v-if="visibility == 'text'" class="btn btn-outline-primary" @click="hideInput()">
<font-awesome-icon icon="eye-slash" />
</a>
</div>
</template>
<script>
export default {
props: {
modelValue: {
type: String,
default: ""
},
placeholder: {
type: String,
default: ""
},
maxlength: {
type: Number,
default: 255
},
autocomplete: {
type: String,
default: undefined,
2021-09-07 00:24:02 +00:00
},
required: {
type: Boolean
},
readonly: {
type: String,
default: undefined,
},
2021-09-07 00:24:02 +00:00
},
2022-04-17 07:27:35 +00:00
emits: [ "update:modelValue" ],
2021-09-07 00:24:02 +00:00
data() {
return {
visibility: "password",
2022-04-13 16:30:32 +00:00
};
2021-09-07 00:24:02 +00:00
},
computed: {
model: {
get() {
2022-04-13 16:30:32 +00:00
return this.modelValue;
2021-09-07 00:24:02 +00:00
},
set(value) {
2022-04-13 16:30:32 +00:00
this.$emit("update:modelValue", value);
2021-09-07 00:24:02 +00:00
}
}
},
created() {
2021-09-07 00:24:02 +00:00
},
methods: {
showInput() {
this.visibility = "text";
},
hideInput() {
this.visibility = "password";
},
2021-09-07 00:24:02 +00:00
}
2022-04-13 16:30:32 +00:00
};
2021-09-07 00:24:02 +00:00
</script>