import * as React from "react"; import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; import { cn } from "@util/index"; import { RadiusType } from "@_types/commonTypes"; type CheckBoxTypes = { id: string; label?: React.ReactNode; sublabel?: React.ReactNode; helperText?: any; size?: "xs" | "sm" | "default" | "md" | "lg" | "xl"; radius?: RadiusType; }; type CheckboxProps = CheckBoxTypes & React.ComponentProps; export const Checkbox: React.FC = ({ id, label, sublabel, helperText, disabled, size = "default", radius = "inherit", ...props }) => { let labelLineHeightStyles = { xs: sublabel || helperText ? 0.5 : 0.1, sm: 0.6, default: 1, md: 0.8, lg: 0.9, xl: 1, }; return (
{(label || helperText) && (
{label && ( )} {sublabel && ( )} {helperText && !disabled && ( )}
)}
); }; const CheckboxElement = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { size?: "xs" | "sm" | "default" | "md" | "lg" | "xl"; radius?: RadiusType; } >(({ radius = "inherit", size = "default", className, ...props }, ref) => { let checkboxRadius = { none: "hawa-rounded-none", inherit: "hawa-rounded-sm", full: "hawa-rounded-full", }; let checkboxSizes = { xs: "hawa-w-3 hawa-h-3", sm: "hawa-w-6 hawa-h-6", default: "hawa-icon", md: "hawa-w-8 hawa-h-8", lg: "hawa-w-10 hawa-h-10", xl: "hawa-w-12 hawa-h-12", }; let checkboxIndicatorSizes = { xs: "0.5em", default: "0.60em", sm: "0.75em", md: "0.875em", lg: "1em", xl: "1.25em", }; return ( {" "} ); }); CheckboxElement.displayName = CheckboxPrimitive.Root.displayName;