mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
62 lines
1.4 KiB
Vue
62 lines
1.4 KiB
Vue
<template>
|
|
<BFormGroup :label="label" :label-for="labelFor" data-test="input-identifier">
|
|
<BFormInput
|
|
:id="labelFor"
|
|
:model-value="value"
|
|
:name="name"
|
|
:placeholder="placeholder"
|
|
type="text"
|
|
:state="meta.valid"
|
|
trim
|
|
class="bg-248"
|
|
:disabled="disabled"
|
|
autocomplete="off"
|
|
@update:model-value="value = $event"
|
|
/>
|
|
<BFormInvalidFeedback v-if="errorMessage">
|
|
{{ errorMessage }}
|
|
</BFormInvalidFeedback>
|
|
</BFormGroup>
|
|
</template>
|
|
<script setup>
|
|
import { computed, watch } from 'vue'
|
|
import { useField } from 'vee-validate'
|
|
|
|
const props = defineProps({
|
|
rules: {
|
|
type: Object,
|
|
default: () => ({
|
|
required: true,
|
|
validIdentifier: true,
|
|
}),
|
|
},
|
|
name: { type: String, required: true },
|
|
label: { type: String, required: true },
|
|
placeholder: { type: String, required: true },
|
|
modelValue: { type: String },
|
|
disabled: { type: Boolean, required: false, default: false },
|
|
})
|
|
|
|
const emit = defineEmits(['update:modelValue', 'onValidation'])
|
|
|
|
const { value, meta, errorMessage } = useField(props.name, props.rules, {
|
|
initialValue: props.modelValue,
|
|
})
|
|
|
|
const labelFor = computed(() => props.name + '-input-field')
|
|
|
|
watch(value, (newValue) => {
|
|
emit('update:modelValue', newValue)
|
|
})
|
|
|
|
watch(
|
|
() => props.modelValue,
|
|
(newValue) => {
|
|
if (newValue !== value.value) {
|
|
value.value = newValue
|
|
emit('onValidation')
|
|
}
|
|
},
|
|
)
|
|
</script>
|