"use client" /** * 表单组件模板 * * 包含项目中常用的各种表单组件 */ import type React from "react" import { Label } from "@/components/ui/label" import { Input } from "@/components/ui/input" import { Textarea } from "@/components/ui/textarea" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" import { Slider } from "@/components/ui/slider" import { Switch } from "@/components/ui/switch" interface FormFieldProps { label: string htmlFor: string required?: boolean description?: string error?: string children: React.ReactNode } /** * 表单字段容器 * 用于包装表单控件 */ export function FormField({ label, htmlFor, required = false, description, error, children }: FormFieldProps) { return (
{children} {description &&

{description}

} {error &&

{error}

}
) } interface TextInputFieldProps { label: string id: string value: string onChange: (value: string) => void placeholder?: string required?: boolean description?: string error?: string type?: string } /** * 文本输入字段 * 用于文本输入 */ export function TextInputField({ label, id, value, onChange, placeholder, required = false, description, error, type = "text", }: TextInputFieldProps) { return ( onChange(e.target.value)} placeholder={placeholder} /> ) } interface TextareaFieldProps { label: string id: string value: string onChange: (value: string) => void placeholder?: string required?: boolean description?: string error?: string } /** * 多行文本输入字段 * 用于多行文本输入 */ export function TextareaField({ label, id, value, onChange, placeholder, required = false, description, error, }: TextareaFieldProps) { return (