2024-12-02 17:20:27 +01:00
|
|
|
<script lang="ts" setup>
|
2025-03-28 01:16:24 +01:00
|
|
|
import type { LabelProps } from "reka-ui";
|
2024-12-02 17:20:27 +01:00
|
|
|
import type { HTMLAttributes } from "vue";
|
2025-06-26 22:39:02 +02:00
|
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
2024-12-02 17:20:27 +01:00
|
|
|
import { useFormField } from "./useFormField";
|
|
|
|
|
|
|
|
|
|
const props = defineProps<LabelProps & { class?: HTMLAttributes["class"] }>();
|
|
|
|
|
|
|
|
|
|
const { error, formItemId } = useFormField();
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<Label
|
2025-04-10 13:55:56 +02:00
|
|
|
data-slot="form-label"
|
|
|
|
|
:data-error="!!error"
|
2024-12-02 17:20:27 +01:00
|
|
|
:class="cn(
|
2025-04-10 13:55:56 +02:00
|
|
|
'data-[error=true]:text-destructive-foreground',
|
2024-12-02 17:20:27 +01:00
|
|
|
props.class,
|
|
|
|
|
)"
|
|
|
|
|
:for="formItemId"
|
|
|
|
|
>
|
|
|
|
|
<slot />
|
|
|
|
|
</Label>
|
|
|
|
|
</template>
|