2022-05-12 10:18:47 +00:00
|
|
|
<template>
|
|
|
|
<div class="input-group mb-3">
|
|
|
|
<input
|
|
|
|
ref="input"
|
|
|
|
v-model="model"
|
|
|
|
class="form-control"
|
|
|
|
:type="type"
|
|
|
|
:placeholder="placeholder"
|
|
|
|
:disabled="!enabled"
|
|
|
|
>
|
|
|
|
<a class="btn btn-outline-primary" @click="action()">
|
|
|
|
<font-awesome-icon :icon="icon" />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-05-31 08:24:39 +00:00
|
|
|
/**
|
|
|
|
* Generic input field with a customizable action on the right.
|
|
|
|
* Action is passed in as a function.
|
|
|
|
*/
|
2022-05-12 10:18:47 +00:00
|
|
|
export default {
|
|
|
|
props: {
|
2022-05-31 08:24:39 +00:00
|
|
|
/**
|
|
|
|
* The value of the input field.
|
|
|
|
*/
|
2022-05-12 10:18:47 +00:00
|
|
|
modelValue: {
|
|
|
|
type: String,
|
|
|
|
default: ""
|
|
|
|
},
|
2022-05-31 08:24:39 +00:00
|
|
|
/**
|
|
|
|
* Whether the input field is enabled / disabled.
|
|
|
|
*/
|
2022-05-12 10:18:47 +00:00
|
|
|
enabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
2022-05-31 08:24:39 +00:00
|
|
|
/**
|
|
|
|
* Placeholder text for the input field.
|
|
|
|
*/
|
2022-05-12 10:18:47 +00:00
|
|
|
placeholder: {
|
|
|
|
type: String,
|
|
|
|
default: ""
|
|
|
|
},
|
2022-05-31 08:24:39 +00:00
|
|
|
/**
|
|
|
|
* The icon displayed in the right button of the input field.
|
|
|
|
* Accepts a Font Awesome icon string identifier.
|
|
|
|
* @example "plus"
|
|
|
|
*/
|
2022-05-12 10:18:47 +00:00
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-05-31 08:24:39 +00:00
|
|
|
/**
|
|
|
|
* The input type of the input field.
|
|
|
|
* @example "email"
|
|
|
|
*/
|
2022-05-12 10:18:47 +00:00
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: "text",
|
|
|
|
},
|
2022-05-31 08:24:39 +00:00
|
|
|
/**
|
|
|
|
* The action to be performed when the button is clicked.
|
|
|
|
* Action is passed in as a function.
|
|
|
|
*/
|
2022-05-12 10:18:47 +00:00
|
|
|
action: {
|
|
|
|
type: Function,
|
|
|
|
default: () => {},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
emits: [ "update:modelValue" ],
|
|
|
|
computed: {
|
2022-05-31 08:24:39 +00:00
|
|
|
/**
|
|
|
|
* Send value update to parent on change.
|
|
|
|
*/
|
2022-05-12 10:18:47 +00:00
|
|
|
model: {
|
|
|
|
get() {
|
|
|
|
return this.modelValue;
|
|
|
|
},
|
|
|
|
set(value) {
|
|
|
|
this.$emit("update:modelValue", value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|