Allow to pass label and description via props
This commit is contained in:
parent
3eaef4a748
commit
caa1010bc7
|
|
@ -1,19 +1,32 @@
|
|||
<script lang="ts" setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useId } from 'radix-vue'
|
||||
import { type HTMLAttributes, provide } from 'vue'
|
||||
import { FORM_ITEM_INJECTION_KEY } from './injectionKeys'
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useId } from "radix-vue";
|
||||
import { type HTMLAttributes, provide } from "vue";
|
||||
import { FORM_ITEM_INJECTION_KEY } from "./injectionKeys";
|
||||
import { useFormField } from "./useFormField";
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
class?: HTMLAttributes["class"];
|
||||
label?: string;
|
||||
description?: string;
|
||||
}>();
|
||||
|
||||
const id = useId()
|
||||
provide(FORM_ITEM_INJECTION_KEY, id)
|
||||
const { error } = useFormField();
|
||||
|
||||
const id = useId();
|
||||
provide(FORM_ITEM_INJECTION_KEY, id);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="cn('space-y-2', props.class)">
|
||||
<FormLabel v-if="props.label">{{ props.label }}</FormLabel>
|
||||
|
||||
<slot />
|
||||
|
||||
<FormDescription v-if="props.description && !error">
|
||||
{{ props.description }}
|
||||
</FormDescription>
|
||||
|
||||
<FormMessage v-if="props.description" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,32 @@
|
|||
<script lang="ts" setup>
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useId } from 'radix-vue'
|
||||
import { type HTMLAttributes, provide } from 'vue'
|
||||
import { FORM_ITEM_INJECTION_KEY } from './injectionKeys'
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useId } from "radix-vue";
|
||||
import { type HTMLAttributes, provide } from "vue";
|
||||
import { FORM_ITEM_INJECTION_KEY } from "./injectionKeys";
|
||||
import { useFormField } from "./useFormField";
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
class?: HTMLAttributes["class"];
|
||||
label?: string;
|
||||
description?: string;
|
||||
}>();
|
||||
|
||||
const id = useId()
|
||||
provide(FORM_ITEM_INJECTION_KEY, id)
|
||||
const { error } = useFormField();
|
||||
|
||||
const id = useId();
|
||||
provide(FORM_ITEM_INJECTION_KEY, id);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="cn('space-y-2', props.class)">
|
||||
<FormLabel v-if="props.label">{{ props.label }}</FormLabel>
|
||||
|
||||
<slot />
|
||||
|
||||
<FormDescription v-if="props.description && !error">
|
||||
{{ props.description }}
|
||||
</FormDescription>
|
||||
|
||||
<FormMessage v-if="props.description" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user