summaryrefslogtreecommitdiffstats
path: root/src/components/ActionInput.vue
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-11-26 09:28:28 +0100
committerDaniel Baumann <daniel@debian.org>2024-11-26 12:25:58 +0100
commita1882b67c41fe9901a0cd8059b5cc78a5beadec0 (patch)
tree2a24507c67aa99a15416707b2f7e645142230ed8 /src/components/ActionInput.vue
parentInitial commit. (diff)
downloaduptime-kuma-a1882b67c41fe9901a0cd8059b5cc78a5beadec0.tar.xz
uptime-kuma-a1882b67c41fe9901a0cd8059b5cc78a5beadec0.zip
Adding upstream version 2.0.0~beta.0+dfsg.upstream/2.0.0_beta.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to '')
-rw-r--r--src/components/ActionInput.vue93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/components/ActionInput.vue b/src/components/ActionInput.vue
new file mode 100644
index 0000000..a61e4f9
--- /dev/null
+++ b/src/components/ActionInput.vue
@@ -0,0 +1,93 @@
+<template>
+ <div class="input-group mb-3">
+ <input
+ ref="input"
+ v-model="model"
+ class="form-control"
+ :type="type"
+ :placeholder="placeholder"
+ :disabled="!enabled"
+ >
+ <button type="button" class="btn btn-outline-primary" :aria-label="actionAriaLabel" @click="action()">
+ <font-awesome-icon :icon="icon" />
+ </button>
+ </div>
+</template>
+
+<script>
+/**
+ * Generic input field with a customizable action on the right.
+ * Action is passed in as a function.
+ */
+export default {
+ props: {
+ /**
+ * The value of the input field.
+ */
+ modelValue: {
+ type: String,
+ default: ""
+ },
+ /**
+ * Whether the input field is enabled / disabled.
+ */
+ enabled: {
+ type: Boolean,
+ default: true
+ },
+ /**
+ * Placeholder text for the input field.
+ */
+ placeholder: {
+ type: String,
+ default: ""
+ },
+ /**
+ * The icon displayed in the right button of the input field.
+ * Accepts a Font Awesome icon string identifier.
+ * @example "plus"
+ */
+ icon: {
+ type: String,
+ required: true,
+ },
+ /**
+ * The input type of the input field.
+ * @example "email"
+ */
+ type: {
+ type: String,
+ default: "text",
+ },
+ /**
+ * The action to be performed when the button is clicked.
+ * Action is passed in as a function.
+ */
+ action: {
+ type: Function,
+ default: () => {},
+ },
+ /**
+ * The aria-label of the action button
+ */
+ actionAriaLabel: {
+ type: String,
+ required: true,
+ }
+ },
+ emits: [ "update:modelValue" ],
+ computed: {
+ /**
+ * Send value update to parent on change.
+ */
+ model: {
+ get() {
+ return this.modelValue;
+ },
+ set(value) {
+ this.$emit("update:modelValue", value);
+ }
+ }
+ },
+};
+</script>