feat: Add textarea form element

This commit is contained in:
2025-12-06 18:00:27 +01:00
parent f1b66c184b
commit 4b06f68265
5 changed files with 52 additions and 18 deletions

View File

@@ -89,6 +89,8 @@ function getResolvedComponent(formElement: FormElementDto) {
return resolveComponent('TheSwitch')
case 'TEXTFIELD':
return resolveComponent('TheInput')
case 'TEXTAREA':
return resolveComponent('TheTextarea')
case 'TITLE_BODY_TEXTFIELDS':
return resolveComponent('TheTitleBodyInput')
case 'DATE':

View File

@@ -0,0 +1,31 @@
<template>
<UFormField :label="label">
<UTextarea v-model="modelValue" class="w-full" autoresize />
</UFormField>
</template>
<script setup lang="ts">
import type { FormOptionDto } from '~~/.api-client'
const props = defineProps<{
label?: string
formOptions: FormOptionDto[]
}>()
const emit = defineEmits<{
(e: 'update:formOptions', value: FormOptionDto[]): void
}>()
const modelValue = computed({
get: () => props.formOptions[0]?.value ?? '',
set: (val) => {
const firstOption = props.formOptions[0]
if (val && firstOption) {
const updatedModelValue = [...props.formOptions]
updatedModelValue[0] = { ...firstOption, value: val.toString() }
emit('update:formOptions', updatedModelValue)
}
}
})
</script>