'use client' import React from 'react' import { Checkbox } from '@/components/ui/checkbox' import { Label } from '@/components/ui/label' export interface CheckboxOption { id: number | string name: string [key: string]: any // 允许额外的属性 } export interface CheckboxGroupProps { options: CheckboxOption[] value?: (number | string)[] onChange?: (value: (number | string)[]) => void className?: string itemClassName?: string labelClassName?: string idPrefix?: string disabled?: boolean } export function CheckboxGroup({ options, value = [], onChange, className = "space-y-2", itemClassName = "flex items-center space-x-2", labelClassName = "text-sm", idPrefix = "checkbox", disabled = false, }: CheckboxGroupProps) { const handleToggle = (optionId: number | string, checked: boolean) => { const newValue = checked ? [...value, optionId] : value.filter((id) => id !== optionId) onChange?.(newValue) } if (!options || options.length === 0) { return null } return (