You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
721 B
30 lines
721 B
<script setup lang="ts">
|
|
import type { HTMLAttributes } from 'vue'
|
|
import { provide } from 'vue'
|
|
import { useId } from 'reka-ui'
|
|
import { cn } from '~/lib/utils'
|
|
import { FORM_ITEM_INJECT_KEY } from '.'
|
|
|
|
/**
|
|
* FormItem component - Container for form fields with proper spacing
|
|
* Provides unique ID context for label and error message association
|
|
*/
|
|
|
|
interface Props {
|
|
class?: HTMLAttributes['class']
|
|
}
|
|
|
|
const props = defineProps<Props>()
|
|
|
|
// Generate unique ID for this form item
|
|
const id = useId()
|
|
|
|
// Provide the ID to child components (FormLabel, FormControl, FormMessage)
|
|
provide(FORM_ITEM_INJECT_KEY, { id })
|
|
</script>
|
|
|
|
<template>
|
|
<div :class="cn('space-y-2', props.class)">
|
|
<slot />
|
|
</div>
|
|
</template>
|
|
|