feat: Add textarea form element
This commit is contained in:
@@ -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':
|
||||
|
||||
31
legalconsenthub/app/components/formelements/TheTextarea.vue
Normal file
31
legalconsenthub/app/components/formelements/TheTextarea.vue
Normal 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>
|
||||
|
||||
Reference in New Issue
Block a user