2021-09-07 00:24:02 +00:00
|
|
|
<template>
|
|
|
|
<div class="input-group mb-3">
|
2021-09-07 08:46:42 +00:00
|
|
|
<input
|
2021-09-07 15:06:49 +00:00
|
|
|
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"
|
2021-09-07 15:06:49 +00:00
|
|
|
: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: {
|
2022-06-01 23:32:05 +00:00
|
|
|
/** The value of the input */
|
2021-09-07 00:24:02 +00:00
|
|
|
modelValue: {
|
|
|
|
type: String,
|
|
|
|
default: ""
|
|
|
|
},
|
2022-06-01 23:32:05 +00:00
|
|
|
/** A placeholder to use */
|
2021-09-07 00:24:02 +00:00
|
|
|
placeholder: {
|
|
|
|
type: String,
|
|
|
|
default: ""
|
|
|
|
},
|
2022-06-02 09:42:37 +00:00
|
|
|
/** Maximum length of the input */
|
2021-09-07 00:24:02 +00:00
|
|
|
maxlength: {
|
|
|
|
type: Number,
|
|
|
|
default: 255
|
|
|
|
},
|
2022-06-01 23:32:05 +00:00
|
|
|
/** Should the field auto complete */
|
2021-09-07 00:24:02 +00:00
|
|
|
autocomplete: {
|
2021-09-07 15:06:49 +00:00
|
|
|
type: String,
|
2022-10-13 11:28:02 +00:00
|
|
|
default: "new-password",
|
2021-09-07 00:24:02 +00:00
|
|
|
},
|
2022-06-01 23:32:05 +00:00
|
|
|
/** Is the input required? */
|
2021-09-07 00:24:02 +00:00
|
|
|
required: {
|
|
|
|
type: Boolean
|
|
|
|
},
|
2022-06-01 23:32:05 +00:00
|
|
|
/** Should the input be read only? */
|
2021-09-07 09:06:33 +00:00
|
|
|
readonly: {
|
2021-09-07 15:06:49 +00:00
|
|
|
type: String,
|
|
|
|
default: undefined,
|
2021-09-07 09:06:33 +00:00
|
|
|
},
|
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 {
|
2021-09-07 09:06:33 +00:00
|
|
|
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
|
|
|
}
|
2021-09-07 09:06:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
2021-09-07 15:06:49 +00:00
|
|
|
|
2021-09-07 00:24:02 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2023-08-11 07:46:41 +00:00
|
|
|
/**
|
|
|
|
* Show users input in plain text
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-09-07 00:24:02 +00:00
|
|
|
showInput() {
|
|
|
|
this.visibility = "text";
|
|
|
|
},
|
2023-08-11 07:46:41 +00:00
|
|
|
/**
|
|
|
|
* Censor users input
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-09-07 00:24:02 +00:00
|
|
|
hideInput() {
|
|
|
|
this.visibility = "password";
|
2021-09-07 09:06:33 +00:00
|
|
|
},
|
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>
|