refactor: TextAreaItem typing

This commit is contained in:
axolotle 2024-07-05 17:20:28 +02:00
parent 0f8fbd4830
commit 32da3d9ee4
2 changed files with 30 additions and 23 deletions

View file

@ -1,43 +1,46 @@
<script setup lang="ts"> <script setup lang="ts">
import { inject } from 'vue' import { computed, inject } from 'vue'
withDefaults( import { ValidationTouchSymbol } from '@/composables/form'
defineProps<{ import type { BaseItemComputedProps, TextAreaItemProps } from '@/types/form'
modelValue?: string | null
id?: string const props = withDefaults(
placeholder?: string defineProps<TextAreaItemProps & BaseItemComputedProps<string | null>>(),
type?: string // FIXME unused?
required?: boolean
state?: boolean | null
name?: string
}>(),
{ {
modelValue: null,
id: undefined, id: undefined,
placeholder: undefined,
type: 'text',
required: false,
state: undefined,
name: undefined, name: undefined,
placeholder: undefined,
touchKey: undefined,
// type: 'text',
ariaDescribedby: undefined,
modelValue: undefined,
state: undefined,
validation: undefined,
}, },
) )
const emit = defineEmits<{ defineEmits<{
'update:modelValue': [value: string] 'update:modelValue': [value: string | null]
}>() }>()
const touch = inject('touch') const model = defineModel<string>()
const touch = inject(ValidationTouchSymbol)
const required = computed(() => 'required' in (props?.validation ?? {}))
</script> </script>
<template> <template>
<BFormTextarea <BFormTextarea
:modelValue="modelValue"
@update:modelValue="emit('update:modelValue', $event)"
:id="id" :id="id"
v-model="model"
:name="name"
:placeholder="placeholder" :placeholder="placeholder"
:required="required" :aria-describedby="ariaDescribedby"
:state="state" :state="state"
:required="required"
rows="4" rows="4"
@blur="touch(name)" @blur="touch?.(touchKey)"
/> />
</template> </template>

View file

@ -93,3 +93,7 @@ export type TagsSelectizeItemProps = BaseWritableItemProps & {
noTags?: boolean noTags?: boolean
tagIcon?: string tagIcon?: string
} }
export type TextAreaItemProps = BaseWritableItemProps & {
// type?: string // FIXME unused?
}