Feat: Use shadcn-ui to build GenerateForm. #3221 (#5449)

### What problem does this PR solve?

Feat: Use shadcn-ui to build GenerateForm. #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-02-27 18:13:41 +08:00
committed by GitHub
parent 651422127c
commit 244cf49ba4
11 changed files with 142 additions and 249 deletions

View File

@ -14,6 +14,8 @@ import {
import { Label } from '@/components/ui/label';
import { cn } from '@/lib/utils';
import { Info } from 'lucide-react';
import { Tooltip, TooltipContent, TooltipTrigger } from './tooltip';
const Form = FormProvider;
@ -88,17 +90,31 @@ FormItem.displayName = 'FormItem';
const FormLabel = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
>(({ className, ...props }, ref) => {
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & {
tooltip?: React.ReactNode;
}
>(({ className, tooltip, ...props }, ref) => {
const { error, formItemId } = useFormField();
return (
<Label
ref={ref}
className={cn(error && 'text-destructive', className)}
className={cn(error && 'text-destructive', className, 'flex')}
htmlFor={formItemId}
{...props}
/>
>
{props.children}
{tooltip && (
<Tooltip>
<TooltipTrigger>
<Info className="size-3 ml-2" />
</TooltipTrigger>
<TooltipContent>
<p>{tooltip}</p>
</TooltipContent>
</Tooltip>
)}
</Label>
);
});
FormLabel.displayName = 'FormLabel';