import React from "react"; import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; import { CheckIcon, RemoveIcon } from "../icons"; import { cls } from "../util"; export interface CheckboxProps { checked: boolean; id?: string; disabled?: boolean; indeterminate?: boolean; onCheckedChange?: (checked: boolean) => void; padding?: boolean; size?: "smallest" | "small" | "medium" | "large"; color?: "primary" | "secondary"; } const sizeClasses = { large: "w-6 h-6 rounded flex items-center justify-center", medium: "w-5 h-5 rounded flex items-center justify-center", small: "w-4 h-4 rounded flex items-center justify-center", smallest: "w-4 h-4 rounded flex items-center justify-center" }; const outerSizeClasses = { medium: "w-10 h-10", small: "w-8 h-8", large: "w-12 h-12 ", smallest: "w-6 h-6" } const paddingClasses = { medium: "p-2", small: "p-2", large: "p-2", smallest: "" } const colorClasses = { primary: "bg-primary", secondary: "bg-secondary" } export const Checkbox = React.memo(({ id, checked, indeterminate = false, padding = true, disabled, size = "medium", onCheckedChange, color = "primary" }: CheckboxProps) => { const isChecked = indeterminate ? false : checked; const iconSize = size === "medium" ? 20 : size === "small" ? 16 : size === "smallest" ? 14 : 24; return (
{indeterminate ? ( ) : ( )}
); });