import React from 'react'; import { formatBytes } from '@/utils/format'; import { cn } from '@/lib/utils'; import type { StorageSizeInfo } from '../useStorageCleaner'; import { CLEAN_OPTION_KEYS, OPTION_LABELS } from '../constants'; import { Checkbox } from '@/components/ui/checkbox'; interface OptionItemProps extends React.HTMLAttributes { labelKey: (typeof CLEAN_OPTION_KEYS)[number]; checked: boolean; sizeInfo?: StorageSizeInfo; onChange: () => void; } export default function OptionItem({ labelKey, checked, sizeInfo, onChange, className, ...props }: OptionItemProps) { const sizeValue = sizeInfo?.value; const isCount = sizeInfo?.displayType === 'count'; const label = OPTION_LABELS[labelKey]; return (
{label} {sizeValue !== undefined && sizeValue > 0 ? ( {isCount ? `${sizeValue} 项` : formatBytes(sizeValue)} ) : ( 无数据 )}
e.stopPropagation()} onCheckedChange={onChange} className="h-4 w-4 shrink-0 rounded border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground" />
); }